dsh-mcviseron-plugin 0.8.1 → 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/CHANGELOG.md +35 -0
- package/README.en.md +8 -8
- package/README.md +10 -10
- package/SECURITY.md +1 -1
- package/docs/linux-restart.md +3 -1
- package/docs/migration-from-standalone.md +1 -1
- package/lib/client.js +106 -4
- package/lib/index.js +32 -0
- package/lib/task-guard.js +31 -0
- package/package.json +1 -1
- package/src/automation-tasks/index.ts +1 -0
- package/src/client/SettingsSection.tsx +4 -0
- package/src/client/SidebarRestartAction.tsx +85 -0
- package/src/client/index.ts +8 -0
- package/src/client/locales.ts +12 -4
- package/src/components/task-guard/index.ts +50 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
## [0.8.3] - 2026-11-22
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- **任务列表 todo 不翻译**:`translateTodoContent` 之前只构造 notice,官方任务面板仍显示英文。现在通过 `session.append('todo/write', { todos })` 写入「中文(English)」的新快照;未来 `todo_write` 在 `todo/write` 事件后迁移,已有列表在下一次 `agent/pre-step` / turn 边界迁移,状态不变。
|
|
6
|
+
- 注意:DSH 在 `tools/pre-execute` 前会 deepFreeze 工具参数,不能直接改写 `todo_write` arguments;因此采用 session 快照迁移,而不是修改执行参数。
|
|
7
|
+
|
|
8
|
+
### Docs
|
|
9
|
+
|
|
10
|
+
- README / SECURITY / 设置项文案说明:`translateTodoContent` 会写入并显示中文标题,已有列表下次 turn 迁移。
|
|
11
|
+
|
|
12
|
+
### Tests
|
|
13
|
+
|
|
14
|
+
- 合计 **130 项测试**;typecheck、build 全绿。
|
|
15
|
+
|
|
16
|
+
## [0.8.3] - 2026-11-22
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **侧边栏底部重启快捷入口**:注册 `sidebar.footer.action`,在设置菜单上方增加「重启 DSH」按钮;宽栏显示图标+文字,窄栏只显示图标。点击复用现有重启路由,设置页的重启/关闭按钮保持不变。路由不可用时按钮自动隐藏。
|
|
21
|
+
|
|
22
|
+
### Tests
|
|
23
|
+
|
|
24
|
+
- 合计 **130 项测试**;typecheck、build 全绿。
|
|
25
|
+
|
|
26
|
+
## [0.8.2] - 2026-11-22
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- **自动化任务 API 的组件内文本**:Settings → MCviseron 插件 → 组件新增「自动化任务 API」行;automation-tasks 的 system prompt 补入 DSH 0.2.2 的 `schedule.list/create/edit` 签名及旧版兼容说明,避免组件只暴露工具名而没有管理 API 文本。
|
|
31
|
+
|
|
32
|
+
### Tests
|
|
33
|
+
|
|
34
|
+
- 129 项测试;typecheck、build 全绿。
|
|
35
|
+
|
|
1
36
|
## [0.8.1] - 2026-11-22
|
|
2
37
|
|
|
3
38
|
### Fixed
|
package/README.en.md
CHANGED
|
@@ -11,7 +11,7 @@ MCviseron's **master plugin for DeepSeek Harness (DSH)**: one npm package and on
|
|
|
11
11
|
| **Appearance · light/dark by time** | `mcviseron` top-level fields | Adds a settings row below DSH's Appearance row and switches the palette from the local wall clock |
|
|
12
12
|
| **Auto-review hardening** | `mcviseron.autoReviewFix` | Stops the whole-Host shutdown from persisting Full access over an Auto session; appends a Chinese translation to the manual-approval prompt |
|
|
13
13
|
| **Todo plan guard** | `mcviseron.taskGuard` | Advisory notices (optional hard stop) when multi-stage work stops updating its todo plan |
|
|
14
|
-
| **Restart / close DSH** | `mcviseron.restart` | Settings tab
|
|
14
|
+
| **Restart / close DSH** | `mcviseron.restart` | Settings tab plus the sidebar-footer **Restart DSH** shortcut; Windows desktop app or Linux/Web/cloud process (supervisor-exit or detached reexec); see [docs/linux-restart.md](docs/linux-restart.md) |
|
|
15
15
|
| **After-session action** | `mcviseron.sessionEnd` | “Restart after session” dropdown in the composer; the AI tool can arm it; restart waits for running tasks |
|
|
16
16
|
| **Auth-cookie cleanup** | built in | Expires old `dsh-auth-*` cookies on every page load, keeping only the current one so restarts cannot push the request header to 16 KB |
|
|
17
17
|
| **Automation task editing** | built-in tools | `automation_task_list/create/update/delete` call the Host schedule service and persist automatically; see [docs/automation-tasks.md](docs/automation-tasks.md) for API compatibility |
|
|
@@ -42,7 +42,7 @@ MCviseron's **master plugin for DeepSeek Harness (DSH)**: one npm package and on
|
|
|
42
42
|
- Optional strict modes: `rejectMissingActive`, `blockAfterCalls`.
|
|
43
43
|
- Source kind follows the session format: v4 uses `plugin:task-guard`, v3 uses `plugin` + `plugin: 'task-guard'`.
|
|
44
44
|
- **Step-intent detection** (`detectStepIntent`): watches the official `agent/assistant-stream` text/reasoning deltas for phrases such as "Now I will …" / "接下来我会 …" and matches them against pending todos. A match adds one targeted, advisory notice per step (with a ready-to-send `todo_write` JSON); a miss, a missing stream, or malformed data is silently skipped and never blocks the task.
|
|
45
|
-
- **Chinese todo
|
|
45
|
+
- **Chinese todo titles** (`translateTodoContent`): English titles are batch-translated into "中文(English)" and stored; an existing list is migrated on the next turn through a new `todo/write` snapshot. The task panel and notices show Chinese while statuses stay unchanged (cached, 3 s default timeout, original text on failure).
|
|
46
46
|
|
|
47
47
|
### 4. Restart / close DSH
|
|
48
48
|
|
|
@@ -155,12 +155,12 @@ Defaults: appearance off / `08:00–23:00`; auto-review both guards on, 6 s, 400
|
|
|
155
155
|
|
|
156
156
|
| DSH version | Status |
|
|
157
157
|
| --- | --- |
|
|
158
|
-
| `0.2.2-rc.5` | ✅ pre-adapted (0.2.2-rc.5 types/deps +
|
|
159
|
-
| `0.2.2-rc.3` | ✅ current desktop (rc.3 types/deps +
|
|
160
|
-
| `0.2.2-rc.1` | ✅ compatible (0.2.2-rc.1 types/deps +
|
|
161
|
-
| `0.2.1-rc.5` | ✅ compatible (rc.5 types/deps +
|
|
162
|
-
| `0.2.1-rc.3` | ✅ compatible (rc.3 types/deps +
|
|
163
|
-
| `0.2.1-rc.2` | ✅ current desktop runtime (
|
|
158
|
+
| `0.2.2-rc.5` | ✅ pre-adapted (0.2.2-rc.5 types/deps + 130 tests; current desktop still rc.3) |
|
|
159
|
+
| `0.2.2-rc.3` | ✅ current desktop (rc.3 types/deps + 130 tests; real runtime verified) |
|
|
160
|
+
| `0.2.2-rc.1` | ✅ compatible (0.2.2-rc.1 types/deps + 130 tests) |
|
|
161
|
+
| `0.2.1-rc.5` | ✅ compatible (rc.5 types/deps + 130 tests) |
|
|
162
|
+
| `0.2.1-rc.3` | ✅ compatible (rc.3 types/deps + 130 tests) |
|
|
163
|
+
| `0.2.1-rc.2` | ✅ current desktop runtime (130 tests + real Cordis contexts) |
|
|
164
164
|
| `0.2.0-rc.x` | ✅ covered by the peer range |
|
|
165
165
|
| `0.1.x` | ❌ unsupported (different settings-namespace model) |
|
|
166
166
|
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ MCviseron 的 **DeepSeek Harness(DSH)总插件**:一个 npm 包、一个 `
|
|
|
11
11
|
| **外观 · 按时间自动切换深浅色** | `mcviseron` 顶层字段 | 「设置 → 通用 → 外观」新增选项,按本机时间切换浅/深色 |
|
|
12
12
|
| **Auto review 修复** | `mcviseron.autoReviewFix` | 关机不再把 Auto 会话写成完全访问;人审提示追加中文译文 |
|
|
13
13
|
| **Todo 计划守卫** | `mcviseron.taskGuard` | 多阶段任务忘记更新 todo 时发出 notice(可选硬拦截) |
|
|
14
|
-
| **重启 / 关闭 DSH** | `mcviseron.restart` |
|
|
14
|
+
| **重启 / 关闭 DSH** | `mcviseron.restart` | 设置页的重启/关闭按钮,以及侧边栏底部「重启 DSH」快捷按钮;Windows 桌面版重启应用,Linux/Web/云服务器使用 supervisor-exit 或 detached reexec |
|
|
15
15
|
| **会话后动作** | `mcviseron.sessionEnd` | 输入框左侧「会话后重启」下拉;AI 工具可设置;重启等待任务结束 |
|
|
16
16
|
| **认证 cookie 清理** | 内置 | 每次页面加载过期旧 `dsh-auth-*`,只保留当前,避免重启把请求头推到 16KB |
|
|
17
17
|
| **自动化任务编辑** | 内置工具 | `automation_task_list/create/update/delete` 直接调用 Host schedule 并自动存盘;API 兼容说明见 [docs/automation-tasks.md](docs/automation-tasks.md) |
|
|
@@ -45,7 +45,7 @@ MCviseron 的 **DeepSeek Harness(DSH)总插件**:一个 npm 包、一个 `
|
|
|
45
45
|
- 都通过官方 `tools/post-execute` 的 `additionalContexts` 送达,不注册 system prompt 段落,不注入用户提示词。
|
|
46
46
|
- 可选严格模式:`rejectMissingActive: true` 拒绝缺少 active 的写入;`blockAfterCalls: N` 在停滞过久时硬拦截下一次工具调用。
|
|
47
47
|
- **步骤意图 + 阶段完成检测**(`detectStepIntent`):监听官方 `agent/assistant-stream`,识别「Now I will …」「接下来…」「Now building the PCB」等步骤意图,以及「All 46 nets routed」「DRC passes clean」「原理图完成」等阶段完成语句。意图按中英文阶段关键词(schematic/原理图、routing/布线、DRC/校验 等)匹配 `pending` todo;完成语句匹配当前 `in_progress` todo。命中时附一条**定向 notice**(每条消息最多一次),带可直接发送的 `todo_write` JSON;不匹配、没有流、解析失败都静默跳过,**绝不阻塞任务**。
|
|
48
|
-
- **中文 todo
|
|
48
|
+
- **中文 todo 标题**(`translateTodoContent`):英文 todo 标题经 `llm` 批量翻译成「中文(English)」,并在下一次 turn 通过一条新的 `todo/write` 快照迁移已有列表;任务面板与 notice 都显示中文,状态不变。按标题缓存、超时 3 秒可配;翻译失败保留原文。
|
|
49
49
|
- notice 的 source kind 按会话格式自动选择:v4 用 `plugin:task-guard`,v3 用 `plugin` + `plugin: 'task-guard'`。
|
|
50
50
|
|
|
51
51
|
### 4. 重启 / 关闭 DSH
|
|
@@ -191,7 +191,7 @@ pnpm add dsh-mcviseron-plugin
|
|
|
191
191
|
| `include` | string[] | `[]` | 只统计这些工具名(支持 `*`);空 = 全部 |
|
|
192
192
|
| `exclude` | string[] | `todo_write`, `ask_user_question` | 不统计的工具名 |
|
|
193
193
|
| `detectStepIntent` | boolean | `true` | 从思考/正文里识别「Now I will …」等句式并匹配 pending todo,命中时发一条定向 notice(仅建议) |
|
|
194
|
-
| `translateTodoContent` | boolean | `true` |
|
|
194
|
+
| `translateTodoContent` | boolean | `true` | 英文 todo 标题写入为「中文(English)」,迁移已有列表并显示在任务面板/notice |
|
|
195
195
|
| `todoTranslationTimeoutMs` | number | `3000` | 单次批量 todo 翻译超时,500–15000 |
|
|
196
196
|
|
|
197
197
|
### `restart`
|
|
@@ -250,12 +250,12 @@ DSH 0.2 的官方设置 apiproxy 不向浏览器暴露第三方命名空间,
|
|
|
250
250
|
|
|
251
251
|
| DSH 版本 | 状态 |
|
|
252
252
|
| --- | --- |
|
|
253
|
-
| `0.2.2-rc.5` | ✅ 预适配(0.2.2-rc.5 类型/依赖 +
|
|
254
|
-
| `0.2.2-rc.3` | ✅ 当前桌面安装(rc.3 类型/依赖 +
|
|
255
|
-
| `0.2.2-rc.1` | ✅ 兼容(0.2.2-rc.1 类型/依赖 +
|
|
256
|
-
| `0.2.1-rc.5` | ✅ 兼容(rc.5 类型/依赖 +
|
|
257
|
-
| `0.2.1-rc.3` | ✅ 兼容(rc.3 类型/依赖 +
|
|
258
|
-
| `0.2.1-rc.2` | ✅ 当前桌面运行版本(
|
|
253
|
+
| `0.2.2-rc.5` | ✅ 预适配(0.2.2-rc.5 类型/依赖 + 130 项测试;当前桌面仍为 rc.3) |
|
|
254
|
+
| `0.2.2-rc.3` | ✅ 当前桌面安装(rc.3 类型/依赖 + 130 项测试;真实运行时验证) |
|
|
255
|
+
| `0.2.2-rc.1` | ✅ 兼容(0.2.2-rc.1 类型/依赖 + 130 项测试) |
|
|
256
|
+
| `0.2.1-rc.5` | ✅ 兼容(rc.5 类型/依赖 + 130 项测试) |
|
|
257
|
+
| `0.2.1-rc.3` | ✅ 兼容(rc.3 类型/依赖 + 130 项测试) |
|
|
258
|
+
| `0.2.1-rc.2` | ✅ 当前桌面运行版本(130 项测试 + 真实 Cordis 上下文) |
|
|
259
259
|
| `0.2.0-rc.x` | ✅ peer 范围覆盖(同一套设置、审批与 hook 接缝) |
|
|
260
260
|
| `0.1.x` | ❌ 不支持:0.1 的插件自行注册设置命名空间,与本插件的条目 id 命名空间模型不同 |
|
|
261
261
|
|
|
@@ -321,7 +321,7 @@ test/
|
|
|
321
321
|
|
|
322
322
|
```bash
|
|
323
323
|
pnpm install
|
|
324
|
-
pnpm check # typecheck +
|
|
324
|
+
pnpm check # typecheck + 130 项测试 + 构建
|
|
325
325
|
```
|
|
326
326
|
|
|
327
327
|
构建产物:`lib/index.js`(master ESM)、`lib/appearance.js`、`lib/auto-review-fix.js`、`lib/task-guard.js`、`lib/restart.js` 与 `lib/client.js`(浏览器模块)。`lib/` 不入库。
|
package/SECURITY.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
- 插件自身不发起外部网络请求、不读取凭据、不执行命令。
|
|
16
16
|
- **Auto review 译文例外(经由宿主)**:开启 `translateApprovalReason` 时,插件会通过 Host 的 `llm` 服务,把审查理由(去掉 `Auto review denied this call:` 前缀后的正文)作为一次短请求发给当前会话的 provider/model,或 `translateProvider`/`translateModel` 指定的模型。请求不携带文件内容或会话记录;可用 `translateApprovalReason: false` 完全关闭。
|
|
17
17
|
- 审批译文失败(超时、无 `llm`、无会话路由、无 `displayReason`、模型报错)一律原样放行审批,不会阻塞或改写审计文本。
|
|
18
|
-
- **Todo 标题译文(经由宿主)**:开启 `translateTodoContent` 时,`mcviseron-task-guard` 会把待展示的 todo 标题(最多 `maxListItems` 条)通过 Host `llm` 服务批量发给当前会话的 provider/model,用于生成「中文(English
|
|
18
|
+
- **Todo 标题译文(经由宿主)**:开启 `translateTodoContent` 时,`mcviseron-task-guard` 会把待展示的 todo 标题(最多 `maxListItems` 条)通过 Host `llm` 服务批量发给当前会话的 provider/model,用于生成「中文(English)」显示;请求不包含会话记录或文件内容,可按需关闭。译文会写入一条新的 `todo/write` 快照(状态不变),用于任务面板与 notice 显示。
|
|
19
19
|
|
|
20
20
|
### 设置桥
|
|
21
21
|
|
package/docs/linux-restart.md
CHANGED
|
@@ -76,7 +76,9 @@ restartPolicy: OnFailure
|
|
|
76
76
|
|
|
77
77
|
直接运行 `dsh web` 时使用 reexec helper;关闭后进程直接结束,不会被重新拉起。
|
|
78
78
|
|
|
79
|
-
##
|
|
79
|
+
## 设置页、侧边栏与会话后动作
|
|
80
|
+
|
|
81
|
+
侧边栏底部新增 **「重启 DSH」** 快捷按钮(`sidebar.footer.action`,位于设置上方);它复用同一 `/api/dsh-mcviseron/restart/execute` 路由,不替代设置页。「设置」里原有的重启/关闭按钮保持不变。
|
|
80
82
|
|
|
81
83
|
- 「重启 / 关闭」设置页同时提供重启与关闭按钮;
|
|
82
84
|
- 状态会显示当前模式(desktop / reexec / supervisor-exit);
|
|
@@ -71,7 +71,7 @@ Todo 守卫字段名也完全一致(`enabled`、`locale`、`staleAfterCalls`
|
|
|
71
71
|
|
|
72
72
|
- 条目 `mcviseron-auto-review` 更名为 **`mcviseron-auto-review-fix`**,模块改为 `dsh-mcviseron-plugin/auto-review-fix`;profile 里直接改 id 与 name 即可,配置字段不变。
|
|
73
73
|
- `mcviseron-task-guard` 新增三个可选字段:`detectStepIntent`(默认 `true`)、`translateTodoContent`(默认 `true`)、`todoTranslationTimeoutMs`(默认 `3000`)。不写即用默认值。
|
|
74
|
-
- 注意:`translateTodoContent` 会把
|
|
74
|
+
- 注意:`translateTodoContent` 会把 todo 标题经宿主 `llm` 翻译并写入新的 `todo/write` 快照;不需要时显式设为 `false`。
|
|
75
75
|
|
|
76
76
|
## 2. 从 0.2.0 的嵌套配置迁移
|
|
77
77
|
|
package/lib/client.js
CHANGED
|
@@ -1434,6 +1434,10 @@ function SettingsSection({ t }) {
|
|
|
1434
1434
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.sessionEnd") }),
|
|
1435
1435
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.sessionEndHint") })
|
|
1436
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
|
+
] }),
|
|
1437
1441
|
archive?.available ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: pageStyles.componentRow, children: [
|
|
1438
1442
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentName, children: t("page.components.archive") }),
|
|
1439
1443
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: pageStyles.componentHint, children: t("page.components.archiveHint") })
|
|
@@ -1443,6 +1447,90 @@ function SettingsSection({ t }) {
|
|
|
1443
1447
|
] });
|
|
1444
1448
|
}
|
|
1445
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
|
+
|
|
1446
1534
|
// src/client/driver.ts
|
|
1447
1535
|
var TICK_MS = 2e4;
|
|
1448
1536
|
var RETRY_MS = 6e4;
|
|
@@ -1620,6 +1708,8 @@ var zh = {
|
|
|
1620
1708
|
"page.restart.restarting": "\u6B63\u5728\u91CD\u542F\u2026\u7A97\u53E3\u4F1A\u77ED\u6682\u5173\u95ED",
|
|
1621
1709
|
"page.restart.failed": "\u91CD\u542F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
1622
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",
|
|
1623
1713
|
"page.components.title": "\u7EC4\u4EF6",
|
|
1624
1714
|
"page.components.appearance": "\u5916\u89C2 \xB7 \u6309\u65F6\u95F4\u5207\u6362",
|
|
1625
1715
|
"page.components.appearanceHint": "\u8BBE\u7F6E\u4F4D\u4E8E\u300C\u901A\u7528 \u2192 \u5916\u89C2\u300D",
|
|
@@ -1674,8 +1764,8 @@ var zh = {
|
|
|
1674
1764
|
"form.taskGuard.maxListItems": "notice \u6700\u591A\u5217\u51FA\u4EFB\u52A1\u6570",
|
|
1675
1765
|
"form.taskGuard.detectStepIntent": "\u8BC6\u522B\u6B65\u9AA4\u610F\u56FE",
|
|
1676
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",
|
|
1677
|
-
"form.taskGuard.translateTodo": "\u4E2D\u6587
|
|
1678
|
-
"form.taskGuard.translateTodoHint": "\
|
|
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",
|
|
1679
1769
|
"form.taskGuard.todoTimeout": "todo \u7FFB\u8BD1\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
1680
1770
|
"form.taskGuard.include": "\u53EA\u7EDF\u8BA1\u8FD9\u4E9B\u5DE5\u5177",
|
|
1681
1771
|
"form.taskGuard.exclude": "\u4E0D\u7EDF\u8BA1\u8FD9\u4E9B\u5DE5\u5177",
|
|
@@ -1698,6 +1788,8 @@ var zh = {
|
|
|
1698
1788
|
"page.components.authCookieHint": "\u81EA\u52A8\u8FD0\u884C\uFF0C\u65E0\u8BBE\u7F6E",
|
|
1699
1789
|
"page.components.sessionEnd": "\u4F1A\u8BDD\u540E\u52A8\u4F5C",
|
|
1700
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",
|
|
1701
1793
|
"page.components.archive": "\u5F52\u6863\u65F6\u95F4\uFF08\u53EF\u9009\uFF09",
|
|
1702
1794
|
"page.components.archiveHint": "\u68C0\u6D4B\u5230\u7B2C\u4E09\u65B9\u5F52\u6863\u63D2\u4EF6\u65F6\u663E\u793A",
|
|
1703
1795
|
"form.sessionEnd.enabled": "\u542F\u7528\u4F1A\u8BDD\u540E\u52A8\u4F5C",
|
|
@@ -1766,6 +1858,8 @@ var en = {
|
|
|
1766
1858
|
"page.restart.restarting": "Restarting\u2026 the window will close briefly",
|
|
1767
1859
|
"page.restart.failed": "Restart failed \u2014 try again",
|
|
1768
1860
|
"page.restart.confirm": "Restart DeepSeek Harness now? Running tasks will be interrupted.",
|
|
1861
|
+
"sidebar.restart": "Restart DSH",
|
|
1862
|
+
"sidebar.restarting": "Restarting\u2026",
|
|
1769
1863
|
"page.components.title": "Components",
|
|
1770
1864
|
"page.components.appearance": "Appearance \xB7 light/dark by time",
|
|
1771
1865
|
"page.components.appearanceHint": "Configured under General \u2192 Appearance",
|
|
@@ -1820,8 +1914,8 @@ var en = {
|
|
|
1820
1914
|
"form.taskGuard.maxListItems": "Maximum tasks listed in a notice",
|
|
1821
1915
|
"form.taskGuard.detectStepIntent": "Detect step intent",
|
|
1822
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",
|
|
1823
|
-
"form.taskGuard.translateTodo": "
|
|
1824
|
-
"form.taskGuard.translateTodoHint": "
|
|
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",
|
|
1825
1919
|
"form.taskGuard.todoTimeout": "Todo translation timeout (ms)",
|
|
1826
1920
|
"form.taskGuard.include": "Count only these tools",
|
|
1827
1921
|
"form.taskGuard.exclude": "Exclude these tools",
|
|
@@ -1844,6 +1938,8 @@ var en = {
|
|
|
1844
1938
|
"page.components.authCookieHint": "Runs automatically; no settings",
|
|
1845
1939
|
"page.components.sessionEnd": "After-session action",
|
|
1846
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",
|
|
1847
1943
|
"page.components.archive": "Archive time (optional)",
|
|
1848
1944
|
"page.components.archiveHint": "Shown only when the third-party archive plugin is detected",
|
|
1849
1945
|
"form.sessionEnd.enabled": "Enable after-session actions",
|
|
@@ -1929,6 +2025,12 @@ function apply(ctx) {
|
|
|
1929
2025
|
order: 20,
|
|
1930
2026
|
locale: NS
|
|
1931
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);
|
|
1932
2034
|
registerSafely(ctx, "settings.section", {
|
|
1933
2035
|
id: "mcviseron",
|
|
1934
2036
|
order: 115,
|
package/lib/index.js
CHANGED
|
@@ -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
|
});
|
|
@@ -14175,6 +14176,34 @@ function suggestedTodoPayload(todos, matched) {
|
|
|
14175
14176
|
}));
|
|
14176
14177
|
return JSON.stringify({ todos: next });
|
|
14177
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
|
+
}
|
|
14178
14207
|
function installTaskGuard(ctx, input) {
|
|
14179
14208
|
const config = resolveConfig(input);
|
|
14180
14209
|
const bus = ctx;
|
|
@@ -14270,6 +14299,7 @@ function installTaskGuard(ctx, input) {
|
|
|
14270
14299
|
});
|
|
14271
14300
|
bus.on("agent/pre-step", async (payload, next) => {
|
|
14272
14301
|
const sessionId = sessionIdOf4(payload.agent);
|
|
14302
|
+
void migrateStoredTodoList(payload.agent.session, config, ctx);
|
|
14273
14303
|
if (sessionId !== "") intentBuffers.delete(sessionId);
|
|
14274
14304
|
const state = sessions.get(sessionId);
|
|
14275
14305
|
if (state !== void 0) {
|
|
@@ -14299,12 +14329,14 @@ function installTaskGuard(ctx, input) {
|
|
|
14299
14329
|
if (event.type === "turn/start" || event.type === "turn/end") {
|
|
14300
14330
|
sessions.delete(sessionId);
|
|
14301
14331
|
intentBuffers.delete(sessionId);
|
|
14332
|
+
void migrateStoredTodoList(session, config, ctx);
|
|
14302
14333
|
return;
|
|
14303
14334
|
}
|
|
14304
14335
|
if (event.type === "todo/write") {
|
|
14305
14336
|
const todos = readTodos(event.data);
|
|
14306
14337
|
if (todos !== null) resetState(sessions, sessionId, todos);
|
|
14307
14338
|
intentBuffers.delete(sessionId);
|
|
14339
|
+
void migrateStoredTodoList(session, config, ctx);
|
|
14308
14340
|
}
|
|
14309
14341
|
});
|
|
14310
14342
|
}
|
package/lib/task-guard.js
CHANGED
|
@@ -295,6 +295,34 @@ function suggestedTodoPayload(todos, matched) {
|
|
|
295
295
|
}));
|
|
296
296
|
return JSON.stringify({ todos: next });
|
|
297
297
|
}
|
|
298
|
+
function latestTodos(session) {
|
|
299
|
+
try {
|
|
300
|
+
const events = session.snapshotEvents?.();
|
|
301
|
+
if (!Array.isArray(events)) return null;
|
|
302
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
303
|
+
const event = events[index];
|
|
304
|
+
if (event?.type !== "todo/write") continue;
|
|
305
|
+
return readTodos(event.data);
|
|
306
|
+
}
|
|
307
|
+
} catch {
|
|
308
|
+
}
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
async function migrateStoredTodoList(session, config, ctx) {
|
|
312
|
+
if (!config.translateTodoContent) return;
|
|
313
|
+
const todos = latestTodos(session);
|
|
314
|
+
if (todos === null || todos.length === 0) return;
|
|
315
|
+
const context = noticeContext({ session }, config, ctx);
|
|
316
|
+
if (!context.translate) return;
|
|
317
|
+
const contents = todos.map((todo) => todo.content);
|
|
318
|
+
const translated = await displayTodoContents(contents, context);
|
|
319
|
+
if (!translated.some((value, index) => value !== contents[index])) return;
|
|
320
|
+
if (typeof session.append !== "function") return;
|
|
321
|
+
try {
|
|
322
|
+
session.append("todo/write", { todos: translated.map((content, index) => ({ content, status: todos[index].status })) });
|
|
323
|
+
} catch {
|
|
324
|
+
}
|
|
325
|
+
}
|
|
298
326
|
function installTaskGuard(ctx, input) {
|
|
299
327
|
const config = resolveConfig(input);
|
|
300
328
|
const bus = ctx;
|
|
@@ -390,6 +418,7 @@ function installTaskGuard(ctx, input) {
|
|
|
390
418
|
});
|
|
391
419
|
bus.on("agent/pre-step", async (payload, next) => {
|
|
392
420
|
const sessionId = sessionIdOf(payload.agent);
|
|
421
|
+
void migrateStoredTodoList(payload.agent.session, config, ctx);
|
|
393
422
|
if (sessionId !== "") intentBuffers.delete(sessionId);
|
|
394
423
|
const state = sessions.get(sessionId);
|
|
395
424
|
if (state !== void 0) {
|
|
@@ -419,12 +448,14 @@ function installTaskGuard(ctx, input) {
|
|
|
419
448
|
if (event.type === "turn/start" || event.type === "turn/end") {
|
|
420
449
|
sessions.delete(sessionId);
|
|
421
450
|
intentBuffers.delete(sessionId);
|
|
451
|
+
void migrateStoredTodoList(session, config, ctx);
|
|
422
452
|
return;
|
|
423
453
|
}
|
|
424
454
|
if (event.type === "todo/write") {
|
|
425
455
|
const todos = readTodos(event.data);
|
|
426
456
|
if (todos !== null) resetState(sessions, sessionId, todos);
|
|
427
457
|
intentBuffers.delete(sessionId);
|
|
458
|
+
void migrateStoredTodoList(session, config, ctx);
|
|
428
459
|
}
|
|
429
460
|
});
|
|
430
461
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mcviseron-plugin",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "DeepSeek Harness (DSH) master plugin — one package hosting MCviseron's DSH components as separate bundle entries: a time-based light/dark Appearance schedule, an Auto-review fix (shutdown preset guard + Chinese approval-reason translation), and a todo plan guard that keeps multi-stage work advancing, one-shot after-session restart/close actions with task-aware waiting, and automatic auth-cookie hygiene for repeated desktop restarts, and model-editable official automation tasks.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -371,6 +371,7 @@ export function apply(ctx: Context): void {
|
|
|
371
371
|
text: [
|
|
372
372
|
'Official DSH automation tasks are writable from this conversation.',
|
|
373
373
|
'Use automation_task_list / automation_task_create / automation_task_update / automation_task_delete; they call the Host schedule service and persist automatically.',
|
|
374
|
+
'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.',
|
|
374
375
|
'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.',
|
|
375
376
|
].join(' '),
|
|
376
377
|
})
|
|
@@ -209,6 +209,10 @@ export function SettingsSection({ t }: SettingsSectionProps) {
|
|
|
209
209
|
<span style={pageStyles.componentName}>{t('page.components.sessionEnd')}</span>
|
|
210
210
|
<span style={pageStyles.componentHint}>{t('page.components.sessionEndHint')}</span>
|
|
211
211
|
</div>
|
|
212
|
+
<div style={pageStyles.componentRow}>
|
|
213
|
+
<span style={pageStyles.componentName}>{t('page.components.automationTasks')}</span>
|
|
214
|
+
<span style={pageStyles.componentHint}>{t('page.components.automationTasksHint')}</span>
|
|
215
|
+
</div>
|
|
212
216
|
{archive?.available
|
|
213
217
|
? (
|
|
214
218
|
<div style={pageStyles.componentRow}>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import type { McviseronKey } from './locales.ts'
|
|
3
|
+
|
|
4
|
+
const STATUS = '/api/dsh-mcviseron/restart/status'
|
|
5
|
+
const EXECUTE = '/api/dsh-mcviseron/restart/execute'
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
wide?: boolean
|
|
9
|
+
t: (key: McviseronKey) => string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** One sidebar footer action: restart DSH without opening Settings. */
|
|
13
|
+
export function SidebarRestartAction({ wide = true, t }: Props) {
|
|
14
|
+
const [available, setAvailable] = useState<boolean | null>(null)
|
|
15
|
+
const [busy, setBusy] = useState(false)
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
let cancelled = false
|
|
19
|
+
void (async () => {
|
|
20
|
+
try {
|
|
21
|
+
const response = await fetch(STATUS, { method: 'GET', cache: 'no-store', credentials: 'same-origin' })
|
|
22
|
+
if (cancelled) return
|
|
23
|
+
if (!response.ok) { setAvailable(false); return }
|
|
24
|
+
const body = await response.json() as { available?: unknown }
|
|
25
|
+
setAvailable(body.available === true)
|
|
26
|
+
} catch {
|
|
27
|
+
if (!cancelled) setAvailable(false)
|
|
28
|
+
}
|
|
29
|
+
})()
|
|
30
|
+
return () => { cancelled = true }
|
|
31
|
+
}, [])
|
|
32
|
+
|
|
33
|
+
if (available !== true) return null
|
|
34
|
+
|
|
35
|
+
const restart = async (): Promise<void> => {
|
|
36
|
+
if (busy || !window.confirm(t('page.restart.confirm'))) return
|
|
37
|
+
setBusy(true)
|
|
38
|
+
try {
|
|
39
|
+
const response = await fetch(EXECUTE, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: { 'content-type': 'application/json' },
|
|
42
|
+
credentials: 'same-origin',
|
|
43
|
+
body: JSON.stringify({ confirm: true, action: 'restart' }),
|
|
44
|
+
})
|
|
45
|
+
if (!response.ok) throw new Error('HTTP ' + String(response.status))
|
|
46
|
+
const body = await response.json() as { ok?: unknown }
|
|
47
|
+
if (body.ok !== true) throw new Error('restart-rejected')
|
|
48
|
+
} catch (error) {
|
|
49
|
+
setBusy(false)
|
|
50
|
+
window.alert(t('page.restart.failed') + ': ' + (error instanceof Error ? error.message : String(error)))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<button
|
|
56
|
+
type="button"
|
|
57
|
+
title={t('sidebar.restart')}
|
|
58
|
+
aria-label={t('sidebar.restart')}
|
|
59
|
+
disabled={busy}
|
|
60
|
+
onClick={() => { void restart() }}
|
|
61
|
+
style={{
|
|
62
|
+
display: 'flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
justifyContent: wide ? 'flex-start' : 'center',
|
|
65
|
+
gap: wide ? 8 : 0,
|
|
66
|
+
width: '100%',
|
|
67
|
+
padding: wide ? '8px 12px' : '8px',
|
|
68
|
+
border: 0,
|
|
69
|
+
borderRadius: 8,
|
|
70
|
+
background: 'transparent',
|
|
71
|
+
color: 'inherit',
|
|
72
|
+
cursor: busy ? 'wait' : 'pointer',
|
|
73
|
+
font: 'inherit',
|
|
74
|
+
textAlign: 'left',
|
|
75
|
+
opacity: busy ? 0.6 : 1,
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
79
|
+
<path d="M13 5.2A5.5 5.5 0 1 0 13.4 10" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" />
|
|
80
|
+
<path d="M13 2.8v3.4H9.6" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />
|
|
81
|
+
</svg>
|
|
82
|
+
{wide ? <span>{busy ? t('sidebar.restarting') : t('sidebar.restart')}</span> : null}
|
|
83
|
+
</button>
|
|
84
|
+
)
|
|
85
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { AppearanceScheduleRow } from './AppearanceScheduleRow.tsx'
|
|
|
8
8
|
import { FallbackRestartRow } from './FallbackRestartRow.tsx'
|
|
9
9
|
import { SessionEndControl } from './SessionEndControl.tsx'
|
|
10
10
|
import { SettingsSection } from './SettingsSection.tsx'
|
|
11
|
+
import { SidebarRestartAction } from './SidebarRestartAction.tsx'
|
|
11
12
|
import { ScheduleDriver, type ThemeFace } from './driver.ts'
|
|
12
13
|
import { en, zh, type McviseronKey } from './locales.ts'
|
|
13
14
|
import { sectionPresence } from './section-presence.ts'
|
|
@@ -135,6 +136,13 @@ export function apply(ctx: ClientContext): void {
|
|
|
135
136
|
locale: NS,
|
|
136
137
|
}, SessionEndControl)
|
|
137
138
|
|
|
139
|
+
registerSafely(ctx, 'sidebar.footer.action', {
|
|
140
|
+
id: 'mcviseron-restart',
|
|
141
|
+
order: 90,
|
|
142
|
+
label: '重启 DSH',
|
|
143
|
+
locale: NS,
|
|
144
|
+
}, SidebarRestartAction)
|
|
145
|
+
|
|
138
146
|
registerSafely(ctx, 'settings.section', {
|
|
139
147
|
id: 'mcviseron',
|
|
140
148
|
order: 115,
|
package/src/client/locales.ts
CHANGED
|
@@ -55,6 +55,8 @@ export const zh = {
|
|
|
55
55
|
'page.restart.restarting': '正在重启…窗口会短暂关闭',
|
|
56
56
|
'page.restart.failed': '重启失败,请重试',
|
|
57
57
|
'page.restart.confirm': '确定要重启 DeepSeek Harness 吗?正在运行的任务会被中断。',
|
|
58
|
+
'sidebar.restart': '重启 DSH',
|
|
59
|
+
'sidebar.restarting': '正在重启…',
|
|
58
60
|
'page.components.title': '组件',
|
|
59
61
|
'page.components.appearance': '外观 · 按时间切换',
|
|
60
62
|
'page.components.appearanceHint': '设置位于「通用 → 外观」',
|
|
@@ -109,8 +111,8 @@ export const zh = {
|
|
|
109
111
|
'form.taskGuard.maxListItems': 'notice 最多列出任务数',
|
|
110
112
|
'form.taskGuard.detectStepIntent': '识别步骤意图',
|
|
111
113
|
'form.taskGuard.detectStepIntentHint': '识别「Now I will …」等步骤意图,以及「All nets routed」「DRC passes」「原理图完成」等阶段完成语句;命中时提供可直接发送的 todo_write',
|
|
112
|
-
'form.taskGuard.translateTodo': '
|
|
113
|
-
'form.taskGuard.translateTodoHint': '
|
|
114
|
+
'form.taskGuard.translateTodo': '中文 todo 标题(写入并显示)',
|
|
115
|
+
'form.taskGuard.translateTodoHint': 'todo_write 标题写成 中文(English);已有列表在下一次 turn 自动迁移,状态不变',
|
|
114
116
|
'form.taskGuard.todoTimeout': 'todo 翻译超时(毫秒)',
|
|
115
117
|
'form.taskGuard.include': '只统计这些工具',
|
|
116
118
|
'form.taskGuard.exclude': '不统计这些工具',
|
|
@@ -134,6 +136,8 @@ export const zh = {
|
|
|
134
136
|
'page.components.authCookieHint': '自动运行,无设置',
|
|
135
137
|
'page.components.sessionEnd': '会话后动作',
|
|
136
138
|
'page.components.sessionEndHint': '输入框左侧的「会话后重启」下拉',
|
|
139
|
+
'page.components.automationTasks': '自动化任务 API',
|
|
140
|
+
'page.components.automationTasksHint': 'automation_task_list/create/update/delete;Host schedule.list/create/edit,详见 docs/automation-tasks.md',
|
|
137
141
|
'page.components.archive': '归档时间(可选)',
|
|
138
142
|
'page.components.archiveHint': '检测到第三方归档插件时显示',
|
|
139
143
|
'form.sessionEnd.enabled': '启用会话后动作',
|
|
@@ -205,6 +209,8 @@ export const en = {
|
|
|
205
209
|
'page.restart.restarting': 'Restarting… the window will close briefly',
|
|
206
210
|
'page.restart.failed': 'Restart failed — try again',
|
|
207
211
|
'page.restart.confirm': 'Restart DeepSeek Harness now? Running tasks will be interrupted.',
|
|
212
|
+
'sidebar.restart': 'Restart DSH',
|
|
213
|
+
'sidebar.restarting': 'Restarting…',
|
|
208
214
|
'page.components.title': 'Components',
|
|
209
215
|
'page.components.appearance': 'Appearance · light/dark by time',
|
|
210
216
|
'page.components.appearanceHint': 'Configured under General → Appearance',
|
|
@@ -259,8 +265,8 @@ export const en = {
|
|
|
259
265
|
'form.taskGuard.maxListItems': 'Maximum tasks listed in a notice',
|
|
260
266
|
'form.taskGuard.detectStepIntent': 'Detect step intent',
|
|
261
267
|
'form.taskGuard.detectStepIntentHint': 'Recognizes step intent (“Now I will …”) and completion statements (“All nets routed”, “DRC passes”); the notice carries a ready todo_write',
|
|
262
|
-
'form.taskGuard.translateTodo': '
|
|
263
|
-
'form.taskGuard.translateTodoHint': '
|
|
268
|
+
'form.taskGuard.translateTodo': 'Chinese todo titles (stored and displayed)',
|
|
269
|
+
'form.taskGuard.translateTodoHint': 'Stores titles as Chinese (English); migrates existing lists on the next turn without changing statuses',
|
|
264
270
|
'form.taskGuard.todoTimeout': 'Todo translation timeout (ms)',
|
|
265
271
|
'form.taskGuard.include': 'Count only these tools',
|
|
266
272
|
'form.taskGuard.exclude': 'Exclude these tools',
|
|
@@ -284,6 +290,8 @@ export const en = {
|
|
|
284
290
|
'page.components.authCookieHint': 'Runs automatically; no settings',
|
|
285
291
|
'page.components.sessionEnd': 'After-session action',
|
|
286
292
|
'page.components.sessionEndHint': 'The “Restart after session” dropdown left of the composer',
|
|
293
|
+
'page.components.automationTasks': 'Automation task API',
|
|
294
|
+
'page.components.automationTasksHint': 'automation_task_list/create/update/delete; Host schedule.list/create/edit; see docs/automation-tasks.md',
|
|
287
295
|
'page.components.archive': 'Archive time (optional)',
|
|
288
296
|
'page.components.archiveHint': 'Shown only when the third-party archive plugin is detected',
|
|
289
297
|
'form.sessionEnd.enabled': 'Enable after-session actions',
|
|
@@ -544,6 +544,53 @@ function suggestedTodoPayload(todos: TodoItem[], matched: TodoItem): string | un
|
|
|
544
544
|
return JSON.stringify({ todos: next })
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
548
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
interface SessionRecordLike {
|
|
552
|
+
readonly id?: unknown
|
|
553
|
+
readonly requestHeader?: () => unknown
|
|
554
|
+
readonly snapshotEvents?: () => readonly unknown[]
|
|
555
|
+
readonly append?: (type: string, data: unknown) => unknown
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function latestTodos(session: SessionRecordLike): TodoItem[] | null {
|
|
559
|
+
try {
|
|
560
|
+
const events = session.snapshotEvents?.()
|
|
561
|
+
if (!Array.isArray(events)) return null
|
|
562
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
563
|
+
const event = events[index] as { type?: unknown; data?: unknown } | undefined
|
|
564
|
+
if (event?.type !== 'todo/write') continue
|
|
565
|
+
return readTodos(event.data)
|
|
566
|
+
}
|
|
567
|
+
} catch {
|
|
568
|
+
/* a host without snapshot access keeps the current list untouched */
|
|
569
|
+
}
|
|
570
|
+
return null
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Migrate an already-stored English plan once, so the official task panel
|
|
575
|
+
* displays the same bilingual titles as future todo_write calls.
|
|
576
|
+
*/
|
|
577
|
+
async function migrateStoredTodoList(session: SessionRecordLike, config: ResolvedConfig, ctx: Context): Promise<void> {
|
|
578
|
+
if (!config.translateTodoContent) return
|
|
579
|
+
const todos = latestTodos(session)
|
|
580
|
+
if (todos === null || todos.length === 0) return
|
|
581
|
+
const context = noticeContext({ session } as AgentLike, config, ctx)
|
|
582
|
+
if (!context.translate) return
|
|
583
|
+
const contents = todos.map(todo => todo.content)
|
|
584
|
+
const translated = await displayTodoContents(contents, context)
|
|
585
|
+
if (!translated.some((value, index) => value !== contents[index])) return
|
|
586
|
+
if (typeof session.append !== 'function') return
|
|
587
|
+
try {
|
|
588
|
+
session.append('todo/write', { todos: translated.map((content, index) => ({ content, status: todos[index].status })) })
|
|
589
|
+
} catch {
|
|
590
|
+
/* a disposed session or host-owned fold rejects the migration */
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
547
594
|
/**
|
|
548
595
|
* Install the todo plan guard on the master plugin context.
|
|
549
596
|
*
|
|
@@ -670,6 +717,7 @@ export function installTaskGuard(ctx: Context, input?: TaskGuardConfig): void {
|
|
|
670
717
|
|
|
671
718
|
bus.on('agent/pre-step', async (payload, next) => {
|
|
672
719
|
const sessionId = sessionIdOf(payload.agent)
|
|
720
|
+
void migrateStoredTodoList(payload.agent.session as unknown as SessionRecordLike, config, ctx)
|
|
673
721
|
if (sessionId !== '') intentBuffers.delete(sessionId)
|
|
674
722
|
const state = sessions.get(sessionId)
|
|
675
723
|
if (state !== undefined) {
|
|
@@ -702,6 +750,7 @@ export function installTaskGuard(ctx: Context, input?: TaskGuardConfig): void {
|
|
|
702
750
|
if (event.type === 'turn/start' || event.type === 'turn/end') {
|
|
703
751
|
sessions.delete(sessionId)
|
|
704
752
|
intentBuffers.delete(sessionId)
|
|
753
|
+
void migrateStoredTodoList(session as unknown as SessionRecordLike, config, ctx)
|
|
705
754
|
return
|
|
706
755
|
}
|
|
707
756
|
|
|
@@ -709,6 +758,7 @@ export function installTaskGuard(ctx: Context, input?: TaskGuardConfig): void {
|
|
|
709
758
|
const todos = readTodos(event.data)
|
|
710
759
|
if (todos !== null) resetState(sessions, sessionId, todos)
|
|
711
760
|
intentBuffers.delete(sessionId)
|
|
761
|
+
void migrateStoredTodoList(session as unknown as SessionRecordLike, config, ctx)
|
|
712
762
|
}
|
|
713
763
|
})
|
|
714
764
|
}
|