dsh-mcviseron-plugin 0.7.8 → 0.8.3

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/client.js CHANGED
@@ -374,7 +374,7 @@ function RestartCard({ t }) {
374
374
  const body = await response.json();
375
375
  if (body.ok !== true) throw new Error("restart-status-rejected");
376
376
  if (body.available === true) {
377
- setState({ kind: "ready", appPath: typeof body.appPath === "string" ? body.appPath : "" });
377
+ setState({ kind: "ready", appPath: typeof body.appPath === "string" ? body.appPath : "", mode: typeof body.mode === "string" ? body.mode : "desktop" });
378
378
  } else {
379
379
  setState({ kind: "unavailable" });
380
380
  }
@@ -402,8 +402,25 @@ function RestartCard({ t }) {
402
402
  setState({ kind: "failed", message: error instanceof Error ? error.message : String(error) });
403
403
  }
404
404
  };
405
- 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");
405
+ const startClose = async () => {
406
+ if (!window.confirm(t("page.restart.closeConfirm"))) return;
407
+ setState({ kind: "closing" });
408
+ try {
409
+ const response = await fetch(EXECUTE, {
410
+ method: "POST",
411
+ headers: { "content-type": "application/json" },
412
+ body: JSON.stringify({ confirm: true, action: "close" })
413
+ });
414
+ if (!response.ok) throw new Error(await readError(response));
415
+ const body = await response.json();
416
+ if (body.ok !== true) throw new Error("close-rejected");
417
+ } catch (error) {
418
+ setState({ kind: "failed", message: error instanceof Error ? error.message : String(error) });
419
+ }
420
+ };
421
+ const status = state.kind === "ready" ? state.mode === "reexec" ? t("page.restart.modeProcess") : state.mode === "supervisor-exit" ? t("page.restart.modeSupervisor") : t("page.restart.ready") : state.kind === "closing" ? t("page.restart.closing") : 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");
406
422
  const canRestart = state.kind === "ready" || state.kind === "failed";
423
+ const canClose = state.kind === "ready";
407
424
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: pageStyles.card, children: [
408
425
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: pageStyles.cardTitle, children: t("page.restart.title") }),
409
426
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: pageStyles.cardBody, children: t("page.restart.description") }),
@@ -413,18 +430,32 @@ function RestartCard({ t }) {
413
430
  ": ",
414
431
  state.appPath
415
432
  ] }) : null,
416
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: pageStyles.cardActions, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
417
- "button",
418
- {
419
- type: "button",
420
- disabled: !canRestart,
421
- onClick: () => {
422
- void startRestart();
423
- },
424
- style: canRestart ? styles.button : styles.buttonDisabled,
425
- children: state.kind === "restarting" ? t("page.restart.restarting") : t("page.restart.button")
426
- }
427
- ) })
433
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: pageStyles.cardActions, children: [
434
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
435
+ "button",
436
+ {
437
+ type: "button",
438
+ disabled: !canRestart,
439
+ onClick: () => {
440
+ void startRestart();
441
+ },
442
+ style: canRestart ? styles.button : styles.buttonDisabled,
443
+ children: state.kind === "restarting" ? t("page.restart.restarting") : t("page.restart.button")
444
+ }
445
+ ),
446
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
447
+ "button",
448
+ {
449
+ type: "button",
450
+ disabled: !canClose,
451
+ onClick: () => {
452
+ void startClose();
453
+ },
454
+ style: canClose ? styles.button : styles.buttonDisabled,
455
+ children: state.kind === "closing" ? t("page.restart.closing") : t("page.restart.close")
456
+ }
457
+ )
458
+ ] })
428
459
  ] });
429
460
  }
430
461
 
@@ -1403,6 +1434,10 @@ function SettingsSection({ t }) {
1403
1434
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.sessionEnd") }),
1404
1435
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.sessionEndHint") })
1405
1436
  ] }),
1437
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1438
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.automationTasks") }),
1439
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.automationTasksHint") })
1440
+ ] }),
1406
1441
  archive?.available ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
1407
1442
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.archive") }),
1408
1443
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.archiveHint") })
@@ -1412,6 +1447,90 @@ function SettingsSection({ t }) {
1412
1447
  ] });
1413
1448
  }
1414
1449
 
1450
+ // src/client/SidebarRestartAction.tsx
1451
+ var import_react7 = require("react");
1452
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1453
+ var STATUS2 = "/api/dsh-mcviseron/restart/status";
1454
+ var EXECUTE2 = "/api/dsh-mcviseron/restart/execute";
1455
+ function SidebarRestartAction({ wide = true, t }) {
1456
+ const [available, setAvailable] = (0, import_react7.useState)(null);
1457
+ const [busy, setBusy] = (0, import_react7.useState)(false);
1458
+ (0, import_react7.useEffect)(() => {
1459
+ let cancelled = false;
1460
+ void (async () => {
1461
+ try {
1462
+ const response = await fetch(STATUS2, { method: "GET", cache: "no-store", credentials: "same-origin" });
1463
+ if (cancelled) return;
1464
+ if (!response.ok) {
1465
+ setAvailable(false);
1466
+ return;
1467
+ }
1468
+ const body = await response.json();
1469
+ setAvailable(body.available === true);
1470
+ } catch {
1471
+ if (!cancelled) setAvailable(false);
1472
+ }
1473
+ })();
1474
+ return () => {
1475
+ cancelled = true;
1476
+ };
1477
+ }, []);
1478
+ if (available !== true) return null;
1479
+ const restart = async () => {
1480
+ if (busy || !window.confirm(t("page.restart.confirm"))) return;
1481
+ setBusy(true);
1482
+ try {
1483
+ const response = await fetch(EXECUTE2, {
1484
+ method: "POST",
1485
+ headers: { "content-type": "application/json" },
1486
+ credentials: "same-origin",
1487
+ body: JSON.stringify({ confirm: true, action: "restart" })
1488
+ });
1489
+ if (!response.ok) throw new Error("HTTP " + String(response.status));
1490
+ const body = await response.json();
1491
+ if (body.ok !== true) throw new Error("restart-rejected");
1492
+ } catch (error) {
1493
+ setBusy(false);
1494
+ window.alert(t("page.restart.failed") + ": " + (error instanceof Error ? error.message : String(error)));
1495
+ }
1496
+ };
1497
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1498
+ "button",
1499
+ {
1500
+ type: "button",
1501
+ title: t("sidebar.restart"),
1502
+ "aria-label": t("sidebar.restart"),
1503
+ disabled: busy,
1504
+ onClick: () => {
1505
+ void restart();
1506
+ },
1507
+ style: {
1508
+ display: "flex",
1509
+ alignItems: "center",
1510
+ justifyContent: wide ? "flex-start" : "center",
1511
+ gap: wide ? 8 : 0,
1512
+ width: "100%",
1513
+ padding: wide ? "8px 12px" : "8px",
1514
+ border: 0,
1515
+ borderRadius: 8,
1516
+ background: "transparent",
1517
+ color: "inherit",
1518
+ cursor: busy ? "wait" : "pointer",
1519
+ font: "inherit",
1520
+ textAlign: "left",
1521
+ opacity: busy ? 0.6 : 1
1522
+ },
1523
+ children: [
1524
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: [
1525
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M13 5.2A5.5 5.5 0 1 0 13.4 10", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" }),
1526
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M13 2.8v3.4H9.6", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" })
1527
+ ] }),
1528
+ wide ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: busy ? t("sidebar.restarting") : t("sidebar.restart") }) : null
1529
+ ]
1530
+ }
1531
+ );
1532
+ }
1533
+
1415
1534
  // src/client/driver.ts
1416
1535
  var TICK_MS = 2e4;
1417
1536
  var RETRY_MS = 6e4;
@@ -1572,18 +1691,25 @@ var zh = {
1572
1691
  "sessionEnd.failed": "\u8BBE\u7F6E\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
1573
1692
  "page.title": "MCviseron \u63D2\u4EF6",
1574
1693
  "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",
1575
- "page.tab.restart": "\u91CD\u542F",
1694
+ "page.tab.restart": "\u91CD\u542F / \u5173\u95ED",
1576
1695
  "page.tab.components": "\u7EC4\u4EF6",
1577
- "page.restart.title": "\u91CD\u542F DeepSeek Harness",
1578
- "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",
1696
+ "page.restart.title": "\u91CD\u542F / \u5173\u95ED DeepSeek Harness",
1697
+ "page.restart.description": "\u91CD\u542F\u6216\u5173\u95ED\u5F53\u524D DSH\uFF08\u684C\u9762\u5E94\u7528\u3001Linux/Web \u8FDB\u7A0B\u6216\u4E91\u6258\u7BA1\u5BB9\u5668\uFF09\uFF1B\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u4F1A\u88AB\u4E2D\u65AD",
1579
1698
  "page.restart.ready": "\u53EF\u7528",
1580
- "page.restart.unavailable": "\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u91CD\u542F\uFF08\u4EC5 Windows \u684C\u9762\u7248\u53EF\u7528\uFF09",
1699
+ "page.restart.modeProcess": "Linux/Web \u8FDB\u7A0B\uFF1A\u5C06\u91CD\u65B0\u62C9\u8D77\u5F53\u524D dsh \u547D\u4EE4",
1700
+ "page.restart.modeSupervisor": "\u7531 systemd / Docker / Kubernetes \u6258\u7BA1\uFF1A\u9000\u51FA\u540E\u7531\u6258\u7BA1\u5668\u91CD\u542F",
1701
+ "page.restart.close": "\u5173\u95ED DSH",
1702
+ "page.restart.closing": "\u6B63\u5728\u5173\u95ED\u2026",
1703
+ "page.restart.closeConfirm": "\u786E\u5B9A\u8981\u5173\u95ED DSH \u5417\uFF1F\u91CD\u542F/\u5173\u95ED\u52A8\u4F5C\u4F1A\u4E2D\u65AD\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u3002",
1704
+ "page.restart.unavailable": "\u5F53\u524D\u73AF\u5883\u6CA1\u6709\u53EF\u7528\u7684\u91CD\u542F\u76EE\u6807",
1581
1705
  "page.restart.routeMissing": "\u91CD\u542F\u63A5\u53E3\u672A\u52A0\u8F7D\uFF1A\u8BF7\u786E\u8BA4 mcviseron-restart \u6761\u76EE\u5DF2\u542F\u7528",
1582
1706
  "page.restart.appPath": "\u5E94\u7528\u8DEF\u5F84",
1583
1707
  "page.restart.button": "\u91CD\u542F",
1584
1708
  "page.restart.restarting": "\u6B63\u5728\u91CD\u542F\u2026\u7A97\u53E3\u4F1A\u77ED\u6682\u5173\u95ED",
1585
1709
  "page.restart.failed": "\u91CD\u542F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
1586
1710
  "page.restart.confirm": "\u786E\u5B9A\u8981\u91CD\u542F DeepSeek Harness \u5417\uFF1F\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u4F1A\u88AB\u4E2D\u65AD\u3002",
1711
+ "sidebar.restart": "\u91CD\u542F DSH",
1712
+ "sidebar.restarting": "\u6B63\u5728\u91CD\u542F\u2026",
1587
1713
  "page.components.title": "\u7EC4\u4EF6",
1588
1714
  "page.components.appearance": "\u5916\u89C2 \xB7 \u6309\u65F6\u95F4\u5207\u6362",
1589
1715
  "page.components.appearanceHint": "\u8BBE\u7F6E\u4F4D\u4E8E\u300C\u901A\u7528 \u2192 \u5916\u89C2\u300D",
@@ -1591,8 +1717,8 @@ var zh = {
1591
1717
  "page.components.autoReviewFixHint": "\u672C\u9875\u300CAuto review \u4FEE\u590D\u300D\u5B50\u9875",
1592
1718
  "page.components.taskGuard": "Todo \u8BA1\u5212\u5B88\u536B",
1593
1719
  "page.components.taskGuardHint": "\u672C\u9875\u300CTodo \u5B88\u536B\u300D\u5B50\u9875",
1594
- "page.components.restart": "\u91CD\u542F DeepSeek Harness",
1595
- "page.components.restartHint": "\u672C\u9875\u300C\u91CD\u542F\u300D\u5B50\u9875",
1720
+ "page.components.restart": "\u91CD\u542F / \u5173\u95ED DSH",
1721
+ "page.components.restartHint": "\u672C\u9875\u300C\u91CD\u542F / \u5173\u95ED\u300D\u5B50\u9875",
1596
1722
  "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",
1597
1723
  "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",
1598
1724
  "page.tab.autoReview": "Auto review \u4FEE\u590D",
@@ -1638,8 +1764,8 @@ var zh = {
1638
1764
  "form.taskGuard.maxListItems": "notice \u6700\u591A\u5217\u51FA\u4EFB\u52A1\u6570",
1639
1765
  "form.taskGuard.detectStepIntent": "\u8BC6\u522B\u6B65\u9AA4\u610F\u56FE",
1640
1766
  "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",
1641
- "form.taskGuard.translateTodo": "\u4E2D\u6587\u5C55\u793A todo \u6807\u9898",
1642
- "form.taskGuard.translateTodoHint": "\u53EA\u5F71\u54CD notice \u5C55\u793A\uFF0C\u4E0D\u6539\u5199\u6A21\u578B\u5199\u5165\u7684 todo",
1767
+ "form.taskGuard.translateTodo": "\u4E2D\u6587 todo \u6807\u9898\uFF08\u5199\u5165\u5E76\u663E\u793A\uFF09",
1768
+ "form.taskGuard.translateTodoHint": "todo_write \u6807\u9898\u5199\u6210 \u4E2D\u6587\uFF08English\uFF09\uFF1B\u5DF2\u6709\u5217\u8868\u5728\u4E0B\u4E00\u6B21 turn \u81EA\u52A8\u8FC1\u79FB\uFF0C\u72B6\u6001\u4E0D\u53D8",
1643
1769
  "form.taskGuard.todoTimeout": "todo \u7FFB\u8BD1\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
1644
1770
  "form.taskGuard.include": "\u53EA\u7EDF\u8BA1\u8FD9\u4E9B\u5DE5\u5177",
1645
1771
  "form.taskGuard.exclude": "\u4E0D\u7EDF\u8BA1\u8FD9\u4E9B\u5DE5\u5177",
@@ -1662,6 +1788,8 @@ var zh = {
1662
1788
  "page.components.authCookieHint": "\u81EA\u52A8\u8FD0\u884C\uFF0C\u65E0\u8BBE\u7F6E",
1663
1789
  "page.components.sessionEnd": "\u4F1A\u8BDD\u540E\u52A8\u4F5C",
1664
1790
  "page.components.sessionEndHint": "\u8F93\u5165\u6846\u5DE6\u4FA7\u7684\u300C\u4F1A\u8BDD\u540E\u91CD\u542F\u300D\u4E0B\u62C9",
1791
+ "page.components.automationTasks": "\u81EA\u52A8\u5316\u4EFB\u52A1 API",
1792
+ "page.components.automationTasksHint": "automation_task_list/create/update/delete\uFF1BHost schedule.list/create/edit\uFF0C\u8BE6\u89C1 docs/automation-tasks.md",
1665
1793
  "page.components.archive": "\u5F52\u6863\u65F6\u95F4\uFF08\u53EF\u9009\uFF09",
1666
1794
  "page.components.archiveHint": "\u68C0\u6D4B\u5230\u7B2C\u4E09\u65B9\u5F52\u6863\u63D2\u4EF6\u65F6\u663E\u793A",
1667
1795
  "form.sessionEnd.enabled": "\u542F\u7528\u4F1A\u8BDD\u540E\u52A8\u4F5C",
@@ -1713,18 +1841,25 @@ var en = {
1713
1841
  "sessionEnd.failed": "Could not update the session-end action",
1714
1842
  "page.title": "MCviseron plugin",
1715
1843
  "page.description": "Settings for the master plugin components. Appearance still lives under General \u2192 Appearance.",
1716
- "page.tab.restart": "Restart",
1844
+ "page.tab.restart": "Restart / close",
1717
1845
  "page.tab.components": "Components",
1718
- "page.restart.title": "Restart DeepSeek Harness",
1719
- "page.restart.description": "Closes and relaunches the desktop application; running tasks are interrupted",
1846
+ "page.restart.title": "Restart / close DeepSeek Harness",
1847
+ "page.restart.description": "Restart or close DSH (desktop app, Linux/Web process, or cloud container); running tasks are interrupted",
1720
1848
  "page.restart.ready": "Available",
1721
- "page.restart.unavailable": "Restarting is available only in the Windows desktop app",
1849
+ "page.restart.modeProcess": "Linux/Web process: relaunch the current dsh command",
1850
+ "page.restart.modeSupervisor": "Managed by systemd / Docker / Kubernetes: exit and let the supervisor restart it",
1851
+ "page.restart.close": "Close DSH",
1852
+ "page.restart.closing": "Closing\u2026",
1853
+ "page.restart.closeConfirm": "Close DSH? Restart/close interrupts running tasks.",
1854
+ "page.restart.unavailable": "No restart target is available in this environment",
1722
1855
  "page.restart.routeMissing": "The restart route is not loaded: check that the mcviseron-restart entry is enabled",
1723
1856
  "page.restart.appPath": "App path",
1724
1857
  "page.restart.button": "Restart",
1725
1858
  "page.restart.restarting": "Restarting\u2026 the window will close briefly",
1726
1859
  "page.restart.failed": "Restart failed \u2014 try again",
1727
1860
  "page.restart.confirm": "Restart DeepSeek Harness now? Running tasks will be interrupted.",
1861
+ "sidebar.restart": "Restart DSH",
1862
+ "sidebar.restarting": "Restarting\u2026",
1728
1863
  "page.components.title": "Components",
1729
1864
  "page.components.appearance": "Appearance \xB7 light/dark by time",
1730
1865
  "page.components.appearanceHint": "Configured under General \u2192 Appearance",
@@ -1732,8 +1867,8 @@ var en = {
1732
1867
  "page.components.autoReviewFixHint": "The Auto-review fix tab on this page",
1733
1868
  "page.components.taskGuard": "Todo plan guard",
1734
1869
  "page.components.taskGuardHint": "The Todo guard tab on this page",
1735
- "page.components.restart": "Restart DeepSeek Harness",
1736
- "page.components.restartHint": "The Restart tab on this page",
1870
+ "page.components.restart": "Restart / close DSH",
1871
+ "page.components.restartHint": "The Restart / close tab on this page",
1737
1872
  "page.components.note": "Component settings are written to the mcviseron entry config; restart DSH if a component still uses the old value.",
1738
1873
  "page.fallback.note": "The settings section is unavailable, so the restart entry falls back to General.",
1739
1874
  "page.tab.autoReview": "Auto-review fix",
@@ -1779,8 +1914,8 @@ var en = {
1779
1914
  "form.taskGuard.maxListItems": "Maximum tasks listed in a notice",
1780
1915
  "form.taskGuard.detectStepIntent": "Detect step intent",
1781
1916
  "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",
1782
- "form.taskGuard.translateTodo": "Show todo titles in Chinese",
1783
- "form.taskGuard.translateTodoHint": "Display-only; stored todos are never rewritten",
1917
+ "form.taskGuard.translateTodo": "Chinese todo titles (stored and displayed)",
1918
+ "form.taskGuard.translateTodoHint": "Stores titles as Chinese (English); migrates existing lists on the next turn without changing statuses",
1784
1919
  "form.taskGuard.todoTimeout": "Todo translation timeout (ms)",
1785
1920
  "form.taskGuard.include": "Count only these tools",
1786
1921
  "form.taskGuard.exclude": "Exclude these tools",
@@ -1803,6 +1938,8 @@ var en = {
1803
1938
  "page.components.authCookieHint": "Runs automatically; no settings",
1804
1939
  "page.components.sessionEnd": "After-session action",
1805
1940
  "page.components.sessionEndHint": "The \u201CRestart after session\u201D dropdown left of the composer",
1941
+ "page.components.automationTasks": "Automation task API",
1942
+ "page.components.automationTasksHint": "automation_task_list/create/update/delete; Host schedule.list/create/edit; see docs/automation-tasks.md",
1806
1943
  "page.components.archive": "Archive time (optional)",
1807
1944
  "page.components.archiveHint": "Shown only when the third-party archive plugin is detected",
1808
1945
  "form.sessionEnd.enabled": "Enable after-session actions",
@@ -1888,6 +2025,12 @@ function apply(ctx) {
1888
2025
  order: 20,
1889
2026
  locale: NS
1890
2027
  }, SessionEndControl);
2028
+ registerSafely(ctx, "sidebar.footer.action", {
2029
+ id: "mcviseron-restart",
2030
+ order: 90,
2031
+ label: "\u91CD\u542F DSH",
2032
+ locale: NS
2033
+ }, SidebarRestartAction);
1891
2034
  registerSafely(ctx, "settings.section", {
1892
2035
  id: "mcviseron",
1893
2036
  order: 115,
package/lib/index.js CHANGED
@@ -10466,13 +10466,13 @@ var require_smtp_transport = __commonJS({
10466
10466
  var require_sendmail_transport = __commonJS({
10467
10467
  "node_modules/.pnpm/nodemailer@6.10.1/node_modules/nodemailer/lib/sendmail-transport/index.js"(exports, module) {
10468
10468
  "use strict";
10469
- var spawn = __require("child_process").spawn;
10469
+ var spawn2 = __require("child_process").spawn;
10470
10470
  var packageData = require_package();
10471
10471
  var shared = require_shared();
10472
10472
  var SendmailTransport = class {
10473
10473
  constructor(options) {
10474
10474
  options = options || {};
10475
- this._spawn = spawn;
10475
+ this._spawn = spawn2;
10476
10476
  this.options = options || {};
10477
10477
  this.name = "Sendmail";
10478
10478
  this.version = packageData.version;
@@ -12121,6 +12121,7 @@ function apply4(ctx) {
12121
12121
  text: [
12122
12122
  "Official DSH automation tasks are writable from this conversation.",
12123
12123
  "Use automation_task_list / automation_task_create / automation_task_update / automation_task_delete; they call the Host schedule service and persist automatically.",
12124
+ 'Host Schedule API (DSH 0.2.2+): list({}) returns { items }; create({ title, prompt, timing, target }, sessionId, signal); edit({ id, action: "update", patch }, sessionId, signal); edit({ id, action: "delete" }, sessionId, signal). Older hosts expose list({ sessionId }), create(sessionId, request), update and delete; these tools normalize both shapes.',
12124
12125
  "Never edit ~/.dsh/storages/schedule.json by hand, and never tell the user to use a command to change a task when these tools are available."
12125
12126
  ].join(" ")
12126
12127
  });
@@ -12941,10 +12942,12 @@ __export(restart_exports, {
12941
12942
  launchRestart: () => launchRestart,
12942
12943
  makeRestartRoutes: () => makeRestartRoutes,
12943
12944
  makeTaskScript: () => makeTaskScript,
12944
- resolveRestartTarget: () => resolveRestartTarget
12945
+ resolveProcessRestartTarget: () => resolveProcessRestartTarget,
12946
+ resolveRestartTarget: () => resolveRestartTarget,
12947
+ restartMode: () => restartMode
12945
12948
  });
12946
- import { execFileSync } from "node:child_process";
12947
- import { appendFileSync as appendFileSync4, existsSync as existsSync2 } from "node:fs";
12949
+ import { execFileSync, spawn } from "node:child_process";
12950
+ import { appendFileSync as appendFileSync4, existsSync as existsSync2, writeFileSync } from "node:fs";
12948
12951
  import { tmpdir as tmpdir4 } from "node:os";
12949
12952
  import { basename, dirname, join as join5, resolve } from "node:path";
12950
12953
  import z3 from "@deepseek-ai/schemastery";
@@ -12959,7 +12962,9 @@ var RESTART_API = {
12959
12962
  execute: "/api/dsh-mcviseron/restart/execute"
12960
12963
  };
12961
12964
  function resolveRestartTarget(execPath, parentPid, exists, override = "", argv = [], platform = process.platform) {
12962
- if (platform !== "win32") return void 0;
12965
+ if (platform !== "win32") {
12966
+ return resolveProcessRestartTarget({ platform, execPath, argv: argv.slice(1), cwd: process.cwd() });
12967
+ }
12963
12968
  if (!Number.isSafeInteger(parentPid) || parentPid <= 0) return void 0;
12964
12969
  const configured = typeof override === "string" ? override.trim() : "";
12965
12970
  const candidate = configured !== "" ? configured : deriveDesktopAppPath(execPath, argv, exists);
@@ -12968,6 +12973,23 @@ function resolveRestartTarget(execPath, parentPid, exists, override = "", argv =
12968
12973
  if (name === "node" || name === "node.exe") return void 0;
12969
12974
  return { mainPid: parentPid, hostPid: process.pid, exePath: candidate };
12970
12975
  }
12976
+ function resolveProcessRestartTarget(options = {}) {
12977
+ const platform = options.platform ?? process.platform;
12978
+ if (platform === "win32") return void 0;
12979
+ const argv = options.argv ?? process.argv.slice(1);
12980
+ if (argv.length === 0 || argv[0] === "") return void 0;
12981
+ const env = options.env ?? process.env;
12982
+ const override = (env.DSH_MCVISERON_RESTART_MODE ?? "").trim().toLowerCase();
12983
+ const supervised = override === "supervisor-exit" || override === "exit" || override !== "reexec" && (env.INVOCATION_ID !== void 0 || env.JOURNAL_STREAM !== void 0 || env.SYSTEMD_EXEC_PID !== void 0 || env.KUBERNETES_SERVICE_HOST !== void 0 || existsSync2("/.dockerenv") || options.pid1 === true || (options.pid ?? process.pid) === 1);
12984
+ const nodeArgs = options.execArgv ?? process.execArgv;
12985
+ return {
12986
+ hostPid: options.pid ?? process.pid,
12987
+ exePath: options.execPath ?? process.execPath,
12988
+ mode: supervised ? "supervisor-exit" : "reexec",
12989
+ argv: [...nodeArgs, ...argv],
12990
+ cwd: options.cwd ?? process.cwd()
12991
+ };
12992
+ }
12971
12993
  function deriveDesktopAppPath(execPath, argv, exists) {
12972
12994
  const isNode = (value) => /^node(\.exe)?$/i.test(basename(value));
12973
12995
  if (!isNode(execPath)) return execPath;
@@ -12978,6 +13000,9 @@ function deriveDesktopAppPath(execPath, argv, exists) {
12978
13000
  const candidate = join5(resolve(runtimeDir, "../../.."), "DeepSeek Harness.exe");
12979
13001
  return exists(candidate) ? candidate : execPath;
12980
13002
  }
13003
+ function restartMode(target) {
13004
+ return target.mode ?? (target.mainPid !== void 0 ? "desktop" : "reexec");
13005
+ }
12981
13006
  var RESTART_TASK_NAME = "DSH-MCviseron-Restart";
12982
13007
  var RESTART_DELAY_SECONDS = 6;
12983
13008
  function restartLogPath() {
@@ -12994,14 +13019,62 @@ function makeTaskScript(target, taskName, delaySeconds) {
12994
13019
  ""
12995
13020
  ].join("\n");
12996
13021
  }
13022
+ function writeRestartLog(message) {
13023
+ try {
13024
+ appendFileSync4(restartLogPath(), (/* @__PURE__ */ new Date()).toISOString() + " " + message + "\n", "utf8");
13025
+ } catch {
13026
+ }
13027
+ }
13028
+ var PROCESS_HELPER = [
13029
+ "const { spawn } = require('node:child_process')",
13030
+ "const [pidText, cwd, exe, ...args] = process.argv.slice(2)",
13031
+ "const pid = Number(pidText)",
13032
+ "const started = Date.now()",
13033
+ "const start = () => {",
13034
+ " try {",
13035
+ ' const child = spawn(exe, args, { cwd, detached: true, stdio: "ignore", env: process.env })',
13036
+ " child.unref()",
13037
+ " } catch { /* the supervisor or user will see the failure */ }",
13038
+ "}",
13039
+ "const timer = setInterval(() => {",
13040
+ " let alive = false",
13041
+ " try { process.kill(pid, 0); alive = true } catch { /* parent is gone */ }",
13042
+ " if (!alive || Date.now() - started > 30_000) { clearInterval(timer); start() }",
13043
+ "}, 100)",
13044
+ "timer.unref?.()"
13045
+ ].join("\n");
13046
+ function ensureProcessHelper() {
13047
+ const path = join5(tmpdir4(), "dsh-mcviseron-restart-helper.cjs");
13048
+ writeFileSync(path, PROCESS_HELPER, "utf8");
13049
+ return path;
13050
+ }
13051
+ function launchProcessRestart(target) {
13052
+ if (target.mode === "supervisor-exit") {
13053
+ writeRestartLog("host: supervised restart requested; exit 75");
13054
+ setTimeout(() => process.exit(75), 300);
13055
+ return;
13056
+ }
13057
+ try {
13058
+ const helper = ensureProcessHelper();
13059
+ const args = [helper, String(process.pid), target.cwd ?? process.cwd(), target.exePath, ...target.argv ?? []];
13060
+ const child = spawn(process.execPath, args, { detached: true, stdio: "ignore", env: { ...process.env, DSH_MCVISERON_RESTARTED: "1" } });
13061
+ child.unref();
13062
+ writeRestartLog("host: detached re-exec helper started");
13063
+ } catch (error) {
13064
+ writeRestartLog("host: re-exec helper failed: " + (error instanceof Error ? error.message : String(error)));
13065
+ throw new Error("cannot start the Linux restart helper", { cause: error });
13066
+ }
13067
+ setTimeout(() => process.exit(0), 300);
13068
+ }
12997
13069
  function launchRestart(target) {
12998
- launchHelper(target);
13070
+ if (restartMode(target) === "desktop") launchHelper(target);
13071
+ else launchProcessRestart(target);
12999
13072
  }
13000
13073
  function closeDesktop(target) {
13001
- const pid = target?.mainPid ?? process.ppid;
13074
+ const mainPid = target?.mainPid;
13002
13075
  setTimeout(() => {
13003
13076
  try {
13004
- if (target !== void 0 || process.platform === "win32") process.kill(pid);
13077
+ if (mainPid !== void 0 && target !== void 0 && restartMode(target) === "desktop") process.kill(mainPid);
13005
13078
  else process.exit(0);
13006
13079
  } catch {
13007
13080
  try {
@@ -13030,10 +13103,12 @@ function launchHelper(target) {
13030
13103
  `, "utf8");
13031
13104
  throw new Error("cannot schedule the restart task: " + message, { cause: error });
13032
13105
  }
13106
+ const mainPid = target.mainPid;
13107
+ if (mainPid === void 0) throw new Error("desktop restart target has no main PID");
13033
13108
  setTimeout(() => {
13034
13109
  try {
13035
- process.kill(target.mainPid);
13036
- appendFileSync4(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: kill sent to ${target.mainPid}
13110
+ process.kill(mainPid);
13111
+ appendFileSync4(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: kill sent to ${mainPid}
13037
13112
  `, "utf8");
13038
13113
  } catch (error) {
13039
13114
  appendFileSync4(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: kill failed: ${error instanceof Error ? error.message : String(error)}
@@ -13071,7 +13146,7 @@ function makeRestartRoutes(deps) {
13071
13146
  if (req.method !== "GET" && req.method !== "POST") return json3(res, 405, { ok: false, error: "method-not-allowed" });
13072
13147
  if (!isLoopbackRequest(req)) return json3(res, 403, { ok: false, error: "forbidden" });
13073
13148
  const target = deps.target();
13074
- json3(res, 200, target === void 0 ? { ok: true, available: false, reason: "desktop-app-unavailable" } : { ok: true, available: true, appPath: target.exePath, mainPid: target.mainPid });
13149
+ json3(res, 200, target === void 0 ? { ok: true, available: false, reason: "restart-target-unavailable" } : { ok: true, available: true, mode: restartMode(target), appPath: target.exePath, mainPid: target.mainPid ?? null });
13075
13150
  } catch (error) {
13076
13151
  json3(res, 500, { ok: false, error: error instanceof Error ? error.message : String(error) });
13077
13152
  }
@@ -13088,13 +13163,16 @@ function makeRestartRoutes(deps) {
13088
13163
  if (body === void 0 || typeof body !== "object" || body === null || body.confirm !== true) {
13089
13164
  return json3(res, 400, { ok: false, error: "confirmation-required" });
13090
13165
  }
13166
+ const action = body.action ?? "restart";
13167
+ if (action !== "restart" && action !== "close") return json3(res, 400, { ok: false, error: "action-invalid" });
13091
13168
  const latest = now();
13092
- if (latest - lastLaunch < 5e3) return json3(res, 429, { ok: false, error: "restart-already-scheduled" });
13169
+ if (action === "restart" && latest - lastLaunch < 5e3) return json3(res, 429, { ok: false, error: "restart-already-scheduled" });
13093
13170
  const target = deps.target();
13094
- if (target === void 0) return json3(res, 409, { ok: false, error: "desktop-app-unavailable" });
13095
- deps.launch(target);
13096
- lastLaunch = latest;
13097
- json3(res, 200, { ok: true, restarting: true, appPath: target.exePath });
13171
+ if (action === "restart" && target === void 0) return json3(res, 409, { ok: false, error: "restart-target-unavailable" });
13172
+ if (action === "restart") deps.launch(target);
13173
+ else (deps.close ?? closeDesktop)(target);
13174
+ if (action === "restart") lastLaunch = latest;
13175
+ json3(res, 200, { ok: true, action, restarting: action === "restart", closing: action === "close", mode: target === void 0 ? null : restartMode(target) });
13098
13176
  } catch (error) {
13099
13177
  json3(res, 500, { ok: false, error: error instanceof Error ? error.message : String(error) });
13100
13178
  }
@@ -13109,7 +13187,8 @@ function apply6(ctx, config) {
13109
13187
  const appPath = typeof plain.appPath === "string" ? plain.appPath : "";
13110
13188
  const routes = makeRestartRoutes({
13111
13189
  target: () => resolveRestartTarget(process.execPath, process.ppid, existsSync2, appPath, process.argv),
13112
- launch: launchHelper
13190
+ launch: launchRestart,
13191
+ close: closeDesktop
13113
13192
  });
13114
13193
  ctx.effect(() => {
13115
13194
  const disposers = routes.map((route) => ctx.webServer.register(route));
@@ -13355,12 +13434,12 @@ function createSessionEndController(deps = {}) {
13355
13434
  };
13356
13435
  const view = (sessionId) => {
13357
13436
  const entry = entries.get(sessionId);
13358
- let available = { restart: false, close: platform === "win32", shutdown: platform === "win32" };
13437
+ let available = { restart: false, close: true, shutdown: platform === "win32" };
13359
13438
  try {
13360
13439
  const target = resolveTarget();
13361
13440
  available = {
13362
13441
  restart: target !== void 0,
13363
- close: target !== void 0 || platform === "win32",
13442
+ close: true,
13364
13443
  shutdown: platform === "win32"
13365
13444
  };
13366
13445
  } catch {
@@ -14097,6 +14176,34 @@ function suggestedTodoPayload(todos, matched) {
14097
14176
  }));
14098
14177
  return JSON.stringify({ todos: next });
14099
14178
  }
14179
+ function latestTodos(session) {
14180
+ try {
14181
+ const events = session.snapshotEvents?.();
14182
+ if (!Array.isArray(events)) return null;
14183
+ for (let index = events.length - 1; index >= 0; index -= 1) {
14184
+ const event = events[index];
14185
+ if (event?.type !== "todo/write") continue;
14186
+ return readTodos(event.data);
14187
+ }
14188
+ } catch {
14189
+ }
14190
+ return null;
14191
+ }
14192
+ async function migrateStoredTodoList(session, config, ctx) {
14193
+ if (!config.translateTodoContent) return;
14194
+ const todos = latestTodos(session);
14195
+ if (todos === null || todos.length === 0) return;
14196
+ const context = noticeContext({ session }, config, ctx);
14197
+ if (!context.translate) return;
14198
+ const contents = todos.map((todo) => todo.content);
14199
+ const translated = await displayTodoContents(contents, context);
14200
+ if (!translated.some((value, index) => value !== contents[index])) return;
14201
+ if (typeof session.append !== "function") return;
14202
+ try {
14203
+ session.append("todo/write", { todos: translated.map((content, index) => ({ content, status: todos[index].status })) });
14204
+ } catch {
14205
+ }
14206
+ }
14100
14207
  function installTaskGuard(ctx, input) {
14101
14208
  const config = resolveConfig(input);
14102
14209
  const bus = ctx;
@@ -14192,6 +14299,7 @@ function installTaskGuard(ctx, input) {
14192
14299
  });
14193
14300
  bus.on("agent/pre-step", async (payload, next) => {
14194
14301
  const sessionId = sessionIdOf4(payload.agent);
14302
+ void migrateStoredTodoList(payload.agent.session, config, ctx);
14195
14303
  if (sessionId !== "") intentBuffers.delete(sessionId);
14196
14304
  const state = sessions.get(sessionId);
14197
14305
  if (state !== void 0) {
@@ -14221,12 +14329,14 @@ function installTaskGuard(ctx, input) {
14221
14329
  if (event.type === "turn/start" || event.type === "turn/end") {
14222
14330
  sessions.delete(sessionId);
14223
14331
  intentBuffers.delete(sessionId);
14332
+ void migrateStoredTodoList(session, config, ctx);
14224
14333
  return;
14225
14334
  }
14226
14335
  if (event.type === "todo/write") {
14227
14336
  const todos = readTodos(event.data);
14228
14337
  if (todos !== null) resetState(sessions, sessionId, todos);
14229
14338
  intentBuffers.delete(sessionId);
14339
+ void migrateStoredTodoList(session, config, ctx);
14230
14340
  }
14231
14341
  });
14232
14342
  }