dsh-xdpool 2.6.5 → 2.6.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 +77 -0
- package/lib/bin.js +217 -7
- package/lib/client.js +26 -4
- package/lib/index.d.ts +177 -5
- package/lib/index.js +638 -23
- package/package.json +2 -2
- package/scripts/link-host-peers.mjs +110 -12
- package/vendor/channel-pack/pack.js +41 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
本项目的所有重要变更都会记录在此文件。
|
|
3
3
|
版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
|
4
|
+
## 2.6.7 — 路由链的渠道成员不再被双重加前缀
|
|
5
|
+
|
|
6
|
+
> 四张 issue:一条数据会被写坏的路由缺陷,两条真实代码缺陷,一条「说清楚」的改动。
|
|
7
|
+
|
|
8
|
+
### 渠道成员 id 被加了两次前缀(#141)
|
|
9
|
+
|
|
10
|
+
一条 9 成员的混合链在路由页报「这些成员暂时不在册」,实际存下来的形态是:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
trae/trae:deepseek-v4.1-flash
|
|
14
|
+
raccoon/raccoon:sn-deepseek-v4-1-flash-1017
|
|
15
|
+
cline/cline:deepseek/deepseek-v4.1-flash-1017:batch
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
两个根因叠加:
|
|
19
|
+
|
|
20
|
+
- `splitPlatforms` 按第一个 `/` 切分。`cline:deepseek/…` 被切成 provider `cline`、model `cline:deepseek/…`,编辑器于是显示双前缀。
|
|
21
|
+
- `flattenDraft` 给所有非池子泳道拼 `${owner}/${model}`,而渠道成员自己的 id(`raccoon:sn-…`)已经带着 owner。
|
|
22
|
+
|
|
23
|
+
结果是运行时匹配不到任何成员,**在这种状态下保存会把双前缀写回配置**——报告里最危险的部分。
|
|
24
|
+
|
|
25
|
+
修法是认冒号:`<channel>:<model>` 本身完整,`<owner>/<model>` 才是第三方 provider 行的写法。渠道头必须是裸标识符(字母、数字、`_`、`-`),所以 `https://host/x` 不会被误认成渠道 `https`。缺成员的归属判断也改成同一套规则,否则 `raccoon:sn-…` 会被归到 `workbuddy` 下。
|
|
26
|
+
|
|
27
|
+
### 出网 fetch 在调用时才读全局(#140)
|
|
28
|
+
|
|
29
|
+
`options.fetchImpl ?? globalThis.fetch` 每次请求都重新读全局。billion-context 会打补丁拦截 `globalThis.fetch` 来做 8 MiB 直连闸门,于是那个补丁成了**所有渠道请求的传输层**——它不知道请求属于哪个会话,结果要么拒绝请求体(422,外层渲染成 400),要么丢掉渠道需要的会话归属。
|
|
30
|
+
|
|
31
|
+
改成创建时捕获一次。显式传入的 `options.fetchImpl` 仍然优先,测试和嵌入方照旧可以替换。
|
|
32
|
+
|
|
33
|
+
### 明确指定的模型不再被显示过滤挡住(#143)
|
|
34
|
+
|
|
35
|
+
卡片勾选决定选择器**列出**什么,不该决定 provider **能服务**什么。`kimi-k3.1-pro` 在名册上、账号也能跑,却因为不在勾选的四项里报 `has no configured model`——拒绝来自一个显示过滤器。
|
|
36
|
+
|
|
37
|
+
现在返回「勾选的在前、其余在后」的并集:默认选择不变,显式指定的 id 也能解析。图片开关和上下文预算仍取 `visible()` 的结果,因为那两项是用户明确说了算的。
|
|
38
|
+
|
|
39
|
+
### zcode 无 code 的风控拒绝被当成裸 405(#132)
|
|
40
|
+
|
|
41
|
+
截图里 `HTTP 405 · request has been blocked due to unusual activity` 被渲染成普通 HTTP 错误,而同一种情况在别处能得到正确的 3012 提示。原因是响应体没有 `code` 字段、状态码既不是 401 也不是 403,所有分支都没命中。
|
|
42
|
+
|
|
43
|
+
这条车道只发一个固定的 POST,405 不可能是真的方法错误——那是 WAF 在回应一个它决定不检查的请求。现在按风控归类,用户看到的是冷却警告而不是一个无从下手的状态码。
|
|
44
|
+
|
|
45
|
+
## 2.6.6 — 免费线上游已关闭;国际版每日活跃;网关支持非流式
|
|
46
|
+
|
|
47
|
+
> 三处独立改动:一个必须如实说明的坏消息,两个来自社区的修复。
|
|
48
|
+
|
|
49
|
+
### 免费模型线已被上游关闭(#96)
|
|
50
|
+
|
|
51
|
+
实测一次裸调用,上游现在回答:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{"type":"error","error":{"type":"FreeUsageLimitError",
|
|
55
|
+
"message":"Free usage limit reached. Free models work in OpenCode
|
|
56
|
+
(https://opencode.ai); subscribe to OpenCode Go to keep going…"}}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
这既不是指纹失配,也不是「按会话计额」——**上游把免费模型收进了自己的客户端**,第三方的 UA、请求头、路径怎么改都进不去。#96 的「从装上就没成功过」不是我们没修对门禁,而是那道门已经不在了。
|
|
60
|
+
|
|
61
|
+
原来的提示让人去更新插件,那在门禁还是指纹的年代是对的,现在是一条死路。现在按名字识别 `FreeUsageLimitError`,直接说明这条路已关闭、给出可用的替代(换渠道,或订阅 OpenCode Go)。
|
|
62
|
+
|
|
63
|
+
### 国际版账号恢复每日活跃上报(PR #138)
|
|
64
|
+
|
|
65
|
+
`scheduler.ts` 原先把 `report` / `streak` 限定为国内版,理由是国际版没有任务中心。这个前提不成立:
|
|
66
|
+
|
|
67
|
+
| 接口 | 国际版实测 |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `POST /v2/report` | `200 {"code":0}` |
|
|
70
|
+
| `GET /activity/growth/streak` | `200`,字段形状与国内版一致 |
|
|
71
|
+
| `GET /activity/growth/tasks` | `200`,返回 5 条任务 |
|
|
72
|
+
|
|
73
|
+
国际版的机制是:**每个被记录的活跃日,服务端次日凌晨发一个 30 积分的 `Bonus Pack`**,没有领取接口。一个请求就能点亮当天活跃(实测 heatmap 当天 score 从 0 变 2、`streak.days` 从 0 变 1),漏一天就真少 30 积分。
|
|
74
|
+
|
|
75
|
+
顺带把「签到活动未开启」记为**跳过**而非失败,不再污染失败计数。
|
|
76
|
+
|
|
77
|
+
### 网关支持 `stream: false`(PR #144)
|
|
78
|
+
|
|
79
|
+
此前池车道与缓冲车道一律按流式处理,客户端发 `stream: false` 也只拿回 SSE。现在两条车道都按请求体决定,非流式请求返回一个完整 JSON 响应。
|
|
80
|
+
|
|
4
81
|
## 2.6.5 — 安装不再被判失败,积分面板不再空白
|
|
5
82
|
|
|
6
83
|
> 五张 issue,三个独立根因。前两张是同一件事的两面:2.6.4 的 postinstall 会把**本来能用的安装**判成失败。
|
package/lib/bin.js
CHANGED
|
@@ -1346,8 +1346,18 @@ var WorkBuddyUpstreamClient = class {
|
|
|
1346
1346
|
if (models.length === 0) throw new Error("workbuddy model catalog resolved to an empty list");
|
|
1347
1347
|
return models;
|
|
1348
1348
|
}
|
|
1349
|
-
/**
|
|
1350
|
-
|
|
1349
|
+
/**
|
|
1350
|
+
* Read-only credits query, aggregated by package. Does not consume credits.
|
|
1351
|
+
*
|
|
1352
|
+
* `signal` is the caller's cancellation, merged with the built-in timeout
|
|
1353
|
+
* rather than replacing it: the pool's background warm must give up when the
|
|
1354
|
+
* host shuts down, and a caller that has already gone away must not leave a
|
|
1355
|
+
* 30 s request running. `AbortSignal.any` is already the repo's way of
|
|
1356
|
+
* combining these (see the pricing probe in the shim), and the timeout stays
|
|
1357
|
+
* in force so a signal-less caller keeps the old behaviour exactly.
|
|
1358
|
+
*/
|
|
1359
|
+
async fetchCredits(credential, signal) {
|
|
1360
|
+
const timeout = AbortSignal.timeout(JSON_TIMEOUT_MS);
|
|
1351
1361
|
const now = /* @__PURE__ */ new Date();
|
|
1352
1362
|
const fmt = (date) => {
|
|
1353
1363
|
const p = (n) => n.toString().padStart(2, "0");
|
|
@@ -1364,7 +1374,7 @@ var WorkBuddyUpstreamClient = class {
|
|
|
1364
1374
|
PackageEndTimeRangeBegin: fmt(now),
|
|
1365
1375
|
PackageEndTimeRangeEnd: fmt(new Date(now.getTime() + 3185136e6))
|
|
1366
1376
|
}),
|
|
1367
|
-
signal: AbortSignal.timeout
|
|
1377
|
+
signal: signal === void 0 ? timeout : AbortSignal.any([timeout, signal])
|
|
1368
1378
|
});
|
|
1369
1379
|
const envelope = await readEnvelope(response);
|
|
1370
1380
|
if (!response.ok || envelope.code !== 0) throw envelopeError(response.status, envelope);
|
|
@@ -3546,6 +3556,13 @@ const EXHAUST_COOLDOWN_MS = 18e5;
|
|
|
3546
3556
|
*/
|
|
3547
3557
|
const CREDENTIAL_DEAD_COOLDOWN_MS = 18e5;
|
|
3548
3558
|
/**
|
|
3559
|
+
* Shortest gap between two attempts at the same account's deadline reading.
|
|
3560
|
+
*
|
|
3561
|
+
* Only failed attempts are actually throttled by this: a successful read stamps
|
|
3562
|
+
* the reading itself, so {@link EXPIRY_READING_TTL_MS} takes over from there.
|
|
3563
|
+
*/
|
|
3564
|
+
const EXPIRY_WARM_RETRY_MS = 6e4;
|
|
3565
|
+
/**
|
|
3549
3566
|
* Does this refresh failure prove the credential itself is dead?
|
|
3550
3567
|
*
|
|
3551
3568
|
* The upstream answers a revoked refresh token with `invalid_grant: Offline user
|
|
@@ -3574,6 +3591,7 @@ var WorkBuddyAccountPool = class {
|
|
|
3574
3591
|
credentialDeadCooldownMs;
|
|
3575
3592
|
client;
|
|
3576
3593
|
refreshMarginMs;
|
|
3594
|
+
expiryReadingTtlMs;
|
|
3577
3595
|
accounts = [];
|
|
3578
3596
|
/**
|
|
3579
3597
|
* Files the last scan could not read, with the reason.
|
|
@@ -3669,11 +3687,42 @@ var WorkBuddyAccountPool = class {
|
|
|
3669
3687
|
* their own cycle and are therefore never urgent — which is why this is
|
|
3670
3688
|
* written from the same `fetchCredits` reading that fills `creditBalances`.
|
|
3671
3689
|
*
|
|
3672
|
-
*
|
|
3673
|
-
*
|
|
3690
|
+
* A positive value is a deadline. The two other states are kept in
|
|
3691
|
+
* {@link creditExpiryNone} and {@link creditExpiryReadAt} rather than as a
|
|
3692
|
+
* missing key, because a missing key cannot tell "we never looked" from "we
|
|
3693
|
+
* looked and nothing has a deadline" — and only the first is worth reading
|
|
3694
|
+
* again. An account whose packs are all monthly reads as `none` forever, which
|
|
3695
|
+
* is exactly right: asking again cannot change the answer (S1).
|
|
3674
3696
|
*/
|
|
3675
3697
|
creditExpiry = /* @__PURE__ */ new Map();
|
|
3676
3698
|
/**
|
|
3699
|
+
* Accounts whose last reading found NO one-off deadline (all monthly packs, or
|
|
3700
|
+
* none at all). Written instead of deleting the key, so the account stops
|
|
3701
|
+
* being a candidate for re-reading.
|
|
3702
|
+
*/
|
|
3703
|
+
creditExpiryNone = /* @__PURE__ */ new Set();
|
|
3704
|
+
/** When each account's deadline reading was taken, epoch ms. */
|
|
3705
|
+
creditExpiryReadAt = /* @__PURE__ */ new Map();
|
|
3706
|
+
/**
|
|
3707
|
+
* Accounts whose deadline reading is being fetched right now.
|
|
3708
|
+
*
|
|
3709
|
+
* Same de-duplication idea as {@link refreshInflight}, for the same reason: a
|
|
3710
|
+
* scan-triggered warm and a request-triggered top-up must not both spend a
|
|
3711
|
+
* billing round trip on the same account. A Set rather than a Map of promises
|
|
3712
|
+
* because no caller ever awaits the warm — the point is only that a second
|
|
3713
|
+
* pass skips it.
|
|
3714
|
+
*/
|
|
3715
|
+
expiryWarmInflight = /* @__PURE__ */ new Set();
|
|
3716
|
+
/**
|
|
3717
|
+
* Last time the pool tried to warm an account's deadline reading, epoch ms.
|
|
3718
|
+
*
|
|
3719
|
+
* The TTL is the success gate, not a retry gate: a failed read writes nothing,
|
|
3720
|
+
* so without this a permanently failing billing endpoint would be hit on every
|
|
3721
|
+
* scan and every served request. One attempt per account per minute is cheap
|
|
3722
|
+
* and still recovers quickly from a transient failure.
|
|
3723
|
+
*/
|
|
3724
|
+
expiryWarmAttemptAt = /* @__PURE__ */ new Map();
|
|
3725
|
+
/**
|
|
3677
3726
|
* Last time each account served a request, epoch ms. Drives the idle term
|
|
3678
3727
|
* of the priority-mode weighting below: an account that just served loses to
|
|
3679
3728
|
* one that has been idle, so a small pool stops hammering a single account.
|
|
@@ -3718,6 +3767,7 @@ var WorkBuddyAccountPool = class {
|
|
|
3718
3767
|
this.credentialDeadCooldownMs = options.credentialDeadCooldownMs ?? CREDENTIAL_DEAD_COOLDOWN_MS;
|
|
3719
3768
|
this.client = options.client;
|
|
3720
3769
|
this.refreshMarginMs = options.refreshMarginMs ?? 3e5;
|
|
3770
|
+
this.expiryReadingTtlMs = options.expiryReadingTtlMs ?? 36e5;
|
|
3721
3771
|
this.distribution = options.distribution ?? "priority";
|
|
3722
3772
|
this.persistent = options.persistent ?? false;
|
|
3723
3773
|
this.storePath = accountStorePath();
|
|
@@ -3932,6 +3982,7 @@ var WorkBuddyAccountPool = class {
|
|
|
3932
3982
|
ordered.sort((a, b) => compareFreshness(a.credential, b.credential));
|
|
3933
3983
|
this.accounts = ordered;
|
|
3934
3984
|
this.lastScanAtMs = Date.now();
|
|
3985
|
+
this.warmExpiryReadings();
|
|
3935
3986
|
if (this.persistent) try {
|
|
3936
3987
|
const leaving = this.lastPersistedIds === void 0 ? [] : [...this.lastPersistedIds].filter((id) => !this.accounts.some((account) => account.id === id));
|
|
3937
3988
|
if (leaving.length > 0) this.logger?.warn?.(`dsh-xdpool: ${String(leaving.length)} account(s) are no longer in the pool after a rescan and were removed from the store: ${leaving.join(", ")}. Their credentials are gone unless they are signed in again.`);
|
|
@@ -3942,6 +3993,76 @@ var WorkBuddyAccountPool = class {
|
|
|
3942
3993
|
}
|
|
3943
3994
|
return this.accounts;
|
|
3944
3995
|
}
|
|
3996
|
+
/**
|
|
3997
|
+
* Warm the deadline readings that `expiry` mode sorts on.
|
|
3998
|
+
*
|
|
3999
|
+
* Fire-and-forget on purpose, from `scan()`: the pool's first request arrives
|
|
4000
|
+
* before any reading exists, and the honest answer to that is the documented
|
|
4001
|
+
* fallback plus a log line, not a stalled request. Everything about the call
|
|
4002
|
+
* is chosen to be unable to make things worse:
|
|
4003
|
+
*
|
|
4004
|
+
* - `this.client` may not exist (a host that wired only token refresh), in
|
|
4005
|
+
* which case there is nothing to read with and the pass is a no-op — the
|
|
4006
|
+
* same guard `ensureFresh` uses;
|
|
4007
|
+
* - a dead sign-in is skipped, and a successful read NEVER calls
|
|
4008
|
+
* `clearCredentialDead`. That is the difference between this and
|
|
4009
|
+
* `reviveBenched`: the billing endpoint answers 200 for a banned account
|
|
4010
|
+
* (observed on 11140), so treating a read as proof of health is what got a
|
|
4011
|
+
* banned account revived six times in a day (S2). Only a token refresh or a
|
|
4012
|
+
* fresh sign-in may clear that mark;
|
|
4013
|
+
* - accounts whose reading is fresh enough are skipped, and so are accounts
|
|
4014
|
+
* already being read (S10's de-duplication, mirroring `refreshInflight`);
|
|
4015
|
+
* - a failed read writes nothing and only warns, so the next pass tries
|
|
4016
|
+
* again without the failure being mistaken for a reading.
|
|
4017
|
+
*/
|
|
4018
|
+
warmExpiryReadings() {
|
|
4019
|
+
if (this.client?.fetchCredits === void 0) return;
|
|
4020
|
+
for (const account of this.accounts) this.warmExpiryReadingFor(account.id);
|
|
4021
|
+
}
|
|
4022
|
+
/** One account's warm read; see {@link warmExpiryReadings} for the rules. */
|
|
4023
|
+
async warmOneExpiryReading(account, client) {
|
|
4024
|
+
this.expiryWarmInflight.add(account.id);
|
|
4025
|
+
this.expiryWarmAttemptAt.set(account.id, Date.now());
|
|
4026
|
+
try {
|
|
4027
|
+
const credits = await client.fetchCredits(account.credential);
|
|
4028
|
+
this.noteExpiryOnly(account.id, credits.nearestExpiryMs);
|
|
4029
|
+
} catch (error) {
|
|
4030
|
+
this.logger?.warn?.(`dsh-xdpool: could not read credit deadlines for ${account.label} (read failed); expiry mode keeps falling back for it until a read succeeds`, error);
|
|
4031
|
+
} finally {
|
|
4032
|
+
this.expiryWarmInflight.delete(account.id);
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
/**
|
|
4036
|
+
* Top up one account's deadline reading, from wherever the pool notices it is
|
|
4037
|
+
* missing or stale.
|
|
4038
|
+
*
|
|
4039
|
+
* The request path is the second caller (after `scan()`), because a reading
|
|
4040
|
+
* ages out while the pool is busy too: the shim calls this for the account that
|
|
4041
|
+
* just served a request, which is the one whose spend is most likely to have
|
|
4042
|
+
* moved its deadline. No timer is created — the existing balance refresh is
|
|
4043
|
+
* already the natural heartbeat, and this rides on it.
|
|
4044
|
+
*
|
|
4045
|
+
* Every gate lives here rather than in the callers, so both paths obey exactly
|
|
4046
|
+
* the same rules: no client, no account, a rejected sign-in, an already-running
|
|
4047
|
+
* read, a finished "nothing expires" answer, a fresh reading, or an attempt
|
|
4048
|
+
* made within the last minute all mean "do nothing".
|
|
4049
|
+
*/
|
|
4050
|
+
warmExpiryReadingFor(accountId) {
|
|
4051
|
+
if (this.distribution !== "expiry") return;
|
|
4052
|
+
const client = this.client;
|
|
4053
|
+
if (client?.fetchCredits === void 0) return;
|
|
4054
|
+
const account = this.accounts.find((item) => item.id === accountId);
|
|
4055
|
+
if (account === void 0) return;
|
|
4056
|
+
const now = Date.now();
|
|
4057
|
+
if ((account.credentialDeadUntilMs ?? 0) > now) return;
|
|
4058
|
+
if (this.expiryWarmInflight.has(accountId)) return;
|
|
4059
|
+
const reading = this.expiryReadingOf(accountId, now);
|
|
4060
|
+
if (reading.state === "none") return;
|
|
4061
|
+
if (reading.state === "at" && !reading.stale) return;
|
|
4062
|
+
const lastAttempt = this.expiryWarmAttemptAt.get(accountId) ?? 0;
|
|
4063
|
+
if (lastAttempt > (reading.readAtMs ?? 0) && now - lastAttempt < EXPIRY_WARM_RETRY_MS) return;
|
|
4064
|
+
this.warmOneExpiryReading(account, client);
|
|
4065
|
+
}
|
|
3945
4066
|
/** All accounts, cooldown state included. */
|
|
3946
4067
|
list(region) {
|
|
3947
4068
|
if (region === void 0) return this.accounts;
|
|
@@ -4289,18 +4410,37 @@ var WorkBuddyAccountPool = class {
|
|
|
4289
4410
|
* A pool where nobody has a known expiry therefore behaves exactly like
|
|
4290
4411
|
* priority, which is the honest degradation: without a reading there is
|
|
4291
4412
|
* nothing to sort by.
|
|
4413
|
+
*
|
|
4414
|
+
* What this method must NOT do is pretend. With only SOME readings in hand it
|
|
4415
|
+
* still has to fall back to `pool[0]`, because picking the earliest of the
|
|
4416
|
+
* accounts that happen to have answered would silently drop the account that
|
|
4417
|
+
* really dies first — the failure mode S0 in `EXPIRY-ADVERSARIAL-20261111.md`
|
|
4418
|
+
* called "worse than not fixing it", since the pick looks plausible and is
|
|
4419
|
+
* wrong. So the incomplete case is announced instead: the caller keeps the old
|
|
4420
|
+
* semantics and the log says which accounts were not read.
|
|
4292
4421
|
*/
|
|
4293
4422
|
pickByExpiry(pool) {
|
|
4423
|
+
const now = Date.now();
|
|
4424
|
+
const unread = [];
|
|
4425
|
+
const stale = [];
|
|
4294
4426
|
let best;
|
|
4295
4427
|
let bestAt = Number.POSITIVE_INFINITY;
|
|
4296
4428
|
for (const account of pool) {
|
|
4297
|
-
const
|
|
4298
|
-
if (
|
|
4429
|
+
const reading = this.expiryReadingOf(account.id, now);
|
|
4430
|
+
if (reading.stale) stale.push(account);
|
|
4431
|
+
if (reading.state === "unread" || reading.stale) {
|
|
4432
|
+
unread.push(account);
|
|
4433
|
+
continue;
|
|
4434
|
+
}
|
|
4435
|
+
if (reading.state === "none") continue;
|
|
4436
|
+
const at = reading.at ?? Number.POSITIVE_INFINITY;
|
|
4299
4437
|
if (at < bestAt) {
|
|
4300
4438
|
best = account;
|
|
4301
4439
|
bestAt = at;
|
|
4302
4440
|
}
|
|
4303
4441
|
}
|
|
4442
|
+
if (stale.length > 0) this.logger?.info?.(`dsh-xdpool: expiry mode found ${stale.length} deadline reading(s) older than ${Math.round(this.expiryReadingTtlMs / 6e4)} minute(s) (${stale.map((account) => account.label).join(", ")}); they are being topped up in the background`);
|
|
4443
|
+
if (unread.length > 0) this.logger?.warn?.(`dsh-xdpool: expiry mode has no deadline reading for ${unread.length} of ${pool.length} account(s) (${unread.map((account) => account.label).join(", ")}); falling back to pool order for this pick, which may not be the soonest to expire. Readings are filled in the background after a scan and by the request path.`);
|
|
4304
4444
|
return best ?? pool[0];
|
|
4305
4445
|
}
|
|
4306
4446
|
/**
|
|
@@ -4478,21 +4618,91 @@ var WorkBuddyAccountPool = class {
|
|
|
4478
4618
|
* merged: a pack that has been spent or has died disappears from the next
|
|
4479
4619
|
* reading, and keeping the stale deadline would pin the pool to an account
|
|
4480
4620
|
* whose credits are already gone — the opposite of what `expiry` mode wants.
|
|
4621
|
+
*
|
|
4622
|
+
* "Nothing expires" is a real answer, not the absence of one: it is stored as
|
|
4623
|
+
* {@link creditExpiryNone} so the account is not read again on every pass.
|
|
4481
4624
|
*/
|
|
4482
4625
|
noteCredits(accountId, balance, nearestExpiryMs) {
|
|
4483
4626
|
if (!Number.isFinite(balance)) return;
|
|
4484
4627
|
if (!this.accounts.some((account) => account.id === accountId)) return;
|
|
4485
4628
|
this.creditBalances.set(accountId, balance);
|
|
4629
|
+
this.noteExpiryReading(accountId, nearestExpiryMs);
|
|
4630
|
+
}
|
|
4631
|
+
/**
|
|
4632
|
+
* Record ONLY the deadline, never the balance.
|
|
4633
|
+
*
|
|
4634
|
+
* The scan-triggered warm exists to fill `expiry` mode's sort key. Writing the
|
|
4635
|
+
* balance as a side effect would change what the reserve floor decides — an
|
|
4636
|
+
* account could be pulled out of rotation by a background read the user never
|
|
4637
|
+
* asked for, which is a behaviour change outside this fix's scope (S7 in
|
|
4638
|
+
* `EXPIRY-ADVERSARIAL-20261111.md`; the reserve's own cold-start hole is V4,
|
|
4639
|
+
* fixed separately).
|
|
4640
|
+
*/
|
|
4641
|
+
noteExpiryOnly(accountId, nearestExpiryMs) {
|
|
4642
|
+
if (!this.accounts.some((account) => account.id === accountId)) return;
|
|
4643
|
+
this.noteExpiryReading(accountId, nearestExpiryMs);
|
|
4644
|
+
}
|
|
4645
|
+
/**
|
|
4646
|
+
* The three-state writer both entry points funnel through.
|
|
4647
|
+
*
|
|
4648
|
+
* One place, so the invariant "a finished reading always leaves a state" can be
|
|
4649
|
+
* read off a single function: either a deadline is stored, or the account joins
|
|
4650
|
+
* `creditExpiryNone`. Nothing here deletes the read stamp — that is what makes
|
|
4651
|
+
* "read, found nothing" distinguishable from "never read".
|
|
4652
|
+
*/
|
|
4653
|
+
noteExpiryReading(accountId, nearestExpiryMs) {
|
|
4654
|
+
this.creditExpiryReadAt.set(accountId, Date.now());
|
|
4486
4655
|
if (nearestExpiryMs === void 0 || !Number.isFinite(nearestExpiryMs)) {
|
|
4487
4656
|
this.creditExpiry.delete(accountId);
|
|
4657
|
+
this.creditExpiryNone.add(accountId);
|
|
4488
4658
|
return;
|
|
4489
4659
|
}
|
|
4660
|
+
this.creditExpiryNone.delete(accountId);
|
|
4490
4661
|
this.creditExpiry.set(accountId, nearestExpiryMs);
|
|
4491
4662
|
}
|
|
4492
4663
|
/** Nearest one-off pack expiry for one account, or undefined when none known. */
|
|
4493
4664
|
creditExpiryOf(accountId) {
|
|
4494
4665
|
return this.creditExpiry.get(accountId);
|
|
4495
4666
|
}
|
|
4667
|
+
/**
|
|
4668
|
+
* The full three-state reading for one account, including staleness.
|
|
4669
|
+
*
|
|
4670
|
+
* `stale` is evaluated against {@link EXPIRY_READING_TTL_MS} here rather than
|
|
4671
|
+
* baked into the stored value, so the TTL stays a constant of the policy and
|
|
4672
|
+
* not of the data.
|
|
4673
|
+
*
|
|
4674
|
+
* Only a real deadline can go stale. "We never asked" is not a reading, and
|
|
4675
|
+
* "nothing here has a deadline" does not become less true with age: a monthly
|
|
4676
|
+
* pack does not grow an expiry date by waiting. Keeping `none` permanently
|
|
4677
|
+
* valid is what makes the S1 loop impossible — an account that answered once
|
|
4678
|
+
* is never read again by the expiry machinery, so there is no predicate that
|
|
4679
|
+
* can stay true forever and re-read it on every pass. If such an account does
|
|
4680
|
+
* gain a one-off pack later, the card refresh (which writes through
|
|
4681
|
+
* `noteCredits` on every poll) is what notices.
|
|
4682
|
+
*/
|
|
4683
|
+
expiryReadingOf(accountId, now = Date.now()) {
|
|
4684
|
+
const at = this.creditExpiry.get(accountId);
|
|
4685
|
+
const readAtMs = this.creditExpiryReadAt.get(accountId);
|
|
4686
|
+
if (readAtMs === void 0) return {
|
|
4687
|
+
state: "unread",
|
|
4688
|
+
stale: false
|
|
4689
|
+
};
|
|
4690
|
+
if (at !== void 0) return {
|
|
4691
|
+
state: "at",
|
|
4692
|
+
at,
|
|
4693
|
+
readAtMs,
|
|
4694
|
+
stale: now - readAtMs > this.expiryReadingTtlMs
|
|
4695
|
+
};
|
|
4696
|
+
if (this.creditExpiryNone.has(accountId)) return {
|
|
4697
|
+
state: "none",
|
|
4698
|
+
readAtMs,
|
|
4699
|
+
stale: false
|
|
4700
|
+
};
|
|
4701
|
+
return {
|
|
4702
|
+
state: "unread",
|
|
4703
|
+
stale: false
|
|
4704
|
+
};
|
|
4705
|
+
}
|
|
4496
4706
|
/** Last known balance for one account, or undefined when never read. */
|
|
4497
4707
|
creditsOf(accountId) {
|
|
4498
4708
|
return this.creditBalances.get(accountId);
|
package/lib/client.js
CHANGED
|
@@ -10326,7 +10326,19 @@ window.__ModuleLoader__.load({
|
|
|
10326
10326
|
const out = [];
|
|
10327
10327
|
const seen = /* @__PURE__ */ new Set();
|
|
10328
10328
|
for (const platform of platforms) for (const model of platform.models) {
|
|
10329
|
-
|
|
10329
|
+
/**
|
|
10330
|
+
* A channel member is ALREADY composite (#141).
|
|
10331
|
+
*
|
|
10332
|
+
* `owner` here is the editor's grouping label. For a scan-login channel the
|
|
10333
|
+
* member's own id is `<channel>:<model>` and already carries the owner, so
|
|
10334
|
+
* prefixing it again produced `trae/trae:deepseek-v4.1-flash`. The runtime then
|
|
10335
|
+
* matched nothing and the chain reported every member missing — and a save in that
|
|
10336
|
+
* state would have rewritten the chain with the doubled ids.
|
|
10337
|
+
*
|
|
10338
|
+
* The colon is the test, matching `channelMemberOf` in `combos.ts`.
|
|
10339
|
+
*/
|
|
10340
|
+
const selfOwned = /^[A-Za-z0-9_-]+:/u.test(model);
|
|
10341
|
+
const id = platform.owner === "workbuddy" || selfOwned ? model : `${platform.owner}/${model}`;
|
|
10330
10342
|
if (seen.has(id)) continue;
|
|
10331
10343
|
seen.add(id);
|
|
10332
10344
|
out.push(id);
|
|
@@ -10357,9 +10369,19 @@ window.__ModuleLoader__.load({
|
|
|
10357
10369
|
const known = new Set(Array.isArray(combo.models) ? combo.models : []);
|
|
10358
10370
|
for (const modelId of Array.isArray(combo.missing) ? combo.missing : []) {
|
|
10359
10371
|
if (known.has(modelId)) continue;
|
|
10372
|
+
/**
|
|
10373
|
+
* Read the owner the same way `combos.ts` does, so a missing CHANNEL member is filed
|
|
10374
|
+
* under its channel rather than under a slash prefix (#141).
|
|
10375
|
+
*
|
|
10376
|
+
* `raccoon:sn-…` belongs to `raccoon`; splitting on `/` would find no slash, call it a
|
|
10377
|
+
* pool model, and then `flattenDraft` would write `workbuddy/raccoon:…` back.
|
|
10378
|
+
*/
|
|
10379
|
+
const colon = modelId.indexOf(":");
|
|
10380
|
+
const channelHead = colon > 0 ? modelId.slice(0, colon) : "";
|
|
10381
|
+
const isChannelMember = channelHead !== "" && /^[A-Za-z0-9_-]+$/u.test(channelHead);
|
|
10360
10382
|
const slash = modelId.indexOf("/");
|
|
10361
|
-
const owner = slash === -1 ? "workbuddy" : modelId.slice(0, slash);
|
|
10362
|
-
const model = slash === -1 ? modelId : modelId.slice(slash + 1);
|
|
10383
|
+
const owner = isChannelMember ? channelHead : slash === -1 ? "workbuddy" : modelId.slice(0, slash);
|
|
10384
|
+
const model = isChannelMember ? modelId : slash === -1 ? modelId : modelId.slice(slash + 1);
|
|
10363
10385
|
const group = platforms.find((entry) => entry.owner === owner);
|
|
10364
10386
|
if (group === void 0) platforms.push({
|
|
10365
10387
|
owner,
|
|
@@ -13470,7 +13492,7 @@ window.__ModuleLoader__.load({
|
|
|
13470
13492
|
*
|
|
13471
13493
|
* @module dsh-xdpool/version
|
|
13472
13494
|
*/
|
|
13473
|
-
const POOL_VERSION = "2.6.
|
|
13495
|
+
const POOL_VERSION = "2.6.7";
|
|
13474
13496
|
//#endregion
|
|
13475
13497
|
//#region src/client/PoolCard.tsx
|
|
13476
13498
|
/**
|