dsh-connect-workbuddy 5.29.1 → 5.30.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,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.30.0 (2026-11-21)
4
+
5
+ > 功能版:当天已完成的签到/兑换/点亮改为落盘的本地记录,不再每次轮询重读上游。
6
+
7
+ > ⚠️ 本版在 5.29.1 发布之后新增,须单独发布。
8
+
9
+ - 用户指出:当天已签到/已兑换/已点亮应记在本地,没记录才去刷新。此前签到用 10 分钟
10
+ TTL 缓存、过期就对**每个账号**重读一次(含早签到的),白费上游请求。
11
+ - 新增 `daily-done-store.ts`:按 (能力, 区) 落盘 `$DSH_HOME`,记当天已完成的账号 id,
12
+ 以**本地日**为界自动失效。读到一次"已完成"(不管插件做的还是用户在官方客户端做的)
13
+ 就写记录,之后当天不再读,重启也保留;只有没记录时才读一次。
14
+ - 签到:`checkedInToday` 与首屏 `cachedCheckedInToday` 改读该记录;签到批处理成功行写入
15
+ 记录(替代旧的删缓存)。成长两项的每账号戳记也统一从该记录读,并与既有成长落盘状态合并,
16
+ 兼容老存档。
17
+ - 5 条新单测(记录/不重读/三能力隔离/首屏映射/落盘无 token)+ 变异验证(让 isDoneToday
18
+ 恒假即红)。修一处测试隔离问题:内存镜像的键带上 `$DSH_HOME`,避免换 home 的测试互相污染。
19
+ `pnpm run check` 全过(3778 条测试)。Host 侧改动,需重启 DSH 加载。
20
+
3
21
  ## 5.29.1 (2026-11-21)
4
22
 
5
23
  > 样式版:三个状态戳从文字改成图标 + hover tooltip。用户要求「用图标表达、不要文字」。
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-C65HMbxG.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-BzYVKa0r.js";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { realpathSync } from "node:fs";
@@ -11490,7 +11490,7 @@ function describeRosterSeenPayload(raw) {
11490
11490
  //#endregion
11491
11491
  //#region src/version.ts
11492
11492
  /** The npm package version this build was produced from. */
11493
- const WORKBUDDY_CONNECT_VERSION = "5.29.1";
11493
+ const WORKBUDDY_CONNECT_VERSION = "5.30.0";
11494
11494
  //#endregion
11495
11495
  //#region src/host-heartbeat.ts
11496
11496
  /**
package/lib/index.d.ts CHANGED
@@ -5729,18 +5729,18 @@ interface WorkBuddyPoolDeps {
5729
5729
  * Today's check-in state, from the cells already measured this process.
5730
5730
  *
5731
5731
  * The first-paint counterpart of {@link checkedInToday}: reads the Host's
5732
- * measurement cache and nothing else, so a first paint never waits on one
5733
- * upstream request per account. An account it has not measured is simply
5732
+ * local done-today memory and nothing else, so a first paint never waits on
5733
+ * one upstream request per account. An account it has not measured is simply
5734
5734
  * absent, which the card renders as unknown — the same meaning as a failed
5735
5735
  * per-account read in the full document.
5736
5736
  */
5737
- cachedCheckedInToday?(region: WorkBuddyRegion): Readonly<Record<string, boolean>>;
5737
+ cachedCheckedInToday?(region: WorkBuddyRegion): Promise<Readonly<Record<string, boolean>>> | Readonly<Record<string, boolean>>;
5738
5738
  /**
5739
5739
  * Per-account growth completion for today (issue #286), from the runner's own
5740
5740
  * day state — no upstream read. `true` only for accounts the job settled today;
5741
5741
  * absent for accounts it has not covered. Drives the per-row 已兑换/已点亮 stamp.
5742
5742
  */
5743
- growthDoneAccountIds?(region: WorkBuddyRegion, cap: 'growth-redeem' | 'growth-activity'): Readonly<Record<string, boolean>>;
5743
+ growthDoneAccountIds?(region: WorkBuddyRegion, cap: 'growth-redeem' | 'growth-activity'): Promise<Readonly<Record<string, boolean>>> | Readonly<Record<string, boolean>>;
5744
5744
  /**
5745
5745
  * Claimable promotional benefits per account id (issue #79).
5746
5746
  *
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-C65HMbxG.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-BzYVKa0r.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";
@@ -11364,7 +11364,7 @@ function mergeTransferRecords(records, indexes, region, knownRegionOfDomain) {
11364
11364
  * @module dsh-connect-workbuddy/account-pool-store
11365
11365
  */
11366
11366
  /** On-disk format version; readers reject anything else. */
11367
- const STORE_FORMAT_VERSION$2 = 1;
11367
+ const STORE_FORMAT_VERSION$3 = 1;
11368
11368
  /** Filename prefix for one region's measured pool facts. */
11369
11369
  const POOL_STORE_PREFIX = ".workbuddy-pool";
11370
11370
  /** Whether a parsed value looks like a stored probe. */
@@ -11454,7 +11454,7 @@ async function readPoolProbes(region) {
11454
11454
  }
11455
11455
  if (typeof parsed !== "object" || parsed === null) return {};
11456
11456
  const document = parsed;
11457
- if (document.version !== STORE_FORMAT_VERSION$2) return {};
11457
+ if (document.version !== STORE_FORMAT_VERSION$3) return {};
11458
11458
  if (typeof document.probes !== "object" || document.probes === null) return {};
11459
11459
  const probes = {};
11460
11460
  for (const [accountId, probe] of Object.entries(document.probes)) {
@@ -11557,7 +11557,7 @@ async function writePoolProbes(region, updates) {
11557
11557
  const merged = { ...existing };
11558
11558
  for (const [accountId, update] of Object.entries(updates)) merged[accountId] = mergePoolProbe(existing[accountId], update);
11559
11559
  await writeFileAtomic(path, `${JSON.stringify({
11560
- version: STORE_FORMAT_VERSION$2,
11560
+ version: STORE_FORMAT_VERSION$3,
11561
11561
  probes: merged
11562
11562
  }, null, 2)}\n`, {
11563
11563
  mode: 384,
@@ -11587,7 +11587,7 @@ async function reconcilePoolCredits(region, readings) {
11587
11587
  changed = true;
11588
11588
  }
11589
11589
  if (changed) await writeFileAtomic(path, `${JSON.stringify({
11590
- version: STORE_FORMAT_VERSION$2,
11590
+ version: STORE_FORMAT_VERSION$3,
11591
11591
  probes
11592
11592
  }, null, 2)}\n`, {
11593
11593
  mode: 384,
@@ -11765,23 +11765,6 @@ function todaySummary(state, nowMs) {
11765
11765
  return summarizeAutoCheckin(state);
11766
11766
  }
11767
11767
  /**
11768
- * Whether a cached check-in reading may still be served.
11769
- *
11770
- * Two conditions, and the second is the one that took a bug report: a reading is
11771
- * an answer to "has this account checked in TODAY", so it must not survive local
11772
- * midnight. The TTL alone would serve a `true` read taken at 23:58 until 00:08,
11773
- * so the column would assert a check-in that has not happened — the per-account
11774
- * half of the same lie as {@link todaySummary}.
11775
- *
11776
- * The day is derived from `atMs` rather than stored beside it: the read time
11777
- * already says which day the answer belongs to, and a second field could drift
11778
- * out of step with it.
11779
- */
11780
- function checkinReadingFresh(atMs, nowMs, ttlMs) {
11781
- if (nowMs - atMs >= ttlMs) return false;
11782
- return localDayKey(atMs) === localDayKey(nowMs);
11783
- }
11784
- /**
11785
11768
  * The accounts an attempt should address, in the pool's own order.
11786
11769
  *
11787
11770
  * Only members that are not already done. Enterprise members are dropped HERE
@@ -11819,7 +11802,7 @@ function pendingTargets(targets, state) {
11819
11802
  * @module dsh-connect-workbuddy/auto-checkin-store
11820
11803
  */
11821
11804
  /** On-disk format version; readers reject anything else. */
11822
- const STORE_FORMAT_VERSION$1 = 1;
11805
+ const STORE_FORMAT_VERSION$2 = 1;
11823
11806
  /** Filename prefix for one region's auto-check-in memory. */
11824
11807
  const AUTO_CHECKIN_PREFIX = ".workbuddy-auto-checkin";
11825
11808
  /** Whether a parsed value looks like a stored state. */
@@ -11854,7 +11837,7 @@ async function readAutoCheckinState(region) {
11854
11837
  }
11855
11838
  if (typeof parsed !== "object" || parsed === null) return void 0;
11856
11839
  const document = parsed;
11857
- if (document.version !== STORE_FORMAT_VERSION$1) return void 0;
11840
+ if (document.version !== STORE_FORMAT_VERSION$2) return void 0;
11858
11841
  const regions = document.regions;
11859
11842
  if (typeof regions !== "object" || regions === null) return void 0;
11860
11843
  const state = regions[region];
@@ -11876,7 +11859,7 @@ async function writeAutoCheckinState(region, state) {
11876
11859
  [region]: state
11877
11860
  };
11878
11861
  await writeFileAtomic(path, `${JSON.stringify({
11879
- version: STORE_FORMAT_VERSION$1,
11862
+ version: STORE_FORMAT_VERSION$2,
11880
11863
  regions
11881
11864
  }, null, 2)}\n`, {
11882
11865
  mode: 384,
@@ -11901,7 +11884,7 @@ async function readDocument(path) {
11901
11884
  }
11902
11885
  if (typeof parsed !== "object" || parsed === null) return {};
11903
11886
  const document = parsed;
11904
- if (document.version !== STORE_FORMAT_VERSION$1) return {};
11887
+ if (document.version !== STORE_FORMAT_VERSION$2) return {};
11905
11888
  const regions = document.regions;
11906
11889
  if (typeof regions !== "object" || regions === null) return {};
11907
11890
  const clean = {};
@@ -11909,6 +11892,113 @@ async function readDocument(path) {
11909
11892
  return clean;
11910
11893
  }
11911
11894
  //#endregion
11895
+ //#region src/daily-done-store.ts
11896
+ /**
11897
+ * On-disk "done today" memory for the three per-account day facts (issue #286
11898
+ * follow-up): checked-in / tier-redeemed / active-today.
11899
+ *
11900
+ * WHY THIS EXISTS. The card used to RE-READ "did this account check in today"
11901
+ * from upstream every 10 minutes, for every account — including ones that had
11902
+ * been done since morning. The user asked for the obvious: once a fact is true
11903
+ * today, remember it locally and stop asking; only read when there is no record
11904
+ * yet (a fresh day, or an account the plugin has never observed). This module is
11905
+ * that memory. It is keyed by (kind, region), persisted under `$DSH_HOME`, and
11906
+ * bounded by the LOCAL day so a `true` read at 23:58 never answers for 00:08.
11907
+ *
11908
+ * It deliberately does NOT distinguish "we did it" from "the user did it in the
11909
+ * official client": both are observed as `true` from upstream and both mean the
11910
+ * same thing to the card — done today, nothing more to do. That is why the read
11911
+ * path writes the record: the first observation (whoever caused it) is enough.
11912
+ *
11913
+ * Reads/writes never throw — a corrupt or missing file means "nothing done
11914
+ * today", and the caller then performs the one read this module saves.
11915
+ *
11916
+ * No token, no account name in the file — only account ids and a local day key.
11917
+ *
11918
+ * @module dsh-connect-workbuddy/daily-done-store
11919
+ */
11920
+ const STORE_FORMAT_VERSION$1 = 1;
11921
+ /** A process-local mirror so the hot path never touches the disk. */
11922
+ const memory = {};
11923
+ /**
11924
+ * Cache key includes the resolved home so a changed `$DSH_HOME` (only ever a
11925
+ * test fixture in practice) cannot reuse another home's memory. In production
11926
+ * the home is fixed for the process, so this is a pure correctness safeguard.
11927
+ */
11928
+ const keyOf = (kind, region) => `${resolveDshHome()}:${kind}:${region}`;
11929
+ function filePath(kind, region) {
11930
+ return join(resolveDshHome(), `.workbuddy-daydone-${kind}.${region}.json`);
11931
+ }
11932
+ function isDocument(value) {
11933
+ if (typeof value !== "object" || value === null) return false;
11934
+ const doc = value;
11935
+ return doc["version"] === STORE_FORMAT_VERSION$1 && typeof doc["day"] === "string" && Array.isArray(doc["ids"]) && doc["ids"].every((id) => typeof id === "string");
11936
+ }
11937
+ /** Load one (kind, region) from disk into the mirror, once. Never throws. */
11938
+ async function load(kind, region) {
11939
+ const key = keyOf(kind, region);
11940
+ const hit = memory[key];
11941
+ if (hit !== void 0) return hit;
11942
+ let loaded = {
11943
+ day: localDayKey(Date.now()),
11944
+ ids: /* @__PURE__ */ new Set()
11945
+ };
11946
+ try {
11947
+ const raw = await readFile(filePath(kind, region), "utf8");
11948
+ const parsed = JSON.parse(raw);
11949
+ if (isDocument(parsed) && parsed.day === localDayKey(Date.now())) loaded = {
11950
+ day: parsed.day,
11951
+ ids: new Set(parsed.ids)
11952
+ };
11953
+ } catch {}
11954
+ memory[key] = loaded;
11955
+ return loaded;
11956
+ }
11957
+ /** Is this account already recorded done TODAY? No disk read after the first. */
11958
+ async function isDoneToday(kind, region, accountId) {
11959
+ const state = await load(kind, region);
11960
+ if (state.day !== localDayKey(Date.now())) {
11961
+ memory[keyOf(kind, region)] = {
11962
+ day: localDayKey(Date.now()),
11963
+ ids: /* @__PURE__ */ new Set()
11964
+ };
11965
+ return false;
11966
+ }
11967
+ return state.ids.has(accountId);
11968
+ }
11969
+ /** Record one (or several) accounts done today. Never throws. */
11970
+ async function markDoneToday(kind, region, accountIds) {
11971
+ if (accountIds.length === 0) return;
11972
+ const key = keyOf(kind, region);
11973
+ const today = localDayKey(Date.now());
11974
+ const state = memory[key]?.day === today ? memory[key] : {
11975
+ day: today,
11976
+ ids: /* @__PURE__ */ new Set()
11977
+ };
11978
+ for (const id of accountIds) state.ids.add(id);
11979
+ memory[key] = state;
11980
+ const path = filePath(kind, region);
11981
+ try {
11982
+ await withFileLock(path, async () => {
11983
+ const document = {
11984
+ version: STORE_FORMAT_VERSION$1,
11985
+ day: today,
11986
+ ids: [...state.ids]
11987
+ };
11988
+ await writeFileAtomic(path, `${JSON.stringify(document, null, 2)}\n`, {
11989
+ mode: 384,
11990
+ dirMode: 448
11991
+ });
11992
+ });
11993
+ } catch {}
11994
+ }
11995
+ /** The full done-today set for one (kind, region), for the first-paint map. */
11996
+ async function doneTodayMap(kind, region) {
11997
+ const state = await load(kind, region);
11998
+ if (state.day !== localDayKey(Date.now())) return {};
11999
+ return Object.fromEntries([...state.ids].map((id) => [id, true]));
12000
+ }
12001
+ //#endregion
11912
12002
  //#region src/growth-acp.ts
11913
12003
  /** Normalize a session link to its ACP endpoint, without duplicating the suffix. */
11914
12004
  function resolveAcpEndpoint(link) {
@@ -12944,9 +13034,9 @@ async function workBuddyWebPool(deps, region, fast = false) {
12944
13034
  const byId = new Map(members.map((member) => [member.account.id, member]));
12945
13035
  const rankedIds = new Set(ranked.map((row) => row.account.id));
12946
13036
  const others = await pool.otherAccounts?.(region) ?? [];
12947
- const checkedIn = fast ? pool.cachedCheckedInToday?.(region) ?? {} : await pool.checkedInToday?.(region).catch(() => ({})) ?? {};
12948
- const growthRedeemed = pool.growthDoneAccountIds?.(region, "growth-redeem") ?? {};
12949
- const growthActive = pool.growthDoneAccountIds?.(region, "growth-activity") ?? {};
13037
+ const checkedIn = fast ? await pool.cachedCheckedInToday?.(region) ?? {} : await pool.checkedInToday?.(region).catch(() => ({})) ?? {};
13038
+ const growthRedeemed = await pool.growthDoneAccountIds?.(region, "growth-redeem") ?? {};
13039
+ const growthActive = await pool.growthDoneAccountIds?.(region, "growth-activity") ?? {};
12950
13040
  const claimable = fast ? pool.cachedBenefits?.(region) ?? {} : await pool.benefits?.(region).catch(() => ({})) ?? {};
12951
13041
  const rows = [...ranked.map((row) => ({
12952
13042
  account: row.account,
@@ -14423,35 +14513,15 @@ function apply(ctx, config) {
14423
14513
  };
14424
14514
  })());
14425
14515
  /**
14426
- * How long a check-in reading is reused before asking the upstream again.
14427
- *
14428
- * The card polls the usage route every 60 seconds, but "did this account
14429
- * check in today" changes only when a check-in runs or the day rolls over.
14430
- * Without a cache, a 10-account pool cost ~14,400 upstream requests a day for
14431
- * an answer that was almost always identical.
14432
- */
14433
- const CHECKIN_CACHE_MS = 6e5;
14434
- /**
14435
- * Per-region, per-account check-in readings.
14436
- *
14437
- * Invalidated by this plugin's own check-in batch (the only writer that can
14438
- * change the answer during a session), so the user sees their result
14439
- * immediately instead of waiting out the TTL.
14440
- *
14441
- * A reading is ALSO bounded by the local day, not just by the TTL — see
14442
- * `checkinReadingFresh`. Both readers go through it, because an entry is an
14443
- * answer to "has this account checked in TODAY" and a `true` read at 23:58
14444
- * must not be served at 00:08.
14445
- */
14446
- const checkinStateCache = {};
14447
- /**
14448
14516
  * Per-region, per-account benefit readings (issue #79).
14449
14517
  *
14450
- * Same shape and same reasoning as `checkinStateCache`: claim state changes
14451
- * when a human acts on the web page or in the desktop app, not spontaneously,
14452
- * so a per-poll read of two endpoints per account would be thousands of
14453
- * requests a day to learn nothing. Coarser than the check-in TTL because a
14454
- * benefit window is measured in days, not hours.
14518
+ * "Did this account check in today" is NOT cached here any more: it lives in
14519
+ * the persistent done-today memory (`daily-done-store`), so a fact observed
14520
+ * once is never re-read that day — not even after a restart. Benefit claim
14521
+ * state changes when a human acts on the web page or in the desktop app, not
14522
+ * spontaneously, so a per-poll read of two endpoints per account would be
14523
+ * thousands of requests a day to learn nothing. Its window is measured in
14524
+ * days, not hours.
14455
14525
  */
14456
14526
  const benefitStateCache = {};
14457
14527
  const settingsNs = settingsNamespaceOf(ctx);
@@ -15534,22 +15604,14 @@ function apply(ctx, config) {
15534
15604
  if (region !== "cn" || !poolPreferencesOf(current(), region).enabled) return {};
15535
15605
  const store = stacks[region].store;
15536
15606
  const accounts = await store.accounts();
15537
- const now = Date.now();
15538
15607
  const entries = await Promise.all(accounts.map(async (account) => {
15539
15608
  if (account.enterprise === true) return void 0;
15540
- const cached = checkinStateCache[region]?.[account.id];
15541
- if (cached !== void 0 && checkinReadingFresh(cached.atMs, now, CHECKIN_CACHE_MS)) return [account.id, cached.checkedIn];
15609
+ if (await isDoneToday("checkin", region, account.id)) return [account.id, true];
15542
15610
  const credential = await store.credentialFor(account.id).catch(() => void 0);
15543
15611
  if (credential === void 0) return void 0;
15544
15612
  const status = await client.fetchCheckinStatus(credential).catch(() => void 0);
15545
15613
  if (status === void 0 || !status.active) return void 0;
15546
- checkinStateCache[region] = {
15547
- ...checkinStateCache[region],
15548
- [account.id]: {
15549
- checkedIn: status.todayCheckedIn,
15550
- atMs: now
15551
- }
15552
- };
15614
+ if (status.todayCheckedIn) await markDoneToday("checkin", region, [account.id]);
15553
15615
  return [account.id, status.todayCheckedIn];
15554
15616
  }));
15555
15617
  return Object.fromEntries(entries.filter((entry) => entry !== void 0));
@@ -15562,17 +15624,15 @@ function apply(ctx, config) {
15562
15624
  * on one request per account. An unmeasured account is absent, which the
15563
15625
  * card already renders as unknown rather than as "not checked in".
15564
15626
  */
15565
- cachedCheckedInToday(region) {
15566
- if (!poolPreferencesOf(current(), region).enabled) return {};
15567
- const now = Date.now();
15568
- const state = checkinStateCache[region] ?? {};
15569
- const cached = {};
15570
- for (const [accountId, entry] of Object.entries(state)) {
15571
- if (!checkinReadingFresh(entry.atMs, now, CHECKIN_CACHE_MS)) continue;
15572
- cached[accountId] = entry.checkedIn;
15573
- }
15574
- return cached;
15575
- },
15627
+ /**
15628
+ * Today's checked-in accounts for the first paint (issue #77).
15629
+ *
15630
+ * Reads the persistent done-today memory and NOTHING else: no upstream
15631
+ * request, so painting never blocks, and — unlike the old in-memory TTL
15632
+ * cache — it survives a restart within the same day. An account with no
15633
+ * record is absent, which the card already renders as unknown.
15634
+ */
15635
+ cachedCheckedInToday: (region) => doneTodayMap("checkin", region),
15576
15636
  /**
15577
15637
  * Claimable promotional benefits per account (issue #79).
15578
15638
  *
@@ -15684,11 +15744,10 @@ function apply(ctx, config) {
15684
15744
  * it, regardless of whether it redeemed or was already active. No upstream
15685
15745
  * read, so it is safe on the card's poll.
15686
15746
  */
15687
- growthDoneAccountIds: (region, cap) => {
15688
- const state = growthState[growthKey(cap, region)];
15689
- if (state === void 0 || state.day !== localDayKey(Date.now())) return {};
15690
- const map = {};
15691
- for (const id of state.doneAccountIds) map[id] = true;
15747
+ growthDoneAccountIds: async (region, cap) => {
15748
+ const map = { ...await doneTodayMap(cap, region) };
15749
+ const state = growthState[growthKey(cap, region)] ?? await readGrowthState(cap, region);
15750
+ if (state !== void 0 && state.day === localDayKey(Date.now())) for (const id of state.doneAccountIds) map[id] = true;
15692
15751
  return map;
15693
15752
  },
15694
15753
  /**
@@ -15710,6 +15769,7 @@ function apply(ctx, config) {
15710
15769
  const folded = foldGrowthAttempt(state, rows.map((row) => row.accountId), all.length, nowMs);
15711
15770
  growthState[key] = folded;
15712
15771
  await writeGrowthState(cap, region, folded);
15772
+ await markDoneToday(cap, region, rows.map((row) => row.accountId));
15713
15773
  return rows.map((row) => ({
15714
15774
  accountId: row.accountId,
15715
15775
  accountName: row.accountName,
@@ -15720,11 +15780,7 @@ function apply(ctx, config) {
15720
15780
  },
15721
15781
  checkin: async (region) => {
15722
15782
  const rows = await checkinAllAccounts(await poolTargets(region), poolRunnerDeps(region));
15723
- for (const row of rows) {
15724
- if (row.status === "failed") continue;
15725
- const cached = checkinStateCache[region];
15726
- if (cached !== void 0) delete cached[row.accountId];
15727
- }
15783
+ await markDoneToday("checkin", region, rows.filter((row) => row.status === "claimed" || row.status === "already").map((row) => row.accountId));
15728
15784
  if (rows.some((row) => row.status !== "failed")) {
15729
15785
  await poolMembersOf(region);
15730
15786
  await applyPoolSelection(region);
@@ -16416,11 +16472,7 @@ function apply(ctx, config) {
16416
16472
  return;
16417
16473
  }
16418
16474
  const rows = await checkinAllAccounts(targets, poolRunnerDeps(region));
16419
- for (const row of rows) {
16420
- if (row.status === "failed") continue;
16421
- const cached = checkinStateCache[region];
16422
- if (cached !== void 0) delete cached[row.accountId];
16423
- }
16475
+ await markDoneToday("checkin", region, rows.filter((row) => row.status === "claimed" || row.status === "already").map((row) => row.accountId));
16424
16476
  if (rows.some((row) => row.status !== "failed")) {
16425
16477
  await poolMembersOf(region);
16426
16478
  await applyPoolSelection(region);
@@ -16560,9 +16612,11 @@ function apply(ctx, config) {
16560
16612
  scheduleGrowth(cap, region, GROWTH_IDLE_MS);
16561
16613
  return;
16562
16614
  }
16563
- const folded = foldGrowthAttempt(state, (await runGrowthBatch(cap, region, targets)).map((row) => row.accountId), all.length, nowMs);
16615
+ const rows = await runGrowthBatch(cap, region, targets);
16616
+ const folded = foldGrowthAttempt(state, rows.map((row) => row.accountId), all.length, nowMs);
16564
16617
  growthState[key] = folded;
16565
16618
  await writeGrowthState(cap, region, folded);
16619
+ await markDoneToday(cap, region, rows.map((row) => row.accountId));
16566
16620
  scheduleGrowth(cap, region, GROWTH_IDLE_MS);
16567
16621
  } catch (error) {
16568
16622
  ctx.logger.warn(`dsh-connect-workbuddy: growth tick failed (${cap}/${region})`, error);
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.29.1",
5
+ "version": "5.30.0",
6
6
  "author": "dingminhua",
7
7
  "copyright": "Copyright (c) 2026 LaoDing",
8
8
  "license": "MIT",