dsh-mcviseron-plugin 0.6.2 → 0.6.4
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 +18 -0
- package/README.en.md +33 -8
- package/README.md +42 -9
- package/docs/automation-task.md +1 -1
- package/docs/release.md +6 -5
- package/docs/session-end.md +97 -0
- package/lib/appearance.js +11 -2
- package/lib/auto-review-fix.js +3 -0
- package/lib/client.js +466 -61
- package/lib/index.js +11933 -93
- package/lib/restart.js +22 -0
- package/lib/task-guard.js +3 -0
- package/package.json +15 -13
- package/src/api.ts +6 -0
- package/src/client/ConfigForm.tsx +31 -1
- package/src/client/SessionEndControl.tsx +332 -0
- package/src/client/SettingsSection.tsx +25 -3
- package/src/client/index.ts +15 -0
- package/src/client/locales.ts +56 -0
- package/src/index.ts +12 -1
- package/src/restart/index.ts +29 -0
- package/src/routes.ts +6 -0
- package/src/session-end/email.ts +163 -0
- package/src/session-end/index.ts +608 -0
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,24 @@
|
|
|
11
11
|
- Restart 组件支持 macOS/Linux(当前仅 Windows 桌面版)。
|
|
12
12
|
- 把定时巡检任务 prompt 更新为当前单条目架构。
|
|
13
13
|
|
|
14
|
+
## [0.6.4] - 2026-10-23
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **v0.6.3 重启后插件不加载**:宿主 bundle 内联的 CJS `nodemailer` 在 ESM 里触发 `Dynamic require of "events" is not supported`,导致整个 `lib/index.js` 导入失败。为所有 host bundle 注入 `createRequire(import.meta.url)` 的 `require` shim,并在 `build.mjs` 构建后实际 `import()` 一次 `lib/index.js` 作为回归门禁。v0.6.3 的 npm 包已发布且仍含此缺陷,本版覆盖。
|
|
19
|
+
|
|
20
|
+
## [0.6.3] - 2026-10-22
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- **会话后动作**:输入框左侧「会话后重启」下拉(关闭 / 重启 DSH / 关闭 DSH / 关闭电脑),默认关闭且每次 DSH 启动重置;最终回复完整显示后执行一次。
|
|
25
|
+
- **AI 工具** `set_session_end_action`:AI 可在改完插件后设置重启/关闭 DSH;AI 设置时输入框显示醒目非弹窗提示,关机仅用户可选。
|
|
26
|
+
- **重启任务探寻**:会话后重启会等待所有运行中的 agent turn(含等待审批/回答)与后台 job 结束;设置页的重启按钮仍立即执行。
|
|
27
|
+
- **邮件联动**:已安装且配置可发送的 `dsh-email-notify` 时,AI 开启动作会复用其 SMTP 配置发送提醒邮件(不修改邮件插件);可在设置页关闭或改模板。
|
|
28
|
+
- **会话后动作设置子页**:启用、渲染等待、AI 邮件提醒、邮件主题/正文模板。
|
|
29
|
+
- **圆角下拉菜单**:输入框动作选择器由原生 `select` 改为自绘菜单(14px 菜单卡片、10px 选项圆角、悬停/选中态),避免系统下拉的方角外观。
|
|
30
|
+
- 合计 **92 项测试**。
|
|
31
|
+
|
|
14
32
|
## [0.6.2] - 2026-10-21
|
|
15
33
|
|
|
16
34
|
### Fixed
|
package/README.en.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.md)
|
|
4
4
|
|
|
5
|
-
MCviseron's **master plugin for DeepSeek Harness (DSH)**: one npm package and one `mcviseron` profile entry hosting
|
|
5
|
+
MCviseron's **master plugin for DeepSeek Harness (DSH)**: one npm package and one `mcviseron` profile entry hosting five components. DSH `client-modules` only composes a browser half for a Loader row whose name exactly equals the package name, so the master entry must be `dsh-mcviseron-plugin`; components run as sub-plugins and own settings sub-pages. The former `dsh-auto-review-restart-fix` and `dsh-task-guard` are merged here and will be deprecated.
|
|
6
6
|
|
|
7
7
|
## Components
|
|
8
8
|
|
|
@@ -12,6 +12,7 @@ MCviseron's **master plugin for DeepSeek Harness (DSH)**: one npm package and on
|
|
|
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
14
|
| **Restart DeepSeek Harness** | `mcviseron.restart` | Button in Settings → MCviseron plugin that closes and relaunches the desktop application |
|
|
15
|
+
| **After-session action** | `mcviseron.sessionEnd` | “Restart after session” dropdown in the composer; the AI tool can arm it; restart waits for running tasks |
|
|
15
16
|
|
|
16
17
|
> 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 settings sub-pages.
|
|
17
18
|
|
|
@@ -25,9 +26,9 @@ MCviseron's **master plugin for DeepSeek Harness (DSH)**: one npm package and on
|
|
|
25
26
|
### 2. Auto-review hardening
|
|
26
27
|
|
|
27
28
|
- Drops `permissionPresets.set` writes while the root Cordis fiber is not `ACTIVE`, so a whole-Host shutdown no longer migrates Auto sessions to Full access.
|
|
28
|
-
- Appends a `【审查理由 · 中文翻译】` block to the localized `displayReason`
|
|
29
|
+
- Appends a `【审查理由 · 中文翻译】` block to the localized `displayReason` and to the audited `reason` (original text stays as the prefix); `displayReason.en` stays byte-identical.
|
|
29
30
|
- Translation uses the session's provider/model (or a pinned pair), caches per source string (256 entries), times out after 6 s, and passes the approval through unchanged on any failure.
|
|
30
|
-
- A reviewer note that is
|
|
31
|
+
- A reviewer note that is predominantly Chinese is never translated again; an English note that merely quotes Chinese or contains a Chinese path is still translated.
|
|
31
32
|
|
|
32
33
|
### 3. Todo plan guard
|
|
33
34
|
|
|
@@ -47,12 +48,22 @@ MCviseron's **master plugin for DeepSeek Harness (DSH)**: one npm package and on
|
|
|
47
48
|
- Desktop-only: under `dsh web` the status route reports unavailable and the row hides.
|
|
48
49
|
- **Why not a tray item**: DSH builds its tray menu inside the Electron main process (`DesktopTray` in `lib/main.js`); plugins run in the Host child process and DSH exposes no tray extension point. The Settings row is the supported equivalent.
|
|
49
50
|
|
|
51
|
+
### 5. After-session action
|
|
52
|
+
|
|
53
|
+
- A **“Restart after session”** dropdown left of the composer: Off / Restart DSH / Close DSH / Shut down PC. It starts off on every DSH launch.
|
|
54
|
+
- Runs once after the final reply has fully rendered (3 s grace by default); sending a new message during the grace cancels it.
|
|
55
|
+
- The AI can arm **restart** or **close DSH** through `set_session_end_action` (never shutdown). The composer shows a colored, non-modal reminder; shutdown is user-only.
|
|
56
|
+
- **Restart performs a task probe**: it waits while any agent turn (including one waiting for approval/answer) or background job is running, then restarts. Close/shutdown do not wait. **The Settings restart button is not affected** and still runs immediately.
|
|
57
|
+
- State is in Host memory and one-shot; it is cleared before launch, so a fresh process, plugin load, or repeated turn/end cannot cause a restart loop.
|
|
58
|
+
- **Email link**: if `dsh-email-notify` is installed and configured sendable, arming the action reuses its SMTP settings to send one reminder; the email plugin is not modified. Configure or disable it under Settings → MCviseron plugin → After-session action. See [docs/session-end.md](docs/session-end.md).
|
|
59
|
+
|
|
50
60
|
## Settings page
|
|
51
61
|
|
|
52
62
|
Settings gains a first-level **MCviseron plugin** section (`settings.section`, id `mcviseron`). Components own a tab there when they have a settings surface:
|
|
53
63
|
|
|
54
64
|
- **Restart**: restart DeepSeek Harness (this component's settings).
|
|
55
|
-
- **
|
|
65
|
+
- **After-session action**: enable switch, render grace, AI email reminder, subject/body templates.
|
|
66
|
+
- **Components**: list the five components and their configuration surfaces.
|
|
56
67
|
|
|
57
68
|
The Appearance component is intentionally **not** here — its row stays under General → Appearance. Auto review and Todo guard have editable sub-pages; the Components tab is an overview.
|
|
58
69
|
|
|
@@ -93,23 +104,37 @@ Add `dsh-mcviseron-plugin` to `dsh.profile.bundles` and remove `dsh-auto-review-
|
|
|
93
104
|
restart:
|
|
94
105
|
enabled: true
|
|
95
106
|
appPath: ""
|
|
107
|
+
sessionEnd:
|
|
108
|
+
enabled: true
|
|
109
|
+
graceMs: 3000
|
|
110
|
+
notifyEmailOnAi: true
|
|
111
|
+
emailSubject: "[DSH session-end action] {{actionText}}"
|
|
112
|
+
emailBody: |-
|
|
113
|
+
The AI requested {{actionText}} after this session.
|
|
114
|
+
|
|
115
|
+
Session: {{sessionName}}
|
|
116
|
+
Session ID: {{sessionId}}
|
|
117
|
+
Time: {{time}}
|
|
118
|
+
Reason: {{reason}}
|
|
96
119
|
```
|
|
97
120
|
|
|
98
|
-
Defaults: appearance off / `08:00–23:00`; auto-review both guards on, 6 s, 4000 chars; task-guard on, `zh`, stale at 5 / repeat 4, no blocking, step-intent detection and todo translation on (3 s), excludes `todo_write` and `ask_user_question
|
|
121
|
+
Defaults: appearance off / `08:00–23:00`; auto-review both guards on, 6 s, 4000 chars; task-guard on, `zh`, stale at 5 / repeat 4, no blocking, step-intent detection and todo translation on (3 s), excludes `todo_write` and `ask_user_question`; session-end on, 3 s grace, AI email reminder on with reusable `dsh-email-notify` SMTP settings.
|
|
122
|
+
|
|
123
|
+
`sessionEnd`: `enabled` (boolean, true), `graceMs` (0–15000, 3000), `notifyEmailOnAi` (boolean, true), `emailSubject` / `emailBody` (templates; see `docs/session-end.md`).
|
|
99
124
|
|
|
100
125
|
## How it works
|
|
101
126
|
|
|
102
127
|
- `cordis.patch.yml` inserts one `mcviseron` master entry (`name: dsh-mcviseron-plugin`).
|
|
103
|
-
- `src/index.ts` mounts the
|
|
128
|
+
- `src/index.ts` mounts the five components with `ctx.plugin`; each keeps its own `inject` and implementation.
|
|
104
129
|
- `src/appearance` owns the two loopback routes (`/api/dsh-mcviseron/settings/describe|mutate`) the browser uses; the browser half lives in `src/client/` and registers the settings section and sub-pages.
|
|
105
|
-
- The settings bridge accepts appearance top-level fields and nested `autoReviewFix.*` / `taskGuard.*` / `restart.*` paths.
|
|
130
|
+
- The settings bridge accepts appearance top-level fields and nested `autoReviewFix.*` / `taskGuard.*` / `restart.*` / `sessionEnd.*` paths.
|
|
106
131
|
- The master entry and components unwrap DSH 0.2 volatile config references before use.
|
|
107
132
|
|
|
108
133
|
## Compatibility
|
|
109
134
|
|
|
110
135
|
| DSH version | Status |
|
|
111
136
|
| --- | --- |
|
|
112
|
-
| `0.2.1-rc.2` | ✅ verified (desktop profile;
|
|
137
|
+
| `0.2.1-rc.2` | ✅ verified (desktop profile; 92 tests + real Cordis contexts) |
|
|
113
138
|
| `0.2.0-rc.x` | ✅ covered by the peer range |
|
|
114
139
|
| `0.1.x` | ❌ unsupported (different settings-namespace model) |
|
|
115
140
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.en.md) | 中文
|
|
4
4
|
|
|
5
|
-
MCviseron 的 **DeepSeek Harness(DSH)总插件**:一个 npm 包、一个 `mcviseron` profile
|
|
5
|
+
MCviseron 的 **DeepSeek Harness(DSH)总插件**:一个 npm 包、一个 `mcviseron` profile 条目挂载五个组件。DSH 的 `client-modules` 只给 Loader 行名称精确等于包名的条目组合浏览器半区,因此 master 条目名必须是 `dsh-mcviseron-plugin`;组件作为子插件运行,设置页提供各自子页。原 `dsh-auto-review-restart-fix` 与 `dsh-task-guard` 已并入本插件并逐步废弃。
|
|
6
6
|
|
|
7
7
|
## 组件
|
|
8
8
|
|
|
@@ -12,6 +12,7 @@ MCviseron 的 **DeepSeek Harness(DSH)总插件**:一个 npm 包、一个 `
|
|
|
12
12
|
| **Auto review 修复** | `mcviseron.autoReviewFix` | 关机不再把 Auto 会话写成完全访问;人审提示追加中文译文 |
|
|
13
13
|
| **Todo 计划守卫** | `mcviseron.taskGuard` | 多阶段任务忘记更新 todo 时发出 notice(可选硬拦截) |
|
|
14
14
|
| **重启 DeepSeek Harness** | `mcviseron.restart` | 「设置 → MCviseron 插件」里的重启按钮:关闭并重新启动桌面应用 |
|
|
15
|
+
| **会话后动作** | `mcviseron.sessionEnd` | 输入框左侧「会话后重启」下拉;AI 工具可设置;重启等待任务结束 |
|
|
15
16
|
|
|
16
17
|
> 0.6.1 起回到**单一** `mcviseron` 条目:DSH `client-modules` 只给精确包名条目组合浏览器半区,子路径条目会让整个客户端插件(外观行、设置分区、重启回退)消失。组件仍在内部作为子插件运行,设置页有 Auto review / Todo 子页。
|
|
17
18
|
|
|
@@ -51,12 +52,22 @@ MCviseron 的 **DeepSeek Harness(DSH)总插件**:一个 npm 包、一个 `
|
|
|
51
52
|
- 只在桌面版可用;`dsh web` 下状态接口返回不可用,设置行自动隐藏。
|
|
52
53
|
- **为什么不做成托盘菜单项**:DSH 的托盘菜单由 Electron 主进程的 `lib/main.js` 直接构建(`DesktopTray`),插件运行在独立的 Host 子进程里,官方没有提供托盘扩展点;因此本组件只能在设置页提供等价入口。
|
|
53
54
|
|
|
55
|
+
### 5. 会话后动作
|
|
56
|
+
|
|
57
|
+
- 对话输入框左侧新增 **「会话后重启」** 下拉:关闭 / 重启 DSH / 关闭 DSH / 关闭电脑;默认关闭,每次 DSH 启动都从关闭开始。
|
|
58
|
+
- 本轮最终回复完整显示后(默认再等 3 秒)执行一次;如果用户在这段等待内发了新消息,动作取消。
|
|
59
|
+
- AI 通过工具 `set_session_end_action` 设置 **重启** 或 **关闭 DSH**(不能设置关机)。AI 设置后,输入框出现醒目的非弹窗提示;关机只能由用户在下拉里选择。
|
|
60
|
+
- **重启会先做任务探寻**:只要还有运行中的 agent 会话(含等待审批/回答)或后台 job,就持续等待,直到全部结束;关闭 DSH / 关机不等待。**设置页的重启按钮不受此约束**,仍然立即执行。
|
|
61
|
+
- 状态只存在 Host 内存里,一次性执行;执行前先清除,重启后的新进程不会继承,不会因为加载插件或重复 turn/end 无限重启。
|
|
62
|
+
- **邮件联动**:如果已安装并配置了可发送的 `dsh-email-notify`,AI 开启动作时会复用它的 SMTP 配置发送提醒邮件;不修改邮件插件。可在「设置 → MCviseron 插件 → 会话后动作」关闭或改模板。详见 [docs/session-end.md](docs/session-end.md)。
|
|
63
|
+
|
|
54
64
|
## 设置页
|
|
55
65
|
|
|
56
66
|
设置里新增一个一级分区 **「MCviseron 插件」**(`settings.section`,id `mcviseron`),组件按需在这里拥有子页:
|
|
57
67
|
|
|
58
68
|
- **重启**:重启 DeepSeek Harness(本组件的设置面)。
|
|
59
|
-
-
|
|
69
|
+
- **会话后动作**:启用开关、显示等待、AI 邮件提醒、邮件主题/正文模板。
|
|
70
|
+
- **组件**:列出五个组件及其配置位置。
|
|
60
71
|
|
|
61
72
|
外观组件**不在**这里——它的设置行仍留在「通用 → 外观」,位置不变。没有设置面的组件不占用子页;`autoReview` / `taskGuard` 继续通过 profile 配置,组件子页会注明这一点。
|
|
62
73
|
|
|
@@ -110,6 +121,18 @@ pnpm add dsh-mcviseron-plugin
|
|
|
110
121
|
restart:
|
|
111
122
|
enabled: true
|
|
112
123
|
appPath: ""
|
|
124
|
+
sessionEnd:
|
|
125
|
+
enabled: true
|
|
126
|
+
graceMs: 3000
|
|
127
|
+
notifyEmailOnAi: true
|
|
128
|
+
emailSubject: "[DSH 会话后动作] {{actionText}}"
|
|
129
|
+
emailBody: |-
|
|
130
|
+
AI 已请求在本轮会话结束后{{actionText}}。
|
|
131
|
+
|
|
132
|
+
会话:{{sessionName}}
|
|
133
|
+
会话 ID:{{sessionId}}
|
|
134
|
+
时间:{{time}}
|
|
135
|
+
理由:{{reason}}
|
|
113
136
|
```
|
|
114
137
|
|
|
115
138
|
### 外观(Config 顶层字段)
|
|
@@ -156,6 +179,16 @@ pnpm add dsh-mcviseron-plugin
|
|
|
156
179
|
| `enabled` | boolean | `true` | 是否注册设置页重启按钮与接口 |
|
|
157
180
|
| `appPath` | string | `''` | 显式指定应用 exe;空 = 从 Host 进程推导 |
|
|
158
181
|
|
|
182
|
+
### `sessionEnd`
|
|
183
|
+
|
|
184
|
+
| 字段 | 类型 | 默认值 | 说明 |
|
|
185
|
+
| --- | --- | --- | --- |
|
|
186
|
+
| `enabled` | boolean | `true` | 是否显示输入框下拉并允许 AI 设置 |
|
|
187
|
+
| `graceMs` | number | `3000` | turn/end 后等待最终文字渲染的时间,0–15000 |
|
|
188
|
+
| `notifyEmailOnAi` | boolean | `true` | AI 开启动作时发送邮件;需要已配置的 `dsh-email-notify` |
|
|
189
|
+
| `emailSubject` | string | `[DSH 会话后动作] {{actionText}}` | 邮件主题模板 |
|
|
190
|
+
| `emailBody` | string | 见上方 YAML | 邮件正文模板,支持 `{{actionText}}` / `{{sessionName}}` / `{{sessionId}}` / `{{time}}` / `{{reason}}` |
|
|
191
|
+
|
|
159
192
|
## 工作原理
|
|
160
193
|
|
|
161
194
|
### 单一 master 条目
|
|
@@ -168,15 +201,15 @@ pnpm add dsh-mcviseron-plugin
|
|
|
168
201
|
name: dsh-mcviseron-plugin
|
|
169
202
|
```
|
|
170
203
|
|
|
171
|
-
包根导出 `.` → `lib/index.js`。`src/index.ts` 的 `apply()` 用 `ctx.plugin`
|
|
204
|
+
包根导出 `.` → `lib/index.js`。`src/index.ts` 的 `apply()` 用 `ctx.plugin` 依次挂载五个子组件,每个子组件保留自己的 `inject`、`Config` 与实现;设置页由 `src/client/` 注册。
|
|
172
205
|
|
|
173
206
|
### 组件装配
|
|
174
207
|
|
|
175
|
-
- `src/index.ts`:master 条目,挂载 appearance / auto-review-fix / task-guard / restart。
|
|
208
|
+
- `src/index.ts`:master 条目,挂载 appearance / auto-review-fix / task-guard / restart / session-end。
|
|
176
209
|
- `src/appearance/index.ts`:只有 Host 设置桥(`ctx.settings.configure({ auto: false })` + 两条 loopback 路由);浏览器半边在 `src/client/`,读取 `mcviseron` 命名空间并驱动 `ctx.theme.setTheme`。
|
|
177
210
|
- `src/auto-review-fix/index.ts`:`installAutoReview`,通过 `ctx.inject(['permissionPresets' | 'approval'])` 特性探测并包装服务。
|
|
178
211
|
- `src/task-guard/index.ts`:`installTaskGuard`,注册 `tools/pre-execute`、`tools/post-execute`、`agent/pre-step`、`session/event`。
|
|
179
|
-
- master
|
|
212
|
+
- master 与五个子组件都会先 `toPlain()` 展开 DSH 0.2 的 volatile 配置引用,再交给实现。
|
|
180
213
|
|
|
181
214
|
### 设置桥
|
|
182
215
|
|
|
@@ -185,7 +218,7 @@ DSH 0.2 的官方设置 apiproxy 不向浏览器暴露第三方命名空间,
|
|
|
185
218
|
- `POST /api/dsh-mcviseron/settings/describe`
|
|
186
219
|
- `POST /api/dsh-mcviseron/settings/mutate`
|
|
187
220
|
|
|
188
|
-
只接受命名空间 `mcviseron`;顶层接受 `enabled` / `lightStart` / `lightEnd`,并允许 `autoReviewFix.*` / `taskGuard.*` / `restart.*` 嵌套路径(类型与范围会校验)。所有请求执行 loopback 地址 + Host 头 + 同源校验。
|
|
221
|
+
只接受命名空间 `mcviseron`;顶层接受 `enabled` / `lightStart` / `lightEnd`,并允许 `autoReviewFix.*` / `taskGuard.*` / `restart.*` / `sessionEnd.*` 嵌套路径(类型与范围会校验)。所有请求执行 loopback 地址 + Host 头 + 同源校验。
|
|
189
222
|
|
|
190
223
|
### 时间语义(appearance)
|
|
191
224
|
|
|
@@ -195,7 +228,7 @@ DSH 0.2 的官方设置 apiproxy 不向浏览器暴露第三方命名空间,
|
|
|
195
228
|
|
|
196
229
|
| DSH 版本 | 状态 |
|
|
197
230
|
| --- | --- |
|
|
198
|
-
| `0.2.1-rc.2` | ✅ 本版本验证(desktop profile;
|
|
231
|
+
| `0.2.1-rc.2` | ✅ 本版本验证(desktop profile;92 项测试 + 真实 Cordis 上下文) |
|
|
199
232
|
| `0.2.0-rc.x` | ✅ peer 范围覆盖(同一套设置、审批与 hook 接缝) |
|
|
200
233
|
| `0.1.x` | ❌ 不支持:0.1 的插件自行注册设置命名空间,与本插件的条目 id 命名空间模型不同 |
|
|
201
234
|
|
|
@@ -225,7 +258,7 @@ src/
|
|
|
225
258
|
volatile.ts 展开 DSH volatile 配置引用
|
|
226
259
|
loopback.ts loopback 信任栅栏
|
|
227
260
|
routes.ts settings describe/mutate 桥(含嵌套组件路径)
|
|
228
|
-
index.ts master 条目:Config +
|
|
261
|
+
index.ts master 条目:Config + 挂载五个子组件
|
|
229
262
|
appearance/index.ts 外观子组件:设置桥
|
|
230
263
|
auto-review-fix/index.ts Auto review 子组件:Config + 装配
|
|
231
264
|
task-guard/index.ts Todo 守卫子组件:Config + 装配
|
|
@@ -261,7 +294,7 @@ test/
|
|
|
261
294
|
|
|
262
295
|
```bash
|
|
263
296
|
pnpm install
|
|
264
|
-
pnpm check # typecheck +
|
|
297
|
+
pnpm check # typecheck + 92 项测试 + 构建
|
|
265
298
|
```
|
|
266
299
|
|
|
267
300
|
构建产物:`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/docs/automation-task.md
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
3. 若发布了新版本:
|
|
39
39
|
a. 执行 pnpm install,把 @deepseek-ai/dsh-client-connection、dsh-client-locale、dsh-client-ui-settings、dsh-client-ui-slots、dsh-client-ui-renderer、dsh-host-webserver、dsh-settings、@deepseek-ai/cordis 的开发依赖升级到与最新 DSH 相同版本,并更新 peerDependencies 范围。
|
|
40
40
|
b. 对照最新包的类型声明与 lib 实现,按组件逐层修复不兼容处(先 Host 设置桥,再 autoReview、taskGuard,最后浏览器外观行)。
|
|
41
|
-
c. 执行 pnpm check(tsc --noEmit +
|
|
41
|
+
c. 执行 pnpm check(tsc --noEmit + 92 项 node 测试 + esbuild 构建),补齐或修正测试;必要时更新 test/plugin.test.ts 的装配断言。
|
|
42
42
|
d. 更新 CHANGELOG.md(新版本段落记录兼容版本与修复)、README.md / README.en.md 的兼容性表;提交并推送到 main。
|
|
43
43
|
4. 不要执行 npm publish;不要重启或关闭正在运行的 DSH;不要修改 D:\Program\DSH-Plugin-Class 下的其他插件仓库。
|
|
44
44
|
|
package/docs/release.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# 发布 dsh-mcviseron-plugin 到 npm
|
|
2
2
|
|
|
3
|
-
## 当前状态(2026-10-
|
|
3
|
+
## 当前状态(2026-10-23)
|
|
4
4
|
|
|
5
|
-
- 包名 **`dsh-mcviseron-plugin` 已发布 0.6.
|
|
5
|
+
- 包名 **`dsh-mcviseron-plugin` 已发布 0.6.3**;**v0.6.3 的 host bundle 导入缺陷由 v0.6.4 修复**。
|
|
6
6
|
- npm 账号 `mcviseron` 已恢复正常,可执行首次手动发布。
|
|
7
7
|
- 本机全局 registry 指向 npmmirror,发布时必须显式指定 `--registry=https://registry.npmjs.org/`。
|
|
8
|
-
- 首次发布 **v0.6.1 已手动完成**;从 **v0.6.2** 起由 `.github/workflows/publish.yml` 通过 OIDC Trusted Publishing
|
|
8
|
+
- 首次发布 **v0.6.1 已手动完成**;从 **v0.6.2** 起由 `.github/workflows/publish.yml` 通过 OIDC Trusted Publishing 发布,tag 推送即发布。
|
|
9
|
+
- **不要安装 0.6.3**:该版本的 host bundle 在启动时触发 `Dynamic require of "events"`,插件会被 DSH 判为加载失败。
|
|
9
10
|
|
|
10
11
|
## 首次发布(账号解冻后)
|
|
11
12
|
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
|
|
49
50
|
```powershell
|
|
50
51
|
npm view dsh-mcviseron-plugin version dist-tags.latest --registry=https://registry.npmjs.org/
|
|
51
|
-
curl.exe -sI https://registry.npmjs.org/dsh-mcviseron-plugin/-/dsh-mcviseron-plugin-0.6.
|
|
52
|
+
curl.exe -sI https://registry.npmjs.org/dsh-mcviseron-plugin/-/dsh-mcviseron-plugin-0.6.4.tgz | Select-Object -First 1
|
|
52
53
|
curl.exe -X PUT "https://registry.npmmirror.com/-/package/dsh-mcviseron-plugin/syncs"
|
|
53
54
|
```
|
|
54
55
|
|
|
@@ -76,7 +77,7 @@ Trusted Publisher 绑定后,**推送 `v*` tag 即直接发布**,不再需要
|
|
|
76
77
|
|
|
77
78
|
> `workflow_dispatch` 默认只做 `npm pack --dry-run`;要发布当前 `main` 的版本,取消勾选 `dry-run` 再运行。
|
|
78
79
|
>
|
|
79
|
-
> v0.6.
|
|
80
|
+
> 从 v0.6.3 起 tag 推送直接发布;v0.6.4 覆盖 v0.6.3 的启动导入缺陷。
|
|
80
81
|
|
|
81
82
|
## 回滚与故障
|
|
82
83
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# 会话后动作(sessionEnd)
|
|
2
|
+
|
|
3
|
+
输入框左侧的「会话后重启」下拉,以及 AI 工具 `set_session_end_action`。
|
|
4
|
+
|
|
5
|
+
## 行为
|
|
6
|
+
|
|
7
|
+
| 动作 | 谁可以设置 | 执行时机 | 是否等待任务 |
|
|
8
|
+
| --- | --- | --- | --- |
|
|
9
|
+
| 关闭 | 用户 / AI | — | — |
|
|
10
|
+
| 重启 DSH | 用户 / AI | 本轮最终回复显示完 + `graceMs` | **是**:等待所有运行中的 agent turn 和后台 job |
|
|
11
|
+
| 关闭 DSH | 用户 / AI | 同上 | 否 |
|
|
12
|
+
| 关闭电脑 | **仅用户** | 同上 | 否 |
|
|
13
|
+
|
|
14
|
+
- 状态只保存在 Host 内存,DSH 每次启动都是关闭;不写 profile、不写 localStorage。
|
|
15
|
+
- 动作是**一次性**的:执行前先清除状态,再调用重启/关闭/关机;不会因为加载插件或重复 `turn/end` 反复重启。
|
|
16
|
+
- 新 turn 开始时,如果上一个 turn 结束后的等待计时器还在,会取消并清除动作;用户在等待期间发消息就不会被意外重启。
|
|
17
|
+
- 「设置 → MCviseron 插件 → 重启」是另一个组件,仍然**立即**执行,不受任务等待约束。
|
|
18
|
+
|
|
19
|
+
## 任务探寻
|
|
20
|
+
|
|
21
|
+
重启前读取:
|
|
22
|
+
|
|
23
|
+
- `ctx.agents.list()` 中 `status === 'running'` 的 agent(包含等待审批/回答的 turn、子 agent);
|
|
24
|
+
- `ctx.jobs.list()` 中 `status === 'running' | 'stopping'` 的后台 job(同时按全局和 live owner 收集,去重)。
|
|
25
|
+
|
|
26
|
+
任意一项存在就每 2 秒复查一次,直到全部结束;等待期间输入框的提示会显示「等待其它任务结束」。关闭 DSH / 关机不等待。
|
|
27
|
+
|
|
28
|
+
## AI 工具
|
|
29
|
+
|
|
30
|
+
工具名:`set_session_end_action`
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{ "action": "restart" | "close" | "off", "reason": "optional" }
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- AI 只能设置 `restart` / `close` / `off`;`shutdown` 被拒绝。
|
|
37
|
+
- 工具返回后,输入框通过 1.5 秒轮询拿到 `requestedBy: "ai"`,显示醒目但非弹窗的提示。
|
|
38
|
+
- 工具设置后到 `turn/end` 才排入执行队列;如果 AI 在最终回复前设置,本轮结束后触发。
|
|
39
|
+
|
|
40
|
+
## 邮件联动(可选)
|
|
41
|
+
|
|
42
|
+
当同时满足以下条件时,AI 设置 `restart`/`close` 会发送一封提醒邮件:
|
|
43
|
+
|
|
44
|
+
1. 已安装 `dsh-email-notify`,且其设置命名空间 `email-notify` 可读;
|
|
45
|
+
2. `enabled` 不为 false,且 `smtpHost` / `smtpUser` / `smtpPassword` / `mailTo` 均可发送(`mailFrom` 为空时回退到 `smtpUser`);
|
|
46
|
+
3. 本插件的 `sessionEnd.notifyEmailOnAi` 为 `true`(默认)。
|
|
47
|
+
|
|
48
|
+
实现方式:
|
|
49
|
+
|
|
50
|
+
- 通过 Host 的 `settings.describe({ redactSecrets: false })` 读取邮件插件已经配置的 SMTP 字段(仅 Host 内部使用,不经过浏览器,不打印密码);
|
|
51
|
+
- 用内置的 `nodemailer` 发送自定义主题/正文,**不修改 `dsh-email-notify`**;
|
|
52
|
+
- 邮件发送是异步 best-effort:失败只写 `%TEMP%\dsh-mcviseron-session-end.log`,不阻塞工具结果和重启动作;
|
|
53
|
+
- 同一 session + action 60 秒内只发一次,避免 AI 重复调用造成轰炸。
|
|
54
|
+
|
|
55
|
+
模板字段:
|
|
56
|
+
|
|
57
|
+
| 占位符 | 值 |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `{{action}}` | `restart` / `close` |
|
|
60
|
+
| `{{actionText}}` | 重启 DeepSeek Harness / 关闭 DeepSeek Harness |
|
|
61
|
+
| `{{sessionName}}` | 会话标题(缺失时用 sessionId) |
|
|
62
|
+
| `{{sessionId}}` | 会话 ID |
|
|
63
|
+
| `{{time}}` | 本地时间 |
|
|
64
|
+
| `{{reason}}` | 工具参数 `reason`,空时显示「(未提供)」 |
|
|
65
|
+
|
|
66
|
+
## 配置
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
sessionEnd:
|
|
70
|
+
enabled: true # 输入框下拉 + AI 工具
|
|
71
|
+
graceMs: 3000 # 最终回复渲染等待,0–15000
|
|
72
|
+
notifyEmailOnAi: true # AI 开启时发邮件
|
|
73
|
+
emailSubject: "[DSH 会话后动作] {{actionText}}"
|
|
74
|
+
emailBody: |-
|
|
75
|
+
AI 已请求在本轮会话结束后{{actionText}}。
|
|
76
|
+
|
|
77
|
+
会话:{{sessionName}}
|
|
78
|
+
会话 ID:{{sessionId}}
|
|
79
|
+
时间:{{time}}
|
|
80
|
+
理由:{{reason}}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
这些字段也在「设置 → MCviseron 插件 → 会话后动作」子页中提供;配置修改后如果运行中的组件还没拿到新值,重启 DSH 生效。
|
|
84
|
+
|
|
85
|
+
## 接口
|
|
86
|
+
|
|
87
|
+
| 方法 | 路径 | 用途 |
|
|
88
|
+
| --- | --- | --- |
|
|
89
|
+
| POST | `/api/dsh-mcviseron/session-end/state` | 查询当前 session 状态(1.5 秒轮询) |
|
|
90
|
+
| POST | `/api/dsh-mcviseron/session-end/set` | 用户下拉设置;只允许 loopback |
|
|
91
|
+
|
|
92
|
+
## 限制
|
|
93
|
+
|
|
94
|
+
- 关闭 DSH / 关机按设计不等待任务(只有重启等待)。
|
|
95
|
+
- 欢迎页/浏览器刷新不会重置 Host 内存状态;新的 DSH 进程一定从关闭开始。
|
|
96
|
+
- 邮件联动读取的是抓取时的 SMTP 配置;邮件插件设置改变后,下一次 AI 设置动作会重新读取。
|
|
97
|
+
- 邮件发送失败不会阻止重启/关闭,也不会在 UI 中弹窗;需要诊断时查看上面的临时日志。
|
package/lib/appearance.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
|
|
1
4
|
// src/appearance/index.ts
|
|
2
5
|
import z from "@deepseek-ai/schemastery";
|
|
3
6
|
|
|
@@ -113,7 +116,12 @@ var FIELD_RULES = {
|
|
|
113
116
|
"taskGuard.include": { type: "strings" },
|
|
114
117
|
"taskGuard.exclude": { type: "strings" },
|
|
115
118
|
"restart.enabled": { type: "boolean" },
|
|
116
|
-
"restart.appPath": { type: "string" }
|
|
119
|
+
"restart.appPath": { type: "string" },
|
|
120
|
+
"sessionEnd.enabled": { type: "boolean" },
|
|
121
|
+
"sessionEnd.graceMs": { type: "number", min: 0, max: 15e3 },
|
|
122
|
+
"sessionEnd.notifyEmailOnAi": { type: "boolean" },
|
|
123
|
+
"sessionEnd.emailSubject": { type: "string" },
|
|
124
|
+
"sessionEnd.emailBody": { type: "string" }
|
|
117
125
|
};
|
|
118
126
|
function ruleFor(path) {
|
|
119
127
|
if (!Array.isArray(path) || path.length === 0 || path.length > 2) return void 0;
|
|
@@ -182,7 +190,8 @@ function toPluginView(descriptor) {
|
|
|
182
190
|
...normalizeScheduleConfig(plain),
|
|
183
191
|
autoReviewFix: isRecord(record.autoReviewFix) ? record.autoReviewFix : {},
|
|
184
192
|
taskGuard: isRecord(record.taskGuard) ? record.taskGuard : {},
|
|
185
|
-
restart: isRecord(record.restart) ? record.restart : {}
|
|
193
|
+
restart: isRecord(record.restart) ? record.restart : {},
|
|
194
|
+
sessionEnd: isRecord(record.sessionEnd) ? record.sessionEnd : {}
|
|
186
195
|
},
|
|
187
196
|
revision: descriptor.revision
|
|
188
197
|
};
|