dsh-connect-workbuddy-go 6.0.0 → 6.1.1

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,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.1.1 (2026-11-23)
4
+
5
+ > 修复:面板里的模型区只显示已启用的那几个,未启用的模型没出现,也就无法启用。
6
+
7
+ - **根因**:`workBuddyWebStatus()` 的 `models` 是合并后的目录——已启用的行在前,只在设置里保存过、尚未启用的行在后;6.1.0 把这份目录塞进协议上限 8 项的 `options` 并按前 8 项截断。已启用模型一多,未启用的整段就被截在屏幕外。
8
+ - **改法**:模型区改用可点按的原生 `list`(上限 50 行),整份目录一行一个模型:行尾写 `已启用` / `未启用`,点一下切换、再点一下切回;标题显示 `国内版 · 3/12 已启用`。列表不再按启用状态截断,未启用的模型始终可达。
9
+ - **写入语义不变**:单次点按仍以完整保存值为底(空选择 = 整个目录),结果按目录顺序回写,并拒绝写空——「至少保留一个模型」。区域仍是 `options` 多选,只写真正变化的区域。
10
+ - **测试**:新增回归用例——12 个模型、3 个启用时,尾部 9 行必须是可点的「未启用」行;另覆盖 50 行上限、逐行切换与「空选择 = 全目录」的起点。视图断言改为 `data.modelRows`,且不再出现 `id: "models"`。
11
+
12
+ ## 6.1.0 (2026-11-22)
13
+
14
+ > dsh-Go 面板从「只读看板」改成「顺手能拨的控制面板」:区域与模型两个原生开关,写入走宿主设置;只在桌面成立的附属物不再出现。
15
+
16
+ - **面板可操作**:`src/dsh-go.ts` 新增 `setRegionEnabled` / `setModelsEnabled` 两个可选写入;`index.ts` 在 `dshGo` 注入点用 `ctx.settings.update(settingsNs, { regions: { [region]: … } })` 实现,与 Web 卡片是同一份设置、同一套 `loader/volatile-update` 广播。写入成功后重读状态,开关显示实际落地的值;宿主没有 `update` 时提示「这台主机不能修改设置」。
17
+ - **两个开关的语义**:区域开关只写真正变化的那个区域,一次点按不会覆盖兄弟区域的已保存槽位;模型开关只列协议上限的 8 行,但计算下一组选择时以完整保存值为底——没显示出来的 id 不会因为一次点按被删掉。空选择在上游表示「整个目录」,所以面板拒绝发送空数组,并保留「至少保留一个模型」。
18
+ - **面板收敛**:顶部一句状态 + 两行区域(账号 · 模型数 · 积分)+ 两个开关 + `刷新` / `设置`。删掉复制摘要、倍率列表与只读明细——那些在桌面上成立,在手机上只是把设置页搬进一个更窄的地方。「设置」把人送到 App 的插件页,账号、登录与图片输入仍在那里。
19
+ - **不再误报「已关闭」**:读不到状态的区域先显示「暂不可用」,不把「没读到」说成用户关掉的。
20
+ - **清单**:面板标题简化为 `WorkBuddy`;包描述补上「可操作面板」。
21
+ - **测试**:重写 `tests/dsh-go.spec.ts`(区域/模型选项、8 行上限、空选择=全目录、按完整保存值合并、至少保留一个、只写变化区域、只读宿主、动作与视图绑定);`pnpm run typecheck`、全量测试、`build` 与 dsh-Go `plugin-kit check --load` 全过。
22
+
3
23
  ## 6.0.0 (2026-11-22)
4
24
 
5
25
  > 更名与 id 迁移:包名 `dsh-connect-workbuddy` → `dsh-connect-workbuddy-go`,作者改为 sheng-888。功能无回退,但设置键不继承。
package/README.en.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  A [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle plugin that connects locally signed-in WorkBuddy models to the DSH model picker — **both the CN app and the international WorkBuddy AI app are supported** — with an account pool, selectable model management, and a set of read-only capabilities built around credits: **every catalog refresh reads each model's credit multiplier from upstream** (the `x0.79` figure comes entirely from the upstream catalog; the plugin neither hard-codes it nor guesses), image input is toggled per model, multiple accounts can be switched or fail over automatically through the pool, and daily check-in plus read-only credit overviews shown as compact pills on the card and in the composer. **The CN and international sides are two parallel providers (`workbuddy` / `workbuddy-global`) that can be used at the same time**; the settings page separates them with tabs for convenient management. All it needs is a WorkBuddy sign-in on this machine — or **one sign-in from the browser**.
20
20
 
21
- > **This is a community fork.** Upstream is [dingminhua/dsh-connect-workbuddy](https://github.com/dingminhua/dsh-connect-workbuddy) by LaoDing, published under MIT. This fork is maintained by **sheng-888**; the package name and plugin id are both `dsh-connect-workbuddy-go`, so it can coexist with the original but the two do not share settings. Compared with upstream it adds native dsh-Go (Android / HarmonyOS / iOS) status strip and panel, and reports platform capability honestly. See [LICENSE](LICENSE) and [CHANGELOG.md](CHANGELOG.md) for upstream copyright and full history.
21
+ > **This is a community fork.** Upstream is [dingminhua/dsh-connect-workbuddy](https://github.com/dingminhua/dsh-connect-workbuddy) by LaoDing, published under MIT. This fork is maintained by **sheng-888**; the package name and plugin id are both `dsh-connect-workbuddy-go`, so it can coexist with the original but the two do not share settings. Compared with upstream it adds a native dsh-Go (Android / HarmonyOS / iOS) status strip and an interactive panel — region switches plus a tap-to-toggle model list backed by the same settings as the web card — and reports platform capability honestly. See [LICENSE](LICENSE) and [CHANGELOG.md](CHANGELOG.md) for upstream copyright and full history.
22
22
 
23
23
  ### Icon style
24
24
 
package/README.md CHANGED
@@ -440,7 +440,7 @@ dsh plugin --profile desktop exec dsh-connect-workbuddy-go doctor # 第一行
440
440
 
441
441
  ### 手机版 dsh-Go(Android / HarmonyOS / iOS)
442
442
 
443
- 插件带一份 `dshGo` 原生界面:输入框上方的状态条显示 `WorkBuddy · 账号名`,点开是「全部功能 › WorkBuddy 账号」面板。面板只读地列出两个区域的连接状态、当前账号、积分与模型数;数据来自 Web 卡片同一条状态路由,`刷新` 会重新读取。没有 dsh-Go 桥接的宿主看不到这两个位置,其余行为不变。
443
+ 插件带一份 `dshGo` 原生界面:输入框上方的状态条显示 `WorkBuddy · 账号名`,点开是「全部功能 › WorkBuddy」面板。面板按手机的信息密度重排:顶部一句状态,下面两行区域(账号、模型数、积分),然后是「启用的区域」多选与整份模型目录——两者点按即写入宿主设置,与 Web 卡片是同一份配置,卡片会随广播同步。模型一行一个,行尾写明「已启用 / 未启用」,点一下切换、再点一下切回,标题里的 `3/12 已启用` 是当前启用的数量;整个目录都会列出,未启用的模型不会被截在屏幕外。至少保留一个模型(上游把空选择理解为「整个目录」,面板不会把它发出去)。账号、登录与图片输入这些低频操作仍在插件设置里,面板底部的「设置」按钮直接把人送过去。没有 dsh-Go 桥接的宿主看不到这两个位置,其余行为不变。
444
444
 
445
445
  - **登录**:手机上没有 WorkBuddy 桌面端,请用卡片里的「扫码登录 / 网页登录」完成 OAuth。不要依赖扫描桌面 auth 文件、`$wbEncrypted` 解密或 `WORKBUDDY_APP_EXECUTABLE`——这些在 Android PRoot 与 HarmonyOS 上都没有可读的桌面 App。
446
446
  - **真实设备值**:真实值档需要桌面端 SDK 签发设备 token;手机端没有这条取链,插件会把该档如实标成「暂不可用」,虚拟值档(含逐账号设备参数)正常工作。设备 SDK 分区、CLI bridge 与桌面可执行文件扫描同样只适用于桌面。
package/lib/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Dn as findWorkbuddyAppExecutableWithSource, F as WorkBuddyCredentialStore, Fn as hostPeersInfo, In as resolveDshHome, 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, _n as deriveDeviceId, a as readHostHeartbeat, b as readDeviceSettings, bn as protectCredentialDirectory, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, et as DEFAULT_WIRE_PROFILE, f as WORKBUDDY_CN_BASE_ENV, g as createTuringSdk, gn as readDeviceSalt, hn as ensureDeviceSalt, lt as describeRequestHeaderNames, m as piAiRuntimeInfo, mn as readDeviceTokenFile, o as workbuddyHostHeartbeatPath, p as resolveCnGateway, pn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, r as isHeartbeatProcessAlive, rt as WorkBuddyUpstreamClient, u as describeRosterSeenPayload, w as FALLBACK_WORKBUDDY_MODELS, xn as WORKBUDDY_APP_EXECUTABLE_ENV, yn as inspectCredentialDirectory, z as defaultDesktopAuthDirs } from "./host-heartbeat-nje07RES.js";
2
+ import { Dn as findWorkbuddyAppExecutableWithSource, F as WorkBuddyCredentialStore, Fn as hostPeersInfo, In as resolveDshHome, 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, _n as deriveDeviceId, a as readHostHeartbeat, b as readDeviceSettings, bn as protectCredentialDirectory, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, et as DEFAULT_WIRE_PROFILE, f as WORKBUDDY_CN_BASE_ENV, g as createTuringSdk, gn as readDeviceSalt, hn as ensureDeviceSalt, lt as describeRequestHeaderNames, m as piAiRuntimeInfo, mn as readDeviceTokenFile, o as workbuddyHostHeartbeatPath, p as resolveCnGateway, pn as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, r as isHeartbeatProcessAlive, rt as WorkBuddyUpstreamClient, u as describeRosterSeenPayload, w as FALLBACK_WORKBUDDY_MODELS, xn as WORKBUDDY_APP_EXECUTABLE_ENV, yn as inspectCredentialDirectory, z as defaultDesktopAuthDirs } from "./host-heartbeat-Bb9YyCEo.js";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { realpathSync } from "node:fs";
@@ -11607,7 +11607,7 @@ function describeRosterSeenPayload(raw) {
11607
11607
  //#endregion
11608
11608
  //#region src/version.ts
11609
11609
  /** The npm package version this build was produced from. */
11610
- const WORKBUDDY_CONNECT_VERSION = "6.0.0";
11610
+ const WORKBUDDY_CONNECT_VERSION = "6.1.1";
11611
11611
  //#endregion
11612
11612
  //#region src/host-heartbeat.ts
11613
11613
  /**
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as CREDENTIAL_REJECTED_CODE, $t as imageModelChoices, A as withoutRouters, An as macosBundleExecutable, At as attachBusyLevels, B as defaultDesktopAuthPath, Bt as VIDEO_TAG_IMAGE_TO_VIDEO, C as setDeviceMode, Cn as deriveAtRestKey, Ct as parseUpstreamModel, D as applyContextBudgets, Dt as requestEvidenceOf, E as WorkBuddyCatalog, En as findWorkbuddyAppExecutable, Et as regionOf, F as WorkBuddyCredentialStore, Ft as lastRefusalFor, G as parseWorkBuddyAuth, Gt as resolveVideoParams, H as isEncryptedCredentialError, Ht as WorkBuddyVideoError, I as WorkBuddyEncryptedCredentialError, In as resolveDshHome, It as offDefaultFor, J as workbuddyOwnAuthPath, Jt as IMAGE_TAG_TEXT_TO_IMAGE, K as preferredAccountName, Kt as IMAGE_SIZE_LIMITS_WIDE, L as authFileName, Ln as withFileLock, Lt as offRefused, M as WORKBUDDY_AUTH_FILENAME, Mn as openEncryptedField, Mt as selectPromoBadge, N as WORKBUDDY_AUTH_FILE_ENV, Nn as readAtRestKey, Nt as REFUSES_OFF_MODEL_IDS, O as deriveCatalog, On as isEncryptedFieldWrapper, Ot as rewriteSessionTitleModel, Pn as workbuddyAppExecutableCandidates, Pt as defaultOffModelIds, Q as CONTEXT_OVERFLOW_MARKER, Qt as imageMimeForPath, R as defaultDesktopAuthCandidates, Rn as writeFileAtomic, Rt as recordRefusal, S as saveDeviceSdkSettings, Sn as clearAtRestKeyCache, St as parseReasoning, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as fetchAtRestKeyPayload, Tt as prepareChatBody, U as isVaultAccountId, Ut as parseSupportedSecondsRange, V as hasEncryptedCredentialFields, Vt as VIDEO_TAG_TEXT_TO_VIDEO, W as legacyWorkbuddyOwnAuthPath, Wt as pickVideoModel, X as APP_VERSION, Xt as WorkBuddyImageError, Yt as MAX_INPUT_IMAGE_BYTES, Z as BODY_OVERSIZE_MARKER, Zt as imageDataUrl, _ as createDeviceProfileLookup, _t as isToolSchemaRejectBody, a as readHostHeartbeat, an as sniffImageMime, at as classifyUpstreamError, b as readDeviceSettings, bt as openingEvidenceOfBody, c as WORKBUDDY_CONNECT_VERSION, cn as pruneTempDir, ct as deriveStableConversationId, dn as isRouterModelId, dt as growthHostOf, en as imageSizeLimitsOf, fn as nativeModalityOf, ft as isBodyOversizeRefusal, g as createTuringSdk, gt as isFirstMessageGateBody, h as createDeviceSdkPort, ht as isCredentialRejectedError, i as processStartTimeMs, in as pickMediaModel, it as channelGateMemberOf, j as ENCRYPTED_CREDENTIAL_CODE, jn as macosNestedAppBundles, jt as promoBadgeTone, k as fallbackModelsFor, kn as isWorkbuddyBundle, kt as toolSchemaRejectAdvice, l as createFileRosterSeenStore, ln as NATIVE_MODALITY_BY_MODEL_ID, m as piAiRuntimeInfo, mt as isConversationIdGateBody, n as clearHostHeartbeat, nn as isWatermarkFreeImageModel, nt as WorkBuddyCredentialRejectedError, o as workbuddyHostHeartbeatPath, on as parseQueueAnswer, ot as conversationIdFromSessionId, p as resolveCnGateway, pt as isContextTooLongBody, q as workbuddyAccountId, qt as IMAGE_TAG_IMAGE_TO_IMAGE, r as isHeartbeatProcessAlive, rn as parseImageDataUrl, rt as WorkBuddyUpstreamClient, s as writeHostHeartbeat, sn as queueNoticeText, st as declaredTools, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tn as isBareBase64Image, tt as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, un as imageDefaultFor, ut as forceNeutralHead, v as describeDerivedDevices, vn as isDeviceId, vt as knownRegionOf, w as FALLBACK_WORKBUDDY_MODELS, wn as deriveAtRestKeyId, wt as perturbChannelFingerprints, x as saveDeviceProfile, xn as WORKBUDDY_APP_EXECUTABLE_ENV, xt as parseCreditMultiplier, y as isDeviceMode, yt as modelIdOfBody, z as defaultDesktopAuthDirs, zt as withEffectiveOff } from "./host-heartbeat-nje07RES.js";
1
+ import { $ as CREDENTIAL_REJECTED_CODE, $t as imageModelChoices, A as withoutRouters, An as macosBundleExecutable, At as attachBusyLevels, B as defaultDesktopAuthPath, Bt as VIDEO_TAG_IMAGE_TO_VIDEO, C as setDeviceMode, Cn as deriveAtRestKey, Ct as parseUpstreamModel, D as applyContextBudgets, Dt as requestEvidenceOf, E as WorkBuddyCatalog, En as findWorkbuddyAppExecutable, Et as regionOf, F as WorkBuddyCredentialStore, Ft as lastRefusalFor, G as parseWorkBuddyAuth, Gt as resolveVideoParams, H as isEncryptedCredentialError, Ht as WorkBuddyVideoError, I as WorkBuddyEncryptedCredentialError, In as resolveDshHome, It as offDefaultFor, J as workbuddyOwnAuthPath, Jt as IMAGE_TAG_TEXT_TO_IMAGE, K as preferredAccountName, Kt as IMAGE_SIZE_LIMITS_WIDE, L as authFileName, Ln as withFileLock, Lt as offRefused, M as WORKBUDDY_AUTH_FILENAME, Mn as openEncryptedField, Mt as selectPromoBadge, N as WORKBUDDY_AUTH_FILE_ENV, Nn as readAtRestKey, Nt as REFUSES_OFF_MODEL_IDS, O as deriveCatalog, On as isEncryptedFieldWrapper, Ot as rewriteSessionTitleModel, Pn as workbuddyAppExecutableCandidates, Pt as defaultOffModelIds, Q as CONTEXT_OVERFLOW_MARKER, Qt as imageMimeForPath, R as defaultDesktopAuthCandidates, Rn as writeFileAtomic, Rt as recordRefusal, S as saveDeviceSdkSettings, Sn as clearAtRestKeyCache, St as parseReasoning, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, Tn as fetchAtRestKeyPayload, Tt as prepareChatBody, U as isVaultAccountId, Ut as parseSupportedSecondsRange, V as hasEncryptedCredentialFields, Vt as VIDEO_TAG_TEXT_TO_VIDEO, W as legacyWorkbuddyOwnAuthPath, Wt as pickVideoModel, X as APP_VERSION, Xt as WorkBuddyImageError, Yt as MAX_INPUT_IMAGE_BYTES, Z as BODY_OVERSIZE_MARKER, Zt as imageDataUrl, _ as createDeviceProfileLookup, _t as isToolSchemaRejectBody, a as readHostHeartbeat, an as sniffImageMime, at as classifyUpstreamError, b as readDeviceSettings, bt as openingEvidenceOfBody, c as WORKBUDDY_CONNECT_VERSION, cn as pruneTempDir, ct as deriveStableConversationId, dn as isRouterModelId, dt as growthHostOf, en as imageSizeLimitsOf, fn as nativeModalityOf, ft as isBodyOversizeRefusal, g as createTuringSdk, gt as isFirstMessageGateBody, h as createDeviceSdkPort, ht as isCredentialRejectedError, i as processStartTimeMs, in as pickMediaModel, it as channelGateMemberOf, j as ENCRYPTED_CREDENTIAL_CODE, jn as macosNestedAppBundles, jt as promoBadgeTone, k as fallbackModelsFor, kn as isWorkbuddyBundle, kt as toolSchemaRejectAdvice, l as createFileRosterSeenStore, ln as NATIVE_MODALITY_BY_MODEL_ID, m as piAiRuntimeInfo, mt as isConversationIdGateBody, n as clearHostHeartbeat, nn as isWatermarkFreeImageModel, nt as WorkBuddyCredentialRejectedError, o as workbuddyHostHeartbeatPath, on as parseQueueAnswer, ot as conversationIdFromSessionId, p as resolveCnGateway, pt as isContextTooLongBody, q as workbuddyAccountId, qt as IMAGE_TAG_IMAGE_TO_IMAGE, r as isHeartbeatProcessAlive, rn as parseImageDataUrl, rt as WorkBuddyUpstreamClient, s as writeHostHeartbeat, sn as queueNoticeText, st as declaredTools, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tn as isBareBase64Image, tt as WORKBUDDY_FALLBACK_SYSTEM_PROMPT, un as imageDefaultFor, ut as forceNeutralHead, v as describeDerivedDevices, vn as isDeviceId, vt as knownRegionOf, w as FALLBACK_WORKBUDDY_MODELS, wn as deriveAtRestKeyId, wt as perturbChannelFingerprints, x as saveDeviceProfile, xn as WORKBUDDY_APP_EXECUTABLE_ENV, xt as parseCreditMultiplier, y as isDeviceMode, yt as modelIdOfBody, z as defaultDesktopAuthDirs, zt as withEffectiveOff } from "./host-heartbeat-Bb9YyCEo.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";
@@ -13893,13 +13893,10 @@ function registerWorkBuddyStatusRoute(ctx, deps) {
13893
13893
  const WORKBUDDY_DSH_GO_PANEL = "workbuddy";
13894
13894
  const WORKBUDDY_DSH_GO_STRIP = "status";
13895
13895
  const REGIONS = ["cn", "global"];
13896
+ /** The protocol caps one `list` at fifty rows; rosters are far shorter in practice. */
13897
+ const MODEL_ROW_LIMIT = 50;
13896
13898
  const ZH = {
13897
13899
  brand: "WorkBuddy",
13898
- region: "区域",
13899
- account: "账号",
13900
- status: "状态",
13901
- credits: "积分",
13902
- models: "模型",
13903
13900
  signedIn: "已连接",
13904
13901
  signedOut: "未登录",
13905
13902
  failed: "读取失败",
@@ -13914,22 +13911,23 @@ const ZH = {
13914
13911
  notLoggedIn: "WorkBuddy 未登录",
13915
13912
  allClosed: "两个区域都已关闭",
13916
13913
  noModels: "暂无可用模型",
13917
- localOnly: "积分在面板打开后读取",
13914
+ regionsLabel: "启用的区域",
13915
+ footer: "点按即生效;账号与登录在插件设置里",
13918
13916
  refresh: "刷新",
13919
13917
  refreshing: "正在刷新",
13920
- copy: "复制摘要",
13921
- copied: "已复制",
13922
- nothing: "还没有可复制的内容",
13918
+ settings: "设置",
13919
+ saved: "已更新",
13920
+ saveFailed: "保存失败",
13921
+ readOnly: "这台主机不能修改设置",
13922
+ keepOne: "至少保留一个模型",
13923
+ on: "已启用",
13924
+ off: "未启用",
13923
13925
  regionName: (region) => region === "cn" ? "国内版" : "国际版",
13924
- modelsTitle: (label, count) => `${label} · ${count} 个模型`
13926
+ modelsTitle: (label, enabled, total, capped) => `${label} · ${enabled}/${total} 已启用${capped ? `(列前 ${MODEL_ROW_LIMIT} 个)` : ""}`,
13927
+ modelCount: (count) => `${count} 个模型`
13925
13928
  };
13926
13929
  const EN = {
13927
13930
  brand: "WorkBuddy",
13928
- region: "Region",
13929
- account: "Account",
13930
- status: "Status",
13931
- credits: "Credits",
13932
- models: "Models",
13933
13931
  signedIn: "Connected",
13934
13932
  signedOut: "Signed out",
13935
13933
  failed: "Read failed",
@@ -13944,14 +13942,20 @@ const EN = {
13944
13942
  notLoggedIn: "WorkBuddy is signed out",
13945
13943
  allClosed: "Both regions are off",
13946
13944
  noModels: "No models available",
13947
- localOnly: "Credits load when the panel opens",
13945
+ regionsLabel: "Regions",
13946
+ footer: "Changes apply immediately · Accounts and sign-in live in plugin settings",
13948
13947
  refresh: "Refresh",
13949
13948
  refreshing: "Refreshing",
13950
- copy: "Copy summary",
13951
- copied: "Copied",
13952
- nothing: "Nothing to copy yet",
13949
+ settings: "Settings",
13950
+ saved: "Updated",
13951
+ saveFailed: "Could not save",
13952
+ readOnly: "Settings are read-only on this host",
13953
+ keepOne: "Keep at least one model",
13954
+ on: "On",
13955
+ off: "Off",
13953
13956
  regionName: (region) => region === "cn" ? "CN" : "Global",
13954
- modelsTitle: (label, count) => `${label} · ${count} models`
13957
+ modelsTitle: (label, enabled, total, capped) => `${label} · ${enabled}/${total} enabled${capped ? ` (first ${MODEL_ROW_LIMIT} shown)` : ""}`,
13958
+ modelCount: (count) => `${count} models`
13955
13959
  };
13956
13960
  function words(locale) {
13957
13961
  return typeof locale === "string" && locale.toLowerCase().startsWith("en") ? EN : ZH;
@@ -14025,36 +14029,59 @@ function modelCount(snapshot) {
14025
14029
  function stateText(snapshot, w) {
14026
14030
  if (snapshot.state === "unavailable") return w.unavailable;
14027
14031
  if (!snapshot.enabled) return w.closed;
14028
- if (snapshot.state === "signed-in") return w.signedIn;
14029
14032
  if (snapshot.state === "error") return w.failed;
14033
+ if (snapshot.state === "signed-in") return w.signedIn;
14030
14034
  if (snapshot.credentialRejected) return w.rejected;
14031
14035
  if (snapshot.selectionLost) return w.reselect;
14032
14036
  return w.signedOut;
14033
14037
  }
14034
- function accountText(snapshot, w) {
14035
- if (snapshot.state === "signed-in") return snapshot.accountName.trim() === "" ? w.unnamed : snapshot.accountName;
14036
- if (snapshot.accountCount > 0) return `${snapshot.accountCount} ${w.accountsSuffix}`;
14037
- return "—";
14038
- }
14039
14038
  function numberText(value) {
14040
14039
  return new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(value);
14041
14040
  }
14042
- function multiplierText(value) {
14043
- if (value === void 0 || !Number.isFinite(value)) return void 0;
14044
- return `x${value.toFixed(2).replace(/\.?0+$/u, "")}`;
14041
+ /** One region's subtitle: who serves it, then how many models are in play. */
14042
+ function regionSubtitle(snapshot, w) {
14043
+ if (snapshot.state !== "signed-in" || !snapshot.enabled) return stateText(snapshot, w);
14044
+ return `${snapshot.accountName.trim() === "" ? w.unnamed : clip(snapshot.accountName, 16)}${snapshot.accountCount > 1 ? ` · ${snapshot.accountCount} ${w.accountsSuffix}` : ""} · ${w.modelCount(modelCount(snapshot))}`;
14045
14045
  }
14046
- function modelRows(snapshot) {
14047
- const enabled = new Set(snapshot.enabledModelIds);
14048
- return (enabled.size === 0 ? snapshot.models : snapshot.models.filter((model) => enabled.has(model.id))).slice(0, 6).map((model) => {
14049
- const row = {
14050
- title: model.name.trim() === "" ? model.id : model.name,
14051
- icon: "robot"
14052
- };
14053
- if (model.id !== row.title) row.subtitle = model.id;
14054
- const multiplier = multiplierText(model.creditMultiplier);
14055
- if (multiplier !== void 0) row.trailing = multiplier;
14056
- return row;
14057
- });
14046
+ function regionRow(snapshot, w) {
14047
+ const tone = snapshot.state === "error" || snapshot.state === "unavailable" ? "bad" : !snapshot.enabled ? "muted" : snapshot.state === "signed-in" ? "good" : "warn";
14048
+ return {
14049
+ title: w.regionName(snapshot.region),
14050
+ subtitle: regionSubtitle(snapshot, w),
14051
+ trailing: snapshot.enabled && snapshot.state === "signed-in" && snapshot.credits !== void 0 ? numberText(snapshot.credits) : "—",
14052
+ icon: "wallet",
14053
+ tone
14054
+ };
14055
+ }
14056
+ /**
14057
+ * One region's model roster as tappable rows — every model, enabled or not.
14058
+ *
14059
+ * An EMPTY saved selection means "serve the whole directory", so every row
14060
+ * reads as enabled — the list must not paint a never-configured region as
14061
+ * "nothing on". The count and the rows come from the same predicate so the
14062
+ * header and the list never disagree.
14063
+ */
14064
+ function modelRowsOf(snapshot, w) {
14065
+ const saved = new Set(snapshot.enabledModelIds);
14066
+ const isOn = (id) => saved.size === 0 || saved.has(id);
14067
+ return {
14068
+ rows: snapshot.models.slice(0, MODEL_ROW_LIMIT).map((model) => {
14069
+ const name = model.name.trim() === "" ? model.id : model.name;
14070
+ const row = {
14071
+ title: name,
14072
+ trailing: isOn(model.id) ? w.on : w.off,
14073
+ tone: isOn(model.id) ? "good" : "muted",
14074
+ action: {
14075
+ id: "toggleModel",
14076
+ args: { id: model.id }
14077
+ }
14078
+ };
14079
+ if (name !== model.id) row.subtitle = model.id;
14080
+ return row;
14081
+ }),
14082
+ enabled: snapshot.models.filter((model) => isOn(model.id)).length,
14083
+ capped: snapshot.models.length > MODEL_ROW_LIMIT
14084
+ };
14058
14085
  }
14059
14086
  /** The panel's data model. Every label is resolved here, once, for the app's locale. */
14060
14087
  function dshGoPanelData(snapshots, locale) {
@@ -14064,24 +14091,21 @@ function dshGoPanelData(snapshots, locale) {
14064
14091
  const allClosed = snapshots.length > 0 && snapshots.every((snapshot) => !snapshot.enabled);
14065
14092
  const headline = live !== void 0 ? w.ready : allClosed ? w.allClosed : anyBad ? w.notReady : w.notLoggedIn;
14066
14093
  const tone = live !== void 0 ? "good" : allClosed ? "info" : anyBad ? "bad" : "warn";
14067
- const rows = snapshots.map((snapshot) => [
14068
- w.regionName(snapshot.region),
14069
- accountText(snapshot, w),
14070
- stateText(snapshot, w),
14071
- snapshot.state === "signed-in" && snapshot.credits !== void 0 ? numberText(snapshot.credits) : "—",
14072
- snapshot.state === "signed-in" ? String(modelCount(snapshot)) : "—"
14073
- ]);
14074
- const focus = live ?? snapshots.find((snapshot) => snapshot.state === "signed-in") ?? snapshots.find((snapshot) => snapshot.enabled) ?? snapshots[0];
14075
- const models = focus?.state === "signed-in" ? modelRows(focus) : [];
14076
- const modelsTitle = focus?.state === "signed-in" ? w.modelsTitle(w.regionName(focus.region), modelCount(focus)) : w.noModels;
14094
+ const models = live === void 0 ? void 0 : modelRowsOf(live, w);
14077
14095
  const note = snapshots.map((snapshot) => snapshot.message).find((message) => message !== void 0);
14078
14096
  return {
14079
14097
  headline,
14080
14098
  tone,
14081
- rows,
14082
- modelsTitle,
14083
- models,
14084
- footer: note === void 0 ? w.localOnly : `${w.localOnly} · ${note}`
14099
+ regionRows: snapshots.map((snapshot) => regionRow(snapshot, w)),
14100
+ regionsLabel: w.regionsLabel,
14101
+ regionOptions: REGIONS.map((region) => ({
14102
+ label: w.regionName(region),
14103
+ value: region
14104
+ })),
14105
+ selectedRegions: snapshots.filter((snapshot) => snapshot.enabled).map((snapshot) => snapshot.region),
14106
+ modelsLabel: live === void 0 || live.models.length === 0 ? w.noModels : w.modelsTitle(w.regionName(live.region), models?.enabled ?? 0, live.models.length, models?.capped === true),
14107
+ modelRows: models?.rows ?? [],
14108
+ footer: note === void 0 ? w.footer : `${w.footer} · ${note}`
14085
14109
  };
14086
14110
  }
14087
14111
  /** The one line above the composer, capped at the protocol's 24 characters. */
@@ -14112,7 +14136,15 @@ function dshGoStripData(snapshots, locale) {
14112
14136
  tone: "warn"
14113
14137
  };
14114
14138
  }
14115
- /** The panel's structure. Values are bindings, so pushes stay small. */
14139
+ /**
14140
+ * The panel's structure. Values are bindings, so pushes stay small.
14141
+ *
14142
+ * Three blocks, in reading order: what is happening (headline + one row per
14143
+ * region), which region is offered to DSH, and which models that region puts
14144
+ * in the picker. Region toggles and per-model taps are the only writes a phone
14145
+ * should make without a keyboard; everything else is one tap away in plugin
14146
+ * settings.
14147
+ */
14116
14148
  function dshGoPanelView(locale) {
14117
14149
  const w = words(locale);
14118
14150
  return {
@@ -14124,24 +14156,29 @@ function dshGoPanelView(locale) {
14124
14156
  tone: { $: "data.tone" }
14125
14157
  },
14126
14158
  {
14127
- type: "table",
14128
- columns: [
14129
- w.region,
14130
- w.account,
14131
- w.status,
14132
- w.credits,
14133
- w.models
14134
- ],
14135
- rows: { $: "data.rows" }
14159
+ type: "list",
14160
+ items: { $: "data.regionRows" }
14161
+ },
14162
+ {
14163
+ type: "text",
14164
+ text: { $: "data.regionsLabel" },
14165
+ tone: "muted"
14166
+ },
14167
+ {
14168
+ type: "options",
14169
+ id: "regions",
14170
+ multi: true,
14171
+ options: { $: "data.regionOptions" },
14172
+ selected: { $: "data.selectedRegions" }
14136
14173
  },
14137
14174
  {
14138
14175
  type: "text",
14139
- text: { $: "data.modelsTitle" },
14176
+ text: { $: "data.modelsLabel" },
14140
14177
  tone: "muted"
14141
14178
  },
14142
14179
  {
14143
14180
  type: "list",
14144
- items: { $: "data.models" }
14181
+ items: { $: "data.modelRows" }
14145
14182
  },
14146
14183
  {
14147
14184
  type: "actions",
@@ -14151,9 +14188,9 @@ function dshGoPanelView(locale) {
14151
14188
  action: "refresh",
14152
14189
  style: "primary"
14153
14190
  }, {
14154
- label: w.copy,
14155
- icon: "copy",
14156
- action: "copy"
14191
+ label: w.settings,
14192
+ icon: "settings",
14193
+ action: "settings"
14157
14194
  }]
14158
14195
  },
14159
14196
  {
@@ -14164,18 +14201,27 @@ function dshGoPanelView(locale) {
14164
14201
  ]
14165
14202
  };
14166
14203
  }
14167
- /** Plain text for the copy action; the data is already localized. */
14168
- function dshGoCopyText(data) {
14169
- const lines = [data.headline, ...data.rows.map((row) => row.join(" · "))];
14170
- if (data.models.length > 0) lines.push(data.modelsTitle, ...data.models.map((model) => `- ${model.title}${model.trailing === void 0 ? "" : ` ${model.trailing}`}`));
14171
- lines.push(data.footer);
14172
- return lines.join("\n");
14204
+ /** The `values` an `options(multi)` press carries, or undefined for junk. */
14205
+ function optionValues(event) {
14206
+ const value = event?.value;
14207
+ if (typeof value !== "object" || value === null) return void 0;
14208
+ const values = value.values;
14209
+ if (!Array.isArray(values)) return void 0;
14210
+ return values.filter((entry) => typeof entry === "string");
14211
+ }
14212
+ /** The `args` a list row's action carries, or undefined for junk. */
14213
+ function actionArgs(event) {
14214
+ const value = event?.value;
14215
+ if (typeof value !== "object" || value === null) return void 0;
14216
+ return value;
14173
14217
  }
14174
14218
  function registerWorkBuddyDshGo(ctx, source) {
14175
14219
  ctx.inject(["dshGo"], (dshCtx) => {
14176
14220
  const bridge = dshCtx.dshGo;
14177
14221
  if (bridge === void 0) return;
14178
- let latest;
14222
+ let latestSnapshots = [];
14223
+ /** Re-read and re-emit after a write, so the panel shows what landed. */
14224
+ let repush;
14179
14225
  const readAll = async (detail) => Promise.all(REGIONS.map(async (region) => {
14180
14226
  try {
14181
14227
  return dshGoSnapshotOf(region, await source.status(region, detail));
@@ -14192,29 +14238,94 @@ function registerWorkBuddyDshGo(ctx, source) {
14192
14238
  const run = ++generation;
14193
14239
  const fast = await readAll("fast");
14194
14240
  if (cancelled || run !== generation) return;
14195
- latest = dshGoPanelData(fast, caps?.locale);
14196
- emit(latest);
14241
+ latestSnapshots = fast;
14242
+ emit(dshGoPanelData(fast, caps?.locale));
14197
14243
  const full = await readAll("full");
14198
14244
  if (cancelled || run !== generation) return;
14199
- latest = dshGoPanelData(full, caps?.locale);
14200
- emit(latest);
14245
+ latestSnapshots = full;
14246
+ emit(dshGoPanelData(full, caps?.locale));
14247
+ };
14248
+ const rerun = () => {
14249
+ push();
14201
14250
  };
14251
+ repush = rerun;
14202
14252
  push();
14203
14253
  return () => {
14204
14254
  cancelled = true;
14255
+ if (repush === rerun) repush = void 0;
14205
14256
  };
14206
14257
  },
14207
14258
  actions: {
14208
- refresh: (_scope, event) => ({
14209
- refresh: WORKBUDDY_DSH_GO_PANEL,
14210
- toast: words(event?.locale).refreshing
14211
- }),
14212
- copy: (_scope, event) => {
14213
- const w = words(event?.locale);
14214
- return latest === void 0 ? { toast: w.nothing } : {
14215
- copy: dshGoCopyText(latest),
14216
- toast: w.copied
14259
+ refresh: (_scope, event) => {
14260
+ repush?.();
14261
+ return {
14262
+ refresh: WORKBUDDY_DSH_GO_PANEL,
14263
+ toast: words(event?.locale).refreshing
14217
14264
  };
14265
+ },
14266
+ settings: () => ({ open: "plugins" }),
14267
+ /**
14268
+ * Turn a region on or off. The value is the COMPLETE next set, because
14269
+ * `options(multi)` sends every remaining selection on each press; write
14270
+ * only the regions that actually moved so one press never rewrites the
14271
+ * sibling's saved slot.
14272
+ */
14273
+ regions: async (_scope, event) => {
14274
+ const w = words(event?.locale);
14275
+ const values = optionValues(event);
14276
+ if (values === void 0) return { toast: w.saveFailed };
14277
+ if (source.setRegionEnabled === void 0) return { toast: w.readOnly };
14278
+ try {
14279
+ for (const region of REGIONS) {
14280
+ const snapshot = latestSnapshots.find((entry) => entry.region === region);
14281
+ const enabled = values.includes(region);
14282
+ if (snapshot !== void 0 && snapshot.enabled === enabled) continue;
14283
+ if (!await source.setRegionEnabled(region, enabled)) {
14284
+ repush?.();
14285
+ return { toast: w.saveFailed };
14286
+ }
14287
+ }
14288
+ repush?.();
14289
+ return { toast: w.saved };
14290
+ } catch {
14291
+ repush?.();
14292
+ return { toast: w.saveFailed };
14293
+ }
14294
+ },
14295
+ /**
14296
+ * Flip one model for the region the panel is showing.
14297
+ *
14298
+ * The press names a single id, so the next set is computed against the
14299
+ * FULL saved selection — ids other rows show must survive the tap. An
14300
+ * empty saved selection means "the whole directory", which is why the
14301
+ * effective set starts from the roster in that case. The result is
14302
+ * roster-ordered and roster-bounded: an id upstream no longer publishes
14303
+ * cannot be served, so it is not carried forward.
14304
+ */
14305
+ toggleModel: async (_scope, event) => {
14306
+ const w = words(event?.locale);
14307
+ const id = actionArgs(event)?.id;
14308
+ const live = latestSnapshots.find((entry) => entry.enabled && entry.state === "signed-in");
14309
+ if (typeof id !== "string" || live === void 0) return { toast: w.saveFailed };
14310
+ if (source.setModelsEnabled === void 0) return { toast: w.readOnly };
14311
+ if (!live.models.some((model) => model.id === id)) {
14312
+ repush?.();
14313
+ return { toast: w.saveFailed };
14314
+ }
14315
+ const saved = new Set(live.enabledModelIds);
14316
+ const next = new Set(saved.size === 0 ? live.models.map((model) => model.id) : [...saved]);
14317
+ if (next.has(id)) next.delete(id);
14318
+ else next.add(id);
14319
+ const ids = live.models.filter((model) => next.has(model.id)).map((model) => model.id);
14320
+ if (ids.length === 0) return { toast: w.keepOne };
14321
+ try {
14322
+ if (!await source.setModelsEnabled(live.region, ids)) return { toast: w.saveFailed };
14323
+ repush?.();
14324
+ return { toast: w.saved };
14325
+ } catch {
14326
+ repush?.();
14327
+ return { toast: w.saveFailed };
14328
+ }
14218
14329
  }
14219
14330
  }
14220
14331
  });
@@ -16402,7 +16513,27 @@ function apply(ctx, config) {
16402
16513
  readStatus = (region, detail) => workBuddyWebStatus(statusDeps, region, { detail });
16403
16514
  });
16404
16515
  ctx.inject(["dshGo"], (dshCtx) => {
16405
- registerWorkBuddyDshGo(dshCtx, { status: async (region, detail) => readStatus === void 0 ? void 0 : readStatus(region, detail) });
16516
+ /**
16517
+ * One region's `regions` slot, written through the same deep-merging
16518
+ * settings service the Web card saves into. `update` merges objects but
16519
+ * replaces arrays, which is exactly what a partial region patch and a
16520
+ * new `enabledModelIds` list need.
16521
+ *
16522
+ * The service is resolved at press time (it is optional and may appear
16523
+ * after mount) and the namespace is the Loader entry id, never the bare
16524
+ * constant — `settings.update` resolves entries by exact id.
16525
+ */
16526
+ const writeRegion = async (region, patch) => {
16527
+ const host = hostSettings();
16528
+ if (host?.update === void 0) return false;
16529
+ await host.update(settingsNs, { regions: { [region]: patch } });
16530
+ return true;
16531
+ };
16532
+ registerWorkBuddyDshGo(dshCtx, {
16533
+ status: async (region, detail) => readStatus === void 0 ? void 0 : readStatus(region, detail),
16534
+ setRegionEnabled: (region, enabled) => writeRegion(region, { enabled }),
16535
+ setModelsEnabled: (region, ids) => ids.length === 0 ? false : writeRegion(region, { enabledModelIds: [...ids] })
16536
+ });
16406
16537
  });
16407
16538
  /**
16408
16539
  * The region's nearest monthly quota refresh, or undefined when unknown.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-connect-workbuddy-go",
3
3
  "displayName": "DSH Connect WorkBuddy Go",
4
- "description": "把本机登录的 WorkBuddy 模型(国内版与国际版)接入 DeepSeek Harness:每次刷新按上游目录自动读取每个模型的积分倍率,支持逐模型图片输入开关、多账号切换与账号池自动换号,并提供每日签到、卡片与输入框里的胶囊积分读数等只读积分概览。社区分支,新增 dsh-Go 手机原生状态条与面板。",
5
- "version": "6.0.0",
4
+ "description": "把本机登录的 WorkBuddy 模型(国内版与国际版)接入 DeepSeek Harness:每次刷新按上游目录自动读取每个模型的积分倍率,支持逐模型图片输入开关、多账号切换与账号池自动换号,并提供每日签到、卡片与输入框里的胶囊积分读数等只读积分概览。社区分支,新增 dsh-Go 手机原生状态条与可操作面板。",
5
+ "version": "6.1.1",
6
6
  "author": "sheng-888",
7
7
  "copyright": "Copyright (c) 2026 sheng-888. Based on dsh-connect-workbuddy by LaoDing (MIT).",
8
8
  "license": "MIT",
@@ -101,7 +101,7 @@
101
101
  {
102
102
  "id": "workbuddy",
103
103
  "title": {
104
- "zh": "WorkBuddy 账号",
104
+ "zh": "WorkBuddy",
105
105
  "en": "WorkBuddy"
106
106
  },
107
107
  "icon": "wallet",