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/CHANGELOG.md +63 -0
- package/README.en.md +12 -11
- package/README.md +15 -14
- package/SECURITY.md +1 -1
- package/docs/automation-tasks.md +49 -0
- package/docs/linux-restart.md +98 -0
- package/docs/migration-from-standalone.md +1 -1
- package/lib/client.js +173 -30
- package/lib/index.js +130 -20
- package/lib/restart.js +94 -16
- package/lib/task-guard.js +31 -0
- package/package.json +1 -1
- package/src/automation-tasks/index.ts +1 -0
- package/src/client/RestartCard.tsx +38 -5
- 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 +34 -16
- package/src/components/task-guard/index.ts +50 -0
- package/src/restart/index.ts +139 -30
- package/src/session-end/index.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
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
|
+
|
|
36
|
+
## [0.8.1] - 2026-11-22
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- **Linux CI 测试环境差异**:`resolveRestartTarget` 的 Linux 目标单测不再假定必然是 reexec;CI runner 若带 systemd 环境变量时允许 supervisor-exit,具体模式由 `resolveProcessRestartTarget` 的独立测试覆盖。
|
|
41
|
+
|
|
42
|
+
### Tests
|
|
43
|
+
|
|
44
|
+
- 129 项测试;typecheck、build 全绿。
|
|
45
|
+
|
|
46
|
+
## [0.8.0] - 2026-11-22
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- **Linux / Web / 云服务器重启与关闭**:重启目标从 Windows 桌面扩展到非 Windows Host 进程。systemd / Docker / Kubernetes / PID 1 使用 supervisor-exit(退出码 75);普通 `dsh web` 使用 detached reexec helper,等待旧 PID 退出后再启动同一 argv/cwd。可用 `DSH_MCVISERON_RESTART_MODE=reexec|supervisor-exit` 覆盖。
|
|
51
|
+
- **设置页「重启 / 关闭」**:状态显示 desktop / reexec / supervisor-exit;新增关闭 DSH 按钮;Linux/Web 下 `set_session_end_action` 的 restart/close 可用,OS 关机仍为 Windows-only。
|
|
52
|
+
- **文档**:新增 [docs/linux-restart.md](docs/linux-restart.md),包含 systemd、Docker、Kubernetes 和普通 CLI 的部署/停止策略。
|
|
53
|
+
|
|
54
|
+
### Tests
|
|
55
|
+
|
|
56
|
+
- 合计 **129 项测试**;typecheck、build 全绿。
|
|
57
|
+
|
|
1
58
|
## [Unreleased]
|
|
2
59
|
|
|
3
60
|
### 计划中
|
|
@@ -6,6 +63,12 @@
|
|
|
6
63
|
- 设置行支持「立即测试」预览按钮。
|
|
7
64
|
- Restart 组件支持 macOS/Linux(当前仅 Windows 桌面版)。
|
|
8
65
|
|
|
66
|
+
## [Unreleased]
|
|
67
|
+
|
|
68
|
+
### Docs
|
|
69
|
+
|
|
70
|
+
- 在 `docs/automation-tasks.md` 补充 Host Schedule 管理 API:0.2.2 的 `list({}) -> { items }`、`create(request, sessionId, signal)`、`edit({ id, action, patch }, sessionId, signal)`,以及旧版 `list({ sessionId })` / `create(sessionId, request)` / `update` / `delete` 的兼容层与 timing 映射;README 组件表加入文档链接。
|
|
71
|
+
|
|
9
72
|
## [0.7.8] - 2026-11-22
|
|
10
73
|
|
|
11
74
|
### Fixed
|
package/README.en.md
CHANGED
|
@@ -11,10 +11,10 @@ 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
|
|
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
|
-
| **Automation task editing** | built-in tools | `automation_task_list/create/update/delete` call the Host schedule service and persist automatically |
|
|
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 |
|
|
18
18
|
| **Archive-time integration (optional)** | conditional | Shows the Archive time tab only when `@linxin666/dsh-session-archive` is detected; no registration when absent |
|
|
19
19
|
|
|
20
20
|
> 0.6.1 returns to a **single** `mcviseron` entry: DSH `client-modules` only composes a browser half for an exact package-name Loader row, and subpath rows silently dropped the whole client plugin. Components still run as sub-plugins and expose Auto-review / Todo / session-end / conditional archive-time sub-pages.
|
|
@@ -42,11 +42,12 @@ 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
|
-
### 4. Restart
|
|
47
|
+
### 4. Restart / close DSH
|
|
48
48
|
|
|
49
|
-
-
|
|
49
|
+
- Windows desktop: the **Restart / close** tab asks for confirmation and restarts or closes the desktop app.
|
|
50
|
+
- Linux / Web / cloud: a plain `dsh web` process uses a detached reexec helper; systemd / Docker / Kubernetes / PID 1 use supervisor-exit (code 75); close exits with code 0 and the deployment policy decides whether it restarts. See [docs/linux-restart.md](docs/linux-restart.md).
|
|
50
51
|
- A detached PowerShell helper closes the Electron main process; the Host performs its normal graceful shutdown when its IPC channel disconnects; the helper waits for both processes, clears `ELECTRON_RUN_AS_NODE`, and starts the application again.
|
|
51
52
|
- Running tasks are interrupted (same warning as the tray Quit); plugins, settings, and session records are not modified.
|
|
52
53
|
- Desktop-only: under `dsh web` the status route reports unavailable and the row hides.
|
|
@@ -154,12 +155,12 @@ Defaults: appearance off / `08:00–23:00`; auto-review both guards on, 6 s, 400
|
|
|
154
155
|
|
|
155
156
|
| DSH version | Status |
|
|
156
157
|
| --- | --- |
|
|
157
|
-
| `0.2.2-rc.5` | ✅ pre-adapted (0.2.2-rc.5 types/deps +
|
|
158
|
-
| `0.2.2-rc.3` | ✅ current desktop (rc.3 types/deps +
|
|
159
|
-
| `0.2.2-rc.1` | ✅ compatible (0.2.2-rc.1 types/deps +
|
|
160
|
-
| `0.2.1-rc.5` | ✅ compatible (rc.5 types/deps +
|
|
161
|
-
| `0.2.1-rc.3` | ✅ compatible (rc.3 types/deps +
|
|
162
|
-
| `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) |
|
|
163
164
|
| `0.2.0-rc.x` | ✅ covered by the peer range |
|
|
164
165
|
| `0.1.x` | ❌ unsupported (different settings-namespace model) |
|
|
165
166
|
|
package/README.md
CHANGED
|
@@ -11,10 +11,10 @@ MCviseron 的 **DeepSeek Harness(DSH)总插件**:一个 npm 包、一个 `
|
|
|
11
11
|
| **外观 · 按时间自动切换深浅色** | `mcviseron` 顶层字段 | 「设置 → 通用 → 外观」新增选项,按本机时间切换浅/深色 |
|
|
12
12
|
| **Auto review 修复** | `mcviseron.autoReviewFix` | 关机不再把 Auto 会话写成完全访问;人审提示追加中文译文 |
|
|
13
13
|
| **Todo 计划守卫** | `mcviseron.taskGuard` | 多阶段任务忘记更新 todo 时发出 notice(可选硬拦截) |
|
|
14
|
-
| **重启
|
|
14
|
+
| **重启 / 关闭 DSH** | `mcviseron.restart` | 设置页的重启/关闭按钮,以及侧边栏底部「重启 DSH」快捷按钮;Windows 桌面版重启应用,Linux/Web/云服务器使用 supervisor-exit 或 detached reexec |
|
|
15
15
|
| **会话后动作** | `mcviseron.sessionEnd` | 输入框左侧「会话后重启」下拉;AI 工具可设置;重启等待任务结束 |
|
|
16
16
|
| **认证 cookie 清理** | 内置 | 每次页面加载过期旧 `dsh-auth-*`,只保留当前,避免重启把请求头推到 16KB |
|
|
17
|
-
| **自动化任务编辑** | 内置工具 | `automation_task_list/create/update/delete` 直接调用 Host schedule
|
|
17
|
+
| **自动化任务编辑** | 内置工具 | `automation_task_list/create/update/delete` 直接调用 Host schedule 并自动存盘;API 兼容说明见 [docs/automation-tasks.md](docs/automation-tasks.md) |
|
|
18
18
|
| **归档时间集成(可选)** | 条件注册 | 仅检测到 `@linxin666/dsh-session-archive` 时显示「归档时间」子页;未安装不注册 |
|
|
19
19
|
|
|
20
20
|
> 0.6.1 起回到**单一** `mcviseron` 条目:DSH `client-modules` 只给精确包名条目组合浏览器半区,子路径条目会让整个客户端插件(外观行、设置分区、重启回退)消失。组件仍在内部作为子插件运行,设置页有 Auto review / Todo / 会话后动作 / 条件归档时间子页。
|
|
@@ -45,12 +45,13 @@ 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
|
-
### 4. 重启
|
|
51
|
+
### 4. 重启 / 关闭 DSH
|
|
52
52
|
|
|
53
|
-
-
|
|
53
|
+
- Windows 桌面版:「设置 → MCviseron 插件 → 重启 / 关闭」子页提供重启与关闭按钮,点击后确认并重启/关闭桌面应用。
|
|
54
|
+
- Linux / Web / 云服务器:普通 `dsh web` 使用 detached reexec;systemd / Docker / Kubernetes / PID 1 使用 supervisor-exit(退出码 75);关闭使用 exit 0,保持停止还是被托管器拉起由部署策略决定。详见 [docs/linux-restart.md](docs/linux-restart.md)。
|
|
54
55
|
- 重启方式:Host 写一个临时 PowerShell 助手(detached),先关闭 Electron 主进程;Host 在 IPC 断开后按官方流程优雅关闭所有插件与会话;助手等待主进程与 Host 退出后,清除 `ELECTRON_RUN_AS_NODE` 并重新启动应用。
|
|
55
56
|
- 会中断正在运行的任务(与托盘「退出」的提示一致),不会修改插件、配置或会话记录。
|
|
56
57
|
- 只在桌面版可用;`dsh web` 下状态接口返回不可用,设置行自动隐藏。
|
|
@@ -85,7 +86,7 @@ MCviseron 的 **DeepSeek Harness(DSH)总插件**:一个 npm 包、一个 `
|
|
|
85
86
|
|
|
86
87
|
设置里新增一个一级分区 **「MCviseron 插件」**(`settings.section`,id `mcviseron`),组件按需在这里拥有子页:
|
|
87
88
|
|
|
88
|
-
-
|
|
89
|
+
- **重启 / 关闭**:Windows 桌面版重启 Electron;Linux/Web 按进程模式重启或关闭(见 [docs/linux-restart.md](docs/linux-restart.md))。
|
|
89
90
|
- **会话后动作**:启用开关、显示等待、AI 邮件提醒、邮件主题/正文模板。
|
|
90
91
|
- **归档时间(条件)**:检测到第三方归档插件时显示;未安装或禁用时不注册、不显示。
|
|
91
92
|
- **组件**:列出八个组件及其配置位置。
|
|
@@ -190,7 +191,7 @@ pnpm add dsh-mcviseron-plugin
|
|
|
190
191
|
| `include` | string[] | `[]` | 只统计这些工具名(支持 `*`);空 = 全部 |
|
|
191
192
|
| `exclude` | string[] | `todo_write`, `ask_user_question` | 不统计的工具名 |
|
|
192
193
|
| `detectStepIntent` | boolean | `true` | 从思考/正文里识别「Now I will …」等句式并匹配 pending todo,命中时发一条定向 notice(仅建议) |
|
|
193
|
-
| `translateTodoContent` | boolean | `true` |
|
|
194
|
+
| `translateTodoContent` | boolean | `true` | 英文 todo 标题写入为「中文(English)」,迁移已有列表并显示在任务面板/notice |
|
|
194
195
|
| `todoTranslationTimeoutMs` | number | `3000` | 单次批量 todo 翻译超时,500–15000 |
|
|
195
196
|
|
|
196
197
|
### `restart`
|
|
@@ -249,12 +250,12 @@ DSH 0.2 的官方设置 apiproxy 不向浏览器暴露第三方命名空间,
|
|
|
249
250
|
|
|
250
251
|
| DSH 版本 | 状态 |
|
|
251
252
|
| --- | --- |
|
|
252
|
-
| `0.2.2-rc.5` | ✅ 预适配(0.2.2-rc.5 类型/依赖 +
|
|
253
|
-
| `0.2.2-rc.3` | ✅ 当前桌面安装(rc.3 类型/依赖 +
|
|
254
|
-
| `0.2.2-rc.1` | ✅ 兼容(0.2.2-rc.1 类型/依赖 +
|
|
255
|
-
| `0.2.1-rc.5` | ✅ 兼容(rc.5 类型/依赖 +
|
|
256
|
-
| `0.2.1-rc.3` | ✅ 兼容(rc.3 类型/依赖 +
|
|
257
|
-
| `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 上下文) |
|
|
258
259
|
| `0.2.0-rc.x` | ✅ peer 范围覆盖(同一套设置、审批与 hook 接缝) |
|
|
259
260
|
| `0.1.x` | ❌ 不支持:0.1 的插件自行注册设置命名空间,与本插件的条目 id 命名空间模型不同 |
|
|
260
261
|
|
|
@@ -320,7 +321,7 @@ test/
|
|
|
320
321
|
|
|
321
322
|
```bash
|
|
322
323
|
pnpm install
|
|
323
|
-
pnpm check # typecheck +
|
|
324
|
+
pnpm check # typecheck + 130 项测试 + 构建
|
|
324
325
|
```
|
|
325
326
|
|
|
326
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/automation-tasks.md
CHANGED
|
@@ -27,6 +27,55 @@ DSH 官方的 `schedule_create/list/update/delete` 只在声明了
|
|
|
27
27
|
- `weekly`:`{ time, time_zone, weekdays }`;
|
|
28
28
|
- `cron`:`{ expression, time_zone }`。
|
|
29
29
|
|
|
30
|
+
## Host Schedule 管理 API
|
|
31
|
+
|
|
32
|
+
组件不直接编辑 `schedule.json`,只调用 Host 的 `ctx.schedule` 服务。DSH 0.2.2
|
|
33
|
+
与旧版接口不同,组件用 `typeof schedule.edit === 'function'` 探测并分层适配:
|
|
34
|
+
|
|
35
|
+
### DSH 0.2.2+
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// 列表:分页信封
|
|
39
|
+
const page = await schedule.list({}, exec.signal)
|
|
40
|
+
// page.items: ScheduleTask[]
|
|
41
|
+
|
|
42
|
+
// 创建:request 带 target,sessionId 作为绑定参数
|
|
43
|
+
const task = await schedule.create({
|
|
44
|
+
title: '...',
|
|
45
|
+
prompt: '...',
|
|
46
|
+
timing: { kind: 'weekly', weekly: { time: '09:00', time_zone: 'Asia/Shanghai', weekdays: [6] } },
|
|
47
|
+
target: { kind: 'session', sessionId },
|
|
48
|
+
}, sessionId, exec.signal)
|
|
49
|
+
|
|
50
|
+
// 修改 / 删除:统一走 edit
|
|
51
|
+
await schedule.edit({ id, action: 'update', patch }, sessionId, exec.signal)
|
|
52
|
+
await schedule.edit({ id, action: 'delete' }, sessionId, exec.signal)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 旧版 API
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const tasks = await schedule.list({ sessionId }, exec.signal) // ScheduleTask[]
|
|
59
|
+
const task = await schedule.create(sessionId, request, exec.signal)
|
|
60
|
+
await schedule.update(sessionId, id, patch, exec.signal)
|
|
61
|
+
await schedule.delete(sessionId, id, exec.signal)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 工具参数到 timing 的映射
|
|
65
|
+
|
|
66
|
+
| 工具参数 | Host timing |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `after_seconds` | `{ kind: 'after', after_seconds }` |
|
|
69
|
+
| `at` | `{ kind: 'at', at }` |
|
|
70
|
+
| `every_seconds` | `{ kind: 'every', every_seconds }` |
|
|
71
|
+
| `daily` | `{ kind: 'daily', daily }` |
|
|
72
|
+
| `weekly` | `{ kind: 'weekly', weekly }` |
|
|
73
|
+
| `cron` | `{ kind: 'cron', cron }` |
|
|
74
|
+
|
|
75
|
+
`listRecords()` 同时接受 `ScheduleTask[]` 和 `{ items: ScheduleTask[] }`,避免
|
|
76
|
+
0.2.2 升级后 `.find is not a function`。旧 API 的 update/delete 只在新 API 缺失时
|
|
77
|
+
才使用。
|
|
78
|
+
|
|
30
79
|
## 自动存盘
|
|
31
80
|
|
|
32
81
|
工具直接调用 `ctx.schedule`;该方法负责持久化,和官方自动化任务 UI 使用同一个
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Linux / Web / 云服务器上的重启与关闭
|
|
2
|
+
|
|
3
|
+
Windows 桌面版继续使用 Electron 主进程 + Task Scheduler 的原地重启;Linux、Web 与云服务器使用 Host 进程级方案。
|
|
4
|
+
|
|
5
|
+
## 目标解析
|
|
6
|
+
|
|
7
|
+
`resolveRestartTarget()` 在非 Windows 平台返回 ProcessTarget:
|
|
8
|
+
|
|
9
|
+
- `execPath`:`process.execPath`(通常是 node);
|
|
10
|
+
- `argv`:`process.execArgv` + `process.argv.slice(1)`,即当前 dsh 命令及参数;
|
|
11
|
+
- `cwd`:当前工作目录;
|
|
12
|
+
- `mode`:`reexec` 或 `supervisor-exit`。
|
|
13
|
+
|
|
14
|
+
### supervisor-exit
|
|
15
|
+
|
|
16
|
+
以下任一条件成立时,重启请求只退出 Host,由外层托管器拉起:
|
|
17
|
+
|
|
18
|
+
- systemd:`INVOCATION_ID` / `JOURNAL_STREAM` / `SYSTEMD_EXEC_PID`;
|
|
19
|
+
- Kubernetes:`KUBERNETES_SERVICE_HOST`;
|
|
20
|
+
- Docker:存在 `/.dockerenv`;
|
|
21
|
+
- 进程 PID 为 1(容器入口);
|
|
22
|
+
- `DSH_MCVISERON_RESTART_MODE=supervisor-exit`(或 `exit`)。
|
|
23
|
+
|
|
24
|
+
退出码为 **75**(`EX_TEMPFAIL`),便于 `Restart=on-failure` / Docker `on-failure` 识别为需要重启。
|
|
25
|
+
|
|
26
|
+
### reexec
|
|
27
|
+
|
|
28
|
+
普通 `dsh web` 进程:
|
|
29
|
+
|
|
30
|
+
1. 写入一个 detached Node helper;
|
|
31
|
+
2. helper 等待原 PID 退出;
|
|
32
|
+
3. helper 用相同 `execPath`、argv、cwd 和环境启动新进程;
|
|
33
|
+
4. 原进程退出。
|
|
34
|
+
|
|
35
|
+
helper 会最多等待原进程 30 秒,避免端口未释放就启动新实例。可用
|
|
36
|
+
`DSH_MCVISERON_RESTART_MODE=reexec` 强制该模式。
|
|
37
|
+
|
|
38
|
+
## 关闭
|
|
39
|
+
|
|
40
|
+
关闭请求执行 `process.exit(0)`(桌面版关闭 Electron 主进程),不再启动新进程。
|
|
41
|
+
关闭后是否真正保持停止,由托管器策略决定:
|
|
42
|
+
|
|
43
|
+
### systemd
|
|
44
|
+
|
|
45
|
+
```ini
|
|
46
|
+
[Service]
|
|
47
|
+
ExecStart=/usr/bin/dsh web --host 0.0.0.0 --port 3000
|
|
48
|
+
Restart=on-failure
|
|
49
|
+
RestartSec=3
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- 重启:进程以 75 退出,systemd 重新拉起;
|
|
53
|
+
- 关闭:进程以 0 退出,systemd 不再拉起。
|
|
54
|
+
|
|
55
|
+
### Docker
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
docker run --restart on-failure ...
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- 重启:75 退出,Docker 重新拉起;
|
|
62
|
+
- 关闭:0 退出,保持停止。
|
|
63
|
+
- 若使用 `--restart unless-stopped`,关闭也会被 Docker 重新拉起;这是 Docker 策略,不是插件能覆盖的。
|
|
64
|
+
|
|
65
|
+
### Kubernetes
|
|
66
|
+
|
|
67
|
+
```yaml
|
|
68
|
+
restartPolicy: OnFailure
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- 重启:75 退出,kubelet 重启容器;
|
|
72
|
+
- 关闭:0 退出,Pod 保持 Completed。
|
|
73
|
+
- `restartPolicy: Always` 下关闭也会被重新拉起;需要停止时使用 `kubectl delete pod` 或调整策略。
|
|
74
|
+
|
|
75
|
+
### 普通 CLI
|
|
76
|
+
|
|
77
|
+
直接运行 `dsh web` 时使用 reexec helper;关闭后进程直接结束,不会被重新拉起。
|
|
78
|
+
|
|
79
|
+
## 设置页、侧边栏与会话后动作
|
|
80
|
+
|
|
81
|
+
侧边栏底部新增 **「重启 DSH」** 快捷按钮(`sidebar.footer.action`,位于设置上方);它复用同一 `/api/dsh-mcviseron/restart/execute` 路由,不替代设置页。「设置」里原有的重启/关闭按钮保持不变。
|
|
82
|
+
|
|
83
|
+
- 「重启 / 关闭」设置页同时提供重启与关闭按钮;
|
|
84
|
+
- 状态会显示当前模式(desktop / reexec / supervisor-exit);
|
|
85
|
+
- `set_session_end_action` 的 `restart` / `close` 在 Linux/Web 同样可用;
|
|
86
|
+
- 操作系统关机仍是 Windows-only,Linux 上不提供。
|
|
87
|
+
|
|
88
|
+
## 安全与限制
|
|
89
|
+
|
|
90
|
+
- 路由仍只接受 loopback 请求并需要 `confirm: true`;
|
|
91
|
+
- 重启不会执行任意命令,只复用当前进程的 `execPath`、argv、cwd;
|
|
92
|
+
- supervisor-exit 依赖托管器配置;没有托管器的环境应使用 reexec;
|
|
93
|
+
- reexec 需要当前进程有权限启动新进程;容器内建议使用 supervisor-exit;
|
|
94
|
+
- 日志:`$TMPDIR/dsh-mcviseron-restart.log`(Windows 为 `%TEMP%`)。
|
|
95
|
+
|
|
96
|
+
## 测试
|
|
97
|
+
|
|
98
|
+
`test/restart.test.ts` 覆盖 Windows 桌面目标、Linux reexec/supervisor 探测、环境变量覆盖、状态/执行路由与关闭动作;`test/session-end.test.ts` 覆盖 Linux 的 restart/close 可用性。
|
|
@@ -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
|
|