dsh-grok-subscription 1.0.3 → 1.0.4

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.en.md CHANGED
@@ -25,7 +25,7 @@ Models, reasoning effort, and weekly quota all stay inside DSH.
25
25
 
26
26
  ## Three-step start
27
27
 
28
- 1. **Install the plugin.** Run the command below; to select a candidate version, enter the full `package@version`, for example `dsh-grok-subscription@1.0.3`.
28
+ 1. **Install the plugin.** Run the command below; to select a candidate version, enter the full `package@version`, for example `dsh-grok-subscription@1.0.4`.
29
29
 
30
30
  ```sh
31
31
  dsh plugin --profile web add BaronCyrus/dsh-grok-subscription
@@ -89,7 +89,7 @@ dsh plugin --profile web add BaronCyrus/dsh-grok-subscription
89
89
  You can also install the version published on npm:
90
90
 
91
91
  ```sh
92
- dsh plugin --profile web add dsh-grok-subscription@1.0.3
92
+ dsh plugin --profile web add dsh-grok-subscription@1.0.4
93
93
  ```
94
94
 
95
95
  DSH handles target selection, the profile lock, dependency resolution, and bundle activation.
package/README.md CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  ## 三步开始
27
27
 
28
- 1. **安装插件**:在终端运行下面的命令;指定候选版本时填写完整的 `包名@版本`,例如 `dsh-grok-subscription@1.0.3`。
28
+ 1. **安装插件**:在终端运行下面的命令;指定候选版本时填写完整的 `包名@版本`,例如 `dsh-grok-subscription@1.0.4`。
29
29
 
30
30
  ```sh
31
31
  dsh plugin --profile web add BaronCyrus/dsh-grok-subscription
@@ -89,7 +89,7 @@ dsh plugin --profile web add BaronCyrus/dsh-grok-subscription
89
89
  也可以按 npm 上的已发布版本安装:
90
90
 
91
91
  ```sh
92
- dsh plugin --profile web add dsh-grok-subscription@1.0.3
92
+ dsh plugin --profile web add dsh-grok-subscription@1.0.4
93
93
  ```
94
94
 
95
95
  目标选择、profile 锁、依赖解析和 bundle 激活均由 DSH 负责。
package/lib/client.js CHANGED
@@ -20,8 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/client.jsx
21
21
  var client_exports = {};
22
22
  __export(client_exports, {
23
+ GrokSubscriptionPanel: () => GrokSubscriptionPanel,
23
24
  GrokSubscriptionSection: () => GrokSubscriptionSection,
24
25
  RPC_CALL_TIMEOUT_MS: () => RPC_CALL_TIMEOUT_MS,
26
+ SectionBoundary: () => SectionBoundary,
27
+ UsagePanel: () => UsagePanel,
25
28
  apply: () => apply,
26
29
  callRpc: () => callRpc,
27
30
  inject: () => inject,
@@ -34,7 +37,7 @@ var import_react2 = require("react");
34
37
  var zh = {
35
38
  nav: "Grok \u8BA2\u9605",
36
39
  title: "Grok \u8BA2\u9605",
37
- subtitle: "\u7528 SuperGrok / X Premium\uFF08Grok Build\uFF09\u4F1A\u8BDD\uFF0C\u800C\u4E0D\u662F XAI_API_KEY\u3002\xB7 1.0.3",
40
+ subtitle: "\u7528 SuperGrok / X Premium\uFF08Grok Build\uFF09\u4F1A\u8BDD\uFF0C\u800C\u4E0D\u662F XAI_API_KEY\u3002\xB7 1.0.4",
38
41
  signedIn: "\u5DF2\u767B\u5F55",
39
42
  signedOut: "\u672A\u767B\u5F55",
40
43
  account: "\u8D26\u6237",
@@ -54,6 +57,7 @@ var zh = {
54
57
  pullHint: "\u5B89\u5168\u8BFB\u53D6 ~/.grok/auth.json\uFF08\u62D2\u7EDD\u7B26\u53F7\u94FE\u63A5\u4E0E\u7EC4/\u5176\u4ED6\u4EBA\u53EF\u8BFB\uFF09\uFF0C\u53EA\u628A\u77ED\u671F access token \u5199\u5165 DSH\u3002",
55
58
  loginHelp: "\u767B\u5F55\u65B9\u5F0F\u8BF4\u660E",
56
59
  refreshCatalog: "\u5237\u65B0\u6A21\u578B\u76EE\u5F55",
60
+ renderError: "\u754C\u9762\u6E32\u67D3\u5931\u8D25",
57
61
  busy: "\u5904\u7406\u4E2D\u2026",
58
62
  busyCatalog: "\u6B63\u5728\u5237\u65B0\u6A21\u578B\u76EE\u5F55\u2026",
59
63
  busyUsage: "\u6B63\u5728\u5237\u65B0\u7528\u91CF\u2026",
@@ -83,7 +87,7 @@ var zh = {
83
87
  var en = {
84
88
  nav: "Grok Subscription",
85
89
  title: "Grok Subscription",
86
- subtitle: "Use a SuperGrok / X Premium (Grok Build) session, not XAI_API_KEY. \xB7 1.0.3",
90
+ subtitle: "Use a SuperGrok / X Premium (Grok Build) session, not XAI_API_KEY. \xB7 1.0.4",
87
91
  signedIn: "Signed in",
88
92
  signedOut: "Signed out",
89
93
  account: "Account",
@@ -103,6 +107,7 @@ var en = {
103
107
  pullHint: "Reads ~/.grok/auth.json securely (refuses symlinks and group/other-readable files) and stores only the short-lived access token in DSH.",
104
108
  loginHelp: "How signing in works",
105
109
  refreshCatalog: "Refresh model catalog",
110
+ renderError: "Failed to render this panel",
106
111
  busy: "Working\u2026",
107
112
  busyCatalog: "Refreshing model catalog\u2026",
108
113
  busyUsage: "Refreshing usage\u2026",
@@ -614,6 +619,32 @@ async function callRpc(rpc, endpoint, payload = {}) {
614
619
  if (timer) clearTimeout(timer);
615
620
  }
616
621
  }
622
+ var SectionBoundary = class extends import_react2.Component {
623
+ constructor(props) {
624
+ super(props);
625
+ this.state = { error: void 0 };
626
+ }
627
+ static getDerivedStateFromError(error) {
628
+ return { error };
629
+ }
630
+ render() {
631
+ const { error } = this.state;
632
+ if (!error) return this.props.children;
633
+ const t = this.props.t;
634
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "grokSubscription", children: [
635
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { children: SETTINGS_STYLE }),
636
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gsHead", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: t("title") }) }),
637
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gsCard", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "gsStatus gsStatus--error", children: [
638
+ t("renderError"),
639
+ ": ",
640
+ error instanceof Error ? error.message : String(error)
641
+ ] }) })
642
+ ] });
643
+ }
644
+ };
645
+ function GrokSubscriptionPanel(props) {
646
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SectionBoundary, { t: props.t, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GrokSubscriptionSection, { ...props }) });
647
+ }
617
648
  function Chevron() {
618
649
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { className: "gsChevron", width: "12", height: "12", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4 6l4 4 4-4", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) });
619
650
  }
@@ -625,12 +656,16 @@ function Chip({ tone = "off", children }) {
625
656
  }
626
657
  function UsagePanel({ usage, t, usageBusy, onRefresh, signedIn }) {
627
658
  const ok = usage?.status === "ok";
628
- const used = ok ? formatPercent(usage.usedPercent) : void 0;
629
- const remaining = ok ? formatPercent(usage.remainingPercent) : void 0;
659
+ const usedNumber = ok && Number.isFinite(usage.usedPercent) ? usage.usedPercent : void 0;
660
+ const remainingNumber = ok && Number.isFinite(usage.remainingPercent) ? usage.remainingPercent : void 0;
661
+ const used = usedNumber !== void 0 ? formatPercent(usedNumber) : void 0;
662
+ const remaining = remainingNumber !== void 0 ? formatPercent(remainingNumber) : void 0;
630
663
  const resetLabel = usage?.periodEndLocal || usage?.periodEnd;
631
- const gaugeValue = remaining ?? (used !== void 0 ? formatPercent(100 - Number(used)) : void 0);
632
- const gaugeLabel = remaining !== void 0 ? t("usageRemaining") : t("usageUsed");
633
- const fill = typeof gaugeValue === "number" && Number.isFinite(gaugeValue) ? Math.min(100, Math.max(0, gaugeValue)) : 0;
664
+ const gaugeNumber = remainingNumber ?? (usedNumber !== void 0 ? 100 - usedNumber : void 0);
665
+ const gaugeValue = gaugeNumber !== void 0 ? formatPercent(gaugeNumber) : void 0;
666
+ const gaugeLabel = remainingNumber !== void 0 ? t("usageRemaining") : t("usageUsed");
667
+ const fill = gaugeNumber === void 0 ? 0 : Math.min(100, Math.max(0, gaugeNumber));
668
+ const products = Array.isArray(usage?.productUsage) ? usage.productUsage : [];
634
669
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gsCard", children: [
635
670
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gsCardHead", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: t("usageTitle") }) }),
636
671
  ok && (used !== void 0 || remaining !== void 0) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gsGauge", children: [
@@ -660,11 +695,11 @@ function UsagePanel({ usage, t, usageBusy, onRefresh, signedIn }) {
660
695
  t("usageUnavailable"),
661
696
  usage?.reason ? `: ${usage.reason}` : ""
662
697
  ] }),
663
- Array.isArray(usage.productUsage) && usage.productUsage.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gsRows", children: usage.productUsage.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gsRow", children: [
698
+ products.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gsRows", children: products.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gsRow", children: [
664
699
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: row.name ?? "\u2014" }),
665
700
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gsRowValue", children: typeof row.usedPercent === "number" ? `${formatPercent(row.usedPercent)}%` : "\u2014" })
666
701
  ] }, `${row.name ?? "row"}-${index}`)) }) : null,
667
- usage.fetchedAt ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "gsHint", children: [
702
+ usage?.fetchedAt ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "gsHint", children: [
668
703
  t("usageFetchedAt"),
669
704
  ": ",
670
705
  usage.fetchedAt
@@ -879,7 +914,7 @@ function apply(ctx) {
879
914
  label: () => t("nav"),
880
915
  locale: LOCALE_NS,
881
916
  inject: () => ({ rpc, t })
882
- }, GrokSubscriptionSection));
917
+ }, GrokSubscriptionPanel));
883
918
  const installDirectorySlots = (scope) => {
884
919
  let modelDirectories;
885
920
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-grok-subscription",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Use a SuperGrok or X Premium Grok Build subscription in DeepSeek Harness",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -39,6 +39,7 @@
39
39
  },
40
40
  "scripts": {
41
41
  "build": "node scripts/build.mjs",
42
+ "pretest": "npm run build",
42
43
  "test": "node --test tests/*.test.mjs",
43
44
  "check": "npm test && npm run build"
44
45
  },
@@ -55,8 +56,12 @@
55
56
  "node": "^22.19.0 || >=24.0.0"
56
57
  },
57
58
  "peerDependencies": {
59
+ "@deepseek-ai/dsh-api-remotes": "^0.1.5-rc.2",
58
60
  "@deepseek-ai/dsh-client-connection": "^0.1.5-rc.2",
59
61
  "@deepseek-ai/dsh-client-locale": "^0.1.5-rc.2",
62
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.5-rc.2",
63
+ "@deepseek-ai/dsh-client-ui-model-selection": "^0.1.5-rc.2",
64
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.5-rc.2",
60
65
  "@deepseek-ai/dsh-client-ui-settings": "^0.1.5-rc.2",
61
66
  "@deepseek-ai/dsh-client-ui-slots": "^0.1.5-rc.2",
62
67
  "@deepseek-ai/dsh-credentials": "^0.1.5-rc.2",
@@ -66,11 +71,7 @@
66
71
  "@deepseek-ai/dsh-web": "^0.1.5-rc.2",
67
72
  "@earendil-works/pi-ai": "^0.82.1",
68
73
  "react": "^18.2.0",
69
- "react-dom": "^18.2.0",
70
- "@deepseek-ai/dsh-api-remotes": "^0.1.5-rc.2",
71
- "@deepseek-ai/dsh-client-ui-conversation": "^0.1.5-rc.2",
72
- "@deepseek-ai/dsh-client-ui-model-selection": "^0.1.5-rc.2",
73
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.5-rc.2"
74
+ "react-dom": "^18.2.0"
74
75
  },
75
76
  "peerDependenciesMeta": {
76
77
  "@deepseek-ai/dsh-client-connection": {
@@ -123,7 +124,9 @@
123
124
  }
124
125
  },
125
126
  "devDependencies": {
126
- "esbuild": "^0.25.0"
127
+ "esbuild": "^0.25.0",
128
+ "react": "^18.3.1",
129
+ "react-dom": "^18.3.1"
127
130
  },
128
131
  "author": "BaronCyrus",
129
132
  "repository": {