dsh-mcviseron-plugin 0.0.0-stage → 0.6.2
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 +222 -0
- package/CONTRIBUTING.md +60 -0
- package/LICENSE +202 -0
- package/README.en.md +146 -0
- package/README.md +287 -2
- package/SECURITY.md +38 -0
- package/cordis.patch.yml +12 -0
- package/docs/automation-task.md +63 -0
- package/docs/migration-from-standalone.md +115 -0
- package/docs/release.md +85 -0
- package/lib/appearance.js +320 -0
- package/lib/auto-review-fix.js +453 -0
- package/lib/client.js +1266 -0
- package/lib/index.js +1701 -0
- package/lib/restart.js +226 -0
- package/lib/task-guard.js +736 -0
- package/package.json +148 -4
- package/scripts/repair-profile.mjs +77 -0
- package/src/api.ts +5 -0
- package/src/appearance/index.ts +103 -0
- package/src/auto-review-fix/index.ts +45 -0
- package/src/client/AppearanceScheduleRow.tsx +112 -0
- package/src/client/ConfigForm.tsx +284 -0
- package/src/client/FallbackRestartRow.tsx +23 -0
- package/src/client/RestartCard.tsx +108 -0
- package/src/client/SettingsSection.tsx +110 -0
- package/src/client/bridge.ts +131 -0
- package/src/client/driver.ts +166 -0
- package/src/client/index.ts +114 -0
- package/src/client/locales.ts +193 -0
- package/src/client/primitives.d.ts +15 -0
- package/src/client/section-presence.ts +33 -0
- package/src/client/styles.ts +154 -0
- package/src/components/auto-review-fix/index.ts +421 -0
- package/src/components/auto-review-fix/translate.ts +235 -0
- package/src/components/task-guard/index.ts +1077 -0
- package/src/index.ts +71 -0
- package/src/loopback.ts +48 -0
- package/src/namespace.ts +7 -0
- package/src/restart/index.ts +268 -0
- package/src/routes.ts +228 -0
- package/src/schedule.ts +125 -0
- package/src/task-guard/index.ts +52 -0
- package/src/volatile.ts +32 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,1266 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-mcviseron-plugin",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
var module = { exports: {} };
|
|
7
|
+
var exports = module.exports;
|
|
8
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
|
|
27
|
+
// src/client/index.ts
|
|
28
|
+
var index_exports = {};
|
|
29
|
+
__export(index_exports, {
|
|
30
|
+
apply: () => apply,
|
|
31
|
+
inject: () => inject
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/client/AppearanceScheduleRow.tsx
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
|
|
38
|
+
// src/schedule.ts
|
|
39
|
+
var DEFAULT_SCHEDULE_CONFIG = {
|
|
40
|
+
enabled: false,
|
|
41
|
+
lightStart: "08:00",
|
|
42
|
+
lightEnd: "23:00"
|
|
43
|
+
};
|
|
44
|
+
var TIME_OF_DAY = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
|
45
|
+
function parseTimeOfDay(value) {
|
|
46
|
+
const match = TIME_OF_DAY.exec(value);
|
|
47
|
+
if (match === null) return void 0;
|
|
48
|
+
return Number(match[1]) * 60 + Number(match[2]);
|
|
49
|
+
}
|
|
50
|
+
function formatTimeOfDay(minutes) {
|
|
51
|
+
const hours = Math.floor(minutes / 60);
|
|
52
|
+
const rest = minutes % 60;
|
|
53
|
+
return String(hours).padStart(2, "0") + ":" + String(rest).padStart(2, "0");
|
|
54
|
+
}
|
|
55
|
+
function normalizeScheduleConfig(input) {
|
|
56
|
+
const record = input !== null && typeof input === "object" ? input : {};
|
|
57
|
+
const lightStart = typeof record.lightStart === "string" && parseTimeOfDay(record.lightStart) !== void 0 ? record.lightStart : DEFAULT_SCHEDULE_CONFIG.lightStart;
|
|
58
|
+
const lightEnd = typeof record.lightEnd === "string" && parseTimeOfDay(record.lightEnd) !== void 0 ? record.lightEnd : DEFAULT_SCHEDULE_CONFIG.lightEnd;
|
|
59
|
+
const enabled = typeof record.enabled === "boolean" ? record.enabled : DEFAULT_SCHEDULE_CONFIG.enabled;
|
|
60
|
+
return { enabled, lightStart, lightEnd };
|
|
61
|
+
}
|
|
62
|
+
function startMinutes(config) {
|
|
63
|
+
return parseTimeOfDay(config.lightStart) ?? parseTimeOfDay(DEFAULT_SCHEDULE_CONFIG.lightStart);
|
|
64
|
+
}
|
|
65
|
+
function endMinutes(config) {
|
|
66
|
+
return parseTimeOfDay(config.lightEnd) ?? parseTimeOfDay(DEFAULT_SCHEDULE_CONFIG.lightEnd);
|
|
67
|
+
}
|
|
68
|
+
function periodAt(now, config) {
|
|
69
|
+
const start = startMinutes(config);
|
|
70
|
+
const end = endMinutes(config);
|
|
71
|
+
if (start === end) return "light";
|
|
72
|
+
const minutes = now.getHours() * 60 + now.getMinutes();
|
|
73
|
+
if (start < end) return minutes >= start && minutes < end ? "light" : "dark";
|
|
74
|
+
return minutes >= start || minutes < end ? "light" : "dark";
|
|
75
|
+
}
|
|
76
|
+
function boundaryAfter(now, minutes) {
|
|
77
|
+
const at = new Date(now.getTime());
|
|
78
|
+
at.setHours(Math.floor(minutes / 60), minutes % 60, 0, 0);
|
|
79
|
+
if (at.getTime() <= now.getTime()) at.setDate(at.getDate() + 1);
|
|
80
|
+
return at;
|
|
81
|
+
}
|
|
82
|
+
function nextTransition(now, config) {
|
|
83
|
+
const start = startMinutes(config);
|
|
84
|
+
const end = endMinutes(config);
|
|
85
|
+
if (start === end) return void 0;
|
|
86
|
+
const startAt = boundaryAfter(now, start);
|
|
87
|
+
const endAt = boundaryAfter(now, end);
|
|
88
|
+
const at = startAt.getTime() <= endAt.getTime() ? startAt : endAt;
|
|
89
|
+
return { at, period: periodAt(at, config) };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/client/AppearanceScheduleRow.tsx
|
|
93
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
94
|
+
|
|
95
|
+
// src/client/styles.ts
|
|
96
|
+
var labelPrimary = "var(--dsw-alias-label-primary, #1f2329)";
|
|
97
|
+
var labelSecondary = "var(--dsw-alias-label-secondary, #5c6570)";
|
|
98
|
+
var labelTertiary = "var(--dsw-alias-label-tertiary, #8a919b)";
|
|
99
|
+
var borderL2 = "var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08))";
|
|
100
|
+
var fieldFill = "var(--dsw-alias-bg-layer-1, rgba(0, 0, 0, 0.03))";
|
|
101
|
+
var accent = "var(--dsw-alias-state-business-primary, #4176e6)";
|
|
102
|
+
var pageStyles = {
|
|
103
|
+
page: { display: "flex", flexDirection: "column", gap: 16, padding: "4px 0" },
|
|
104
|
+
heading: { margin: 0, fontSize: 18, lineHeight: "26px", color: labelPrimary },
|
|
105
|
+
lede: { margin: 0, fontSize: 13, lineHeight: "20px", color: labelSecondary },
|
|
106
|
+
tabs: { display: "flex", gap: 4, borderBottom: "1px solid " + borderL2 },
|
|
107
|
+
tab: {
|
|
108
|
+
padding: "8px 12px",
|
|
109
|
+
border: "none",
|
|
110
|
+
background: "transparent",
|
|
111
|
+
color: labelSecondary,
|
|
112
|
+
fontSize: 13,
|
|
113
|
+
fontFamily: "inherit",
|
|
114
|
+
cursor: "pointer"
|
|
115
|
+
},
|
|
116
|
+
tabActive: { boxShadow: "inset 0 -2px 0 " + accent, color: labelPrimary },
|
|
117
|
+
card: {
|
|
118
|
+
display: "flex",
|
|
119
|
+
flexDirection: "column",
|
|
120
|
+
gap: 8,
|
|
121
|
+
padding: "14px 16px",
|
|
122
|
+
border: "1px solid " + borderL2,
|
|
123
|
+
borderRadius: 10
|
|
124
|
+
},
|
|
125
|
+
cardTitle: { fontSize: 14, lineHeight: "20px", color: labelPrimary },
|
|
126
|
+
cardBody: { fontSize: 12, lineHeight: "18px", color: labelSecondary },
|
|
127
|
+
cardStatus: { fontSize: 12, lineHeight: "18px", color: labelTertiary },
|
|
128
|
+
cardActions: { display: "flex", justifyContent: "flex-end", gap: 8 },
|
|
129
|
+
componentRow: {
|
|
130
|
+
display: "flex",
|
|
131
|
+
justifyContent: "space-between",
|
|
132
|
+
alignItems: "baseline",
|
|
133
|
+
gap: 16,
|
|
134
|
+
padding: "8px 0",
|
|
135
|
+
borderBottom: "1px solid " + borderL2
|
|
136
|
+
},
|
|
137
|
+
componentName: { fontSize: 13, lineHeight: "20px", color: labelPrimary },
|
|
138
|
+
componentHint: { fontSize: 12, lineHeight: "18px", color: labelTertiary, textAlign: "right" },
|
|
139
|
+
form: { display: "flex", flexDirection: "column", gap: 10 },
|
|
140
|
+
formRow: {
|
|
141
|
+
display: "flex",
|
|
142
|
+
flexDirection: "column",
|
|
143
|
+
gap: 4,
|
|
144
|
+
padding: "8px 0",
|
|
145
|
+
borderBottom: "1px solid " + borderL2
|
|
146
|
+
},
|
|
147
|
+
formLabel: { fontSize: 13, lineHeight: "18px", color: labelPrimary },
|
|
148
|
+
formHint: { fontSize: 11, lineHeight: "16px", color: labelTertiary },
|
|
149
|
+
formControl: {
|
|
150
|
+
width: "100%",
|
|
151
|
+
maxWidth: 420,
|
|
152
|
+
padding: "4px 8px",
|
|
153
|
+
border: "1px solid " + borderL2,
|
|
154
|
+
borderRadius: 6,
|
|
155
|
+
background: fieldFill,
|
|
156
|
+
color: labelPrimary,
|
|
157
|
+
fontSize: 12,
|
|
158
|
+
fontFamily: "inherit"
|
|
159
|
+
},
|
|
160
|
+
formStatus: { fontSize: 11, lineHeight: "16px", color: labelTertiary }
|
|
161
|
+
};
|
|
162
|
+
var buttonShape = {
|
|
163
|
+
padding: "4px 14px",
|
|
164
|
+
border: "1px solid " + borderL2,
|
|
165
|
+
borderRadius: 6,
|
|
166
|
+
background: fieldFill,
|
|
167
|
+
color: labelPrimary,
|
|
168
|
+
fontSize: 12,
|
|
169
|
+
fontFamily: "inherit",
|
|
170
|
+
cursor: "pointer"
|
|
171
|
+
};
|
|
172
|
+
var styles = {
|
|
173
|
+
row: {
|
|
174
|
+
display: "flex",
|
|
175
|
+
alignItems: "flex-start",
|
|
176
|
+
justifyContent: "space-between",
|
|
177
|
+
gap: 16,
|
|
178
|
+
padding: "10px 0",
|
|
179
|
+
flexWrap: "wrap"
|
|
180
|
+
},
|
|
181
|
+
text: {
|
|
182
|
+
display: "flex",
|
|
183
|
+
flexDirection: "column",
|
|
184
|
+
gap: 4,
|
|
185
|
+
minWidth: 0
|
|
186
|
+
},
|
|
187
|
+
title: {
|
|
188
|
+
fontSize: 14,
|
|
189
|
+
lineHeight: "20px",
|
|
190
|
+
color: labelPrimary
|
|
191
|
+
},
|
|
192
|
+
description: {
|
|
193
|
+
fontSize: 12,
|
|
194
|
+
lineHeight: "18px",
|
|
195
|
+
color: labelSecondary
|
|
196
|
+
},
|
|
197
|
+
status: {
|
|
198
|
+
fontSize: 12,
|
|
199
|
+
lineHeight: "18px",
|
|
200
|
+
color: labelTertiary
|
|
201
|
+
},
|
|
202
|
+
controls: {
|
|
203
|
+
display: "flex",
|
|
204
|
+
alignItems: "center",
|
|
205
|
+
gap: 12,
|
|
206
|
+
flex: "0 0 auto"
|
|
207
|
+
},
|
|
208
|
+
times: {
|
|
209
|
+
display: "flex",
|
|
210
|
+
alignItems: "center",
|
|
211
|
+
gap: 6
|
|
212
|
+
},
|
|
213
|
+
field: {
|
|
214
|
+
display: "flex",
|
|
215
|
+
alignItems: "center",
|
|
216
|
+
gap: 4
|
|
217
|
+
},
|
|
218
|
+
fieldLabel: {
|
|
219
|
+
fontSize: 12,
|
|
220
|
+
lineHeight: "18px",
|
|
221
|
+
color: labelSecondary
|
|
222
|
+
},
|
|
223
|
+
input: {
|
|
224
|
+
width: 84,
|
|
225
|
+
padding: "2px 6px",
|
|
226
|
+
border: "1px solid " + borderL2,
|
|
227
|
+
borderRadius: 6,
|
|
228
|
+
background: fieldFill,
|
|
229
|
+
color: labelPrimary,
|
|
230
|
+
fontSize: 12,
|
|
231
|
+
fontFamily: "inherit"
|
|
232
|
+
},
|
|
233
|
+
dash: {
|
|
234
|
+
fontSize: 12,
|
|
235
|
+
color: labelTertiary
|
|
236
|
+
},
|
|
237
|
+
button: buttonShape,
|
|
238
|
+
buttonDisabled: { ...buttonShape, opacity: 0.6, cursor: "default" }
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// src/client/AppearanceScheduleRow.tsx
|
|
242
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
243
|
+
function AppearanceScheduleRow({ t, driver }) {
|
|
244
|
+
const state = (0, import_react.useSyncExternalStore)(driver.subscribe, driver.getState, driver.getState);
|
|
245
|
+
const [now, setNow] = (0, import_react.useState)(() => /* @__PURE__ */ new Date());
|
|
246
|
+
(0, import_react.useEffect)(() => {
|
|
247
|
+
const timer = setInterval(() => {
|
|
248
|
+
setNow(/* @__PURE__ */ new Date());
|
|
249
|
+
}, 15e3);
|
|
250
|
+
return () => {
|
|
251
|
+
clearInterval(timer);
|
|
252
|
+
};
|
|
253
|
+
}, []);
|
|
254
|
+
(0, import_react.useEffect)(() => {
|
|
255
|
+
if (state.bridge === "loading") void driver.refresh();
|
|
256
|
+
}, [driver, state.bridge]);
|
|
257
|
+
const config = state.config;
|
|
258
|
+
const next = nextTransition(now, config);
|
|
259
|
+
const period = periodAt(now, config);
|
|
260
|
+
const status = (() => {
|
|
261
|
+
if (state.bridge === "unavailable") return t("status.unavailable");
|
|
262
|
+
if (!config.enabled) return t("status.off");
|
|
263
|
+
const periodText = t(period === "light" ? "status.light" : "status.dark");
|
|
264
|
+
if (next === void 0) return periodText;
|
|
265
|
+
return periodText + " \xB7 " + t("row.next") + " " + formatTimeOfDay(next.at.getHours() * 60 + next.at.getMinutes());
|
|
266
|
+
})();
|
|
267
|
+
const write = state.write === "saving" ? t("status.saving") : state.write === "failed" ? t("status.failed") : state.write === "saved" ? t("status.saved") : "";
|
|
268
|
+
const toggle = (enabled) => {
|
|
269
|
+
void driver.update({ enabled });
|
|
270
|
+
};
|
|
271
|
+
const changeTime = (field, value) => {
|
|
272
|
+
if (parseTimeOfDay(value) === void 0) return;
|
|
273
|
+
void driver.update(field === "lightStart" ? { lightStart: value } : { lightEnd: value });
|
|
274
|
+
};
|
|
275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: styles.row, children: [
|
|
276
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: styles.text, children: [
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: styles.title, children: t("row.title") }),
|
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: styles.description, children: t("row.description") }),
|
|
279
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: styles.status, children: write === "" ? status : status + " \xB7 " + write })
|
|
280
|
+
] }),
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: styles.controls, children: [
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: styles.times, title: t("row.timeHint"), children: [
|
|
283
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { style: styles.field, children: [
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: styles.fieldLabel, children: t("row.lightStart") }),
|
|
285
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
286
|
+
"input",
|
|
287
|
+
{
|
|
288
|
+
type: "time",
|
|
289
|
+
step: 60,
|
|
290
|
+
value: config.lightStart,
|
|
291
|
+
"aria-label": t("row.lightStart"),
|
|
292
|
+
onChange: (event) => changeTime("lightStart", event.currentTarget.value),
|
|
293
|
+
style: styles.input
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
] }),
|
|
297
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: styles.dash, children: t("row.dash") }),
|
|
298
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { style: styles.field, children: [
|
|
299
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: styles.fieldLabel, children: t("row.lightEnd") }),
|
|
300
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
301
|
+
"input",
|
|
302
|
+
{
|
|
303
|
+
type: "time",
|
|
304
|
+
step: 60,
|
|
305
|
+
value: config.lightEnd,
|
|
306
|
+
"aria-label": t("row.lightEnd"),
|
|
307
|
+
onChange: (event) => changeTime("lightEnd", event.currentTarget.value),
|
|
308
|
+
style: styles.input
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
] })
|
|
312
|
+
] }),
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
314
|
+
import_dsh_client_ui_primitives.Switch,
|
|
315
|
+
{
|
|
316
|
+
checked: config.enabled,
|
|
317
|
+
label: config.enabled ? t("row.disable") : t("row.enable"),
|
|
318
|
+
title: config.enabled ? t("row.disable") : t("row.enable"),
|
|
319
|
+
onChange: (next2) => {
|
|
320
|
+
toggle(next2);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
] })
|
|
325
|
+
] });
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// src/client/FallbackRestartRow.tsx
|
|
329
|
+
var import_react3 = require("react");
|
|
330
|
+
|
|
331
|
+
// src/client/RestartCard.tsx
|
|
332
|
+
var import_react2 = require("react");
|
|
333
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
334
|
+
var STATUS = "/api/dsh-mcviseron/restart/status";
|
|
335
|
+
var EXECUTE = "/api/dsh-mcviseron/restart/execute";
|
|
336
|
+
async function readError(response) {
|
|
337
|
+
try {
|
|
338
|
+
const body = await response.json();
|
|
339
|
+
if (typeof body.error === "string") return body.error;
|
|
340
|
+
} catch {
|
|
341
|
+
}
|
|
342
|
+
return "HTTP " + String(response.status);
|
|
343
|
+
}
|
|
344
|
+
function RestartCard({ t }) {
|
|
345
|
+
const [state, setState] = (0, import_react2.useState)({ kind: "loading" });
|
|
346
|
+
(0, import_react2.useEffect)(() => {
|
|
347
|
+
let cancelled = false;
|
|
348
|
+
void (async () => {
|
|
349
|
+
try {
|
|
350
|
+
const response = await fetch(STATUS, { method: "GET" });
|
|
351
|
+
if (cancelled) return;
|
|
352
|
+
if (response.status === 404 || response.status === 405) {
|
|
353
|
+
setState({ kind: "route-missing" });
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (!response.ok) throw new Error(await readError(response));
|
|
357
|
+
const body = await response.json();
|
|
358
|
+
if (body.ok !== true) throw new Error("restart-status-rejected");
|
|
359
|
+
if (body.available === true) {
|
|
360
|
+
setState({ kind: "ready", appPath: typeof body.appPath === "string" ? body.appPath : "" });
|
|
361
|
+
} else {
|
|
362
|
+
setState({ kind: "unavailable" });
|
|
363
|
+
}
|
|
364
|
+
} catch (error) {
|
|
365
|
+
if (!cancelled) setState({ kind: "failed", message: error instanceof Error ? error.message : String(error) });
|
|
366
|
+
}
|
|
367
|
+
})();
|
|
368
|
+
return () => {
|
|
369
|
+
cancelled = true;
|
|
370
|
+
};
|
|
371
|
+
}, []);
|
|
372
|
+
const startRestart = async () => {
|
|
373
|
+
if (!window.confirm(t("page.restart.confirm"))) return;
|
|
374
|
+
setState({ kind: "restarting" });
|
|
375
|
+
try {
|
|
376
|
+
const response = await fetch(EXECUTE, {
|
|
377
|
+
method: "POST",
|
|
378
|
+
headers: { "content-type": "application/json" },
|
|
379
|
+
body: JSON.stringify({ confirm: true })
|
|
380
|
+
});
|
|
381
|
+
if (!response.ok) throw new Error(await readError(response));
|
|
382
|
+
const body = await response.json();
|
|
383
|
+
if (body.ok !== true) throw new Error("restart-rejected");
|
|
384
|
+
} catch (error) {
|
|
385
|
+
setState({ kind: "failed", message: error instanceof Error ? error.message : String(error) });
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
const status = state.kind === "ready" ? t("page.restart.ready") : state.kind === "route-missing" ? t("page.restart.routeMissing") : state.kind === "restarting" ? t("page.restart.restarting") : state.kind === "failed" ? t("page.restart.failed") + (state.message !== "" ? " (" + state.message + ")" : "") : state.kind === "loading" ? t("restart.checking") : t("page.restart.unavailable");
|
|
389
|
+
const canRestart = state.kind === "ready" || state.kind === "failed";
|
|
390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: pageStyles.card, children: [
|
|
391
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: pageStyles.cardTitle, children: t("page.restart.title") }),
|
|
392
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: pageStyles.cardBody, children: t("page.restart.description") }),
|
|
393
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: pageStyles.cardStatus, children: status }),
|
|
394
|
+
state.kind === "ready" && state.appPath !== "" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: pageStyles.cardStatus, children: [
|
|
395
|
+
t("page.restart.appPath"),
|
|
396
|
+
": ",
|
|
397
|
+
state.appPath
|
|
398
|
+
] }) : null,
|
|
399
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: pageStyles.cardActions, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
400
|
+
"button",
|
|
401
|
+
{
|
|
402
|
+
type: "button",
|
|
403
|
+
disabled: !canRestart,
|
|
404
|
+
onClick: () => {
|
|
405
|
+
void startRestart();
|
|
406
|
+
},
|
|
407
|
+
style: canRestart ? styles.button : styles.buttonDisabled,
|
|
408
|
+
children: state.kind === "restarting" ? t("page.restart.restarting") : t("page.restart.button")
|
|
409
|
+
}
|
|
410
|
+
) })
|
|
411
|
+
] });
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// src/client/section-presence.ts
|
|
415
|
+
var live = false;
|
|
416
|
+
var failure = "";
|
|
417
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
418
|
+
function emit() {
|
|
419
|
+
for (const listener of [...listeners]) listener();
|
|
420
|
+
}
|
|
421
|
+
var sectionPresence = {
|
|
422
|
+
isLive: () => live,
|
|
423
|
+
failure: () => failure,
|
|
424
|
+
subscribe: (listener) => {
|
|
425
|
+
listeners.add(listener);
|
|
426
|
+
return () => {
|
|
427
|
+
listeners.delete(listener);
|
|
428
|
+
};
|
|
429
|
+
},
|
|
430
|
+
markLive: () => {
|
|
431
|
+
live = true;
|
|
432
|
+
failure = "";
|
|
433
|
+
emit();
|
|
434
|
+
},
|
|
435
|
+
markFailed: (error) => {
|
|
436
|
+
live = false;
|
|
437
|
+
failure = error instanceof Error ? error.message : String(error);
|
|
438
|
+
emit();
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// src/client/FallbackRestartRow.tsx
|
|
443
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
444
|
+
function FallbackRestartRow({ t }) {
|
|
445
|
+
const live2 = (0, import_react3.useSyncExternalStore)(sectionPresence.subscribe, sectionPresence.isLive);
|
|
446
|
+
if (live2) return null;
|
|
447
|
+
const failure2 = sectionPresence.failure();
|
|
448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
449
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { fontSize: 12, color: "var(--dsw-alias-label-tertiary)" }, children: [
|
|
450
|
+
t("page.fallback.note"),
|
|
451
|
+
failure2 !== "" ? " (" + failure2 + ")" : ""
|
|
452
|
+
] }),
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RestartCard, { t })
|
|
454
|
+
] });
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// src/client/SettingsSection.tsx
|
|
458
|
+
var import_react5 = require("react");
|
|
459
|
+
|
|
460
|
+
// src/client/ConfigForm.tsx
|
|
461
|
+
var import_react4 = require("react");
|
|
462
|
+
|
|
463
|
+
// src/api.ts
|
|
464
|
+
var MCVISERON_API = {
|
|
465
|
+
describe: "/api/dsh-mcviseron/settings/describe",
|
|
466
|
+
mutate: "/api/dsh-mcviseron/settings/mutate"
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
// src/namespace.ts
|
|
470
|
+
var MCVISERON_SETTINGS_NAMESPACE = "mcviseron";
|
|
471
|
+
|
|
472
|
+
// src/client/bridge.ts
|
|
473
|
+
function isRecord(value) {
|
|
474
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
475
|
+
}
|
|
476
|
+
async function post(path, body) {
|
|
477
|
+
const response = await fetch(path, {
|
|
478
|
+
method: "POST",
|
|
479
|
+
headers: { "content-type": "application/json" },
|
|
480
|
+
body: JSON.stringify(body)
|
|
481
|
+
});
|
|
482
|
+
if (!response.ok) throw new Error("HTTP " + response.status);
|
|
483
|
+
return await response.json();
|
|
484
|
+
}
|
|
485
|
+
async function readScheduleConfig() {
|
|
486
|
+
try {
|
|
487
|
+
const body = await post(MCVISERON_API.describe, {});
|
|
488
|
+
if (body.ok !== true) return void 0;
|
|
489
|
+
const view = body.value?.namespaces?.find((candidate) => String(candidate.ns) === MCVISERON_SETTINGS_NAMESPACE);
|
|
490
|
+
if (view === void 0) return void 0;
|
|
491
|
+
return normalizeScheduleConfig(view.value);
|
|
492
|
+
} catch {
|
|
493
|
+
return void 0;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
async function writeScheduleConfig(config) {
|
|
497
|
+
try {
|
|
498
|
+
const body = await post(MCVISERON_API.mutate, {
|
|
499
|
+
ns: MCVISERON_SETTINGS_NAMESPACE,
|
|
500
|
+
ops: [
|
|
501
|
+
{ op: "set", path: ["enabled"], value: config.enabled },
|
|
502
|
+
{ op: "set", path: ["lightStart"], value: config.lightStart },
|
|
503
|
+
{ op: "set", path: ["lightEnd"], value: config.lightEnd }
|
|
504
|
+
]
|
|
505
|
+
});
|
|
506
|
+
if (body.ok !== true) return void 0;
|
|
507
|
+
return normalizeScheduleConfig(body.value?.value);
|
|
508
|
+
} catch {
|
|
509
|
+
return void 0;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
async function readPluginConfig() {
|
|
513
|
+
try {
|
|
514
|
+
const body = await post(MCVISERON_API.describe, {});
|
|
515
|
+
if (body.ok !== true) return void 0;
|
|
516
|
+
const view = body.value?.namespaces?.find((candidate) => String(candidate.ns) === MCVISERON_SETTINGS_NAMESPACE);
|
|
517
|
+
if (view === void 0) return void 0;
|
|
518
|
+
return {
|
|
519
|
+
value: isRecord(view.value) ? view.value : {},
|
|
520
|
+
revision: typeof view.revision === "number" ? view.revision : void 0,
|
|
521
|
+
writable: body.value?.writable !== false
|
|
522
|
+
};
|
|
523
|
+
} catch {
|
|
524
|
+
return void 0;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
async function writePluginConfig(path, value) {
|
|
528
|
+
try {
|
|
529
|
+
const body = await post(MCVISERON_API.mutate, {
|
|
530
|
+
ns: MCVISERON_SETTINGS_NAMESPACE,
|
|
531
|
+
ops: [{ op: "set", path: [...path], value }]
|
|
532
|
+
});
|
|
533
|
+
if (body.ok !== true) {
|
|
534
|
+
return { ok: false, code: body.code, message: body.message };
|
|
535
|
+
}
|
|
536
|
+
return {
|
|
537
|
+
ok: true,
|
|
538
|
+
value: isRecord(body.value?.value) ? body.value.value : void 0
|
|
539
|
+
};
|
|
540
|
+
} catch (error) {
|
|
541
|
+
return { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// src/client/ConfigForm.tsx
|
|
546
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
547
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
548
|
+
function readPath(config, path) {
|
|
549
|
+
let current = config;
|
|
550
|
+
for (const key of path) {
|
|
551
|
+
if (current === null || typeof current !== "object" || Array.isArray(current)) return void 0;
|
|
552
|
+
current = current[key];
|
|
553
|
+
}
|
|
554
|
+
return current;
|
|
555
|
+
}
|
|
556
|
+
function NumberControl({ value, min, max, disabled, onCommit }) {
|
|
557
|
+
const [draft, setDraft] = (0, import_react4.useState)(value === void 0 ? "" : String(value));
|
|
558
|
+
(0, import_react4.useEffect)(() => {
|
|
559
|
+
setDraft(value === void 0 ? "" : String(value));
|
|
560
|
+
}, [value]);
|
|
561
|
+
const commit = () => {
|
|
562
|
+
const parsed = Number(draft);
|
|
563
|
+
const lower = min ?? Number.NEGATIVE_INFINITY;
|
|
564
|
+
const upper = max ?? Number.POSITIVE_INFINITY;
|
|
565
|
+
if (!Number.isInteger(parsed) || parsed < lower || parsed > upper) {
|
|
566
|
+
setDraft(value === void 0 ? "" : String(value));
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
if (parsed !== value) onCommit(parsed);
|
|
570
|
+
};
|
|
571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
572
|
+
"input",
|
|
573
|
+
{
|
|
574
|
+
type: "number",
|
|
575
|
+
min,
|
|
576
|
+
max,
|
|
577
|
+
value: draft,
|
|
578
|
+
disabled,
|
|
579
|
+
onChange: (event) => {
|
|
580
|
+
setDraft(event.target.value);
|
|
581
|
+
},
|
|
582
|
+
onBlur: commit,
|
|
583
|
+
onKeyDown: (event) => {
|
|
584
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
585
|
+
},
|
|
586
|
+
style: pageStyles.formControl
|
|
587
|
+
}
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
function TextControl({ value, disabled, onCommit }) {
|
|
591
|
+
const [draft, setDraft] = (0, import_react4.useState)(value);
|
|
592
|
+
(0, import_react4.useEffect)(() => {
|
|
593
|
+
setDraft(value);
|
|
594
|
+
}, [value]);
|
|
595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
596
|
+
"input",
|
|
597
|
+
{
|
|
598
|
+
type: "text",
|
|
599
|
+
value: draft,
|
|
600
|
+
disabled,
|
|
601
|
+
onChange: (event) => {
|
|
602
|
+
setDraft(event.target.value);
|
|
603
|
+
},
|
|
604
|
+
onBlur: () => {
|
|
605
|
+
if (draft !== value) onCommit(draft);
|
|
606
|
+
},
|
|
607
|
+
onKeyDown: (event) => {
|
|
608
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
609
|
+
},
|
|
610
|
+
style: pageStyles.formControl
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
function ListControl({ value, disabled, onCommit }) {
|
|
615
|
+
const joined = value.join(", ");
|
|
616
|
+
const [draft, setDraft] = (0, import_react4.useState)(joined);
|
|
617
|
+
(0, import_react4.useEffect)(() => {
|
|
618
|
+
setDraft(value.join(", "));
|
|
619
|
+
}, [value]);
|
|
620
|
+
const commit = () => {
|
|
621
|
+
const next = draft.split(",").map((item) => item.trim()).filter((item) => item !== "");
|
|
622
|
+
if (next.join("\0") !== value.join("\0")) onCommit(next);
|
|
623
|
+
};
|
|
624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
625
|
+
"input",
|
|
626
|
+
{
|
|
627
|
+
type: "text",
|
|
628
|
+
value: draft,
|
|
629
|
+
disabled,
|
|
630
|
+
placeholder: "todo_write, ask_user_question",
|
|
631
|
+
onChange: (event) => {
|
|
632
|
+
setDraft(event.target.value);
|
|
633
|
+
},
|
|
634
|
+
onBlur: commit,
|
|
635
|
+
onKeyDown: (event) => {
|
|
636
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
637
|
+
},
|
|
638
|
+
style: pageStyles.formControl
|
|
639
|
+
}
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
function renderControl(field, value, disabled, commit, t) {
|
|
643
|
+
switch (field.kind) {
|
|
644
|
+
case "switch":
|
|
645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
646
|
+
import_dsh_client_ui_primitives2.Switch,
|
|
647
|
+
{
|
|
648
|
+
checked: value === true,
|
|
649
|
+
label: t(field.label),
|
|
650
|
+
disabled,
|
|
651
|
+
onChange: (next) => {
|
|
652
|
+
commit(next);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
);
|
|
656
|
+
case "number":
|
|
657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
658
|
+
NumberControl,
|
|
659
|
+
{
|
|
660
|
+
value: typeof value === "number" ? value : void 0,
|
|
661
|
+
min: field.min,
|
|
662
|
+
max: field.max,
|
|
663
|
+
disabled,
|
|
664
|
+
onCommit: commit
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
case "text":
|
|
668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TextControl, { value: typeof value === "string" ? value : "", disabled, onCommit: commit });
|
|
669
|
+
case "list":
|
|
670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
671
|
+
ListControl,
|
|
672
|
+
{
|
|
673
|
+
value: Array.isArray(value) ? value.filter((item) => typeof item === "string") : [],
|
|
674
|
+
disabled,
|
|
675
|
+
onCommit: (next) => {
|
|
676
|
+
commit(next);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
);
|
|
680
|
+
case "select":
|
|
681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
682
|
+
"select",
|
|
683
|
+
{
|
|
684
|
+
value: typeof value === "string" ? value : "",
|
|
685
|
+
disabled,
|
|
686
|
+
onChange: (event) => {
|
|
687
|
+
commit(event.target.value);
|
|
688
|
+
},
|
|
689
|
+
style: pageStyles.formControl,
|
|
690
|
+
children: (field.options ?? []).map((option) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: option.value, children: t(option.label) }, option.value))
|
|
691
|
+
}
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function ConfigForm({ t, title, description, fields }) {
|
|
696
|
+
const [config, setConfig] = (0, import_react4.useState)({});
|
|
697
|
+
const [status, setStatus] = (0, import_react4.useState)("loading");
|
|
698
|
+
const [message, setMessage] = (0, import_react4.useState)("");
|
|
699
|
+
(0, import_react4.useEffect)(() => {
|
|
700
|
+
let cancelled = false;
|
|
701
|
+
void (async () => {
|
|
702
|
+
const view = await readPluginConfig();
|
|
703
|
+
if (cancelled) return;
|
|
704
|
+
if (view === void 0) {
|
|
705
|
+
setStatus("unavailable");
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
setConfig(view.value);
|
|
709
|
+
setStatus("ready");
|
|
710
|
+
})();
|
|
711
|
+
return () => {
|
|
712
|
+
cancelled = true;
|
|
713
|
+
};
|
|
714
|
+
}, []);
|
|
715
|
+
const save = async (path, value) => {
|
|
716
|
+
setStatus("saving");
|
|
717
|
+
setMessage("");
|
|
718
|
+
const result = await writePluginConfig(path, value);
|
|
719
|
+
if (result.ok) {
|
|
720
|
+
if (result.value !== void 0) setConfig(result.value);
|
|
721
|
+
setStatus("saved");
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
setStatus("failed");
|
|
725
|
+
setMessage(result.message ?? result.code ?? "");
|
|
726
|
+
};
|
|
727
|
+
const disabled = status === "loading" || status === "saving" || status === "unavailable";
|
|
728
|
+
const statusText = status === "loading" ? t("form.loading") : status === "saving" ? t("form.saving") : status === "saved" ? t("form.saved") : status === "failed" ? t("form.failed") + (message === "" ? "" : " (" + message + ")") : status === "unavailable" ? t("form.unavailable") : t("form.autoSave");
|
|
729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: pageStyles.card, children: [
|
|
730
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.cardTitle, children: t(title) }),
|
|
731
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.cardBody, children: t(description) }),
|
|
732
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.form, children: fields.map((field) => {
|
|
733
|
+
const value = readPath(config, field.path);
|
|
734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: pageStyles.formRow, children: [
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.formLabel, children: t(field.label) }),
|
|
736
|
+
field.hint === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.formHint, children: t(field.hint) }),
|
|
737
|
+
renderControl(field, value, disabled, (next) => {
|
|
738
|
+
void save(field.path, next);
|
|
739
|
+
}, t)
|
|
740
|
+
] }, field.path.join("."));
|
|
741
|
+
}) }),
|
|
742
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: pageStyles.formStatus, children: statusText })
|
|
743
|
+
] });
|
|
744
|
+
}
|
|
745
|
+
var AUTO_REVIEW_FIELDS = [
|
|
746
|
+
{ path: ["autoReviewFix", "translateApprovalReason"], label: "form.autoReview.translate", hint: "form.autoReview.translateHint", kind: "switch" },
|
|
747
|
+
{ path: ["autoReviewFix", "keepPresetGuard"], label: "form.autoReview.keepPreset", hint: "form.autoReview.keepPresetHint", kind: "switch" },
|
|
748
|
+
{ path: ["autoReviewFix", "translateTimeoutMs"], label: "form.autoReview.timeout", kind: "number", min: 500, max: 6e4 },
|
|
749
|
+
{ path: ["autoReviewFix", "translateMaxChars"], label: "form.autoReview.maxChars", kind: "number", min: 100, max: 2e4 },
|
|
750
|
+
{ path: ["autoReviewFix", "translateProvider"], label: "form.autoReview.provider", hint: "form.autoReview.routeHint", kind: "text" },
|
|
751
|
+
{ path: ["autoReviewFix", "translateModel"], label: "form.autoReview.model", hint: "form.autoReview.routeHint", kind: "text" }
|
|
752
|
+
];
|
|
753
|
+
var TASK_GUARD_FIELDS = [
|
|
754
|
+
{ path: ["taskGuard", "enabled"], label: "form.taskGuard.enabled", hint: "form.taskGuard.enabledHint", kind: "switch" },
|
|
755
|
+
{
|
|
756
|
+
path: ["taskGuard", "locale"],
|
|
757
|
+
label: "form.taskGuard.locale",
|
|
758
|
+
kind: "select",
|
|
759
|
+
options: [
|
|
760
|
+
{ value: "zh", label: "form.taskGuard.localeZh" },
|
|
761
|
+
{ value: "en", label: "form.taskGuard.localeEn" }
|
|
762
|
+
]
|
|
763
|
+
},
|
|
764
|
+
{ path: ["taskGuard", "staleAfterCalls"], label: "form.taskGuard.stale", kind: "number", min: 1, max: 1e3 },
|
|
765
|
+
{ path: ["taskGuard", "repeatEveryCalls"], label: "form.taskGuard.repeat", kind: "number", min: 0, max: 1e3 },
|
|
766
|
+
{ path: ["taskGuard", "blockAfterCalls"], label: "form.taskGuard.block", hint: "form.taskGuard.blockHint", kind: "number", min: 0, max: 1e4 },
|
|
767
|
+
{ path: ["taskGuard", "rejectMissingActive"], label: "form.taskGuard.rejectMissingActive", kind: "switch" },
|
|
768
|
+
{
|
|
769
|
+
path: ["taskGuard", "sourceKind"],
|
|
770
|
+
label: "form.taskGuard.sourceKind",
|
|
771
|
+
kind: "select",
|
|
772
|
+
options: [
|
|
773
|
+
{ value: "auto", label: "form.taskGuard.sourceAuto" },
|
|
774
|
+
{ value: "v3", label: "form.taskGuard.sourceV3" },
|
|
775
|
+
{ value: "v4", label: "form.taskGuard.sourceV4" }
|
|
776
|
+
]
|
|
777
|
+
},
|
|
778
|
+
{ path: ["taskGuard", "maxListItems"], label: "form.taskGuard.maxListItems", kind: "number", min: 1, max: 100 },
|
|
779
|
+
{ path: ["taskGuard", "detectStepIntent"], label: "form.taskGuard.detectStepIntent", hint: "form.taskGuard.detectStepIntentHint", kind: "switch" },
|
|
780
|
+
{ path: ["taskGuard", "translateTodoContent"], label: "form.taskGuard.translateTodo", hint: "form.taskGuard.translateTodoHint", kind: "switch" },
|
|
781
|
+
{ path: ["taskGuard", "todoTranslationTimeoutMs"], label: "form.taskGuard.todoTimeout", kind: "number", min: 500, max: 15e3 },
|
|
782
|
+
{ path: ["taskGuard", "include"], label: "form.taskGuard.include", hint: "form.taskGuard.listHint", kind: "list" },
|
|
783
|
+
{ path: ["taskGuard", "exclude"], label: "form.taskGuard.exclude", hint: "form.taskGuard.listHint", kind: "list" }
|
|
784
|
+
];
|
|
785
|
+
|
|
786
|
+
// src/client/SettingsSection.tsx
|
|
787
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
788
|
+
function SettingsSection({ t }) {
|
|
789
|
+
const [tab, setTab] = (0, import_react5.useState)("restart");
|
|
790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.page, children: [
|
|
791
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { style: pageStyles.heading, children: t("page.title") }),
|
|
792
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: pageStyles.lede, children: t("page.description") }),
|
|
793
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.tabs, role: "tablist", children: [
|
|
794
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
795
|
+
"button",
|
|
796
|
+
{
|
|
797
|
+
type: "button",
|
|
798
|
+
role: "tab",
|
|
799
|
+
"aria-selected": tab === "restart",
|
|
800
|
+
onClick: () => {
|
|
801
|
+
setTab("restart");
|
|
802
|
+
},
|
|
803
|
+
style: tab === "restart" ? { ...pageStyles.tab, ...pageStyles.tabActive } : pageStyles.tab,
|
|
804
|
+
children: t("page.tab.restart")
|
|
805
|
+
}
|
|
806
|
+
),
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
808
|
+
"button",
|
|
809
|
+
{
|
|
810
|
+
type: "button",
|
|
811
|
+
role: "tab",
|
|
812
|
+
"aria-selected": tab === "autoReview",
|
|
813
|
+
onClick: () => {
|
|
814
|
+
setTab("autoReview");
|
|
815
|
+
},
|
|
816
|
+
style: tab === "autoReview" ? { ...pageStyles.tab, ...pageStyles.tabActive } : pageStyles.tab,
|
|
817
|
+
children: t("page.tab.autoReview")
|
|
818
|
+
}
|
|
819
|
+
),
|
|
820
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
821
|
+
"button",
|
|
822
|
+
{
|
|
823
|
+
type: "button",
|
|
824
|
+
role: "tab",
|
|
825
|
+
"aria-selected": tab === "taskGuard",
|
|
826
|
+
onClick: () => {
|
|
827
|
+
setTab("taskGuard");
|
|
828
|
+
},
|
|
829
|
+
style: tab === "taskGuard" ? { ...pageStyles.tab, ...pageStyles.tabActive } : pageStyles.tab,
|
|
830
|
+
children: t("page.tab.taskGuard")
|
|
831
|
+
}
|
|
832
|
+
),
|
|
833
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
834
|
+
"button",
|
|
835
|
+
{
|
|
836
|
+
type: "button",
|
|
837
|
+
role: "tab",
|
|
838
|
+
"aria-selected": tab === "components",
|
|
839
|
+
onClick: () => {
|
|
840
|
+
setTab("components");
|
|
841
|
+
},
|
|
842
|
+
style: tab === "components" ? { ...pageStyles.tab, ...pageStyles.tabActive } : pageStyles.tab,
|
|
843
|
+
children: t("page.tab.components")
|
|
844
|
+
}
|
|
845
|
+
)
|
|
846
|
+
] }),
|
|
847
|
+
tab === "restart" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RestartCard, { t }) : tab === "autoReview" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
848
|
+
ConfigForm,
|
|
849
|
+
{
|
|
850
|
+
t,
|
|
851
|
+
title: "page.autoReview.title",
|
|
852
|
+
description: "page.autoReview.description",
|
|
853
|
+
fields: AUTO_REVIEW_FIELDS
|
|
854
|
+
}
|
|
855
|
+
) : tab === "taskGuard" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
856
|
+
ConfigForm,
|
|
857
|
+
{
|
|
858
|
+
t,
|
|
859
|
+
title: "page.taskGuard.title",
|
|
860
|
+
description: "page.taskGuard.description",
|
|
861
|
+
fields: TASK_GUARD_FIELDS
|
|
862
|
+
}
|
|
863
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.card, children: [
|
|
864
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.cardTitle, children: t("page.components.title") }),
|
|
865
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.componentRow, children: [
|
|
866
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentName, children: t("page.components.appearance") }),
|
|
867
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.appearanceHint") })
|
|
868
|
+
] }),
|
|
869
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.componentRow, children: [
|
|
870
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentName, children: t("page.components.autoReviewFix") }),
|
|
871
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.autoReviewFixHint") })
|
|
872
|
+
] }),
|
|
873
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.componentRow, children: [
|
|
874
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentName, children: t("page.components.taskGuard") }),
|
|
875
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.taskGuardHint") })
|
|
876
|
+
] }),
|
|
877
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: pageStyles.componentRow, children: [
|
|
878
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentName, children: t("page.components.restart") }),
|
|
879
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.restartHint") })
|
|
880
|
+
] }),
|
|
881
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: pageStyles.cardStatus, children: t("page.components.note") })
|
|
882
|
+
] })
|
|
883
|
+
] });
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
// src/client/driver.ts
|
|
887
|
+
var TICK_MS = 2e4;
|
|
888
|
+
var RETRY_MS = 6e4;
|
|
889
|
+
var ScheduleDriver = class {
|
|
890
|
+
/**
|
|
891
|
+
* @param themeOf - resolves the theme service lazily, so the row still works
|
|
892
|
+
* while the theme plugin is absent or reloading.
|
|
893
|
+
* @param now - clock seam for tests and for hosts with a fake clock.
|
|
894
|
+
*/
|
|
895
|
+
constructor(themeOf, now = () => /* @__PURE__ */ new Date()) {
|
|
896
|
+
this.themeOf = themeOf;
|
|
897
|
+
this.now = now;
|
|
898
|
+
}
|
|
899
|
+
state = {
|
|
900
|
+
config: { ...DEFAULT_SCHEDULE_CONFIG },
|
|
901
|
+
bridge: "loading",
|
|
902
|
+
write: "idle",
|
|
903
|
+
applied: void 0
|
|
904
|
+
};
|
|
905
|
+
listeners = /* @__PURE__ */ new Set();
|
|
906
|
+
timer;
|
|
907
|
+
started = false;
|
|
908
|
+
lastRefresh = 0;
|
|
909
|
+
/** Stable snapshot reader for `useSyncExternalStore`. */
|
|
910
|
+
getState = () => this.state;
|
|
911
|
+
/** Subscribe to state changes; returns the unsubscriber. */
|
|
912
|
+
subscribe = (listener) => {
|
|
913
|
+
this.listeners.add(listener);
|
|
914
|
+
return () => {
|
|
915
|
+
this.listeners.delete(listener);
|
|
916
|
+
};
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* Start the loop. Idempotent; the returned function stops it.
|
|
920
|
+
* @returns cleanup for `ctx.effect`.
|
|
921
|
+
*/
|
|
922
|
+
start() {
|
|
923
|
+
if (this.started) return () => {
|
|
924
|
+
};
|
|
925
|
+
this.started = true;
|
|
926
|
+
void this.refresh();
|
|
927
|
+
this.timer = setInterval(() => {
|
|
928
|
+
this.tick();
|
|
929
|
+
}, TICK_MS);
|
|
930
|
+
const onWake = () => {
|
|
931
|
+
this.tick();
|
|
932
|
+
};
|
|
933
|
+
const doc = typeof document === "undefined" ? void 0 : document;
|
|
934
|
+
doc?.addEventListener("visibilitychange", onWake);
|
|
935
|
+
if (typeof window !== "undefined") window.addEventListener("focus", onWake);
|
|
936
|
+
return () => {
|
|
937
|
+
this.started = false;
|
|
938
|
+
if (this.timer !== void 0) clearInterval(this.timer);
|
|
939
|
+
this.timer = void 0;
|
|
940
|
+
doc?.removeEventListener("visibilitychange", onWake);
|
|
941
|
+
if (typeof window !== "undefined") window.removeEventListener("focus", onWake);
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Load the durable config (initial load, row mount, and retry after a
|
|
946
|
+
* failed bridge). A missing namespace keeps the defaults.
|
|
947
|
+
*/
|
|
948
|
+
async refresh() {
|
|
949
|
+
this.lastRefresh = Date.now();
|
|
950
|
+
const config = await readScheduleConfig();
|
|
951
|
+
if (config === void 0) {
|
|
952
|
+
if (this.state.bridge !== "unavailable") this.setState({ bridge: "unavailable" });
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
this.setState({ config, bridge: "ready", write: this.state.write === "failed" ? "idle" : this.state.write });
|
|
956
|
+
this.apply();
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Persist a patch through the Host bridge and apply it right away. A refused
|
|
960
|
+
* write reverts to the previously persisted config and reports `failed`.
|
|
961
|
+
* @param patch - the fields the user changed.
|
|
962
|
+
*/
|
|
963
|
+
async update(patch) {
|
|
964
|
+
const next = normalizeScheduleConfig({ ...this.state.config, ...patch });
|
|
965
|
+
if (next.enabled === this.state.config.enabled && next.lightStart === this.state.config.lightStart && next.lightEnd === this.state.config.lightEnd) return;
|
|
966
|
+
this.setState({ write: "saving" });
|
|
967
|
+
const saved = await writeScheduleConfig(next);
|
|
968
|
+
if (saved === void 0) {
|
|
969
|
+
this.setState({ write: "failed" });
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
this.setState({ config: saved, bridge: "ready", write: "saved", applied: void 0 });
|
|
973
|
+
this.apply();
|
|
974
|
+
}
|
|
975
|
+
/** Re-read the clock, retry a dead bridge, and apply a changed period. */
|
|
976
|
+
tick() {
|
|
977
|
+
if (this.state.bridge === "unavailable" && Date.now() - this.lastRefresh > RETRY_MS) {
|
|
978
|
+
void this.refresh();
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
this.apply();
|
|
982
|
+
}
|
|
983
|
+
apply() {
|
|
984
|
+
if (!this.state.config.enabled) {
|
|
985
|
+
if (this.state.applied !== void 0) this.setState({ applied: void 0 });
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
const period = periodAt(this.now(), this.state.config);
|
|
989
|
+
if (this.state.applied === period) return;
|
|
990
|
+
const theme = this.themeOf();
|
|
991
|
+
if (theme === void 0) return;
|
|
992
|
+
try {
|
|
993
|
+
theme.setTheme(period);
|
|
994
|
+
} catch (error) {
|
|
995
|
+
console.error("[dsh-mcviseron-plugin] failed to apply the scheduled theme:", error);
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
this.setState({ applied: period });
|
|
999
|
+
}
|
|
1000
|
+
setState(patch) {
|
|
1001
|
+
this.state = { ...this.state, ...patch };
|
|
1002
|
+
for (const listener of this.listeners) listener();
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
// src/client/locales.ts
|
|
1007
|
+
var zh = {
|
|
1008
|
+
"row.title": "\u6309\u65F6\u95F4\u81EA\u52A8\u5207\u6362\u6DF1\u6D45\u8272",
|
|
1009
|
+
"row.description": "\u6309\u672C\u673A\u65F6\u95F4\u5728\u6D45\u8272\u4E0E\u6DF1\u8272\u4E4B\u95F4\u81EA\u52A8\u5207\u6362\uFF1A\u65E9\u95F4\u65F6\u6BB5\u7528\u6D45\u8272\uFF0C\u5176\u4F59\u65F6\u95F4\u7528\u6DF1\u8272",
|
|
1010
|
+
"row.enable": "\u5F00\u542F\u6309\u65F6\u95F4\u81EA\u52A8\u5207\u6362\u6DF1\u6D45\u8272",
|
|
1011
|
+
"row.disable": "\u5173\u95ED\u6309\u65F6\u95F4\u81EA\u52A8\u5207\u6362\u6DF1\u6D45\u8272",
|
|
1012
|
+
"row.lightStart": "\u65E9\u95F4\u5F00\u59CB",
|
|
1013
|
+
"row.lightEnd": "\u65E9\u95F4\u7ED3\u675F",
|
|
1014
|
+
"row.dash": "\u81F3",
|
|
1015
|
+
"row.next": "\u4E0B\u6B21\u5207\u6362",
|
|
1016
|
+
"row.timeHint": "\u4F7F\u7528\u672C\u673A\u65F6\u95F4\uFF0C\u81EA\u52A8\u9002\u914D\u65F6\u533A\u4E0E\u590F\u4EE4\u65F6",
|
|
1017
|
+
"status.light": "\u5F53\u524D\u4E3A\u65E9\u95F4\uFF08\u6D45\u8272\uFF09",
|
|
1018
|
+
"status.dark": "\u5F53\u524D\u4E3A\u665A\u95F4\uFF08\u6DF1\u8272\uFF09",
|
|
1019
|
+
"status.off": "\u5DF2\u5173\u95ED\uFF0C\u914D\u8272\u8DDF\u968F\u5916\u89C2\u8BBE\u7F6E\u4E2D\u7684\u9009\u62E9",
|
|
1020
|
+
"status.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u63D2\u4EF6\u8BBE\u7F6E\uFF1A\u8BF7\u786E\u8BA4 profile \u4E2D\u7684\u63D2\u4EF6\u6761\u76EE id \u4E3A mcviseron",
|
|
1021
|
+
"status.saving": "\u4FDD\u5B58\u4E2D\u2026",
|
|
1022
|
+
"status.saved": "\u5DF2\u4FDD\u5B58",
|
|
1023
|
+
"status.failed": "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
1024
|
+
"restart.title": "\u91CD\u542F DeepSeek Harness",
|
|
1025
|
+
"restart.description": "\u5173\u95ED\u5E76\u91CD\u65B0\u542F\u52A8\u684C\u9762\u5E94\u7528\uFF1B\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u4F1A\u88AB\u4E2D\u65AD",
|
|
1026
|
+
"restart.button": "\u91CD\u542F",
|
|
1027
|
+
"restart.checking": "\u6B63\u5728\u68C0\u67E5\u684C\u9762\u73AF\u5883\u2026",
|
|
1028
|
+
"restart.ready": "\u4EC5\u91CD\u542F\u5E94\u7528\uFF0C\u4E0D\u4F1A\u4FEE\u6539\u63D2\u4EF6\u6216\u914D\u7F6E",
|
|
1029
|
+
"restart.restarting": "\u6B63\u5728\u91CD\u542F\u2026\u7A97\u53E3\u4F1A\u77ED\u6682\u5173\u95ED",
|
|
1030
|
+
"restart.failed": "\u91CD\u542F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
1031
|
+
"restart.confirm": "\u786E\u5B9A\u8981\u91CD\u542F DeepSeek Harness \u5417\uFF1F\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u4F1A\u88AB\u4E2D\u65AD\u3002",
|
|
1032
|
+
"page.title": "MCviseron \u63D2\u4EF6",
|
|
1033
|
+
"page.description": "\u603B\u63D2\u4EF6\u7684\u7EC4\u4EF6\u8BBE\u7F6E\u3002\u5916\u89C2\u8BBE\u7F6E\u4ECD\u5728\u300C\u901A\u7528 \u2192 \u5916\u89C2\u300D\u4E2D\u3002",
|
|
1034
|
+
"page.tab.restart": "\u91CD\u542F",
|
|
1035
|
+
"page.tab.components": "\u7EC4\u4EF6",
|
|
1036
|
+
"page.restart.title": "\u91CD\u542F DeepSeek Harness",
|
|
1037
|
+
"page.restart.description": "\u5173\u95ED\u5E76\u91CD\u65B0\u542F\u52A8\u684C\u9762\u5E94\u7528\uFF1B\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u4F1A\u88AB\u4E2D\u65AD",
|
|
1038
|
+
"page.restart.ready": "\u53EF\u7528",
|
|
1039
|
+
"page.restart.unavailable": "\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u91CD\u542F\uFF08\u4EC5 Windows \u684C\u9762\u7248\u53EF\u7528\uFF09",
|
|
1040
|
+
"page.restart.routeMissing": "\u91CD\u542F\u63A5\u53E3\u672A\u52A0\u8F7D\uFF1A\u8BF7\u786E\u8BA4 mcviseron-restart \u6761\u76EE\u5DF2\u542F\u7528",
|
|
1041
|
+
"page.restart.appPath": "\u5E94\u7528\u8DEF\u5F84",
|
|
1042
|
+
"page.restart.button": "\u91CD\u542F",
|
|
1043
|
+
"page.restart.restarting": "\u6B63\u5728\u91CD\u542F\u2026\u7A97\u53E3\u4F1A\u77ED\u6682\u5173\u95ED",
|
|
1044
|
+
"page.restart.failed": "\u91CD\u542F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
1045
|
+
"page.restart.confirm": "\u786E\u5B9A\u8981\u91CD\u542F DeepSeek Harness \u5417\uFF1F\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u4F1A\u88AB\u4E2D\u65AD\u3002",
|
|
1046
|
+
"page.components.title": "\u7EC4\u4EF6",
|
|
1047
|
+
"page.components.appearance": "\u5916\u89C2 \xB7 \u6309\u65F6\u95F4\u5207\u6362",
|
|
1048
|
+
"page.components.appearanceHint": "\u8BBE\u7F6E\u4F4D\u4E8E\u300C\u901A\u7528 \u2192 \u5916\u89C2\u300D",
|
|
1049
|
+
"page.components.autoReviewFix": "Auto review \u4FEE\u590D",
|
|
1050
|
+
"page.components.autoReviewFixHint": "\u672C\u9875\u300CAuto review \u4FEE\u590D\u300D\u5B50\u9875",
|
|
1051
|
+
"page.components.taskGuard": "Todo \u8BA1\u5212\u5B88\u536B",
|
|
1052
|
+
"page.components.taskGuardHint": "\u672C\u9875\u300CTodo \u5B88\u536B\u300D\u5B50\u9875",
|
|
1053
|
+
"page.components.restart": "\u91CD\u542F DeepSeek Harness",
|
|
1054
|
+
"page.components.restartHint": "\u672C\u9875\u300C\u91CD\u542F\u300D\u5B50\u9875",
|
|
1055
|
+
"page.components.note": "\u7EC4\u4EF6\u914D\u7F6E\u5199\u5165 master \u6761\u76EE\uFF08mcviseron\uFF09\u7684 Config\uFF1B\u82E5\u7EC4\u4EF6\u4ECD\u4F7F\u7528\u65E7\u503C\uFF0C\u91CD\u542F DSH \u540E\u751F\u6548\u3002",
|
|
1056
|
+
"page.fallback.note": "\u8BBE\u7F6E\u5206\u533A\u672A\u52A0\u8F7D\uFF0C\u91CD\u542F\u5165\u53E3\u6682\u65F6\u56DE\u9000\u5230\u901A\u7528\u8BBE\u7F6E\u3002",
|
|
1057
|
+
"page.tab.autoReview": "Auto review \u4FEE\u590D",
|
|
1058
|
+
"page.tab.taskGuard": "Todo \u5B88\u536B",
|
|
1059
|
+
"page.autoReview.title": "Auto review \u4FEE\u590D",
|
|
1060
|
+
"page.autoReview.description": "\u9000\u51FA\u4FDD\u62A4\u4E0E\u5BA1\u6279\u7406\u7531\u4E2D\u6587\u7FFB\u8BD1\uFF1B\u7FFB\u8BD1\u540C\u65F6\u5199\u5165\u5BA1\u6279\u4E8B\u4EF6\uFF0C\u90AE\u7BB1\u63D0\u9192\u4E5F\u80FD\u6536\u5230\u3002",
|
|
1061
|
+
"page.taskGuard.title": "Todo \u8BA1\u5212\u5B88\u536B",
|
|
1062
|
+
"page.taskGuard.description": "\u591A\u9636\u6BB5\u4EFB\u52A1\u5FD8\u8BB0\u66F4\u65B0 todo \u65F6\u53D1\u51FA\u5EFA\u8BAE\u6027 notice\u3002",
|
|
1063
|
+
"form.loading": "\u8BFB\u53D6\u4E2D\u2026",
|
|
1064
|
+
"form.saving": "\u4FDD\u5B58\u4E2D\u2026",
|
|
1065
|
+
"form.saved": "\u5DF2\u4FDD\u5B58",
|
|
1066
|
+
"form.failed": "\u4FDD\u5B58\u5931\u8D25",
|
|
1067
|
+
"form.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u63D2\u4EF6\u8BBE\u7F6E\uFF1A\u8BF7\u786E\u8BA4 profile \u4E2D\u7684\u63D2\u4EF6\u6761\u76EE id \u4E3A mcviseron",
|
|
1068
|
+
"form.autoSave": "\u4FEE\u6539\u540E\u81EA\u52A8\u4FDD\u5B58",
|
|
1069
|
+
"form.autoReview.translate": "\u7FFB\u8BD1\u5BA1\u6279\u7406\u7531",
|
|
1070
|
+
"form.autoReview.translateHint": "\u82F1\u6587\u5BA1\u67E5\u7406\u7531\u4F1A\u9644\u4E0A\u4E2D\u6587\u7FFB\u8BD1\uFF0C\u5E76\u5199\u5165\u5BA1\u6279\u4E8B\u4EF6\uFF1B\u8F6C\u624B\u52A8\u540E\u88AB\u62D2\u65F6\uFF0C\u81EA\u52A8\u5BA1\u67E5\u7406\u7531\u4F1A\u4F5C\u4E3A notice \u4EA4\u56DE AI",
|
|
1071
|
+
"form.autoReview.keepPreset": "\u9000\u51FA\u65F6\u4FDD\u6301\u6743\u9650\u9884\u8BBE",
|
|
1072
|
+
"form.autoReview.keepPresetHint": "\u5173\u95ED DSH \u65F6\u4E0D\u518D\u628A Auto \u4F1A\u8BDD\u6539\u6210\u5B8C\u5168\u8BBF\u95EE",
|
|
1073
|
+
"form.autoReview.timeout": "\u7FFB\u8BD1\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
1074
|
+
"form.autoReview.maxChars": "\u6700\u5927\u7FFB\u8BD1\u5B57\u7B26\u6570",
|
|
1075
|
+
"form.autoReview.provider": "\u7FFB\u8BD1 Provider",
|
|
1076
|
+
"form.autoReview.model": "\u7FFB\u8BD1 Model",
|
|
1077
|
+
"form.autoReview.routeHint": "\u7559\u7A7A\u5219\u8DDF\u968F\u5F53\u524D\u4F1A\u8BDD\u7684\u6A21\u578B\u8DEF\u7531",
|
|
1078
|
+
"form.taskGuard.enabled": "\u542F\u7528 Todo \u8BA1\u5212\u5B88\u536B",
|
|
1079
|
+
"form.taskGuard.enabledHint": "\u591A\u9636\u6BB5\u4EFB\u52A1\u5FD8\u8BB0\u66F4\u65B0 todo \u65F6\u53D1\u51FA\u5EFA\u8BAE\u6027 notice",
|
|
1080
|
+
"form.taskGuard.locale": "\u6A21\u578B\u53EF\u89C1\u6587\u672C\u8BED\u8A00",
|
|
1081
|
+
"form.taskGuard.localeZh": "\u4E2D\u6587",
|
|
1082
|
+
"form.taskGuard.localeEn": "English",
|
|
1083
|
+
"form.taskGuard.stale": "\u505C\u6EDE\u9608\u503C\uFF08\u5DE5\u5177\u8C03\u7528\u6B21\u6570\uFF09",
|
|
1084
|
+
"form.taskGuard.repeat": "\u91CD\u590D\u63D0\u9192\u95F4\u9694\uFF08\u5DE5\u5177\u8C03\u7528\u6B21\u6570\uFF09",
|
|
1085
|
+
"form.taskGuard.block": "\u786C\u62E6\u622A\u9608\u503C",
|
|
1086
|
+
"form.taskGuard.blockHint": "0 = \u4E0D\u786C\u62E6\u622A",
|
|
1087
|
+
"form.taskGuard.rejectMissingActive": "\u62D2\u7EDD\u7F3A\u5C11 in_progress \u7684\u5199\u5165",
|
|
1088
|
+
"form.taskGuard.sourceKind": "notice source kind",
|
|
1089
|
+
"form.taskGuard.sourceAuto": "auto\uFF08\u6309\u4F1A\u8BDD\u683C\u5F0F\uFF09",
|
|
1090
|
+
"form.taskGuard.sourceV3": "v3",
|
|
1091
|
+
"form.taskGuard.sourceV4": "v4",
|
|
1092
|
+
"form.taskGuard.maxListItems": "notice \u6700\u591A\u5217\u51FA\u4EFB\u52A1\u6570",
|
|
1093
|
+
"form.taskGuard.detectStepIntent": "\u8BC6\u522B\u6B65\u9AA4\u610F\u56FE",
|
|
1094
|
+
"form.taskGuard.detectStepIntentHint": "\u8BC6\u522B\u300CNow I will \u2026\u300D\u7B49\u6B65\u9AA4\u610F\u56FE\uFF0C\u4EE5\u53CA\u300CAll nets routed\u300D\u300CDRC passes\u300D\u300C\u539F\u7406\u56FE\u5B8C\u6210\u300D\u7B49\u9636\u6BB5\u5B8C\u6210\u8BED\u53E5\uFF1B\u547D\u4E2D\u65F6\u63D0\u4F9B\u53EF\u76F4\u63A5\u53D1\u9001\u7684 todo_write",
|
|
1095
|
+
"form.taskGuard.translateTodo": "\u4E2D\u6587\u5C55\u793A todo \u6807\u9898",
|
|
1096
|
+
"form.taskGuard.translateTodoHint": "\u53EA\u5F71\u54CD notice \u5C55\u793A\uFF0C\u4E0D\u6539\u5199\u6A21\u578B\u5199\u5165\u7684 todo",
|
|
1097
|
+
"form.taskGuard.todoTimeout": "todo \u7FFB\u8BD1\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
1098
|
+
"form.taskGuard.include": "\u53EA\u7EDF\u8BA1\u8FD9\u4E9B\u5DE5\u5177",
|
|
1099
|
+
"form.taskGuard.exclude": "\u4E0D\u7EDF\u8BA1\u8FD9\u4E9B\u5DE5\u5177",
|
|
1100
|
+
"form.taskGuard.listHint": "\u9017\u53F7\u5206\u9694\uFF0C\u652F\u6301 *\uFF1B\u7559\u7A7A\u8868\u793A\u5168\u90E8"
|
|
1101
|
+
};
|
|
1102
|
+
var en = {
|
|
1103
|
+
"row.title": "Switch light/dark by time",
|
|
1104
|
+
"row.description": "Follow the local wall clock: light during the morning window, dark for the rest of the day",
|
|
1105
|
+
"row.enable": "Enable the light/dark schedule",
|
|
1106
|
+
"row.disable": "Disable the light/dark schedule",
|
|
1107
|
+
"row.lightStart": "Light starts",
|
|
1108
|
+
"row.lightEnd": "Light ends",
|
|
1109
|
+
"row.dash": "to",
|
|
1110
|
+
"row.next": "Next switch",
|
|
1111
|
+
"row.timeHint": "Uses the local wall clock; time zones and daylight saving are handled automatically",
|
|
1112
|
+
"status.light": "Morning window (light)",
|
|
1113
|
+
"status.dark": "Evening window (dark)",
|
|
1114
|
+
"status.off": "Off \u2014 the palette follows the Appearance choice",
|
|
1115
|
+
"status.unavailable": "Cannot read the plugin settings: check that the profile entry id is mcviseron",
|
|
1116
|
+
"status.saving": "Saving\u2026",
|
|
1117
|
+
"status.saved": "Saved",
|
|
1118
|
+
"status.failed": "Save failed \u2014 try again",
|
|
1119
|
+
"restart.title": "Restart DeepSeek Harness",
|
|
1120
|
+
"restart.description": "Closes and relaunches the desktop application; running tasks are interrupted",
|
|
1121
|
+
"restart.button": "Restart",
|
|
1122
|
+
"restart.checking": "Checking the desktop environment\u2026",
|
|
1123
|
+
"restart.ready": "Only the app restarts; plugins and settings are untouched",
|
|
1124
|
+
"restart.restarting": "Restarting\u2026 the window will close briefly",
|
|
1125
|
+
"restart.failed": "Restart failed \u2014 try again",
|
|
1126
|
+
"restart.confirm": "Restart DeepSeek Harness now? Running tasks will be interrupted.",
|
|
1127
|
+
"page.title": "MCviseron plugin",
|
|
1128
|
+
"page.description": "Settings for the master plugin components. Appearance still lives under General \u2192 Appearance.",
|
|
1129
|
+
"page.tab.restart": "Restart",
|
|
1130
|
+
"page.tab.components": "Components",
|
|
1131
|
+
"page.restart.title": "Restart DeepSeek Harness",
|
|
1132
|
+
"page.restart.description": "Closes and relaunches the desktop application; running tasks are interrupted",
|
|
1133
|
+
"page.restart.ready": "Available",
|
|
1134
|
+
"page.restart.unavailable": "Restarting is available only in the Windows desktop app",
|
|
1135
|
+
"page.restart.routeMissing": "The restart route is not loaded: check that the mcviseron-restart entry is enabled",
|
|
1136
|
+
"page.restart.appPath": "App path",
|
|
1137
|
+
"page.restart.button": "Restart",
|
|
1138
|
+
"page.restart.restarting": "Restarting\u2026 the window will close briefly",
|
|
1139
|
+
"page.restart.failed": "Restart failed \u2014 try again",
|
|
1140
|
+
"page.restart.confirm": "Restart DeepSeek Harness now? Running tasks will be interrupted.",
|
|
1141
|
+
"page.components.title": "Components",
|
|
1142
|
+
"page.components.appearance": "Appearance \xB7 light/dark by time",
|
|
1143
|
+
"page.components.appearanceHint": "Configured under General \u2192 Appearance",
|
|
1144
|
+
"page.components.autoReviewFix": "Auto-review fix",
|
|
1145
|
+
"page.components.autoReviewFixHint": "The Auto-review fix tab on this page",
|
|
1146
|
+
"page.components.taskGuard": "Todo plan guard",
|
|
1147
|
+
"page.components.taskGuardHint": "The Todo guard tab on this page",
|
|
1148
|
+
"page.components.restart": "Restart DeepSeek Harness",
|
|
1149
|
+
"page.components.restartHint": "The Restart tab on this page",
|
|
1150
|
+
"page.components.note": "Component settings are written to the mcviseron entry config; restart DSH if a component still uses the old value.",
|
|
1151
|
+
"page.fallback.note": "The settings section is unavailable, so the restart entry falls back to General.",
|
|
1152
|
+
"page.tab.autoReview": "Auto-review fix",
|
|
1153
|
+
"page.tab.taskGuard": "Todo guard",
|
|
1154
|
+
"page.autoReview.title": "Auto-review fix",
|
|
1155
|
+
"page.autoReview.description": "Shutdown guard and Chinese approval-reason translation; the translation is also written into the approval event so email reminders receive it.",
|
|
1156
|
+
"page.taskGuard.title": "Todo plan guard",
|
|
1157
|
+
"page.taskGuard.description": "Advisory notices when multi-stage work stops updating its todo plan.",
|
|
1158
|
+
"form.loading": "Loading\u2026",
|
|
1159
|
+
"form.saving": "Saving\u2026",
|
|
1160
|
+
"form.saved": "Saved",
|
|
1161
|
+
"form.failed": "Save failed",
|
|
1162
|
+
"form.unavailable": "Cannot read the plugin settings: check that the profile entry id is mcviseron",
|
|
1163
|
+
"form.autoSave": "Changes save automatically",
|
|
1164
|
+
"form.autoReview.translate": "Translate the approval reason",
|
|
1165
|
+
"form.autoReview.translateHint": "Appends a Chinese translation to the reviewer note and writes it into the approval event; a manual rejection returns the auto-review reason to the AI",
|
|
1166
|
+
"form.autoReview.keepPreset": "Keep the permission preset on shutdown",
|
|
1167
|
+
"form.autoReview.keepPresetHint": "Stops DSH from rewriting Auto sessions to Full access while exiting",
|
|
1168
|
+
"form.autoReview.timeout": "Translation timeout (ms)",
|
|
1169
|
+
"form.autoReview.maxChars": "Maximum translation characters",
|
|
1170
|
+
"form.autoReview.provider": "Translation provider",
|
|
1171
|
+
"form.autoReview.model": "Translation model",
|
|
1172
|
+
"form.autoReview.routeHint": "Empty follows the current session route",
|
|
1173
|
+
"form.taskGuard.enabled": "Enable the Todo plan guard",
|
|
1174
|
+
"form.taskGuard.enabledHint": "Advisory notices when multi-stage work stops updating its todo plan",
|
|
1175
|
+
"form.taskGuard.locale": "Model-visible language",
|
|
1176
|
+
"form.taskGuard.localeZh": "\u4E2D\u6587",
|
|
1177
|
+
"form.taskGuard.localeEn": "English",
|
|
1178
|
+
"form.taskGuard.stale": "Stale threshold (tool calls)",
|
|
1179
|
+
"form.taskGuard.repeat": "Repeat interval (tool calls)",
|
|
1180
|
+
"form.taskGuard.block": "Hard-stop threshold",
|
|
1181
|
+
"form.taskGuard.blockHint": "0 = never hard-stop",
|
|
1182
|
+
"form.taskGuard.rejectMissingActive": "Reject writes without an in_progress task",
|
|
1183
|
+
"form.taskGuard.sourceKind": "Notice source kind",
|
|
1184
|
+
"form.taskGuard.sourceAuto": "auto (follow the session format)",
|
|
1185
|
+
"form.taskGuard.sourceV3": "v3",
|
|
1186
|
+
"form.taskGuard.sourceV4": "v4",
|
|
1187
|
+
"form.taskGuard.maxListItems": "Maximum tasks listed in a notice",
|
|
1188
|
+
"form.taskGuard.detectStepIntent": "Detect step intent",
|
|
1189
|
+
"form.taskGuard.detectStepIntentHint": "Recognizes step intent (\u201CNow I will \u2026\u201D) and completion statements (\u201CAll nets routed\u201D, \u201CDRC passes\u201D); the notice carries a ready todo_write",
|
|
1190
|
+
"form.taskGuard.translateTodo": "Show todo titles in Chinese",
|
|
1191
|
+
"form.taskGuard.translateTodoHint": "Display-only; stored todos are never rewritten",
|
|
1192
|
+
"form.taskGuard.todoTimeout": "Todo translation timeout (ms)",
|
|
1193
|
+
"form.taskGuard.include": "Count only these tools",
|
|
1194
|
+
"form.taskGuard.exclude": "Exclude these tools",
|
|
1195
|
+
"form.taskGuard.listHint": "Comma-separated, * supported; empty means all"
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
// src/client/index.ts
|
|
1199
|
+
var NS = "mcviseron";
|
|
1200
|
+
var inject = ["slots", "locale"];
|
|
1201
|
+
function registerSafely(ctx, name, options, component, onRegistered, onFailed) {
|
|
1202
|
+
const slots = ctx.slots;
|
|
1203
|
+
try {
|
|
1204
|
+
slots.inject(name, () => {
|
|
1205
|
+
try {
|
|
1206
|
+
const dispose = slots.register({ name, ...options }, component);
|
|
1207
|
+
onRegistered?.();
|
|
1208
|
+
return dispose;
|
|
1209
|
+
} catch (error) {
|
|
1210
|
+
console.error("[mcviseron] cannot register " + name, error);
|
|
1211
|
+
onFailed?.(error);
|
|
1212
|
+
return () => {
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
} catch (error) {
|
|
1217
|
+
console.error("[mcviseron] cannot inject " + name, error);
|
|
1218
|
+
onFailed?.(error);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
function apply(ctx) {
|
|
1222
|
+
try {
|
|
1223
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "mcviseron: dictionaries");
|
|
1224
|
+
} catch (error) {
|
|
1225
|
+
console.error("[mcviseron] cannot register dictionaries", error);
|
|
1226
|
+
}
|
|
1227
|
+
const themeOf = () => {
|
|
1228
|
+
try {
|
|
1229
|
+
const get = ctx.get;
|
|
1230
|
+
return typeof get === "function" ? get.call(ctx, "theme") : void 0;
|
|
1231
|
+
} catch {
|
|
1232
|
+
return void 0;
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
const driver = new ScheduleDriver(themeOf);
|
|
1236
|
+
try {
|
|
1237
|
+
ctx.effect(() => driver.start(), "mcviseron: appearance schedule driver");
|
|
1238
|
+
} catch (error) {
|
|
1239
|
+
console.error("[mcviseron] cannot start the appearance driver", error);
|
|
1240
|
+
}
|
|
1241
|
+
registerSafely(ctx, "settings.general.item", {
|
|
1242
|
+
id: "mcviseron-appearance-schedule",
|
|
1243
|
+
order: 10.5,
|
|
1244
|
+
locale: NS,
|
|
1245
|
+
inject: () => ({ driver })
|
|
1246
|
+
}, AppearanceScheduleRow);
|
|
1247
|
+
registerSafely(ctx, "settings.general.item", {
|
|
1248
|
+
id: "mcviseron-restart-fallback",
|
|
1249
|
+
order: 13,
|
|
1250
|
+
locale: NS
|
|
1251
|
+
}, FallbackRestartRow);
|
|
1252
|
+
registerSafely(ctx, "settings.section", {
|
|
1253
|
+
id: "mcviseron",
|
|
1254
|
+
order: 115,
|
|
1255
|
+
label: "MCviseron",
|
|
1256
|
+
locale: NS
|
|
1257
|
+
}, SettingsSection, () => {
|
|
1258
|
+
sectionPresence.markLive();
|
|
1259
|
+
}, (error) => {
|
|
1260
|
+
sectionPresence.markFailed(error);
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
return module.exports;
|
|
1265
|
+
}
|
|
1266
|
+
});
|