dsh-connect-workbuddy 5.21.0 → 5.21.2
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 +70 -0
- package/README.md +3 -2
- package/lib/bin.js +1 -1
- package/lib/client.js +237 -27
- package/lib/{host-heartbeat-BLfxyXIA.js → host-heartbeat-CxvijdHh.js} +1 -1
- package/lib/index.d.ts +39 -0
- package/lib/index.js +136 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.21.2 (2026-11-09)
|
|
4
|
+
|
|
5
|
+
> 版本号是 **patch**:新增一个配置键(`pollIntervalMs`)与一个「能力」栏控件,
|
|
6
|
+
> 不改既有键的含义,不动路由。
|
|
7
|
+
|
|
8
|
+
### 新增:刷新频率可配,默认从 60 秒改成 5 分钟
|
|
9
|
+
|
|
10
|
+
有人问「60 秒轮询是不是太频繁」。查下来确实偏密,而且**成本是可以算出来的**:
|
|
11
|
+
每次刷新要为池内每个账号各读一次积分和一次签到状态,4 个账号的池子按 60 秒算是
|
|
12
|
+
一天约 **11,520 个请求**——换来的却是变化很慢的余额数字。
|
|
13
|
+
|
|
14
|
+
于是它变成一个设置而不是另一个常数:五档(1 / 5 / 10 / 30 / 60 分钟),默认
|
|
15
|
+
**5 分钟**。「能力」栏点一下即生效,不走保存。
|
|
16
|
+
|
|
17
|
+
- 新增共享常量 `WORKBUDDY_POLL_INTERVALS_MS` / `WORKBUDDY_DEFAULT_POLL_INTERVAL_MS`:
|
|
18
|
+
卡片的下拉、Host 的校验、面板的回退都读同一份,控件与校验不会各说各话。
|
|
19
|
+
- **取值是封闭集合,不是自由数字**:这个间隔直接驱动 `setInterval`,手写一个 `0`
|
|
20
|
+
会把「偶尔刷新」变成「不停刷新」。所以 Host 读配置时强制回落,`workBuddyWebStatus`
|
|
21
|
+
再对依赖的答案复检一次——**两处是刻意的纵深**,删掉任意一处测试仍然绿(另一层挡着),
|
|
22
|
+
两处都删才会红。
|
|
23
|
+
- **输入框的账号面板跟随同一个值**:它原先自己写死 60 秒,只是碰巧等于卡片的 60 秒,
|
|
24
|
+
任意一边改动就会让两个界面对同一个账号给出不同说法——这正是当初把它钉在 60 秒的
|
|
25
|
+
理由(面板要渲染的「被限流 / 模型繁忙」最短冷却只有 2 分钟)。现在只有一个间隔,
|
|
26
|
+
那个取舍交回给用户:想要更紧的反馈就选 1 分钟。
|
|
27
|
+
- 代价说明:选 5 分钟以上时,面板里那类 2 分钟冷却的标注最多会晚一个间隔更新。
|
|
28
|
+
这是**用户显式选择**的结果,不再是两个界面互相矛盾。
|
|
29
|
+
|
|
30
|
+
### 关于「未签到」那列
|
|
31
|
+
|
|
32
|
+
顺带确认(并写进测试):它**不是顺便看到的**,而是每个账号一次独立的
|
|
33
|
+
`checkin-activity-status` 请求,与积分是两个不同接口。所以调低刷新频率会同时减少
|
|
34
|
+
这两类请求——这也是把它做成设置的主要动机。
|
|
35
|
+
|
|
36
|
+
## 5.21.1 (2026-11-09)
|
|
37
|
+
|
|
38
|
+
> ⚠️ **这一版没有单独发到 npm**:改动与 5.21.2 一起发布,所以 registry 上不会出现
|
|
39
|
+
> `5.21.1` 这个版本号。这里保留记录,是因为下面修的是两处真实的行为缺陷,而不是
|
|
40
|
+
> 一次可以悄悄吞掉的中间态。
|
|
41
|
+
>
|
|
42
|
+
> 版本号是 **patch**:不改配置键、不动路由、不改定时器,只修**读取路径**上两处
|
|
43
|
+
> 「把昨天当成今天」的判断。
|
|
44
|
+
|
|
45
|
+
### 修复:跨过本地 0 点后,卡片仍把昨天的签到进度当成今天(issue #232)
|
|
46
|
+
|
|
47
|
+
报告的现象是 0 点 08 分的截图:表头写着「今日:4 个全部已签」,而下面每一行都读
|
|
48
|
+
「未签到」。两者都是真的——**行**读的是上游(缓存 ≤10 分钟),**表头**读的是运行器
|
|
49
|
+
的内存状态,而那份状态还停在昨天。
|
|
50
|
+
|
|
51
|
+
自动签到是一个 30 分钟的**心跳**:一天签完之后,下一轮要等 `AUTO_CHECKIN_IDLE_MS`
|
|
52
|
+
才跑,所以 0 点后最多半小时内,内存里的 `day` 仍是昨天。`autoCheckinToday` 直接
|
|
53
|
+
把这份状态总结成「今日」,于是界面在一天刚开始时宣布它已经结束了。
|
|
54
|
+
|
|
55
|
+
改的是读取,不是调度(报告者也明确说不需要卡 0 点):
|
|
56
|
+
|
|
57
|
+
- 新增 `todaySummary(state, nowMs)`:`state.day` 不是今天时返回 `undefined`,卡片
|
|
58
|
+
把它渲染成「没有状态行」——这是诚实的答案(今天还没有跑过),而补一个
|
|
59
|
+
`0 / 0` 的摘要会读成「池子是空的」。
|
|
60
|
+
- 新增 `checkinReadingFresh(atMs, nowMs, ttlMs)`:签到读数的缓存**同时**受 TTL 和
|
|
61
|
+
本地日约束。此前 23:58 读到的 `true` 可以一路服务到 00:08——那是同一个谎的
|
|
62
|
+
逐账号版本,只是发生在表格里而不是表头上。日期从 `atMs` 推导,不另存一份字段,
|
|
63
|
+
两份时间才不会漂移。
|
|
64
|
+
|
|
65
|
+
定时器、退避、幂等语义(先读状态、已签判 `already`、不重复领取)全部不变;轮询
|
|
66
|
+
发现今天没签就签,本来就是既有行为,本次只是让**报告**与**事实**对齐。
|
|
67
|
+
|
|
68
|
+
### 文档:README 里「不提供自动签到」的旧说法
|
|
69
|
+
|
|
70
|
+
`README.md` 两处仍写着插件不提供自动签到、只在你点按钮时执行——那是 #191 之前的
|
|
71
|
+
事实。改为:默认只在按钮按下时执行,另有一个默认关闭的开关授权后台领取。
|
|
72
|
+
|
|
3
73
|
## 5.21.0 (2026-11-08)
|
|
4
74
|
|
|
5
75
|
> 版本号是 **minor**:注册的**条数**随宿主的声明变化(`single` 一条、`keyed` 每个
|
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
- **设置页 tab 切换** —— 设置页顶部为「国内版 / 国际版」两个 tab,各含独立的账号池与模型管理;每个 tab 的账号、目录、勾选与未保存草稿完全隔离——在一个 tab 里切账号或刷新模型,不会触碰另一边的运行时目录与会话。
|
|
47
47
|
- **可单独关闭任一版本供应商** —— 每个 tab 右侧有一个勾选框(默认都勾选)。**取消勾选即把该供应商从 DSH 模型选择器里彻底撤掉**(不是只藏起 tab):它的路由与「设置 → 模型」页的目录条目一并摘除,启动时也不再为它发无用请求。账号、积分、目录与勾选**全部保留**,重新勾选即完整恢复。典型用法是「我根本用不到国际版」——关掉它,让选择器干净。注意:若某会话此前选中的正是被关闭供应商的模型,该会话再调用会报 `NO_ADAPTER`,卡片会在关闭态的 tab 上明确提示这一点,不会静默失败。
|
|
48
48
|
- **设置页分栏:账号 / 模型 / 能力 / 诊断** —— 原来这一页是一列 3000 多像素的长页,把两类互不相干的事情混排在一起:**运维账号**(谁在服务、还剩多少、切换顺序、签到日志)与**编辑目录**(勾模型、上下文预算、推理档、关闭思考)。它们连提交语义都不同——账号改动点一下即生效,目录改动是草稿、必须点保存——所以「保存」按钮常常离它要保存的东西隔着三屏。现在分栏,一栏只做一件事;**切栏既不会重新拉取,也不会丢掉未保存的目录草稿**(非活动栏留在页面里,只是通过 `hidden` 不可见,因此也不进入无障碍树)。第三栏「能力」放的是**授权类开关**——允许调用本机 CodeBuddy CLI、允许模型自主生图、积分读数显示在哪——它们点一下即生效、从不经过保存,而且每一个都留着长自己子选项的位置(CLI 的工作目录、生图的尺寸或价格上限),所以不挤在账号表格上方那一小条里。第四栏「诊断」是只读的事实表:当前区域、上游域名、真正在服务的账号名、登录有效期、目录里共几个模型、启用了几个、账号池开关,以及上游最近一次错误的**原文**(原样引用,不翻译、不概括)——这一栏存在的唯一理由就是能被整段贴进问题反馈,所以里面没有任何会改设置的控件。
|
|
49
|
+
- **刷新频率(`pollIntervalMs`,默认 5 分钟)** —— 卡片多久重读一次账号表。**这是一次真实的请求量决定**:每次刷新要为池内每个账号各读一次积分(`/v2/billing/meter/get-user-resource`)和一次签到状态(`/v2/billing/meter/checkin-activity-status`),所以 4 个账号的池子按旧的固定 60 秒算,一天约 11,520 个请求——而这些数字本来动得很慢。默认改成 **5 分钟**(约为原来的 1/5),「能力」栏给五档:1 / 5 / 10 / 30 / 60 分钟,点一下即生效、不走保存。**输入框的账号面板跟随同一个值**:此前它自己写死 60 秒,只是「碰巧」等于卡片的 60 秒,两边一旦改动就会对同一个账号给出不同说法(面板还画着「模型繁忙」、卡片已经说恢复正常)——现在只有一个间隔,改一处两处一起变。**取值是封闭的五档**:配置文件里手写的 `0` 或别的数字一律回落到默认值,因为「不刷新」和「疯狂刷新」都不是用户想要的,而这个数字直接驱动 `setInterval`。
|
|
49
50
|
- **可选:侧边栏入口(`sidebarPanel`,默认关闭)** —— 在 DSH 侧边栏加一行 WorkBuddy,点开就是**这张卡片的整页版**(左上有「返回会话」)。分栏挤在设置面板那 800px 里时,账号表格、模型目录与诊断原文都只有半屏宽;整页版把同一批东西摊到整栏。**默认关闭**:这一行占的是**所有已安装插件共用的全局侧边栏座位**,而「设置 → WorkBuddy」本来就能打开同一页,一次升级不该替用户占这个位置。开关在「能力」栏,**勾上即出现、取消即消失,不走保存**——与这一栏其它授权类开关一致。
|
|
50
51
|
- **关掉时是把注册注销,不是渲染空组件**:侧边栏导航行是用槽位**条目元数据**(`label` + 图标)拼的,组件返回 `null` 只会得到一颗**空白但仍可点**的按钮。所以决策点在 `apply`(`src/client/panel-switch.ts` 是卡片与入口之间的接缝),关掉即 `dispose`。
|
|
51
52
|
- **首屏状态问宿主,不问浏览器里的设置镜像**:那份镜像在部分 0.1.7 上是陈的,且只在命名空间**边缘**触发、不在**值变化**时触发——一份陈的 `false` 会让这一行整个会话都不出现,且没有任何事件来纠正它。所以种子读宿主自己的答案(usage 文档的 `sidebarPanelEnabled`)。
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
- **对话输入框积分读数(国内版 / 国际版自动切换)** —— 对话输入框左侧工具栏常驻一行可点击的读数(如 `WB CN · 1,072`),**按本会话当前选中的模型自动切换区域**:选中 WB CN 的模型就显示国内版余额,选中 WB AI 的模型就显示国际版余额;用其它 provider 的模型时该读数完全不出现。每 5 分钟自动刷新,也可点开手动刷新。点击读数弹出面板:**按账号列出的余额表格**,点某一行即可切换到该账号(与卡片上的账号选择是同一个设置);**当前不能用的账号会在行内标出原因**(如「被限流」「积分耗尽」),标注口径与账号池表格一致。面板里的余额只在打开时才去查,因此不会让 5 分钟的后台刷新按账号数翻倍。要关掉某一边,就在卡片对应区域的 tab 下取消勾选「在输入框工具栏显示积分读数」;该区域的供应商被关闭时,读数不显示、开关也置灰。同一个开关下面还有「显示位置」这一行:默认在输入框工具栏(与模型选择同一行,位于模型选择器左侧、与权限切换器隔开),改成「输入框下方」后读数落到轮次/步数/token 统计那一行——装了别的插件把工具栏座位占掉时用得上。
|
|
67
68
|
|
|
68
69
|
<img src="docs/assets/dsh-connect-workbuddy-composer-credits.png" width="360" alt="对话输入框积分面板:国内版账号余额表格、一键测试按钮与最近刷新时间(账号名已用实心块覆盖)" />
|
|
69
|
-
- **账号池:多账号批量操作与自动换号** —— 把要用的账号勾进池子,即可**签到勾选的账号**、**测试勾选的账号 × 你指定的模型**(默认挑该区域倍率为 0 的免费模型);开启**启用账号池**即同时打开**自动换号**——某个请求在上游失败时,插件会依次用池内其他可用账号重试,直到有一个接手、或全部不可用为止,然后才把错误报给你。成员**默认一个都不含**、必须显式勾选(「本机有登录」不等于「要拿它去签到和花积分」);**开启后由池子的排序决定每一次请求用谁**(可用优先,其次快过期先花、积分高、凭据更新的);失败时依次用池内其他可用账号重试。排序**从不写回你保存的选择**——关掉开关,你选定的账号立刻完全生效。只有请求本身不合法(HTTP 400)不换号:同一个请求体换谁都是 400
|
|
70
|
+
- **账号池:多账号批量操作与自动换号** —— 把要用的账号勾进池子,即可**签到勾选的账号**、**测试勾选的账号 × 你指定的模型**(默认挑该区域倍率为 0 的免费模型);开启**启用账号池**即同时打开**自动换号**——某个请求在上游失败时,插件会依次用池内其他可用账号重试,直到有一个接手、或全部不可用为止,然后才把错误报给你。成员**默认一个都不含**、必须显式勾选(「本机有登录」不等于「要拿它去签到和花积分」);**开启后由池子的排序决定每一次请求用谁**(可用优先,其次快过期先花、积分高、凭据更新的);失败时依次用池内其他可用账号重试。排序**从不写回你保存的选择**——关掉开关,你选定的账号立刻完全生效。只有请求本身不合法(HTTP 400)不换号:同一个请求体换谁都是 400,重试只会白等。**这个开关只管「插件要不要自己决定」**:关掉它,插件不再替你选账号、也不再替你换号,但**签到与测试仍然可用**。测试走的是与模型行同一套真实体积探测,因此**有真实成本**;签到会真实领取奖励,因此**默认只在你点按钮时执行**——另有一个**默认关闭**的「每天自动签到」开关,打开后插件才在后台替你领取(先读状态、已签的不重复领取,漏一天会断连签)。详见[账号池](#账号池)。
|
|
70
71
|
- **企业版 / 教育版账号:签到与「领取」不适用** —— 带 `enterpriseId` 的席位(企业版或教育版)在池子里**不显示签到列、不显示福利活动,也不会发出领取请求**(5.8.0,issue #129):上游对这类成员的个人权益**写**接口一律拒绝(实测 `10001`),而它的**读**接口照样把活动列出来、标着「未领」——所以「读到了」绝不能当成「可以领」。积分也在另一本账上(企业用量 = 上限 − 已用),个人积分表对这种账号返回空列表。这个判断贯穿池卡片、输入框胶囊与 Web 状态页,并且在账号进入池子的那一刻就带上标记,而不是等用户点了按钮才发现不支持。
|
|
71
72
|
- **可选:让上游用量页把这笔记成官方客户端发的那笔(5.8.0,issue #132,默认关闭)** —— 开 `usageIdentity` 后 chat 请求带上 `X-IDE-Name: WorkBuddy`(连同 `X-IDE-Type: CLI` 与版本号;版本号取自现有的产品 UA,不留第二个硬编码数字),用量页的「使用端」由此不再空白;会话身份三件套同时改成官方客户端那种 **32 位十六进制 UUIDv7** 并补上 `X-Request-ID`——网关把这个 id 回显成 SSE 的 `id` 并写进用量页,此前带连字符的 v4 与官方记录摆在同一页上像两种客户端;**每请求现生成、互不相同**这条没有放松。**`User-Agent` 在两种取值下都一字未动**——账单与限流认的是 CLI 通道;生图路径也不跟着这个开关变,它保持自己 2026-10-21 实测过的形状。**默认关**的理由:形状本身不修任何东西(`11128` 的三道门读的是消息开头、会话 id 有没有、首条是不是 system,头改不动其中任何一条),而实测证据来自报告者的账号与旧版本、本插件未在真机复现——一次纯显示对齐不该让所有账号先承担风险。另有可选的 `keepPromptLast`(**默认关闭**):用量页的「请求」列取自 body 里**最后一条** `user` 消息,而宿主把时间采样、运行时上下文、`<system-reminder>` 追加在你真正输入的那句**之后**,那一列于是常年记的是注入块;开启后把这些注入块**搬到真实输入之前**(只变顺序;另外会剥掉**被记录那一条**真实输入前面的 `<acp …>mNNNNN</acp>` 标记,否则那一列仍然以标记开头而等于没修,更早的消息一律保留自己的标记,因为模型靠它们引用历史)。默认关的理由是它会改变上游会数到的消息顺序、并删掉真实输入的几个前导字符;搬移只匹配宿主自己的注入前缀,而普通对话在没有注入尾块时逐字节不变(连标记也不剥)——这两点各有专门测试钉住。
|
|
72
73
|
- **可选:把每个新会话的标题请求改到隐藏轻量模型(issue #133,默认关闭)** —— DSH 宿主每个新会话会发一次标题生成请求,走的是与对话相同的 provider,于是这笔按主付费模型的费率计费。开启 `sessionTitle.enabled` 后,插件把能按宿主标题模板(`Generate the session title from this JSON array of human messages:` 开头、整条 body 只有这一条 user 消息)识别出的标题请求改写到 `sessionTitle.model`(默认 `wb-lite`)。报告者实测该模型对这类请求 **0 积分**,但注意三点:这仍是**真实上游请求**,请求数照算;证据是报告者账号级的,本插件未复现;识别按 fail-closed 设计——宿主若改模板,改写静默停止、回到原计费,不会误伤普通对话。若上游拒绝该模型,只是该会话标题生成失败一次,不影响主对话。另外,`sessionTitle` 与本条及上一条的 `usageIdentity` / `keepPromptLast` / `extraInjectedPrefixes` 一样,都是插件挂载时读一次配置:**改完 `cordis.patch.yml` 后需要重载插件或重启 DSH 才生效**,热改不生效。
|
|
@@ -185,7 +186,7 @@ DSH PiAiAdapter(每个 provider 一套)
|
|
|
185
186
|
|
|
186
187
|
**测试目标是哪个模型**:默认是**该区域目录里倍率为 0 的免费模型**(实测国内版当前只有 `hy3` 一个;**不写死名字**,因为上游会改倍率——`deepseek-v4.1-flash` 就已从 0 变成 0.11),也可以在下拉里指定一个具体模型。指定的模型若已离开目录,**手动动作会明确拒绝**(`target-model-stale`),而不是偷偷换一个——你点的是「测这个模型」,换掉就是答非所问。
|
|
187
188
|
|
|
188
|
-
**成本与边界**:测试是真实请求,指向免费模型时(倍率 0
|
|
189
|
+
**成本与边界**:测试是真实请求,指向免费模型时(倍率 0)几乎不花钱,但它**不是零成本的空转**;签到则会真实领取当日奖励。默认两个动作都**只在你点按钮时执行**;自动签到是一个**显式的、默认关闭**的开关,打开它才是你授权插件替你领——它先读状态,已签到的不重复领取。
|
|
189
190
|
|
|
190
191
|
### 池成员是显式勾选,默认一个都不含
|
|
191
192
|
|
package/lib/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as DEFAULT_WIRE_PROFILE, Cn as hostPeersInfo, F as WorkBuddyCredentialStore, J as workbuddyOwnAuthPath, N as WORKBUDDY_AUTH_FILE_ENV, 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 deriveDeviceId, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, cn as protectCredentialDirectory, d as rosterSeenPath, f as WORKBUDDY_CN_BASE_ENV, g as createTuringSdk, hn as findWorkbuddyAppExecutableWithSource, in as readDeviceSalt, ln as WORKBUDDY_APP_EXECUTABLE_ENV, m as piAiRuntimeInfo, nn as readDeviceTokenFile, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, ot as describeRequestHeaderNames, p as resolveCnGateway, r as isHeartbeatProcessAlive, rn as ensureDeviceSalt, sn as inspectCredentialDirectory, tn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, u as describeRosterSeenPayload, w as FALLBACK_WORKBUDDY_MODELS, wn as resolveDshHome, z as defaultDesktopAuthDirs } from "./host-heartbeat-
|
|
2
|
+
import { $ as DEFAULT_WIRE_PROFILE, Cn as hostPeersInfo, F as WorkBuddyCredentialStore, J as workbuddyOwnAuthPath, N as WORKBUDDY_AUTH_FILE_ENV, 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 deriveDeviceId, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, cn as protectCredentialDirectory, d as rosterSeenPath, f as WORKBUDDY_CN_BASE_ENV, g as createTuringSdk, hn as findWorkbuddyAppExecutableWithSource, in as readDeviceSalt, ln as WORKBUDDY_APP_EXECUTABLE_ENV, m as piAiRuntimeInfo, nn as readDeviceTokenFile, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, ot as describeRequestHeaderNames, p as resolveCnGateway, r as isHeartbeatProcessAlive, rn as ensureDeviceSalt, sn as inspectCredentialDirectory, tn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, u as describeRosterSeenPayload, w as FALLBACK_WORKBUDDY_MODELS, wn as resolveDshHome, z as defaultDesktopAuthDirs } from "./host-heartbeat-CxvijdHh.js";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { realpathSync } from "node:fs";
|
package/lib/client.js
CHANGED
|
@@ -137,6 +137,33 @@ window.__ModuleLoader__.load({
|
|
|
137
137
|
/** How long the card waits between polls while the user is scanning. */
|
|
138
138
|
const OAUTH_POLL_INTERVAL_MS = 2e3;
|
|
139
139
|
/**
|
|
140
|
+
* The refresh intervals the card offers, in milliseconds.
|
|
141
|
+
*
|
|
142
|
+
* SHARED between the Host (which validates the saved value) and the browser
|
|
143
|
+
* (which renders the dropdown), so the control and its validation cannot drift:
|
|
144
|
+
* a value the dropdown can produce is always a value the Host accepts, and the
|
|
145
|
+
* Host's fallback is always a value the dropdown can show.
|
|
146
|
+
*
|
|
147
|
+
* A CLOSED SET rather than a free number because this interval decides the
|
|
148
|
+
* plugin's upstream request volume — one credits read plus one check-in read per
|
|
149
|
+
* pooled account, per refresh.
|
|
150
|
+
*/
|
|
151
|
+
const WORKBUDDY_POLL_INTERVALS_MS = [
|
|
152
|
+
6e4,
|
|
153
|
+
3e5,
|
|
154
|
+
6e5,
|
|
155
|
+
18e5,
|
|
156
|
+
36e5
|
|
157
|
+
];
|
|
158
|
+
/**
|
|
159
|
+
* The default refresh interval: 5 minutes.
|
|
160
|
+
*
|
|
161
|
+
* Moved off the old hard-coded 60 s. A 4-account pool at 60 s costs ~11,520
|
|
162
|
+
* requests a day for figures that move slowly; 5 minutes is a fifth of that and
|
|
163
|
+
* still five times finer than the 30-minute auto check-in heartbeat.
|
|
164
|
+
*/
|
|
165
|
+
const WORKBUDDY_DEFAULT_POLL_INTERVAL_MS = 3e5;
|
|
166
|
+
/**
|
|
140
167
|
* Plugin-owned account transfer endpoint: the batch export / import of
|
|
141
168
|
* credentials between machines and between tools of the SAME format family.
|
|
142
169
|
*
|
|
@@ -1087,6 +1114,50 @@ window.__ModuleLoader__.load({
|
|
|
1087
1114
|
throw hostError instanceof Error ? hostError : new WorkBuddySettingsWriteError("sidebarPanel", "neither the Host save endpoint nor the settings scope persisted the value");
|
|
1088
1115
|
}
|
|
1089
1116
|
/**
|
|
1117
|
+
* Read the card's refresh interval out of a settings snapshot.
|
|
1118
|
+
*
|
|
1119
|
+
* Coerced against the offered set, and an unrecognized value reads as the
|
|
1120
|
+
* default. The direction matters: this number drives `setInterval`, so a typo in
|
|
1121
|
+
* the settings file must not become a sub-second poll. Coercing on READ as well
|
|
1122
|
+
* as on the Host means a stale browser mirror cannot arm a cadence the Host
|
|
1123
|
+
* would have refused.
|
|
1124
|
+
*/
|
|
1125
|
+
function pollIntervalMsOf(value) {
|
|
1126
|
+
const raw = value?.pollIntervalMs;
|
|
1127
|
+
return typeof raw === "number" && WORKBUDDY_POLL_INTERVALS_MS.includes(raw) ? raw : WORKBUDDY_DEFAULT_POLL_INTERVAL_MS;
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Persist the card's refresh interval.
|
|
1131
|
+
*
|
|
1132
|
+
* Same two-writer shape as {@link writeSidebarPanelEnabled}: the Host endpoint is
|
|
1133
|
+
* authoritative, the settings scope is the fallback for an older Host. A plain
|
|
1134
|
+
* top-level number, so there is no sibling state to preserve.
|
|
1135
|
+
*
|
|
1136
|
+
* @param scope - the bound settings scope for this plugin's namespace.
|
|
1137
|
+
* @param intervalMs - one of {@link WORKBUDDY_POLL_INTERVALS_MS}.
|
|
1138
|
+
* @throws {WorkBuddySettingsWriteError} when neither writer persists the value.
|
|
1139
|
+
*/
|
|
1140
|
+
async function writePollIntervalMs(scope, intervalMs) {
|
|
1141
|
+
let hostError;
|
|
1142
|
+
try {
|
|
1143
|
+
const authoritative = await saveViaHostEndpoint("pollIntervalMs", void 0, intervalMs);
|
|
1144
|
+
if (authoritative !== void 0) try {
|
|
1145
|
+
await scope.set("pollIntervalMs", authoritative["pollIntervalMs"]);
|
|
1146
|
+
} catch {}
|
|
1147
|
+
return;
|
|
1148
|
+
} catch (error) {
|
|
1149
|
+
hostError = error;
|
|
1150
|
+
}
|
|
1151
|
+
let delivered = false;
|
|
1152
|
+
try {
|
|
1153
|
+
delivered = await scope.set("pollIntervalMs", intervalMs) !== false;
|
|
1154
|
+
} catch {
|
|
1155
|
+
delivered = false;
|
|
1156
|
+
}
|
|
1157
|
+
if (delivered && pollIntervalMsOf(scope.getSnapshot().value) === intervalMs) return;
|
|
1158
|
+
throw hostError instanceof Error ? hostError : new WorkBuddySettingsWriteError("pollIntervalMs", "neither the Host save endpoint nor the settings scope persisted the value");
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1090
1161
|
* Read the CodeBuddy-CLI route's PINNED model out of a settings snapshot.
|
|
1091
1162
|
*
|
|
1092
1163
|
* `''` is a real answer here, not a missing one: it means "nothing is pinned,
|
|
@@ -8931,7 +9002,19 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
8931
9002
|
*
|
|
8932
9003
|
* @module dsh-connect-workbuddy/client/WorkBuddyCard
|
|
8933
9004
|
*/
|
|
8934
|
-
|
|
9005
|
+
/**
|
|
9006
|
+
* The refresh cadence when the Host does not say.
|
|
9007
|
+
*
|
|
9008
|
+
* The Host answers with the SAVED interval on every document (see
|
|
9009
|
+
* `pollIntervalMs`), and that is what the card actually arms — this constant is
|
|
9010
|
+
* only the fallback for an older Host that cannot answer, so it stays a plain
|
|
9011
|
+
* number rather than a second source of truth.
|
|
9012
|
+
*
|
|
9013
|
+
* It is NOT a module-level `POLL_INTERVAL_MS` any more: the value is a setting
|
|
9014
|
+
* now, and a constant that the timer did not read would be exactly the kind of
|
|
9015
|
+
* duplicate that drifts from the control it describes.
|
|
9016
|
+
*/
|
|
9017
|
+
const FALLBACK_POLL_INTERVAL_MS = 3e5;
|
|
8935
9018
|
/**
|
|
8936
9019
|
* Retry cadence for a status read that FAILED.
|
|
8937
9020
|
*
|
|
@@ -9463,6 +9546,9 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
9463
9546
|
*/
|
|
9464
9547
|
const [sidebarPanelOn, setSidebarPanelOn] = (0, react.useState)(void 0);
|
|
9465
9548
|
const [sidebarPanelBusy, setSidebarPanelBusy] = (0, react.useState)(false);
|
|
9549
|
+
/** This card's own successful write of the refresh interval, if any. */
|
|
9550
|
+
const [pollIntervalOn, setPollIntervalOn] = (0, react.useState)(void 0);
|
|
9551
|
+
const [pollIntervalBusy, setPollIntervalBusy] = (0, react.useState)(false);
|
|
9466
9552
|
/**
|
|
9467
9553
|
* The CN gateway editor's draft (issue #220). `undefined` = "not edited", so
|
|
9468
9554
|
* the field shows the SAVED value and a background refresh cannot overwrite
|
|
@@ -9726,6 +9812,18 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
9726
9812
|
*/
|
|
9727
9813
|
const signedIn = status.status === "signed-in";
|
|
9728
9814
|
/**
|
|
9815
|
+
* The refresh cadence to arm, from the Host's answer.
|
|
9816
|
+
*
|
|
9817
|
+
* Read off the ACTIVE region's document, which is the one the timer refreshes.
|
|
9818
|
+
* An absent or unrecognized value falls back to 5 minutes — the same coercion
|
|
9819
|
+
* the Host applies, so a hand-edited profile cannot make the card poll faster
|
|
9820
|
+
* than the setting allows.
|
|
9821
|
+
*/
|
|
9822
|
+
const pollIntervalMs = (() => {
|
|
9823
|
+
const raw = "pollIntervalMs" in status ? status.pollIntervalMs : void 0;
|
|
9824
|
+
return typeof raw === "number" && WORKBUDDY_POLL_INTERVALS_MS.includes(raw) ? raw : FALLBACK_POLL_INTERVAL_MS;
|
|
9825
|
+
})();
|
|
9826
|
+
/**
|
|
9729
9827
|
* Whether the ACTIVE region knows of any account at all.
|
|
9730
9828
|
*
|
|
9731
9829
|
* This is the poll's precondition in place of `status === 'signed-in'`. The
|
|
@@ -9740,7 +9838,7 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
9740
9838
|
const controller = new AbortController();
|
|
9741
9839
|
const timer = window.setInterval(() => {
|
|
9742
9840
|
refreshUsage(activeRegion, controller.signal);
|
|
9743
|
-
},
|
|
9841
|
+
}, pollIntervalMs);
|
|
9744
9842
|
return () => {
|
|
9745
9843
|
window.clearInterval(timer);
|
|
9746
9844
|
controller.abort();
|
|
@@ -9749,7 +9847,8 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
9749
9847
|
open,
|
|
9750
9848
|
activeRegion,
|
|
9751
9849
|
refreshUsage,
|
|
9752
|
-
status.status
|
|
9850
|
+
status.status,
|
|
9851
|
+
pollIntervalMs
|
|
9753
9852
|
]);
|
|
9754
9853
|
/**
|
|
9755
9854
|
* 设备头设置:卡片打开时读一次。
|
|
@@ -10106,6 +10205,35 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
10106
10205
|
* see `panel-switch.ts`. Publishing only AFTER the write is verified keeps the
|
|
10107
10206
|
* two from disagreeing: the row never appears for a value the Host refused.
|
|
10108
10207
|
*/
|
|
10208
|
+
/**
|
|
10209
|
+
* The refresh interval, read from the status document first and the settings
|
|
10210
|
+
* snapshot second.
|
|
10211
|
+
*
|
|
10212
|
+
* The document is the fresher of the two (the Host answers with the value it
|
|
10213
|
+
* actually stored), but the settings snapshot is what a save is verified
|
|
10214
|
+
* against, and it is also the only thing available before the first document
|
|
10215
|
+
* lands. Reading both, in that order, means the picker never shows a value the
|
|
10216
|
+
* timer is not using.
|
|
10217
|
+
*/
|
|
10218
|
+
const pollIntervalValue = () => {
|
|
10219
|
+
if (pollIntervalOn !== void 0) return pollIntervalOn;
|
|
10220
|
+
const fromSettings = pollIntervalMsOf(settingsScope?.getSnapshot().value);
|
|
10221
|
+
if ("pollIntervalMs" in status && typeof status.pollIntervalMs === "number" && WORKBUDDY_POLL_INTERVALS_MS.includes(status.pollIntervalMs)) return status.pollIntervalMs;
|
|
10222
|
+
return fromSettings;
|
|
10223
|
+
};
|
|
10224
|
+
const changePollInterval = async (intervalMs) => {
|
|
10225
|
+
if (settingsScope === void 0) return;
|
|
10226
|
+
setPollIntervalBusy(true);
|
|
10227
|
+
try {
|
|
10228
|
+
await writePollIntervalMs(settingsScope, intervalMs);
|
|
10229
|
+
if (mounted.current) setPollIntervalOn(intervalMs);
|
|
10230
|
+
await refreshUsage(activeRegion);
|
|
10231
|
+
} catch (error) {
|
|
10232
|
+
if (mounted.current) setAccountError(error instanceof Error ? error.message : t("row.requestFailed"));
|
|
10233
|
+
} finally {
|
|
10234
|
+
if (mounted.current) setPollIntervalBusy(false);
|
|
10235
|
+
}
|
|
10236
|
+
};
|
|
10109
10237
|
const toggleSidebarPanel = async (enabled) => {
|
|
10110
10238
|
if (settingsScope === void 0) return;
|
|
10111
10239
|
setSidebarPanelBusy(true);
|
|
@@ -11274,6 +11402,74 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
11274
11402
|
}) : null
|
|
11275
11403
|
]
|
|
11276
11404
|
});
|
|
11405
|
+
/**
|
|
11406
|
+
* The refresh cadence, as a five-option picker.
|
|
11407
|
+
*
|
|
11408
|
+
* It lives in the capability panel because it commits on the click like every
|
|
11409
|
+
* other control there — no Save button. A dropdown rather than a free number
|
|
11410
|
+
* because the offered set IS the validation: the same five values are what the
|
|
11411
|
+
* Host accepts, so the control cannot produce something the Host refuses.
|
|
11412
|
+
*
|
|
11413
|
+
* Placed last among the capability groups: it changes how often the plugin
|
|
11414
|
+
* ASKS, not what it may do, and it is the one control here whose effect is
|
|
11415
|
+
* purely about request volume.
|
|
11416
|
+
*/
|
|
11417
|
+
const pollIntervalPreference = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11418
|
+
className: "dsm-workbuddy-prefs",
|
|
11419
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
11420
|
+
className: "dsm-workbuddy-pref-hint",
|
|
11421
|
+
children: t("row.pollIntervalLead")
|
|
11422
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
11423
|
+
className: "dsm-workbuddy-pref dsm-workbuddy-upstream-pref",
|
|
11424
|
+
title: t("row.pollIntervalHint"),
|
|
11425
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
11426
|
+
className: "dsm-workbuddy-pref-copy",
|
|
11427
|
+
children: [
|
|
11428
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
11429
|
+
className: "dsm-workbuddy-pref-label",
|
|
11430
|
+
children: t("row.pollIntervalLabel")
|
|
11431
|
+
}),
|
|
11432
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
11433
|
+
className: "dsm-workbuddy-pref-hint",
|
|
11434
|
+
children: t("row.pollIntervalHint")
|
|
11435
|
+
}),
|
|
11436
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
11437
|
+
className: "dsm-workbuddy-credit-position",
|
|
11438
|
+
value: String(pollIntervalValue()),
|
|
11439
|
+
disabled: !canWrite || saving || poolBusy || pollIntervalBusy,
|
|
11440
|
+
"aria-label": t("row.pollIntervalAria"),
|
|
11441
|
+
onChange: (event) => {
|
|
11442
|
+
const next = Number(event.currentTarget.value);
|
|
11443
|
+
if (!WORKBUDDY_POLL_INTERVALS_MS.includes(next)) return;
|
|
11444
|
+
changePollInterval(next);
|
|
11445
|
+
},
|
|
11446
|
+
children: [
|
|
11447
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
11448
|
+
value: String(6e4),
|
|
11449
|
+
children: t("row.pollInterval1m")
|
|
11450
|
+
}),
|
|
11451
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
11452
|
+
value: String(3e5),
|
|
11453
|
+
children: t("row.pollInterval5m")
|
|
11454
|
+
}),
|
|
11455
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
11456
|
+
value: String(6e5),
|
|
11457
|
+
children: t("row.pollInterval10m")
|
|
11458
|
+
}),
|
|
11459
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
11460
|
+
value: String(18e5),
|
|
11461
|
+
children: t("row.pollInterval30m")
|
|
11462
|
+
}),
|
|
11463
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
11464
|
+
value: String(36e5),
|
|
11465
|
+
children: t("row.pollInterval60m")
|
|
11466
|
+
})
|
|
11467
|
+
]
|
|
11468
|
+
})
|
|
11469
|
+
]
|
|
11470
|
+
})
|
|
11471
|
+
})]
|
|
11472
|
+
});
|
|
11277
11473
|
const sidebarPanelPreference = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11278
11474
|
className: "dsm-workbuddy-prefs",
|
|
11279
11475
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -12230,6 +12426,7 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
12230
12426
|
channelRejectContinuePreference,
|
|
12231
12427
|
dropAllThinkingPreference,
|
|
12232
12428
|
sidebarPanelPreference,
|
|
12429
|
+
pollIntervalPreference,
|
|
12233
12430
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12234
12431
|
className: "dsm-workbuddy-prefs",
|
|
12235
12432
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -12683,28 +12880,6 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
12683
12880
|
*/
|
|
12684
12881
|
const COMPOSER_CREDITS_REFRESH_INTERVAL_MS = 3e5;
|
|
12685
12882
|
/**
|
|
12686
|
-
* Refresh period for the panel's per-account table, while it stays open.
|
|
12687
|
-
*
|
|
12688
|
-
* Deliberately NOT the readout's five minutes. The table carries two things,
|
|
12689
|
-
* and the faster-moving one decides the cadence:
|
|
12690
|
-
*
|
|
12691
|
-
* - the balance, which barely moves, and
|
|
12692
|
-
* - each account's `excludedBy` ("被限流" / "模型繁忙"), which is derived from
|
|
12693
|
-
* the pool's own cooldowns — and the SHORTEST of those is the model-scoped
|
|
12694
|
-
* two-minute throttle (`MODEL_BUSY_COOLDOWN_MS`).
|
|
12695
|
-
*
|
|
12696
|
-
* At five minutes the table could state an account is 模型繁忙 long after the
|
|
12697
|
-
* upstream let it serve again, and the pool card — which polls every 60 s
|
|
12698
|
-
* (`POLL_INTERVAL_MS` in `WorkBuddyCard.tsx`) — would say it is fine at the same
|
|
12699
|
-
* moment. Two surfaces disagreeing about one account is exactly the complaint
|
|
12700
|
-
* this constant answers, so the table now converges on the card's cadence
|
|
12701
|
-
* instead of its own.
|
|
12702
|
-
*
|
|
12703
|
-
* The cost is bounded and paid only while the panel is open: one `fetchCredits`
|
|
12704
|
-
* per account per minute, the same read the card already makes when it is open.
|
|
12705
|
-
*/
|
|
12706
|
-
const COMPOSER_ACCOUNT_REFRESH_INTERVAL_MS = 6e4;
|
|
12707
|
-
/**
|
|
12708
12883
|
* Provider routes whose credit balance this readout can show, mapped to the
|
|
12709
12884
|
* region to read it from.
|
|
12710
12885
|
*
|
|
@@ -12853,6 +13028,22 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
12853
13028
|
const owned = provider === void 0 ? void 0 : WORKBUDDY_COMPOSER_PROVIDERS[provider];
|
|
12854
13029
|
const activeRegion = region ?? owned;
|
|
12855
13030
|
const [usage, setUsage] = (0, react.useState)(void 0);
|
|
13031
|
+
/**
|
|
13032
|
+
* The refresh cadence, taken from the SAME document the card polls.
|
|
13033
|
+
*
|
|
13034
|
+
* The panel used to hold its own 60s constant, and that was the whole reason
|
|
13035
|
+
* the two surfaces could contradict each other about one account: the card
|
|
13036
|
+
* re-ranked every minute while a panel opened at a different cadence drew a
|
|
13037
|
+
* frozen verdict. Sharing the Host's value means there is one cadence to
|
|
13038
|
+
* reason about, and changing it in the card changes it here too.
|
|
13039
|
+
*
|
|
13040
|
+
* An absent value (the panel opened before any document landed) falls back to
|
|
13041
|
+
* the same default the Host uses, so the first timer is never armed at 0.
|
|
13042
|
+
*/
|
|
13043
|
+
const refreshIntervalMs = (() => {
|
|
13044
|
+
const raw = usage !== void 0 && "pollIntervalMs" in usage ? usage.pollIntervalMs : void 0;
|
|
13045
|
+
return typeof raw === "number" && WORKBUDDY_POLL_INTERVALS_MS.includes(raw) ? raw : WORKBUDDY_DEFAULT_POLL_INTERVAL_MS;
|
|
13046
|
+
})();
|
|
12856
13047
|
const [accountCredits, setAccountCredits] = (0, react.useState)(void 0);
|
|
12857
13048
|
const [switchingId, setSwitchingId] = (0, react.useState)(void 0);
|
|
12858
13049
|
/**
|
|
@@ -13047,7 +13238,7 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
13047
13238
|
if (cancelled) return;
|
|
13048
13239
|
timer = window.setInterval(() => {
|
|
13049
13240
|
fetchAccountCredits(controller.signal);
|
|
13050
|
-
},
|
|
13241
|
+
}, refreshIntervalMs);
|
|
13051
13242
|
});
|
|
13052
13243
|
return () => {
|
|
13053
13244
|
cancelled = true;
|
|
@@ -13057,7 +13248,8 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
13057
13248
|
}, [
|
|
13058
13249
|
open,
|
|
13059
13250
|
activeRegion,
|
|
13060
|
-
fetchAccountCredits
|
|
13251
|
+
fetchAccountCredits,
|
|
13252
|
+
refreshIntervalMs
|
|
13061
13253
|
]);
|
|
13062
13254
|
(0, react.useEffect)(() => {
|
|
13063
13255
|
if (!open) return void 0;
|
|
@@ -15044,6 +15236,15 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
15044
15236
|
"row.cnBaseCleared": "Back to the built-in CN gateway.",
|
|
15045
15237
|
"row.diagCnBase": "CN gateway",
|
|
15046
15238
|
"row.diagCnBaseDefault": "built-in (copilot.tencent.com)",
|
|
15239
|
+
"row.pollIntervalLead": "Refresh frequency",
|
|
15240
|
+
"row.pollIntervalLabel": "Refresh the account table",
|
|
15241
|
+
"row.pollIntervalHint": "How often the card re-reads credits and check-in state. One refresh costs a credits read plus a check-in read per pooled account, so this is the setting that decides the plugin's upstream request volume. The composer account panel follows this value, so the two never disagree about one account. Takes effect on the next poll — no Save needed.",
|
|
15242
|
+
"row.pollIntervalAria": "Refresh frequency for the account table",
|
|
15243
|
+
"row.pollInterval1m": "Every 1 minute",
|
|
15244
|
+
"row.pollInterval5m": "Every 5 minutes (default)",
|
|
15245
|
+
"row.pollInterval10m": "Every 10 minutes",
|
|
15246
|
+
"row.pollInterval30m": "Every 30 minutes",
|
|
15247
|
+
"row.pollInterval60m": "Every 60 minutes",
|
|
15047
15248
|
"row.sidebarPanelLabel": "Show WorkBuddy in the sidebar",
|
|
15048
15249
|
"row.sidebarPanelHint": "Adds a WorkBuddy row to the DSH sidebar that opens this card as a full page. Off by default: the row takes a global sidebar slot shared by every installed plugin, and the Plugins page already reaches the same content. Takes effect on the click — no Save needed — and switching it off while the page is open returns you to the conversation.",
|
|
15049
15250
|
"row.cliBridgeModelLabel": "CLI model",
|
|
@@ -15589,6 +15790,15 @@ ${u} ${p}-pool .sw input:checked+.sw-track::after{transform:translateX(16px)}
|
|
|
15589
15790
|
"row.cnBaseCleared": "已回到内置 CN 网关。",
|
|
15590
15791
|
"row.diagCnBase": "CN 网关",
|
|
15591
15792
|
"row.diagCnBaseDefault": "内置(copilot.tencent.com)",
|
|
15793
|
+
"row.pollIntervalLead": "刷新频率",
|
|
15794
|
+
"row.pollIntervalLabel": "刷新账号表",
|
|
15795
|
+
"row.pollIntervalHint": "卡片多久重读一次积分与签到状态。每次刷新要为池内每个账号各读一次积分和一次签到状态,所以这一项决定插件的上游请求量。输入框的账号面板跟随同一个值,两处不会对同一个账号给出不同说法。下一次轮询即生效,不用保存。",
|
|
15796
|
+
"row.pollIntervalAria": "账号表的刷新频率",
|
|
15797
|
+
"row.pollInterval1m": "每 1 分钟",
|
|
15798
|
+
"row.pollInterval5m": "每 5 分钟(默认)",
|
|
15799
|
+
"row.pollInterval10m": "每 10 分钟",
|
|
15800
|
+
"row.pollInterval30m": "每 30 分钟",
|
|
15801
|
+
"row.pollInterval60m": "每 60 分钟",
|
|
15592
15802
|
"row.sidebarPanelLabel": "在侧边栏显示 WorkBuddy",
|
|
15593
15803
|
"row.sidebarPanelHint": "在 DSH 侧边栏加一个 WorkBuddy 行,点开就是这张卡片的整页版。默认关闭:这一行占的是所有插件共用的全局侧边栏座位,而「插件」页本来就能看到同样的内容。点一下即生效,不用保存;页面开着时关掉它,会直接回到对话。",
|
|
15594
15804
|
"row.cliBridgeModelLabel": "CLI 模型",
|
|
@@ -10527,7 +10527,7 @@ function describeRosterSeenPayload(raw) {
|
|
|
10527
10527
|
//#endregion
|
|
10528
10528
|
//#region src/version.ts
|
|
10529
10529
|
/** The npm package version this build was produced from. */
|
|
10530
|
-
const WORKBUDDY_CONNECT_VERSION = "5.21.
|
|
10530
|
+
const WORKBUDDY_CONNECT_VERSION = "5.21.2";
|
|
10531
10531
|
//#endregion
|
|
10532
10532
|
//#region src/host-heartbeat.ts
|
|
10533
10533
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -4189,6 +4189,15 @@ type WorkBuddyWebUsage =
|
|
|
4189
4189
|
* that cannot answer must not be read as consent.
|
|
4190
4190
|
*/
|
|
4191
4191
|
sidebarPanelEnabled?: boolean;
|
|
4192
|
+
/**
|
|
4193
|
+
* How often the card should re-read this document, in milliseconds.
|
|
4194
|
+
*
|
|
4195
|
+
* GLOBAL like `sidebarPanelEnabled`, and carried on the Host's answer for
|
|
4196
|
+
* the same measured reason: on the stale-mirror 0.1.7 deployment an
|
|
4197
|
+
* interval read from the settings mirror could be a value the Host never
|
|
4198
|
+
* stored. Absent reads as {@link WORKBUDDY_DEFAULT_POLL_INTERVAL_MS}.
|
|
4199
|
+
*/
|
|
4200
|
+
pollIntervalMs?: number;
|
|
4192
4201
|
/**
|
|
4193
4202
|
* The model the OPTIONAL CodeBuddy CLI route runs on, or `''` for
|
|
4194
4203
|
* "nothing is pinned, the CLI uses its own default".
|
|
@@ -4342,6 +4351,15 @@ type WorkBuddyWebUsage =
|
|
|
4342
4351
|
* that cannot answer must not be read as consent.
|
|
4343
4352
|
*/
|
|
4344
4353
|
sidebarPanelEnabled?: boolean;
|
|
4354
|
+
/**
|
|
4355
|
+
* How often the card should re-read this document, in milliseconds.
|
|
4356
|
+
*
|
|
4357
|
+
* GLOBAL like `sidebarPanelEnabled`, and carried on the Host's answer for
|
|
4358
|
+
* the same measured reason: on the stale-mirror 0.1.7 deployment an
|
|
4359
|
+
* interval read from the settings mirror could be a value the Host never
|
|
4360
|
+
* stored. Absent reads as {@link WORKBUDDY_DEFAULT_POLL_INTERVAL_MS}.
|
|
4361
|
+
*/
|
|
4362
|
+
pollIntervalMs?: number;
|
|
4345
4363
|
/**
|
|
4346
4364
|
* The model the OPTIONAL CodeBuddy CLI route runs on, or `''` for
|
|
4347
4365
|
* "nothing is pinned, the CLI uses its own default".
|
|
@@ -5086,6 +5104,18 @@ interface WorkBuddyStatusRouteOptions {
|
|
|
5086
5104
|
* stale `true` here would draw a row the Host does not honour.
|
|
5087
5105
|
*/
|
|
5088
5106
|
sidebarPanelEnabled?(): boolean;
|
|
5107
|
+
/**
|
|
5108
|
+
* How often the card should re-read this document, in milliseconds.
|
|
5109
|
+
*
|
|
5110
|
+
* Carried on the Host's answer rather than read from the browser's settings
|
|
5111
|
+
* mirror, for the same measured reason as the two flags above: that mirror is
|
|
5112
|
+
* stale for this namespace on the affected 0.1.7 deployments, and a stale
|
|
5113
|
+
* interval would make the card poll at a cadence the Host never stored.
|
|
5114
|
+
*
|
|
5115
|
+
* Optional, and absent reads as the 5-minute default — which is what an older
|
|
5116
|
+
* Host (and any build before the setting existed) should do.
|
|
5117
|
+
*/
|
|
5118
|
+
pollIntervalMs?(): number;
|
|
5089
5119
|
/**
|
|
5090
5120
|
* The model the OPTIONAL CodeBuddy CLI route runs on, or `''` for "the CLI's
|
|
5091
5121
|
* own default".
|
|
@@ -5929,6 +5959,15 @@ interface Config {
|
|
|
5929
5959
|
* 而不必先回滚一个版本。
|
|
5930
5960
|
*/
|
|
5931
5961
|
wireProfile?: 'conservative' | 'balanced';
|
|
5962
|
+
/**
|
|
5963
|
+
* How often the card refreshes its account table, in milliseconds.
|
|
5964
|
+
*
|
|
5965
|
+
* One of 60000 / 300000 / 600000 / 1800000 / 3600000; absent reads as 5
|
|
5966
|
+
* minutes. This is the setting that decides the plugin's upstream request
|
|
5967
|
+
* volume (one credits read plus one check-in read per pooled account, per
|
|
5968
|
+
* refresh), and the composer account panel follows it.
|
|
5969
|
+
*/
|
|
5970
|
+
pollIntervalMs?: number;
|
|
5932
5971
|
/**
|
|
5933
5972
|
* SDK 功能的**总开关**(默认开)。
|
|
5934
5973
|
*
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as imageDefaultFor, A as withoutRouters, At as offRefused, B as defaultDesktopAuthPath, Bt as IMAGE_TAG_TEXT_TO_IMAGE, C as setDeviceMode, Ct as attachBusyLevels, D as applyContextBudgets, Dt as defaultOffModelIds, E as WorkBuddyCatalog, En as writeFileAtomic, Et as REFUSES_OFF_MODEL_IDS, F as WorkBuddyCredentialStore, Ft as WorkBuddyVideoError, G as parseWorkBuddyAuth, Gt as isBareBase64Image, H as isEncryptedCredentialError, Ht as WorkBuddyImageError, I as WorkBuddyEncryptedCredentialError, It as parseSupportedSecondsRange, J as workbuddyOwnAuthPath, Jt as sniffImageMime, K as preferredAccountName, Kt as parseImageDataUrl, L as authFileName, Lt as pickVideoModel, M as WORKBUDDY_AUTH_FILENAME, Mt as withEffectiveOff, N as WORKBUDDY_AUTH_FILE_ENV, Nt as VIDEO_TAG_IMAGE_TO_VIDEO, O as deriveCatalog, Ot as lastRefusalFor, Pt as VIDEO_TAG_TEXT_TO_VIDEO, Q as CREDENTIAL_REJECTED_CODE, Qt as NATIVE_MODALITY_BY_MODEL_ID, R as defaultDesktopAuthCandidates, Rt as resolveVideoParams, S as saveDeviceSdkSettings, Sn as workbuddyAppExecutableCandidates, St as rewriteSessionTitleModel, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as withFileLock, Tt as selectPromoBadge, U as isVaultAccountId, Ut as imageDataUrl, V as hasEncryptedCredentialFields, Vt as MAX_INPUT_IMAGE_BYTES, W as legacyWorkbuddyOwnAuthPath, Wt as imageMimeForPath, X as APP_VERSION, Xt as queueNoticeText, Yt as parseQueueAnswer, Z as CONTEXT_OVERFLOW_MARKER, Zt as pruneTempDir, _ as createDeviceProfileLookup, _n as isWorkbuddyBundle, _t as parseUpstreamModel, a as readHostHeartbeat, at as declaredTools, b as readDeviceSettings, bn as openEncryptedField, bt as regionOf, c as WORKBUDDY_CONNECT_VERSION, ct as isContextTooLongBody, dn as deriveAtRestKey, dt as isFirstMessageGateBody, en as nativeModalityOf, et as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, fn as deriveAtRestKeyId, ft as knownRegionOf, g as createTuringSdk, gn as isEncryptedFieldWrapper, gt as parseReasoning, h as createDeviceSdkPort, ht as parseCreditMultiplier, i as processStartTimeMs, it as classifyUpstreamError, j as ENCRYPTED_CREDENTIAL_CODE, jt as recordRefusal, k as fallbackModelsFor, kt as offDefaultFor, l as createFileRosterSeenStore, ln as WORKBUDDY_APP_EXECUTABLE_ENV, lt as isConversationIdGateBody, m as piAiRuntimeInfo, mn as findWorkbuddyAppExecutable, mt as openingEvidenceOfBody, n as clearHostHeartbeat, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, on as isDeviceId, p as resolveCnGateway, pn as fetchAtRestKeyPayload, pt as modelIdOfBody, q as workbuddyAccountId, qt as pickMediaModel, r as isHeartbeatProcessAlive, rt as channelGateMemberOf, s as writeHostHeartbeat, st as forceNeutralHead, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tt as WorkBuddyCredentialRejectedError, un as clearAtRestKeyCache, ut as isCredentialRejectedError, v as describeDerivedDevices, vn as macosBundleExecutable, vt as perturbChannelFingerprints, w as FALLBACK_WORKBUDDY_MODELS, wn as resolveDshHome, wt as promoBadgeTone, x as saveDeviceProfile, xn as readAtRestKey, xt as requestEvidenceOf, y as isDeviceMode, yn as macosNestedAppBundles, yt as prepareChatBody, z as defaultDesktopAuthDirs, zt as IMAGE_TAG_IMAGE_TO_IMAGE } from "./host-heartbeat-
|
|
1
|
+
import { $t as imageDefaultFor, A as withoutRouters, At as offRefused, B as defaultDesktopAuthPath, Bt as IMAGE_TAG_TEXT_TO_IMAGE, C as setDeviceMode, Ct as attachBusyLevels, D as applyContextBudgets, Dt as defaultOffModelIds, E as WorkBuddyCatalog, En as writeFileAtomic, Et as REFUSES_OFF_MODEL_IDS, F as WorkBuddyCredentialStore, Ft as WorkBuddyVideoError, G as parseWorkBuddyAuth, Gt as isBareBase64Image, H as isEncryptedCredentialError, Ht as WorkBuddyImageError, I as WorkBuddyEncryptedCredentialError, It as parseSupportedSecondsRange, J as workbuddyOwnAuthPath, Jt as sniffImageMime, K as preferredAccountName, Kt as parseImageDataUrl, L as authFileName, Lt as pickVideoModel, M as WORKBUDDY_AUTH_FILENAME, Mt as withEffectiveOff, N as WORKBUDDY_AUTH_FILE_ENV, Nt as VIDEO_TAG_IMAGE_TO_VIDEO, O as deriveCatalog, Ot as lastRefusalFor, Pt as VIDEO_TAG_TEXT_TO_VIDEO, Q as CREDENTIAL_REJECTED_CODE, Qt as NATIVE_MODALITY_BY_MODEL_ID, R as defaultDesktopAuthCandidates, Rt as resolveVideoParams, S as saveDeviceSdkSettings, Sn as workbuddyAppExecutableCandidates, St as rewriteSessionTitleModel, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as withFileLock, Tt as selectPromoBadge, U as isVaultAccountId, Ut as imageDataUrl, V as hasEncryptedCredentialFields, Vt as MAX_INPUT_IMAGE_BYTES, W as legacyWorkbuddyOwnAuthPath, Wt as imageMimeForPath, X as APP_VERSION, Xt as queueNoticeText, Yt as parseQueueAnswer, Z as CONTEXT_OVERFLOW_MARKER, Zt as pruneTempDir, _ as createDeviceProfileLookup, _n as isWorkbuddyBundle, _t as parseUpstreamModel, a as readHostHeartbeat, at as declaredTools, b as readDeviceSettings, bn as openEncryptedField, bt as regionOf, c as WORKBUDDY_CONNECT_VERSION, ct as isContextTooLongBody, dn as deriveAtRestKey, dt as isFirstMessageGateBody, en as nativeModalityOf, et as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, fn as deriveAtRestKeyId, ft as knownRegionOf, g as createTuringSdk, gn as isEncryptedFieldWrapper, gt as parseReasoning, h as createDeviceSdkPort, ht as parseCreditMultiplier, i as processStartTimeMs, it as classifyUpstreamError, j as ENCRYPTED_CREDENTIAL_CODE, jt as recordRefusal, k as fallbackModelsFor, kt as offDefaultFor, l as createFileRosterSeenStore, ln as WORKBUDDY_APP_EXECUTABLE_ENV, lt as isConversationIdGateBody, m as piAiRuntimeInfo, mn as findWorkbuddyAppExecutable, mt as openingEvidenceOfBody, n as clearHostHeartbeat, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, on as isDeviceId, p as resolveCnGateway, pn as fetchAtRestKeyPayload, pt as modelIdOfBody, q as workbuddyAccountId, qt as pickMediaModel, r as isHeartbeatProcessAlive, rt as channelGateMemberOf, s as writeHostHeartbeat, st as forceNeutralHead, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tt as WorkBuddyCredentialRejectedError, un as clearAtRestKeyCache, ut as isCredentialRejectedError, v as describeDerivedDevices, vn as macosBundleExecutable, vt as perturbChannelFingerprints, w as FALLBACK_WORKBUDDY_MODELS, wn as resolveDshHome, wt as promoBadgeTone, x as saveDeviceProfile, xn as readAtRestKey, xt as requestEvidenceOf, y as isDeviceMode, yn as macosNestedAppBundles, yt as prepareChatBody, z as defaultDesktopAuthDirs, zt as IMAGE_TAG_IMAGE_TO_IMAGE } from "./host-heartbeat-CxvijdHh.js";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { appendFile, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
4
|
import { randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
@@ -399,6 +399,33 @@ const WORKBUDDY_DEVICE_PROFILE_PATH = "/plugins/dsh-connect-workbuddy/device-pro
|
|
|
399
399
|
const WORKBUDDY_DEVICE_SDK_PATH = "/plugins/dsh-connect-workbuddy/device-sdk";
|
|
400
400
|
/** Query parameter selecting it. */
|
|
401
401
|
const WORKBUDDY_DEVICE_SDK_ACTION_PARAM = "action";
|
|
402
|
+
/**
|
|
403
|
+
* The refresh intervals the card offers, in milliseconds.
|
|
404
|
+
*
|
|
405
|
+
* SHARED between the Host (which validates the saved value) and the browser
|
|
406
|
+
* (which renders the dropdown), so the control and its validation cannot drift:
|
|
407
|
+
* a value the dropdown can produce is always a value the Host accepts, and the
|
|
408
|
+
* Host's fallback is always a value the dropdown can show.
|
|
409
|
+
*
|
|
410
|
+
* A CLOSED SET rather than a free number because this interval decides the
|
|
411
|
+
* plugin's upstream request volume — one credits read plus one check-in read per
|
|
412
|
+
* pooled account, per refresh.
|
|
413
|
+
*/
|
|
414
|
+
const WORKBUDDY_POLL_INTERVALS_MS = [
|
|
415
|
+
6e4,
|
|
416
|
+
3e5,
|
|
417
|
+
6e5,
|
|
418
|
+
18e5,
|
|
419
|
+
36e5
|
|
420
|
+
];
|
|
421
|
+
/**
|
|
422
|
+
* The default refresh interval: 5 minutes.
|
|
423
|
+
*
|
|
424
|
+
* Moved off the old hard-coded 60 s. A 4-account pool at 60 s costs ~11,520
|
|
425
|
+
* requests a day for figures that move slowly; 5 minutes is a fifth of that and
|
|
426
|
+
* still five times finer than the 30-minute auto check-in heartbeat.
|
|
427
|
+
*/
|
|
428
|
+
const WORKBUDDY_DEFAULT_POLL_INTERVAL_MS = 3e5;
|
|
402
429
|
/** Read the OAuth action off a request URL; unknown/absent means undefined. */
|
|
403
430
|
function oauthActionOf(url) {
|
|
404
431
|
const at = url.indexOf("?");
|
|
@@ -11215,6 +11242,42 @@ function summarizeAutoCheckin(state) {
|
|
|
11215
11242
|
};
|
|
11216
11243
|
}
|
|
11217
11244
|
/**
|
|
11245
|
+
* Today's summary — `undefined` when `state` is not today's.
|
|
11246
|
+
*
|
|
11247
|
+
* The day check is NOT a nicety (issue #232). The state is only rewritten when a
|
|
11248
|
+
* tick runs, and after a finished day the next tick is an idle heartbeat up to
|
|
11249
|
+
* {@link AUTO_CHECKIN_IDLE_MS} away — so for the first half hour of a new local
|
|
11250
|
+
* day the in-memory state still describes YESTERDAY. Summarizing it as today made
|
|
11251
|
+
* the card announce 「今日:N 个全部已签」 at 00:08 while every row underneath
|
|
11252
|
+
* read 未签到, i.e. the one place that is supposed to prove the runner works
|
|
11253
|
+
* claimed the opposite of the truth.
|
|
11254
|
+
*
|
|
11255
|
+
* `undefined` (rather than a zeroed summary) is what the card already renders as
|
|
11256
|
+
* "no status line", and it is the honest answer: nothing has run today yet. The
|
|
11257
|
+
* zeroed variant would invent a denominator for a day no attempt has measured.
|
|
11258
|
+
*/
|
|
11259
|
+
function todaySummary(state, nowMs) {
|
|
11260
|
+
if (state.day !== localDayKey(nowMs)) return void 0;
|
|
11261
|
+
return summarizeAutoCheckin(state);
|
|
11262
|
+
}
|
|
11263
|
+
/**
|
|
11264
|
+
* Whether a cached check-in reading may still be served.
|
|
11265
|
+
*
|
|
11266
|
+
* Two conditions, and the second is the one that took a bug report: a reading is
|
|
11267
|
+
* an answer to "has this account checked in TODAY", so it must not survive local
|
|
11268
|
+
* midnight. The TTL alone would serve a `true` read taken at 23:58 until 00:08,
|
|
11269
|
+
* so the column would assert a check-in that has not happened — the per-account
|
|
11270
|
+
* half of the same lie as {@link todaySummary}.
|
|
11271
|
+
*
|
|
11272
|
+
* The day is derived from `atMs` rather than stored beside it: the read time
|
|
11273
|
+
* already says which day the answer belongs to, and a second field could drift
|
|
11274
|
+
* out of step with it.
|
|
11275
|
+
*/
|
|
11276
|
+
function checkinReadingFresh(atMs, nowMs, ttlMs) {
|
|
11277
|
+
if (nowMs - atMs >= ttlMs) return false;
|
|
11278
|
+
return localDayKey(atMs) === localDayKey(nowMs);
|
|
11279
|
+
}
|
|
11280
|
+
/**
|
|
11218
11281
|
* The accounts an attempt should address, in the pool's own order.
|
|
11219
11282
|
*
|
|
11220
11283
|
* Only members that are not already done. Enterprise members are dropped HERE
|
|
@@ -11369,7 +11432,8 @@ const UPSTREAM_SWITCH_FIELDS = /* @__PURE__ */ new Set([
|
|
|
11369
11432
|
"dropForeignThinking",
|
|
11370
11433
|
"dropAllThinking",
|
|
11371
11434
|
"channelRejectContinue",
|
|
11372
|
-
"sidebarPanel"
|
|
11435
|
+
"sidebarPanel",
|
|
11436
|
+
"pollIntervalMs"
|
|
11373
11437
|
]);
|
|
11374
11438
|
/** A non-null, non-array object: the only shape the slot merge applies to. */
|
|
11375
11439
|
function isPlainRecord(value) {
|
|
@@ -11726,6 +11790,18 @@ async function workBuddyWebStatus(deps, region, options = {}) {
|
|
|
11726
11790
|
const preferredVideoModels = deps.preferredVideoModels?.(region) ?? {};
|
|
11727
11791
|
const cliBridgeEnabled = deps.cliBridgeEnabled?.() === true;
|
|
11728
11792
|
const sidebarPanelEnabled = deps.sidebarPanelEnabled?.() === true;
|
|
11793
|
+
/**
|
|
11794
|
+
* The card's refresh cadence, resolved once per document.
|
|
11795
|
+
*
|
|
11796
|
+
* Coerced against the offered set here as well as on the Host: this value
|
|
11797
|
+
* drives `setInterval`, and an unrecognized number (an older Host, a
|
|
11798
|
+
* hand-edited profile) must degrade to the default rather than to something
|
|
11799
|
+
* like `0`, which would poll continuously.
|
|
11800
|
+
*/
|
|
11801
|
+
const pollIntervalMs = (() => {
|
|
11802
|
+
const raw = deps.pollIntervalMs?.();
|
|
11803
|
+
return typeof raw === "number" && WORKBUDDY_POLL_INTERVALS_MS.includes(raw) ? raw : WORKBUDDY_DEFAULT_POLL_INTERVAL_MS;
|
|
11804
|
+
})();
|
|
11729
11805
|
const cliBridgeModel = deps.cliBridgeModel?.() ?? "";
|
|
11730
11806
|
const cliBridgeEffort = deps.cliBridgeEffort?.() ?? "";
|
|
11731
11807
|
const cliBridgeRegionOrder = deps.cliBridgeRegionOrder?.() ?? "";
|
|
@@ -11746,6 +11822,7 @@ async function workBuddyWebStatus(deps, region, options = {}) {
|
|
|
11746
11822
|
preferredVideoModels,
|
|
11747
11823
|
cliBridgeEnabled,
|
|
11748
11824
|
sidebarPanelEnabled,
|
|
11825
|
+
pollIntervalMs,
|
|
11749
11826
|
cliBridgeModel,
|
|
11750
11827
|
cliBridgeEffort,
|
|
11751
11828
|
cliBridgeRegionOrder,
|
|
@@ -11771,6 +11848,7 @@ async function workBuddyWebStatus(deps, region, options = {}) {
|
|
|
11771
11848
|
preferredVideoModels,
|
|
11772
11849
|
cliBridgeEnabled,
|
|
11773
11850
|
sidebarPanelEnabled,
|
|
11851
|
+
pollIntervalMs,
|
|
11774
11852
|
cliBridgeModel,
|
|
11775
11853
|
cliBridgeEffort,
|
|
11776
11854
|
cliBridgeRegionOrder,
|
|
@@ -11799,6 +11877,7 @@ async function workBuddyWebStatus(deps, region, options = {}) {
|
|
|
11799
11877
|
preferredVideoModels,
|
|
11800
11878
|
cliBridgeEnabled,
|
|
11801
11879
|
sidebarPanelEnabled,
|
|
11880
|
+
pollIntervalMs,
|
|
11802
11881
|
cliBridgeModel,
|
|
11803
11882
|
cliBridgeEffort,
|
|
11804
11883
|
cliBridgeRegionOrder,
|
|
@@ -13023,6 +13102,34 @@ const Config = z.object({
|
|
|
13023
13102
|
]).default("failure").description("When to perturb scanned messages with invisible characters: \"off\" only rescues after a channel-gate refusal, \"failure\" (default) learns from a successful rescue and starts later requests perturbed, \"always\" starts every request with the dense rescue for a gateway whose plain attempt is guaranteed to fail.")),
|
|
13024
13103
|
usageIdentity: asVolatile(z.boolean().default(false).description("Send the chat conversation ids in the official client's 32-hex UUIDv7 shape and add a mirroring X-Request-ID. Off by default — it is a display alignment measured by a reporter, not by this plugin, and the chat channel identity (User-Agent) and request body never change.")),
|
|
13025
13104
|
wireProfile: asVolatile(z.union([z.const("conservative"), z.const("balanced")]).default("balanced").description("Outbound identity profile. \"balanced\" (default) makes every request claim the same client (WorkBuddy product/IDE/agent headers, X-CodeBuddy-Request, Accept-Language, X-Root-Request-ID, and a per-account X-Machine-ID/X-Session-ID pair) and gives the billing routes a User-Agent plus Origin/Referer. \"conservative\" restores the 5.16.0 bytes exactly, including X-Product: SaaS.")),
|
|
13105
|
+
/**
|
|
13106
|
+
* How often the card re-reads the usage document.
|
|
13107
|
+
*
|
|
13108
|
+
* GLOBAL, not per-region: the card polls ONE region at a time (whichever tab
|
|
13109
|
+
* is open), so a per-region value would be a setting the user edits per tab
|
|
13110
|
+
* while only one of them is ever in effect. The composer account panel reads
|
|
13111
|
+
* the same number, which is what keeps the two surfaces from disagreeing
|
|
13112
|
+
* about one account — the complaint that fixed the panel at 60s in the first
|
|
13113
|
+
* place.
|
|
13114
|
+
*
|
|
13115
|
+
* A CLOSED SET of five values rather than a free number: this interval decides
|
|
13116
|
+
* the plugin's upstream request volume, and a typo'd `0` or a hand-written
|
|
13117
|
+
* `1000` would turn a display refresh into a poll the upstream could rate
|
|
13118
|
+
* limit. The same five are what the dropdown offers, so the control and its
|
|
13119
|
+
* validation cannot drift apart.
|
|
13120
|
+
*
|
|
13121
|
+
* WHY THE DEFAULT MOVED OFF 60s: one refresh reads a credits document AND a
|
|
13122
|
+
* check-in status per pooled account, so a 4-account pool at 60s is ~11,520
|
|
13123
|
+
* requests a day for figures that move slowly. 5 minutes is a fifth of that
|
|
13124
|
+
* and still far finer than the 30-minute auto check-in heartbeat.
|
|
13125
|
+
*/
|
|
13126
|
+
pollIntervalMs: asVolatile(z.union([
|
|
13127
|
+
z.const(6e4),
|
|
13128
|
+
z.const(3e5),
|
|
13129
|
+
z.const(6e5),
|
|
13130
|
+
z.const(18e5),
|
|
13131
|
+
z.const(36e5)
|
|
13132
|
+
]).default(3e5).description("How often the card refreshes its account table: 60000 (1 min), 300000 (5 min, default), 600000 (10 min), 1800000 (30 min) or 3600000 (60 min), in milliseconds. One refresh costs a credits read plus a check-in read per pooled account, so this is the setting that decides the plugin's upstream request volume. The composer account panel follows this value so the two surfaces cannot disagree about one account.")),
|
|
13026
13133
|
deviceSdkEnabled: asVolatile(z.boolean().default(false).description("Master switch for the real-device SDK. OFF by default, matching the default Virtual tier: turning it on makes the plugin discover the installed desktop SDK, fetch its device token in a background child process and keep it fresh. A capability that reaches into a third party's native modules on your machine should be opted into, and with the Virtual tier (the default) the token it fetches would never be sent anyway. On: discover, fetch, prewarm. Off: none of that — no discovery, no child process, no prewarming — so the Real tier has no token to send; the Virtual tier is unaffected (its ids derive from the local salt).")),
|
|
13027
13134
|
deviceToken: asVolatile(z.object({
|
|
13028
13135
|
file: z.string().default(""),
|
|
@@ -13332,6 +13439,11 @@ function apply(ctx, config) {
|
|
|
13332
13439
|
* Invalidated by this plugin's own check-in batch (the only writer that can
|
|
13333
13440
|
* change the answer during a session), so the user sees their result
|
|
13334
13441
|
* immediately instead of waiting out the TTL.
|
|
13442
|
+
*
|
|
13443
|
+
* A reading is ALSO bounded by the local day, not just by the TTL — see
|
|
13444
|
+
* `checkinReadingFresh`. Both readers go through it, because an entry is an
|
|
13445
|
+
* answer to "has this account checked in TODAY" and a `true` read at 23:58
|
|
13446
|
+
* must not be served at 00:08.
|
|
13335
13447
|
*/
|
|
13336
13448
|
const checkinStateCache = {};
|
|
13337
13449
|
/**
|
|
@@ -14220,6 +14332,11 @@ function apply(ctx, config) {
|
|
|
14220
14332
|
*/
|
|
14221
14333
|
sidebarPanelEnabled: () => unwrapVolatile(current().sidebarPanel) === true,
|
|
14222
14334
|
/**
|
|
14335
|
+
* The card's refresh cadence, read live so a change takes effect on the
|
|
14336
|
+
* next poll rather than on a plugin reload.
|
|
14337
|
+
*/
|
|
14338
|
+
pollIntervalMs: () => pollIntervalOf(current()),
|
|
14339
|
+
/**
|
|
14223
14340
|
* The model / reasoning effort the optional CodeBuddy CLI route runs on.
|
|
14224
14341
|
*
|
|
14225
14342
|
* `cliBridge` is volatile, hence the unwrap; absent keys read as `''` —
|
|
@@ -14425,7 +14542,7 @@ function apply(ctx, config) {
|
|
|
14425
14542
|
const now = Date.now();
|
|
14426
14543
|
const entries = await Promise.all(accounts.map(async (account) => {
|
|
14427
14544
|
const cached = checkinStateCache[region]?.[account.id];
|
|
14428
|
-
if (cached !== void 0 &&
|
|
14545
|
+
if (cached !== void 0 && checkinReadingFresh(cached.atMs, now, CHECKIN_CACHE_MS)) return [account.id, cached.checkedIn];
|
|
14429
14546
|
const credential = await store.credentialFor(account.id).catch(() => void 0);
|
|
14430
14547
|
if (credential === void 0) return void 0;
|
|
14431
14548
|
const status = await client.fetchCheckinStatus(credential).catch(() => void 0);
|
|
@@ -14455,7 +14572,7 @@ function apply(ctx, config) {
|
|
|
14455
14572
|
const state = checkinStateCache[region] ?? {};
|
|
14456
14573
|
const cached = {};
|
|
14457
14574
|
for (const [accountId, entry] of Object.entries(state)) {
|
|
14458
|
-
if (
|
|
14575
|
+
if (!checkinReadingFresh(entry.atMs, now, CHECKIN_CACHE_MS)) continue;
|
|
14459
14576
|
cached[accountId] = entry.checkedIn;
|
|
14460
14577
|
}
|
|
14461
14578
|
return cached;
|
|
@@ -14556,7 +14673,7 @@ function apply(ctx, config) {
|
|
|
14556
14673
|
if (!autoCheckinEnabled(region)) return void 0;
|
|
14557
14674
|
const state = autoCheckinState[region];
|
|
14558
14675
|
if (state === void 0) return void 0;
|
|
14559
|
-
return
|
|
14676
|
+
return todaySummary(state, Date.now());
|
|
14560
14677
|
},
|
|
14561
14678
|
checkin: async (region) => {
|
|
14562
14679
|
const rows = await checkinAllAccounts(await poolTargets(region), poolRunnerDeps(region));
|
|
@@ -15048,6 +15165,20 @@ function apply(ctx, config) {
|
|
|
15048
15165
|
* upgrade moves nothing on screen.
|
|
15049
15166
|
*/
|
|
15050
15167
|
const creditPositionOf = (config, region) => regionStateOf(config, region).creditPosition === "stats" ? "stats" : "composer";
|
|
15168
|
+
/**
|
|
15169
|
+
* The card's refresh interval, coerced against the offered set.
|
|
15170
|
+
*
|
|
15171
|
+
* Coerced HERE rather than trusted from the config, for the same reason
|
|
15172
|
+
* `resolveProbeInputTokens` coerces its own: a hand-edited `cordis.patch.yml`
|
|
15173
|
+
* can carry any number, and `setInterval(…, 0)` would turn a display refresh
|
|
15174
|
+
* into a busy loop against the upstream. An unrecognized value falls back to
|
|
15175
|
+
* the default rather than to the smallest step — the safe direction for a
|
|
15176
|
+
* setting whose whole purpose is bounding request volume.
|
|
15177
|
+
*/
|
|
15178
|
+
const pollIntervalOf = (config) => {
|
|
15179
|
+
const raw = unwrapVolatile(config.pollIntervalMs);
|
|
15180
|
+
return typeof raw === "number" && WORKBUDDY_POLL_INTERVALS_MS.includes(raw) ? raw : WORKBUDDY_DEFAULT_POLL_INTERVAL_MS;
|
|
15181
|
+
};
|
|
15051
15182
|
const poolPreferencesOf = (config, region) => {
|
|
15052
15183
|
const pool = regionStateOf(config, region).pool;
|
|
15053
15184
|
const probeInputTokens = pool?.probeInputTokens;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "dsh-connect-workbuddy",
|
|
3
3
|
"displayName": "DSH Connect WorkBuddy",
|
|
4
4
|
"description": "把本机登录的 WorkBuddy 模型(国内版与国际版)接入 DeepSeek Harness:每次刷新按上游目录自动读取每个模型的积分倍率,支持逐模型图片输入开关、多账号切换与账号池自动换号,并提供每日签到、卡片与输入框里的胶囊积分读数等只读积分概览。",
|
|
5
|
-
"version": "5.21.
|
|
5
|
+
"version": "5.21.2",
|
|
6
6
|
"author": "dingminhua",
|
|
7
7
|
"copyright": "Copyright (c) 2026 LaoDing",
|
|
8
8
|
"license": "MIT",
|