dsh-connect-workbuddy-go 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.1.0 (2026-11-22)
4
+
5
+ > dsh-Go 面板从「只读看板」改成「顺手能拨的控制面板」:区域与模型两个原生开关,写入走宿主设置;只在桌面成立的附属物不再出现。
6
+
7
+ - **面板可操作**:`src/dsh-go.ts` 新增 `setRegionEnabled` / `setModelsEnabled` 两个可选写入;`index.ts` 在 `dshGo` 注入点用 `ctx.settings.update(settingsNs, { regions: { [region]: … } })` 实现,与 Web 卡片是同一份设置、同一套 `loader/volatile-update` 广播。写入成功后重读状态,开关显示实际落地的值;宿主没有 `update` 时提示「这台主机不能修改设置」。
8
+ - **两个开关的语义**:区域开关只写真正变化的那个区域,一次点按不会覆盖兄弟区域的已保存槽位;模型开关只列协议上限的 8 行,但计算下一组选择时以完整保存值为底——没显示出来的 id 不会因为一次点按被删掉。空选择在上游表示「整个目录」,所以面板拒绝发送空数组,并保留「至少保留一个模型」。
9
+ - **面板收敛**:顶部一句状态 + 两行区域(账号 · 模型数 · 积分)+ 两个开关 + `刷新` / `设置`。删掉复制摘要、倍率列表与只读明细——那些在桌面上成立,在手机上只是把设置页搬进一个更窄的地方。「设置」把人送到 App 的插件页,账号、登录与图片输入仍在那里。
10
+ - **不再误报「已关闭」**:读不到状态的区域先显示「暂不可用」,不把「没读到」说成用户关掉的。
11
+ - **清单**:面板标题简化为 `WorkBuddy`;包描述补上「可操作面板」。
12
+ - **测试**:重写 `tests/dsh-go.spec.ts`(区域/模型选项、8 行上限、空选择=全目录、按完整保存值合并、至少保留一个、只写变化区域、只读宿主、动作与视图绑定);`pnpm run typecheck`、全量测试、`build` 与 dsh-Go `plugin-kit check --load` 全过。
13
+
3
14
  ## 6.0.0 (2026-11-22)
4
15
 
5
16
  > 更名与 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 and model switches 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 卡片是同一份配置,卡片会随广播同步;模型开关只列前 8 个,且至少保留一个(上游把空选择理解为「整个目录」,面板不会把它发出去)。账号、登录与图片输入这些低频操作仍在插件设置里,面板底部的「设置」按钮直接把人送过去。没有 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-DPSsbTAl.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.0";
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-DPSsbTAl.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 `options` component at eight entries. */
13897
+ const MODEL_OPTION_LIMIT = 8;
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,21 @@ 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
13923
  regionName: (region) => region === "cn" ? "国内版" : "国际版",
13924
- modelsTitle: (label, count) => `${label} · ${count} 个模型`
13924
+ modelsTitle: (label, count, capped) => `${label} · ${count} 个模型${capped ? `(前 ${MODEL_OPTION_LIMIT} 个)` : ""}`,
13925
+ modelCount: (count) => `${count} 个模型`
13925
13926
  };
13926
13927
  const EN = {
13927
13928
  brand: "WorkBuddy",
13928
- region: "Region",
13929
- account: "Account",
13930
- status: "Status",
13931
- credits: "Credits",
13932
- models: "Models",
13933
13929
  signedIn: "Connected",
13934
13930
  signedOut: "Signed out",
13935
13931
  failed: "Read failed",
@@ -13944,14 +13940,18 @@ const EN = {
13944
13940
  notLoggedIn: "WorkBuddy is signed out",
13945
13941
  allClosed: "Both regions are off",
13946
13942
  noModels: "No models available",
13947
- localOnly: "Credits load when the panel opens",
13943
+ regionsLabel: "Regions",
13944
+ footer: "Changes apply immediately · Accounts and sign-in live in plugin settings",
13948
13945
  refresh: "Refresh",
13949
13946
  refreshing: "Refreshing",
13950
- copy: "Copy summary",
13951
- copied: "Copied",
13952
- nothing: "Nothing to copy yet",
13947
+ settings: "Settings",
13948
+ saved: "Updated",
13949
+ saveFailed: "Could not save",
13950
+ readOnly: "Settings are read-only on this host",
13951
+ keepOne: "Keep at least one model",
13953
13952
  regionName: (region) => region === "cn" ? "CN" : "Global",
13954
- modelsTitle: (label, count) => `${label} · ${count} models`
13953
+ modelsTitle: (label, count, capped) => `${label} · ${count} models${capped ? ` (first ${MODEL_OPTION_LIMIT})` : ""}`,
13954
+ modelCount: (count) => `${count} models`
13955
13955
  };
13956
13956
  function words(locale) {
13957
13957
  return typeof locale === "string" && locale.toLowerCase().startsWith("en") ? EN : ZH;
@@ -14025,36 +14025,56 @@ function modelCount(snapshot) {
14025
14025
  function stateText(snapshot, w) {
14026
14026
  if (snapshot.state === "unavailable") return w.unavailable;
14027
14027
  if (!snapshot.enabled) return w.closed;
14028
- if (snapshot.state === "signed-in") return w.signedIn;
14029
14028
  if (snapshot.state === "error") return w.failed;
14029
+ if (snapshot.state === "signed-in") return w.signedIn;
14030
14030
  if (snapshot.credentialRejected) return w.rejected;
14031
14031
  if (snapshot.selectionLost) return w.reselect;
14032
14032
  return w.signedOut;
14033
14033
  }
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
14034
  function numberText(value) {
14040
14035
  return new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(value);
14041
14036
  }
14042
- function multiplierText(value) {
14043
- if (value === void 0 || !Number.isFinite(value)) return void 0;
14044
- return `x${value.toFixed(2).replace(/\.?0+$/u, "")}`;
14037
+ /** One region's subtitle: who serves it, then how many models are in play. */
14038
+ function regionSubtitle(snapshot, w) {
14039
+ if (snapshot.state !== "signed-in" || !snapshot.enabled) return stateText(snapshot, w);
14040
+ return `${snapshot.accountName.trim() === "" ? w.unnamed : clip(snapshot.accountName, 16)}${snapshot.accountCount > 1 ? ` · ${snapshot.accountCount} ${w.accountsSuffix}` : ""} · ${w.modelCount(modelCount(snapshot))}`;
14041
+ }
14042
+ function regionRow(snapshot, w) {
14043
+ const tone = snapshot.state === "error" || snapshot.state === "unavailable" ? "bad" : !snapshot.enabled ? "muted" : snapshot.state === "signed-in" ? "good" : "warn";
14044
+ return {
14045
+ title: w.regionName(snapshot.region),
14046
+ subtitle: regionSubtitle(snapshot, w),
14047
+ trailing: snapshot.enabled && snapshot.state === "signed-in" && snapshot.credits !== void 0 ? numberText(snapshot.credits) : "—",
14048
+ icon: "wallet",
14049
+ tone
14050
+ };
14045
14051
  }
14046
- function modelRows(snapshot) {
14052
+ /**
14053
+ * The model switch's two faces for one region: every roster row the protocol
14054
+ * lets us show, plus which of them are currently on.
14055
+ *
14056
+ * An EMPTY saved selection means "serve the whole directory", so every row
14057
+ * reads as selected — the switch must not paint a never-configured region as
14058
+ * "nothing enabled".
14059
+ */
14060
+ function modelSelectionOf(snapshot) {
14061
+ const shown = snapshot.models.slice(0, MODEL_OPTION_LIMIT);
14047
14062
  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
- });
14063
+ return {
14064
+ options: shown.map((model) => {
14065
+ const name = model.name.trim() === "" ? model.id : model.name;
14066
+ return model.id === name ? {
14067
+ label: name,
14068
+ value: model.id
14069
+ } : {
14070
+ label: name,
14071
+ description: model.id,
14072
+ value: model.id
14073
+ };
14074
+ }),
14075
+ selected: shown.filter((model) => enabled.size === 0 || enabled.has(model.id)).map((model) => model.id),
14076
+ capped: snapshot.models.length > MODEL_OPTION_LIMIT
14077
+ };
14058
14078
  }
14059
14079
  /** The panel's data model. Every label is resolved here, once, for the app's locale. */
14060
14080
  function dshGoPanelData(snapshots, locale) {
@@ -14064,24 +14084,22 @@ function dshGoPanelData(snapshots, locale) {
14064
14084
  const allClosed = snapshots.length > 0 && snapshots.every((snapshot) => !snapshot.enabled);
14065
14085
  const headline = live !== void 0 ? w.ready : allClosed ? w.allClosed : anyBad ? w.notReady : w.notLoggedIn;
14066
14086
  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;
14087
+ const models = live === void 0 ? void 0 : modelSelectionOf(live);
14077
14088
  const note = snapshots.map((snapshot) => snapshot.message).find((message) => message !== void 0);
14078
14089
  return {
14079
14090
  headline,
14080
14091
  tone,
14081
- rows,
14082
- modelsTitle,
14083
- models,
14084
- footer: note === void 0 ? w.localOnly : `${w.localOnly} · ${note}`
14092
+ regionRows: snapshots.map((snapshot) => regionRow(snapshot, w)),
14093
+ regionsLabel: w.regionsLabel,
14094
+ regionOptions: REGIONS.map((region) => ({
14095
+ label: w.regionName(region),
14096
+ value: region
14097
+ })),
14098
+ selectedRegions: snapshots.filter((snapshot) => snapshot.enabled).map((snapshot) => snapshot.region),
14099
+ modelsLabel: live === void 0 ? w.noModels : w.modelsTitle(w.regionName(live.region), live.models.length, models?.capped === true),
14100
+ modelOptions: models?.options ?? [],
14101
+ selectedModels: models?.selected ?? [],
14102
+ footer: note === void 0 ? w.footer : `${w.footer} · ${note}`
14085
14103
  };
14086
14104
  }
14087
14105
  /** The one line above the composer, capped at the protocol's 24 characters. */
@@ -14112,7 +14130,14 @@ function dshGoStripData(snapshots, locale) {
14112
14130
  tone: "warn"
14113
14131
  };
14114
14132
  }
14115
- /** The panel's structure. Values are bindings, so pushes stay small. */
14133
+ /**
14134
+ * The panel's structure. Values are bindings, so pushes stay small.
14135
+ *
14136
+ * Three blocks, in reading order: what is happening (headline + one row per
14137
+ * region), which region is offered to DSH, and which models that region puts
14138
+ * in the picker. The two switches are the only writes a phone should make
14139
+ * without a keyboard; everything else is one tap away in plugin settings.
14140
+ */
14116
14141
  function dshGoPanelView(locale) {
14117
14142
  const w = words(locale);
14118
14143
  return {
@@ -14124,24 +14149,32 @@ function dshGoPanelView(locale) {
14124
14149
  tone: { $: "data.tone" }
14125
14150
  },
14126
14151
  {
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" }
14152
+ type: "list",
14153
+ items: { $: "data.regionRows" }
14136
14154
  },
14137
14155
  {
14138
14156
  type: "text",
14139
- text: { $: "data.modelsTitle" },
14157
+ text: { $: "data.regionsLabel" },
14140
14158
  tone: "muted"
14141
14159
  },
14142
14160
  {
14143
- type: "list",
14144
- items: { $: "data.models" }
14161
+ type: "options",
14162
+ id: "regions",
14163
+ multi: true,
14164
+ options: { $: "data.regionOptions" },
14165
+ selected: { $: "data.selectedRegions" }
14166
+ },
14167
+ {
14168
+ type: "text",
14169
+ text: { $: "data.modelsLabel" },
14170
+ tone: "muted"
14171
+ },
14172
+ {
14173
+ type: "options",
14174
+ id: "models",
14175
+ multi: true,
14176
+ options: { $: "data.modelOptions" },
14177
+ selected: { $: "data.selectedModels" }
14145
14178
  },
14146
14179
  {
14147
14180
  type: "actions",
@@ -14151,9 +14184,9 @@ function dshGoPanelView(locale) {
14151
14184
  action: "refresh",
14152
14185
  style: "primary"
14153
14186
  }, {
14154
- label: w.copy,
14155
- icon: "copy",
14156
- action: "copy"
14187
+ label: w.settings,
14188
+ icon: "settings",
14189
+ action: "settings"
14157
14190
  }]
14158
14191
  },
14159
14192
  {
@@ -14164,18 +14197,21 @@ function dshGoPanelView(locale) {
14164
14197
  ]
14165
14198
  };
14166
14199
  }
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");
14200
+ /** The `values` an `options(multi)` press carries, or undefined for junk. */
14201
+ function optionValues(event) {
14202
+ const value = event?.value;
14203
+ if (typeof value !== "object" || value === null) return void 0;
14204
+ const values = value.values;
14205
+ if (!Array.isArray(values)) return void 0;
14206
+ return values.filter((entry) => typeof entry === "string");
14173
14207
  }
14174
14208
  function registerWorkBuddyDshGo(ctx, source) {
14175
14209
  ctx.inject(["dshGo"], (dshCtx) => {
14176
14210
  const bridge = dshCtx.dshGo;
14177
14211
  if (bridge === void 0) return;
14178
- let latest;
14212
+ let latestSnapshots = [];
14213
+ /** Re-read and re-emit after a write, so the switch shows what landed. */
14214
+ let repush;
14179
14215
  const readAll = async (detail) => Promise.all(REGIONS.map(async (region) => {
14180
14216
  try {
14181
14217
  return dshGoSnapshotOf(region, await source.status(region, detail));
@@ -14192,29 +14228,90 @@ function registerWorkBuddyDshGo(ctx, source) {
14192
14228
  const run = ++generation;
14193
14229
  const fast = await readAll("fast");
14194
14230
  if (cancelled || run !== generation) return;
14195
- latest = dshGoPanelData(fast, caps?.locale);
14196
- emit(latest);
14231
+ latestSnapshots = fast;
14232
+ emit(dshGoPanelData(fast, caps?.locale));
14197
14233
  const full = await readAll("full");
14198
14234
  if (cancelled || run !== generation) return;
14199
- latest = dshGoPanelData(full, caps?.locale);
14200
- emit(latest);
14235
+ latestSnapshots = full;
14236
+ emit(dshGoPanelData(full, caps?.locale));
14237
+ };
14238
+ const rerun = () => {
14239
+ push();
14201
14240
  };
14241
+ repush = rerun;
14202
14242
  push();
14203
14243
  return () => {
14204
14244
  cancelled = true;
14245
+ if (repush === rerun) repush = void 0;
14205
14246
  };
14206
14247
  },
14207
14248
  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
14249
+ refresh: (_scope, event) => {
14250
+ repush?.();
14251
+ return {
14252
+ refresh: WORKBUDDY_DSH_GO_PANEL,
14253
+ toast: words(event?.locale).refreshing
14217
14254
  };
14255
+ },
14256
+ settings: () => ({ open: "plugins" }),
14257
+ /**
14258
+ * Turn a region on or off. The value is the COMPLETE next set, because
14259
+ * `options(multi)` sends every remaining selection on each press; write
14260
+ * only the regions that actually moved so one press never rewrites the
14261
+ * sibling's saved slot.
14262
+ */
14263
+ regions: async (_scope, event) => {
14264
+ const w = words(event?.locale);
14265
+ const values = optionValues(event);
14266
+ if (values === void 0) return { toast: w.saveFailed };
14267
+ if (source.setRegionEnabled === void 0) return { toast: w.readOnly };
14268
+ try {
14269
+ for (const region of REGIONS) {
14270
+ const snapshot = latestSnapshots.find((entry) => entry.region === region);
14271
+ const enabled = values.includes(region);
14272
+ if (snapshot !== void 0 && snapshot.enabled === enabled) continue;
14273
+ if (!await source.setRegionEnabled(region, enabled)) {
14274
+ repush?.();
14275
+ return { toast: w.saveFailed };
14276
+ }
14277
+ }
14278
+ repush?.();
14279
+ return { toast: w.saved };
14280
+ } catch {
14281
+ repush?.();
14282
+ return { toast: w.saveFailed };
14283
+ }
14284
+ },
14285
+ /**
14286
+ * Toggle models for the region the panel is showing.
14287
+ *
14288
+ * The press carries only the eight rows on screen, so the next set is
14289
+ * computed against the FULL saved selection — ids that the protocol did
14290
+ * not show must survive a toggle. An empty saved selection means "the
14291
+ * whole directory", which is why the effective set starts from the
14292
+ * roster in that case.
14293
+ */
14294
+ models: async (_scope, event) => {
14295
+ const w = words(event?.locale);
14296
+ const values = optionValues(event);
14297
+ const live = latestSnapshots.find((entry) => entry.enabled && entry.state === "signed-in");
14298
+ if (values === void 0 || live === void 0) return { toast: w.saveFailed };
14299
+ if (source.setModelsEnabled === void 0) return { toast: w.readOnly };
14300
+ const saved = new Set(live.enabledModelIds);
14301
+ const next = new Set(saved.size === 0 ? live.models.map((model) => model.id) : [...saved]);
14302
+ const picked = new Set(values);
14303
+ for (const model of live.models.slice(0, MODEL_OPTION_LIMIT)) if (picked.has(model.id)) next.add(model.id);
14304
+ else next.delete(model.id);
14305
+ const ids = live.models.filter((model) => next.has(model.id)).map((model) => model.id);
14306
+ if (ids.length === 0) return { toast: w.keepOne };
14307
+ try {
14308
+ if (!await source.setModelsEnabled(live.region, ids)) return { toast: w.saveFailed };
14309
+ repush?.();
14310
+ return { toast: w.saved };
14311
+ } catch {
14312
+ repush?.();
14313
+ return { toast: w.saveFailed };
14314
+ }
14218
14315
  }
14219
14316
  }
14220
14317
  });
@@ -16402,7 +16499,27 @@ function apply(ctx, config) {
16402
16499
  readStatus = (region, detail) => workBuddyWebStatus(statusDeps, region, { detail });
16403
16500
  });
16404
16501
  ctx.inject(["dshGo"], (dshCtx) => {
16405
- registerWorkBuddyDshGo(dshCtx, { status: async (region, detail) => readStatus === void 0 ? void 0 : readStatus(region, detail) });
16502
+ /**
16503
+ * One region's `regions` slot, written through the same deep-merging
16504
+ * settings service the Web card saves into. `update` merges objects but
16505
+ * replaces arrays, which is exactly what a partial region patch and a
16506
+ * new `enabledModelIds` list need.
16507
+ *
16508
+ * The service is resolved at press time (it is optional and may appear
16509
+ * after mount) and the namespace is the Loader entry id, never the bare
16510
+ * constant — `settings.update` resolves entries by exact id.
16511
+ */
16512
+ const writeRegion = async (region, patch) => {
16513
+ const host = hostSettings();
16514
+ if (host?.update === void 0) return false;
16515
+ await host.update(settingsNs, { regions: { [region]: patch } });
16516
+ return true;
16517
+ };
16518
+ registerWorkBuddyDshGo(dshCtx, {
16519
+ status: async (region, detail) => readStatus === void 0 ? void 0 : readStatus(region, detail),
16520
+ setRegionEnabled: (region, enabled) => writeRegion(region, { enabled }),
16521
+ setModelsEnabled: (region, ids) => ids.length === 0 ? false : writeRegion(region, { enabledModelIds: [...ids] })
16522
+ });
16406
16523
  });
16407
16524
  /**
16408
16525
  * 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.0",
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",