dsh-codearts 1.2.14 → 1.3.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/lib/bin.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { G as codeartsAccountsPath, H as CodeArtsAccountStore, f as fetchCallerIdentity, i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION, z as isBenefitModel } from "./version-Msk-1m2n.mjs";
2
+ import { i as codeartsAccountsPath, t as CodeArtsAccountStore } from "./auth-CF9XHMX-.mjs";
3
+ import { F as isBenefitModel, s as fetchCallerIdentity } from "./upstream-CVtspzAv.mjs";
4
+ import { i as discoverModels, n as CodeArtsUsageTracker, r as codeartsUsagePath, t as CODEARTS_VERSION } from "./version-CJTTrulR.mjs";
3
5
  import { existsSync, statSync } from "node:fs";
4
6
  //#region src/bin.ts
5
7
  /**
@@ -189,6 +189,21 @@ interface CodeArtsSettingsKey {
189
189
  displayHint: string;
190
190
  displayCreditsToggle: string;
191
191
  displayQueueToggle: string;
192
+ displayModelDetailToggle: string;
193
+ displayAutoClaimTitle: string;
194
+ displayAutoClaimHint: string;
195
+ displayAutoClaimToggle: string;
196
+ displayKeeperTitle: string;
197
+ displayKeeperHint: string;
198
+ displayKeeperToggle: string;
199
+ displayKeeperRunning: string;
200
+ displayKeeperStarting: string;
201
+ displayKeeperDown: string;
202
+ displayKeeperStop: string;
203
+ displayKeeperStopping: string;
204
+ displayKeeperStopped: string;
205
+ displayKeeperStopFailed: string;
206
+ displayKeeperLog: string;
192
207
  displayNotWritable: string;
193
208
  displayFailed: string;
194
209
  displaySidebarTitle: string;
@@ -4,6 +4,7 @@ window.__ModuleLoader__.load({
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ //#endregion
7
8
  let react = require("react");
8
9
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
9
10
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -87,98 +88,98 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
87
88
  document.head.appendChild(tag);
88
89
  }
89
90
  var CodeArtsPluginCard_module_css_default = {
90
- "field": "xoziZG_field",
91
- "sectionHead": "xoziZG_sectionHead",
92
- "trendTip": "xoziZG_trendTip",
93
- "usageFill": "xoziZG_usageFill",
94
- "area": "xoziZG_area",
91
+ "header": "xoziZG_header",
92
+ "accountToggle": "xoziZG_accountToggle",
93
+ "modelChart": "xoziZG_modelChart",
94
+ "modelShare": "xoziZG_modelShare",
95
+ "choiceRow": "xoziZG_choiceRow",
96
+ "heatHourCell": "xoziZG_heatHourCell",
97
+ "accountInfo": "xoziZG_accountInfo",
98
+ "heatHours": "xoziZG_heatHours",
99
+ "headText": "xoziZG_headText",
100
+ "usageBar": "xoziZG_usageBar",
101
+ "bar": "xoziZG_bar",
102
+ "count": "xoziZG_count",
103
+ "avatar": "xoziZG_avatar",
104
+ "statSub": "xoziZG_statSub",
105
+ "heatLegendChip": "xoziZG_heatLegendChip",
106
+ "statusLine": "xoziZG_statusLine",
107
+ "accountRowActions": "xoziZG_accountRowActions",
108
+ "expiryLabel": "xoziZG_expiryLabel",
109
+ "desc": "xoziZG_desc",
95
110
  "body": "xoziZG_body",
96
- "modelName": "xoziZG_modelName",
97
- "doctorName": "xoziZG_doctorName",
111
+ "updated": "xoziZG_updated",
112
+ "usageTipRow": "xoziZG_usageTipRow",
113
+ "heatWeekday": "xoziZG_heatWeekday",
114
+ "doctorRow": "xoziZG_doctorRow",
115
+ "manualForm": "xoziZG_manualForm",
116
+ "heatLegend": "xoziZG_heatLegend",
98
117
  "creditLink": "xoziZG_creditLink",
99
- "manual": "xoziZG_manual",
100
- "statGrid": "xoziZG_statGrid",
118
+ "heatAxisSlot": "xoziZG_heatAxisSlot",
119
+ "skeletonRow": "xoziZG_skeletonRow",
120
+ "link": "xoziZG_link",
121
+ "creditRows": "xoziZG_creditRows",
101
122
  "accountName": "xoziZG_accountName",
102
- "manualSummary": "xoziZG_manualSummary",
123
+ "section": "xoziZG_section",
124
+ "tabPanel": "xoziZG_tabPanel",
125
+ "accountToggleLabel": "xoziZG_accountToggleLabel",
126
+ "creditRow": "xoziZG_creditRow",
127
+ "creditFooter": "xoziZG_creditFooter",
128
+ "creditHint": "xoziZG_creditHint",
129
+ "usageTip": "xoziZG_usageTip",
130
+ "modelFill": "xoziZG_modelFill",
131
+ "doctorName": "xoziZG_doctorName",
132
+ "accountCard": "xoziZG_accountCard",
133
+ "accountRow": "xoziZG_accountRow",
134
+ "tabs": "xoziZG_tabs",
135
+ "modelSpec": "xoziZG_modelSpec",
136
+ "sectionHead": "xoziZG_sectionHead",
137
+ "statValue": "xoziZG_statValue",
138
+ "statLabel": "xoziZG_statLabel",
139
+ "trendTip": "xoziZG_trendTip",
103
140
  "doctorList": "xoziZG_doctorList",
104
- "expiryLabel": "xoziZG_expiryLabel",
141
+ "usageFill": "xoziZG_usageFill",
142
+ "heatCell": "xoziZG_heatCell",
105
143
  "balanceUnit": "xoziZG_balanceUnit",
106
- "heatHours": "xoziZG_heatHours",
144
+ "meta": "xoziZG_meta",
145
+ "name": "xoziZG_name",
146
+ "claimAllRow": "xoziZG_claimAllRow",
147
+ "choices": "xoziZG_choices",
148
+ "modelRow": "xoziZG_modelRow",
107
149
  "statCard": "xoziZG_statCard",
108
- "section": "xoziZG_section",
109
- "statusLine": "xoziZG_statusLine",
110
- "hint": "xoziZG_hint",
111
- "tabPanel": "xoziZG_tabPanel",
112
- "updated": "xoziZG_updated",
113
150
  "balanceRow": "xoziZG_balanceRow",
114
- "name": "xoziZG_name",
115
- "count": "xoziZG_count",
151
+ "heatAxis": "xoziZG_heatAxis",
116
152
  "usageTipName": "xoziZG_usageTipName",
117
- "check": "xoziZG_check",
118
- "skeleton": "xoziZG_skeleton",
119
- "header": "xoziZG_header",
120
- "modelRow": "xoziZG_modelRow",
153
+ "card": "xoziZG_card",
154
+ "accountEntry": "xoziZG_accountEntry",
155
+ "balanceMeta": "xoziZG_balanceMeta",
156
+ "error": "xoziZG_error",
157
+ "usageTipSep": "xoziZG_usageTipSep",
158
+ "hint": "xoziZG_hint",
159
+ "modelName": "xoziZG_modelName",
160
+ "creditBlock": "xoziZG_creditBlock",
161
+ "modelTrack": "xoziZG_modelTrack",
162
+ "modelTokens": "xoziZG_modelTokens",
121
163
  "modelRequests": "xoziZG_modelRequests",
122
- "skeletonRow": "xoziZG_skeletonRow",
123
- "choices": "xoziZG_choices",
124
- "headText": "xoziZG_headText",
125
- "heatCell": "xoziZG_heatCell",
164
+ "manualSummary": "xoziZG_manualSummary",
165
+ "field": "xoziZG_field",
126
166
  "skeletonBreath": "xoziZG_skeletonBreath",
127
- "modelFill": "xoziZG_modelFill",
128
- "modelTrack": "xoziZG_modelTrack",
129
- "accountHint": "xoziZG_accountHint",
130
- "choiceRow": "xoziZG_choiceRow",
131
- "bar": "xoziZG_bar",
132
- "heatWeekday": "xoziZG_heatWeekday",
133
- "claimAllRow": "xoziZG_claimAllRow",
134
- "usageBar": "xoziZG_usageBar",
135
- "modelChart": "xoziZG_modelChart",
136
- "usageTip": "xoziZG_usageTip",
137
- "accountCard": "xoziZG_accountCard",
138
- "balance": "xoziZG_balance",
139
- "creditRow": "xoziZG_creditRow",
140
- "modelShare": "xoziZG_modelShare",
141
- "usageTipSep": "xoziZG_usageTipSep",
142
- "heatLegendChip": "xoziZG_heatLegendChip",
143
- "accountToggle": "xoziZG_accountToggle",
144
- "fieldLabel": "xoziZG_fieldLabel",
145
- "heatAxis": "xoziZG_heatAxis",
146
- "statValue": "xoziZG_statValue",
147
- "modelSpec": "xoziZG_modelSpec",
167
+ "area": "xoziZG_area",
148
168
  "heatGrid": "xoziZG_heatGrid",
149
- "usageTipRow": "xoziZG_usageTipRow",
150
- "statSub": "xoziZG_statSub",
151
- "heatHourCell": "xoziZG_heatHourCell",
152
- "avatar": "xoziZG_avatar",
153
- "expiryRow": "xoziZG_expiryRow",
154
- "creditRows": "xoziZG_creditRows",
155
- "error": "xoziZG_error",
156
- "accountToolbar": "xoziZG_accountToolbar",
157
169
  "sectionLabel": "xoziZG_sectionLabel",
158
- "doctorRow": "xoziZG_doctorRow",
159
- "desc": "xoziZG_desc",
160
- "manualForm": "xoziZG_manualForm",
170
+ "accountToolbar": "xoziZG_accountToolbar",
161
171
  "barFill": "xoziZG_barFill",
162
- "tabs": "xoziZG_tabs",
163
- "accountEntry": "xoziZG_accountEntry",
164
- "accountInfo": "xoziZG_accountInfo",
165
- "creditFooter": "xoziZG_creditFooter",
166
- "link": "xoziZG_link",
167
- "meta": "xoziZG_meta",
168
- "card": "xoziZG_card",
169
- "accountNameRow": "xoziZG_accountNameRow",
170
- "accountRowActions": "xoziZG_accountRowActions",
171
- "accountRow": "xoziZG_accountRow",
172
- "accountToggleLabel": "xoziZG_accountToggleLabel",
173
- "balanceMeta": "xoziZG_balanceMeta",
174
- "danger": "xoziZG_danger",
175
- "creditHint": "xoziZG_creditHint",
176
- "statLabel": "xoziZG_statLabel",
177
- "heatAxisSlot": "xoziZG_heatAxisSlot",
172
+ "fieldLabel": "xoziZG_fieldLabel",
173
+ "accountHint": "xoziZG_accountHint",
178
174
  "actions": "xoziZG_actions",
179
- "modelTokens": "xoziZG_modelTokens",
180
- "heatLegend": "xoziZG_heatLegend",
181
- "creditBlock": "xoziZG_creditBlock"
175
+ "danger": "xoziZG_danger",
176
+ "check": "xoziZG_check",
177
+ "manual": "xoziZG_manual",
178
+ "balance": "xoziZG_balance",
179
+ "skeleton": "xoziZG_skeleton",
180
+ "accountNameRow": "xoziZG_accountNameRow",
181
+ "statGrid": "xoziZG_statGrid",
182
+ "expiryRow": "xoziZG_expiryRow"
182
183
  };
183
184
  //#endregion
184
185
  //#region src/client/CodeArtsPluginCard.tsx
@@ -230,12 +231,16 @@ function claimMessagesOf(data, accountIds, t) {
230
231
  }
231
232
  /**
232
233
  * 开关的兜底值:后端没这条路由(老版本)时按「都显示」渲染,与原有行为一致。
233
- * 侧边栏那一格相反 —— 缺省关闭。
234
+ * 侧边栏那一格相反 —— 缺省关闭;自动领取与常驻保活也缺省关(不替用户动余额、
235
+ * 不替用户在系统里留后台进程)。
234
236
  */
235
237
  const DOCK_DEFAULT = {
236
238
  credits: true,
237
239
  queue: true,
238
- sidebar: false
240
+ sidebar: false,
241
+ modelDetail: true,
242
+ autoClaim: false,
243
+ keepAliveDaemon: false
239
244
  };
240
245
  /**
241
246
  * 上一次读到的状态。`/api/codearts/status` 会顺带去上游拉积分(有 TTL 缓存),
@@ -1030,6 +1035,10 @@ function CodeArtsPluginCard({ t }) {
1030
1035
  const [dockWritable, setDockWritable] = (0, react.useState)(false);
1031
1036
  const [dockSaving, setDockSaving] = (0, react.useState)(false);
1032
1037
  const [dockError, setDockError] = (0, react.useState)(null);
1038
+ /** 「结束守护进程」按钮在飞,防止连点。 */
1039
+ const [keeperStopping, setKeeperStopping] = (0, react.useState)(false);
1040
+ /** 结束按钮的结果/失败原因(成功也留一句,让用户知道进程真没了)。 */
1041
+ const [keeperNotice, setKeeperNotice] = (0, react.useState)(null);
1033
1042
  /**
1034
1043
  * 首次读取状态的三态。为什么要单独记:`status === null` 只说明「还没读到」,
1035
1044
  * 直接按它画就会先闪一下「未登录」,等数据回来再翻成「已登录」—— 看起来像
@@ -1099,6 +1108,40 @@ function CodeArtsPluginCard({ t }) {
1099
1108
  }
1100
1109
  }
1101
1110
  /**
1111
+ * 结束守护进程。
1112
+ *
1113
+ * 服务端在kill之后**顺手把开关写成 false**(见 web-status.ts 的 keeperStopHandler):
1114
+ * 只杀进程不改开关会留下「开关开着却没进程」的矛盾状态,插件下次启动还会把它拉起来。
1115
+ * 这里拿响应里的 `dock` 直接覆盖本地状态,不等下一轮 refreshDock —— 否则按钮点完
1116
+ * 界面上开关还亮着,用户会以为没生效。
1117
+ */
1118
+ async function stopKeeper() {
1119
+ setKeeperStopping(true);
1120
+ setKeeperNotice(null);
1121
+ try {
1122
+ const res = await fetch("/api/codearts/keeper/stop", {
1123
+ method: "POST",
1124
+ headers: {
1125
+ "Content-Type": "application/json",
1126
+ Accept: "application/json"
1127
+ },
1128
+ body: "{}"
1129
+ });
1130
+ const data = await res.json().catch(() => ({}));
1131
+ if (data.dock !== void 0) setDock({
1132
+ ...DOCK_DEFAULT,
1133
+ ...data.dock
1134
+ });
1135
+ if (!res.ok || data.ok === false) setKeeperNotice(t("displayKeeperStopFailed", { message: data.reason ?? data.error ?? `HTTP ${res.status}` }));
1136
+ else setKeeperNotice(t("displayKeeperStopped"));
1137
+ } catch (error) {
1138
+ setKeeperNotice(t("displayKeeperStopFailed", { message: error instanceof Error ? error.message : String(error) }));
1139
+ } finally {
1140
+ setKeeperStopping(false);
1141
+ await Promise.all([refreshDock(), refresh()]);
1142
+ }
1143
+ }
1144
+ /**
1102
1145
  * 领每日签到积分。给 id 就只领那个号,不给就逐个号都领一遍。
1103
1146
  *
1104
1147
  * 除了这一次刚领成,「今天已领」都来自上游的福利活动状态(积分快照里的 welfare),
@@ -1935,33 +1978,125 @@ function CodeArtsPluginCard({ t }) {
1935
1978
  }),
1936
1979
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1937
1980
  className: CodeArtsPluginCard_module_css_default.choices,
1938
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1981
+ children: [
1982
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1983
+ className: CodeArtsPluginCard_module_css_default.choiceRow,
1984
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
1985
+ className: CodeArtsPluginCard_module_css_default.check,
1986
+ checked: dock.credits,
1987
+ disabled: !dockWritable || dockSaving,
1988
+ onChange: (on) => void toggleDock("credits", on),
1989
+ label: t("displayCreditsToggle")
1990
+ })
1991
+ }),
1992
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1993
+ className: CodeArtsPluginCard_module_css_default.choiceRow,
1994
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
1995
+ className: CodeArtsPluginCard_module_css_default.check,
1996
+ checked: dock.queue,
1997
+ disabled: !dockWritable || dockSaving,
1998
+ onChange: (on) => void toggleDock("queue", on),
1999
+ label: t("displayQueueToggle")
2000
+ })
2001
+ }),
2002
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2003
+ className: CodeArtsPluginCard_module_css_default.choiceRow,
2004
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
2005
+ className: CodeArtsPluginCard_module_css_default.check,
2006
+ checked: dock.modelDetail,
2007
+ disabled: !dockWritable || dockSaving,
2008
+ onChange: (on) => void toggleDock("modelDetail", on),
2009
+ label: t("displayModelDetailToggle")
2010
+ })
2011
+ })
2012
+ ]
2013
+ }),
2014
+ !dockWritable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2015
+ className: CodeArtsPluginCard_module_css_default.hint,
2016
+ children: t("displayNotWritable")
2017
+ }),
2018
+ dockError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2019
+ className: CodeArtsPluginCard_module_css_default.error,
2020
+ children: t("displayFailed", { message: dockError })
2021
+ })
2022
+ ]
2023
+ }),
2024
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2025
+ className: CodeArtsPluginCard_module_css_default.section,
2026
+ children: [
2027
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2028
+ className: CodeArtsPluginCard_module_css_default.sectionHead,
2029
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2030
+ className: CodeArtsPluginCard_module_css_default.sectionLabel,
2031
+ children: t("displayAutoClaimTitle")
2032
+ })
2033
+ }),
2034
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2035
+ className: CodeArtsPluginCard_module_css_default.hint,
2036
+ children: t("displayAutoClaimHint")
2037
+ }),
2038
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2039
+ className: CodeArtsPluginCard_module_css_default.choices,
2040
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1939
2041
  className: CodeArtsPluginCard_module_css_default.choiceRow,
1940
2042
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
1941
2043
  className: CodeArtsPluginCard_module_css_default.check,
1942
- checked: dock.credits,
2044
+ checked: dock.autoClaim,
1943
2045
  disabled: !dockWritable || dockSaving,
1944
- onChange: (on) => void toggleDock("credits", on),
1945
- label: t("displayCreditsToggle")
2046
+ onChange: (on) => void toggleDock("autoClaim", on),
2047
+ label: t("displayAutoClaimToggle")
1946
2048
  })
1947
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2049
+ })
2050
+ })
2051
+ ]
2052
+ }),
2053
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2054
+ className: CodeArtsPluginCard_module_css_default.section,
2055
+ children: [
2056
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2057
+ className: CodeArtsPluginCard_module_css_default.sectionHead,
2058
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2059
+ className: CodeArtsPluginCard_module_css_default.sectionLabel,
2060
+ children: t("displayKeeperTitle")
2061
+ }), dock.keepAliveDaemon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2062
+ variant: "outline",
2063
+ size: "sm",
2064
+ disabled: keeperStopping,
2065
+ onClick: () => void stopKeeper(),
2066
+ children: keeperStopping ? t("displayKeeperStopping") : t("displayKeeperStop")
2067
+ })]
2068
+ }),
2069
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2070
+ className: CodeArtsPluginCard_module_css_default.hint,
2071
+ children: t("displayKeeperHint")
2072
+ }),
2073
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2074
+ className: CodeArtsPluginCard_module_css_default.choices,
2075
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1948
2076
  className: CodeArtsPluginCard_module_css_default.choiceRow,
1949
2077
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
1950
2078
  className: CodeArtsPluginCard_module_css_default.check,
1951
- checked: dock.queue,
2079
+ checked: dock.keepAliveDaemon,
1952
2080
  disabled: !dockWritable || dockSaving,
1953
- onChange: (on) => void toggleDock("queue", on),
1954
- label: t("displayQueueToggle")
2081
+ onChange: (on) => void toggleDock("keepAliveDaemon", on),
2082
+ label: t("displayKeeperToggle")
1955
2083
  })
1956
- })]
2084
+ })
1957
2085
  }),
1958
- !dockWritable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2086
+ dock.keepAliveDaemon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1959
2087
  className: CodeArtsPluginCard_module_css_default.hint,
1960
- children: t("displayNotWritable")
2088
+ children: status?.keeper?.alive === true ? t("displayKeeperRunning", {
2089
+ pid: status.keeper.pid ?? "?",
2090
+ time: formatStored(status.keeper.heartbeatAt)
2091
+ }) : status?.keeper?.starting === true ? t("displayKeeperStarting") : t("displayKeeperDown", { message: status?.keeper?.error ?? "" })
1961
2092
  }),
1962
- dockError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1963
- className: CodeArtsPluginCard_module_css_default.error,
1964
- children: t("displayFailed", { message: dockError })
2093
+ keeperNotice !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2094
+ className: CodeArtsPluginCard_module_css_default.hint,
2095
+ children: keeperNotice
2096
+ }),
2097
+ status?.keeper?.logPath !== void 0 && dock.keepAliveDaemon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2098
+ className: CodeArtsPluginCard_module_css_default.hint,
2099
+ children: t("displayKeeperLog", { path: status.keeper.logPath })
1965
2100
  })
1966
2101
  ]
1967
2102
  }),
@@ -2097,16 +2232,35 @@ function CodeArtsPluginCard({ t }) {
2097
2232
  })]
2098
2233
  });
2099
2234
  }
2235
+ BigInt("0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551") >> 1n;
2236
+ new TextEncoder();
2237
+ //#endregion
2238
+ //#region src/web-status.ts
2239
+ /**
2240
+ * 开关的默认值:没有 settings provider(或老配置没这两个键)时保持原有行为 ——
2241
+ * 底部两行都显示;侧边栏相反,缺省不开(那一格是所有插件共用的全局座位)。
2242
+ * `modelDetail` 缺省开(保持老版本的样子),`autoClaim` 缺省关。
2243
+ */
2244
+ const DEFAULT_DOCK_FLAGS = {
2245
+ credits: true,
2246
+ queue: true,
2247
+ sidebar: false,
2248
+ modelDetail: true,
2249
+ autoClaim: false,
2250
+ keepAliveDaemon: false
2251
+ };
2100
2252
  //#endregion
2101
2253
  //#region src/client/dock-line.ts
2102
2254
  /** 段分隔符 —— 与邻居插件一致,改这里等于改整行的样子。 */
2103
2255
  const DOCK_SEGMENT_SEPARATOR = " · ";
2104
- function buildDockLine(parts, t) {
2256
+ function buildDockLine(parts, t, showModelDetail = true) {
2105
2257
  const rest = [];
2106
2258
  rest.push(t("dockProvider", { provider: parts.provider }));
2107
- rest.push(parts.model === void 0 ? t("dockNoModel") : t("dockModel", { model: parts.model }));
2108
- if (parts.ratio !== void 0) rest.push(parts.ratio);
2109
- if (parts.queue !== void 0) rest.push(parts.queue);
2259
+ if (showModelDetail) {
2260
+ rest.push(parts.model === void 0 ? t("dockNoModel") : t("dockModel", { model: parts.model }));
2261
+ if (parts.ratio !== void 0) rest.push(parts.ratio);
2262
+ if (parts.queue !== void 0) rest.push(parts.queue);
2263
+ }
2110
2264
  return {
2111
2265
  ...parts.credits === void 0 ? {} : { credits: parts.credits },
2112
2266
  rest: rest.join(DOCK_SEGMENT_SEPARATOR)
@@ -2332,11 +2486,7 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
2332
2486
  * 名字用 `stripModelSuffixes` 剥掉尾巴,倍率直接用服务端算好的 `ratio`。
2333
2487
  */
2334
2488
  const [modelInfo, setModelInfo] = (0, react.useState)({});
2335
- const [flags, setFlags] = (0, react.useState)({
2336
- credits: true,
2337
- queue: true,
2338
- sidebar: false
2339
- });
2489
+ const [flags, setFlags] = (0, react.useState)(DEFAULT_DOCK_FLAGS);
2340
2490
  const [queued, setQueued] = (0, react.useState)(null);
2341
2491
  const [anchor, setAnchor] = (0, react.useState)(null);
2342
2492
  /**
@@ -2369,11 +2519,7 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
2369
2519
  if (!res.ok) return;
2370
2520
  const data = await res.json().catch(() => void 0);
2371
2521
  if (data === void 0 || !mounted.current) return;
2372
- setFlags(data.dock ?? {
2373
- credits: true,
2374
- queue: true,
2375
- sidebar: false
2376
- });
2522
+ setFlags(data.dock ?? DEFAULT_DOCK_FLAGS);
2377
2523
  setRows(rowsOf(data));
2378
2524
  setModelInfo(Object.fromEntries((data.models ?? []).map((model) => [model.id, {
2379
2525
  name: model.name,
@@ -2496,7 +2642,7 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
2496
2642
  ...modelLabel === "" ? {} : { model: modelLabel },
2497
2643
  ...ratio === void 0 ? {} : { ratio },
2498
2644
  ...zone === "dock" && showQueue && queued !== null ? { queue: t("queueDock", { position: queued.position }) } : {}
2499
- }, t);
2645
+ }, t, flags.modelDetail !== false);
2500
2646
  const fetchedAt = rows.reduce((latest, row) => Math.max(latest, row.fetchedAt ?? 0), 0);
2501
2647
  const lastUpdated = fetchedAt > 0 ? formatClock(fetchedAt) : "";
2502
2648
  const toggle = (event) => {
@@ -2691,14 +2837,14 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
2691
2837
  document.head.appendChild(tag);
2692
2838
  }
2693
2839
  var CodeArtsPanel_module_css_default = {
2840
+ "body": "Z66cgG_body",
2694
2841
  "title": "Z66cgG_title",
2695
- "desc": "Z66cgG_desc",
2696
- "backCaret": "Z66cgG_backCaret",
2697
- "head": "Z66cgG_head",
2698
2842
  "back": "Z66cgG_back",
2843
+ "icon": "Z66cgG_icon",
2844
+ "head": "Z66cgG_head",
2845
+ "desc": "Z66cgG_desc",
2699
2846
  "page": "Z66cgG_page",
2700
- "body": "Z66cgG_body",
2701
- "icon": "Z66cgG_icon"
2847
+ "backCaret": "Z66cgG_backCaret"
2702
2848
  };
2703
2849
  //#endregion
2704
2850
  //#region src/client/CodeArtsPanel.tsx
@@ -2934,9 +3080,24 @@ const zh = {
2934
3080
  dockNoModel: "未选择模型",
2935
3081
  tabDisplay: "显示",
2936
3082
  displayTitle: "输入框两侧显示",
2937
- displayHint: "这两项只管输入框下方那一行的积分与排队两段;中间那段「Provider CodeArts · Model 模型 · 倍率」一直显示,不受开关影响。底部那条每 60 秒读一次设置,所以关掉最多要等一分钟才见效。",
3083
+ displayHint: "这几项只管输入框上下那两行显示什么,不影响任何请求。`Provider CodeArts` 是插件的身份标识,一直显示,不受开关控制;「显示模型与倍率」只收掉它右边那段(模型名、倍率、排队)。底部那条每 60 秒读一次设置,所以关掉最多要等一分钟才见效。",
2938
3084
  displayCreditsToggle: "在输入框工具行显示剩余积分(点开可看各账号明细)",
2939
3085
  displayQueueToggle: "显示上游排队位置",
3086
+ displayModelDetailToggle: "显示模型与倍率(Provider CodeArts 不受影响,始终显示)",
3087
+ displayAutoClaimTitle: "每日签到积分",
3088
+ displayAutoClaimHint: "打开后,DSH 启动约 30 秒会自动把每个已登录账号的每日签到积分领一遍;没领到会隔 30 分钟再试,最多 3 次。上游按天去重,重复领取不会出错。领取结果可以点开积分条查看。注意:这个功能只在 DSH 运行时生效,关掉 DSH 后不会替你领。",
3089
+ displayAutoClaimToggle: "自动领取每日签到积分(默认关闭)",
3090
+ displayKeeperTitle: "常驻保活(DSH 关掉后仍续登录)",
3091
+ displayKeeperHint: "上游给的登录凭证只活 2 小时,但要靠它换新的登录凭证(refresh token),那个能活 30 天。打开这一项后,DSH 会在系统里另起一个独立的后台进程,每 20 分钟替你续一次——所以哪怕 DSH 关着、好几天不开,回来也不用重新登录。这个进程不随 DSH 退出,要用下面的「结束」按钮手动停。默认关闭:不经你同意就在系统里留一个常驻进程不合适。",
3092
+ displayKeeperToggle: "开启常驻保活进程(默认关闭)",
3093
+ displayKeeperRunning: "后台进程运行中 · PID {pid} · 最近心跳 {time}",
3094
+ displayKeeperStarting: "后台进程正在启动……稍等几秒刷新这一页。",
3095
+ displayKeeperDown: "后台进程没有在跑(可能被你结束或启动失败),保活开关已关闭。{message}",
3096
+ displayKeeperStop: "结束进程",
3097
+ displayKeeperStopping: "正在结束……",
3098
+ displayKeeperStopped: "后台进程已结束,保活开关已同时关闭。",
3099
+ displayKeeperStopFailed: "结束失败:{message}",
3100
+ displayKeeperLog: "进程日志:{path}",
2940
3101
  displayNotWritable: "这个宿主没给插件开配置存储,开关只能看不能改。",
2941
3102
  displayFailed: "保存失败:{message}",
2942
3103
  displaySidebarTitle: "侧边栏图标",
@@ -3120,9 +3281,24 @@ const en = {
3120
3281
  dockNoModel: "No model selected",
3121
3282
  tabDisplay: "Display",
3122
3283
  displayTitle: "Around the chat input box",
3123
- displayHint: "These two only control the credits and queue segments of that line under the input box; the middle “Provider CodeArts · Model … · rate” segments always show. The bar re-reads settings every 60 seconds, so hiding the rest can take up to a minute.",
3284
+ displayHint: "These only change what the two lines around the input box show; nothing here touches a request. \"Provider CodeArts\" identifies the plugin and always shows. \"Model and rate\" hides only the part to its right (model name, rate, queue). The bar re-reads settings every 60 seconds, so a change can take up to a minute.",
3124
3285
  displayCreditsToggle: "Show remaining credits in the composer tool row (click for per-account details)",
3125
3286
  displayQueueToggle: "Show the upstream queue position",
3287
+ displayModelDetailToggle: "Show the model and rate (Provider CodeArts is not affected and always shows)",
3288
+ displayAutoClaimTitle: "Daily sign-in credits",
3289
+ displayAutoClaimHint: "When on, about 30 seconds after DSH starts the plugin claims the daily sign-in credits for every signed-in account; if nothing was claimed it retries after 30 minutes, up to 3 times. Upstream deduplicates by day, so claiming twice is harmless. Open the credits bar to see the result. Note: this only runs while DSH is running — it cannot claim for you once DSH is closed.",
3290
+ displayAutoClaimToggle: "Claim daily sign-in credits automatically (off by default)",
3291
+ displayKeeperTitle: "Keep-alive process (stays signed in while DSH is closed)",
3292
+ displayKeeperHint: "The login token upstream hands out only lives 2 hours, but the refresh token behind it lives 30 days. With this on, DSH starts a separate background process that refreshes the credential every 20 minutes — so even after DSH has been closed for days, you come back without signing in again. That process outlives DSH; stop it with the button below. Off by default: leaving a resident process on your machine without asking is not something a plugin should do.",
3293
+ displayKeeperToggle: "Run the keep-alive background process (off by default)",
3294
+ displayKeeperRunning: "Background process running · PID {pid} · last heartbeat {time}",
3295
+ displayKeeperStarting: "The background process is starting… refresh this page in a few seconds.",
3296
+ displayKeeperDown: "The background process is not running (stopped by you, or it failed to start); the keep-alive switch has been turned off. {message}",
3297
+ displayKeeperStop: "Stop process",
3298
+ displayKeeperStopping: "Stopping…",
3299
+ displayKeeperStopped: "Background process stopped and the keep-alive switch turned off.",
3300
+ displayKeeperStopFailed: "Failed to stop: {message}",
3301
+ displayKeeperLog: "Process log: {path}",
3126
3302
  displayNotWritable: "This host gives the plugin nowhere to persist settings, so the switches are read-only.",
3127
3303
  displayFailed: "Failed to save: {message}",
3128
3304
  displaySidebarTitle: "Sidebar icon",
package/lib/index.d.mts CHANGED
@@ -1062,7 +1062,7 @@ declare class CodeArtsCredentialStore {
1062
1062
  clear(): Promise<void>;
1063
1063
  hasCredential(): Promise<boolean>;
1064
1064
  /**
1065
- * 自动续期:若距过期不足 5 分钟且具备 refresh 条件,则刷新并落库。
1065
+ * 自动续期:若距过期不足 `REFRESH_SKEW_MS` 且具备 refresh 条件,则刷新并落库。
1066
1066
  * 返回当前(可能已刷新)凭证。
1067
1067
  */
1068
1068
  ensureFresh(): Promise<CodeArtsCredential | undefined>;
@@ -1158,6 +1158,34 @@ declare class CodeArtsAccountStore {
1158
1158
  * (refresh_token 会轮换,白刷一次就多一次失败风险)。
1159
1159
  */
1160
1160
  forceRefresh(id: string, seenToken?: string): Promise<CodeArtsCredential | undefined>;
1161
+ /**
1162
+ * 从磁盘重读账号文档,丢掉内存里的槽位缓存。
1163
+ *
1164
+ * 给「常驻守护进程」(`keeper-main.ts`)用:它在 DSH 之外续期并写回同一个文档,
1165
+ * 所以插件这边必须定期重读,否则会一直用启动时那份快照 —— 表现为「守护进程明明
1166
+ * 续上了,卡片还显示快过期」,更糟的是插件下一次落库会把守护进程刚写的新
1167
+ * refresh_token 覆盖回旧的,那个号就再也续不上了。
1168
+ *
1169
+ * 只在**没有**在飞的续期时调用(`keepAliveLoop` 里与 `keepAlive` 互斥);
1170
+ * 重读会把所有槽位重建,正在跑的刷新结果会被代际号拦下,不会写回。
1171
+ */
1172
+ reloadFromDisk(): Promise<boolean>;
1173
+ /**
1174
+ * 后台保活:把所有**还能续**的账号过一遍 `ensureFresh`。
1175
+ *
1176
+ * 为什么需要它:`ensureFresh` 只会被「有请求进来」这条路径触发,而凭证有效期是
1177
+ * 固定的 2 小时。用户开着 DSH 但不聊天时,没有任何请求 → 凭证裸奔到过期 → 下一次
1178
+ * 发消息前必须先重新登录。定时调这里,只要 DSH 活着凭证就一直被续上。
1179
+ *
1180
+ * 只刷「距过期不足 `REFRESH_SKEW_MS`」的那些,刚从上游拿到的号不会被白刷一次:
1181
+ * `refresh_token` 是一次性的,多余的刷新只会多一份失败风险。
1182
+ * `stale` 的号(已确认必须重新登录)直接跳过——空转只会白烧请求。
1183
+ */
1184
+ keepAlive(): Promise<{
1185
+ checked: number;
1186
+ refreshed: number;
1187
+ needsLogin: string[];
1188
+ }>;
1161
1189
  }
1162
1190
  //#endregion
1163
1191
  //#region src/account-pool.d.ts
@@ -1736,6 +1764,29 @@ interface Config {
1736
1764
  * 而「设置 → 插件」里本来就能看到同一张卡片,所以这一格交给用户自己决定要不要。
1737
1765
  */
1738
1766
  showSidebarPanel?: boolean;
1767
+ /**
1768
+ * 对话底部的「Model 模型 · x 倍率 · 排队」这几段是否显示。缺省 = 显示。
1769
+ *
1770
+ * 只管 **Model 及其右侧**:`Provider CodeArts` 是插件的身份标识,永远显示,
1771
+ * 不受这个开关控制。关掉之后那一行是 `积分 24,091 · Provider CodeArts`。
1772
+ */
1773
+ showModelDetailDock?: boolean;
1774
+ /**
1775
+ * 后台自动领取每日签到积分(多账号逐个领)。缺省 = **关**。
1776
+ *
1777
+ * 缺省关的理由不是"收益小",而是:这个开关会在用户看不见的时候动他的账号余额,
1778
+ * 默认替他打开不合适。打开后每次启动 30 秒试一轮,领不到再退避重试(最多 3 次),
1779
+ * 结果会留在卡片上给用户看。
1780
+ */
1781
+ autoClaim?: boolean;
1782
+ /**
1783
+ * 常驻凭证守护进程:让 refresh_token 在 **DSH 关掉之后**也继续被续期。
1784
+ *
1785
+ * 缺省 = **关**。理由:它会在 DSH 之外留一个后台进程(用宿主 exe 以 node 形态跑,
1786
+ * 不额外依赖 node 安装),属于用户应当知情并主动选择的东西,不能默认替他开。
1787
+ * 打开后卡片上会显示它的 pid,并给一个「结束」按钮。
1788
+ */
1789
+ keepAliveDaemon?: boolean;
1739
1790
  }
1740
1791
  declare const Config: z<Config>;
1741
1792
  declare function apply(ctx: Context, rawConfig: Config): void;