dsh-subusage 0.13.0 → 0.13.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/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  </div>
20
20
 
21
- > **0.13.0**:余额显示更清晰,设置按需刷新,兼容 Codex Subscription 独立 OAuth。发布与本机升级分开;本页图片是虚构数据离线预览,不是实机验收证明。[查看更新记录](docs/changelog.md)。
21
+ > **0.13.1**:修复已开启 Codex 在状态重建时被过滤,以及传输失败后药丸隐藏、无法继续重试的问题;仍按需刷新,不恢复全量联网初始化。发布与本机升级分开;本页图片是虚构数据离线预览,不是实机验收证明。[查看更新记录](docs/changelog.md)。
22
22
 
23
23
  ## 快速开始
24
24
 
package/lib/client.js CHANGED
@@ -821,8 +821,24 @@ window.__ModuleLoader__.load({
821
821
  snapshot = { ...snapshot, ...value, entries: [...entries.values()] };
822
822
  emit(); return snapshot;
823
823
  };
824
+ const readSettings = () => {
825
+ if (snapshot.settings) return Promise.resolve(snapshot);
826
+ if (!settingsInitial) {
827
+ const request = markRequest([]);
828
+ settingsInitial = Promise.resolve().then(() => call("read", { providerIds: [], force: false, commandCodeAccount: ccAccount })).then(value => merge(value, request)).catch(error => { settingsInitial = null; throw error; });
829
+ }
830
+ return settingsInitial.then(() => snapshot);
831
+ };
824
832
  const refresh = (ids, force = false) => {
825
833
  if (disposed) return Promise.reject(new Error("Client 已卸载"));
834
+ // Codex 等默认关闭的入口必须先读取用户保存的开关,否则冷启动会过滤自己,
835
+ // 又没有任何 RPC 载入 settings,直到切去默认开启的其他厂商才恢复。
836
+ if (!snapshot.settings && ids.some(id => PROVIDER_META[id]?.defaultEnabled === false)) {
837
+ return readSettings().then(() => {
838
+ if (!snapshot.settings) throw new Error("Client 设置尚未读取");
839
+ return refresh(ids, force);
840
+ });
841
+ }
826
842
  // Ark 必须豁免路由检查:它的额度是账号级管控面订阅(一组 AK/SK 查名下全部套餐),
827
843
  // providerVisible 对 volc 同样不看推理路由——这里若按 providerRoutable 过滤,
828
844
  // 「有套餐但本机没装对应 arkcli 路由」的条目在激活刷新、重置到期补拉与定时刷新时
@@ -835,8 +851,12 @@ window.__ModuleLoader__.load({
835
851
  if (inflight.has(id)) return inflight.get(id);
836
852
  const startedEpoch = epoch, request = markRequest([id]);
837
853
  const task = Promise.resolve().then(() => call("refresh", { providerIds: [id], force: !!force, commandCodeAccount: ccAccount })).then((value) => startedEpoch === epoch ? merge(value, request) : snapshot).catch((error) => {
838
- // 传输失败不能擅自 retainPrevious:只有 Host 明确标 stale 才保留。
839
- if (startedEpoch === epoch) merge({ entries: [{ providerId: id, state: "error", error: error instanceof Error ? error.message : String(error), freshness: "unknown", coverage: "partial", windows: [], extras: [] }] }, request);
854
+ // 传输失败不能沿用旧额度;但也不能当作「凭据消失」的证据。
855
+ // 否则 Codex 的无路由查询豁免随 apiDetected 丢失:药丸隐藏且后续刷新被过滤。
856
+ if (startedEpoch === epoch) {
857
+ const previous = snapshot.entries.find(entry => entry.providerId === id);
858
+ merge({ entries: [{ providerId: id, ...(previous?.apiDetected !== undefined ? { apiDetected: previous.apiDetected } : {}), ...(previous?.keySource ? { keySource: previous.keySource } : {}), state: "error", error: error instanceof Error ? error.message : String(error), freshness: "unknown", coverage: "partial", windows: [], extras: [] }] }, request);
859
+ }
840
860
  throw error;
841
861
  }).finally(() => { if (inflight.get(id) === task) inflight.delete(id); });
842
862
  inflight.set(id, task);
@@ -895,14 +915,7 @@ window.__ModuleLoader__.load({
895
915
  return {
896
916
  subscribe, getSnapshot: () => snapshot, refresh, activate,
897
917
  // 设置页先取本机元数据,不等待所有厂商的网络额度请求。
898
- readSettings: () => {
899
- if (snapshot.settings) return Promise.resolve(snapshot);
900
- if (!settingsInitial) {
901
- const request = markRequest([]);
902
- settingsInitial = Promise.resolve().then(() => call("read", { providerIds: [], force: false, commandCodeAccount: ccAccount })).then(value => merge(value, request)).catch(error => { settingsInitial = null; throw error; });
903
- }
904
- return settingsInitial.then(() => snapshot);
905
- },
918
+ readSettings,
906
919
  getCommandCodeAccount: () => ccAccount, setCommandCodeAccount,
907
920
  startMimoLogin: async (request) => { const generation = ++loginGeneration, startedEpoch = epoch; loginJobId = null; return acceptLogin(await call("startMimoLogin", request), generation, startedEpoch); },
908
921
  getMimoLoginStatus: async () => { const generation = loginGeneration, startedEpoch = epoch, jobId = loginPending ? loginJobId : null; return acceptLogin(await call("getMimoLoginStatus"), generation, startedEpoch, jobId); },
package/lib/index.js CHANGED
@@ -11,7 +11,7 @@ import { MimoLogin } from "./mimo-login.js";
11
11
  import { parseVolcAgentPlan, parseVolcCodingPlan, parseVolcSeatAfp, parseVolcSeatCoding, parseVolcSeatIds, volcError, volcSignature } from "./volcengine.js";
12
12
 
13
13
  const name = "dsh-subusage";
14
- const VERSION = "0.13.0";
14
+ const VERSION = "0.13.1";
15
15
  const inject = ["llm"];
16
16
  const PROVIDERS = {
17
17
  "zai-coding-cn": { label: "Z.ai", envName: "ZAI_CODING_CN_API_KEY" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-subusage",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "displayName": "订阅用量显示",
5
5
  "description": "显示独立 DeepSeek API Key 与 DSH 本机账号余额(账号入口默认开启)、火山方舟(arkcli 官方 CLI 路由:Agent / Coding Plan 个人版与企业版席位,设置页合并为一组)、Z.ai(中国与国际)、Kimi、MiMo、OpenCode Go、Command Code、SuperGrok、Codex(ChatGPT 订阅,默认关闭)、MiniMax(中国)、Synthetic、NanoGPT、SiliconFlow、OpenRouter、Novita、Hyperbolic、DeepInfra、Chutes、Ollama Cloud、Vercel AI Gateway、ZenMux、LiteLLM 的订阅余量与余额;共享刷新与凭据管理,默认关闭 17 家。",
6
6
  "keywords": [