dsh-mcviseron-plugin 0.8.1 → 0.8.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 +40 -15
- package/README.en.md +8 -8
- package/README.md +11 -11
- package/SECURITY.md +1 -1
- package/docs/linux-restart.md +3 -1
- package/docs/migration-from-standalone.md +1 -1
- package/docs/release.md +12 -6
- package/lib/client.js +106 -4
- package/lib/index.js +55 -3
- package/lib/restart.js +23 -3
- 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/src/restart/index.ts +26 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
## [0.8.4] - 2026-12-06
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- **Windows 重启偶发只关闭不拉起**:Task Scheduler 在旧 Electron/Host 尚未完全退出时就启动新实例,单实例锁会让新进程直接退出。现在任务 action 改为隐藏的 PowerShell helper,先等待旧 main/host PID 消失(最多 30 秒),再启动应用;设置页和侧边栏共用同一路由,二者都修复。
|
|
6
|
+
|
|
7
|
+
### Tests
|
|
8
|
+
|
|
9
|
+
- 合计 **131 项测试**;typecheck、build 全绿。
|
|
10
|
+
|
|
11
|
+
## [0.8.3] - 2026-11-22
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **侧边栏底部重启快捷入口**:注册 `sidebar.footer.action`,在设置菜单上方增加「重启 DSH」按钮;宽栏显示图标+文字,窄栏只显示图标。点击复用现有重启路由,设置页的重启/关闭按钮保持不变。路由不可用时按钮自动隐藏。
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **任务列表 todo 不翻译**:`translateTodoContent` 之前只构造 notice,官方任务面板仍显示英文。现在通过 `session.append('todo/write', { todos })` 写入「中文(English)」的新快照;未来 `todo_write` 在 `todo/write` 事件后迁移,已有列表在下一次 `agent/pre-step` / turn 边界迁移,状态不变。
|
|
20
|
+
- 注意:DSH 在 `tools/pre-execute` 前会 deepFreeze 工具参数,不能直接改写 `todo_write` arguments;因此采用 session 快照迁移,而不是修改执行参数。
|
|
21
|
+
|
|
22
|
+
### Docs
|
|
23
|
+
|
|
24
|
+
- README / SECURITY / 设置项文案说明:`translateTodoContent` 会写入并显示中文标题,已有列表下次 turn 迁移。
|
|
25
|
+
|
|
26
|
+
### Tests
|
|
27
|
+
|
|
28
|
+
- 合计 **130 项测试**;typecheck、build 全绿。
|
|
29
|
+
|
|
30
|
+
## [0.8.2] - 2026-11-22(未发布,由 0.8.3 取代)
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- **自动化任务 API 的组件内文本**:Settings → MCviseron 插件 → 组件新增「自动化任务 API」行;automation-tasks 的 system prompt 补入 DSH 0.2.2 的 `schedule.list/create/edit` 签名及旧版兼容说明,避免组件只暴露工具名而没有管理 API 文本。
|
|
35
|
+
|
|
36
|
+
### Tests
|
|
37
|
+
|
|
38
|
+
- 129 项测试;typecheck、build 全绿。
|
|
39
|
+
|
|
1
40
|
## [0.8.1] - 2026-11-22
|
|
2
41
|
|
|
3
42
|
### Fixed
|
|
@@ -8,7 +47,7 @@
|
|
|
8
47
|
|
|
9
48
|
- 129 项测试;typecheck、build 全绿。
|
|
10
49
|
|
|
11
|
-
## [0.8.0] - 2026-11-22
|
|
50
|
+
## [0.8.0] - 2026-11-22(未发布,由 0.8.1 取代)
|
|
12
51
|
|
|
13
52
|
### Added
|
|
14
53
|
|
|
@@ -20,20 +59,6 @@
|
|
|
20
59
|
|
|
21
60
|
- 合计 **129 项测试**;typecheck、build 全绿。
|
|
22
61
|
|
|
23
|
-
## [Unreleased]
|
|
24
|
-
|
|
25
|
-
### 计划中
|
|
26
|
-
|
|
27
|
-
- 将「按时间切换」扩展为多时段表(例如白天的多个浅色窗口)。
|
|
28
|
-
- 设置行支持「立即测试」预览按钮。
|
|
29
|
-
- Restart 组件支持 macOS/Linux(当前仅 Windows 桌面版)。
|
|
30
|
-
|
|
31
|
-
## [Unreleased]
|
|
32
|
-
|
|
33
|
-
### Docs
|
|
34
|
-
|
|
35
|
-
- 在 `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 组件表加入文档链接。
|
|
36
|
-
|
|
37
62
|
## [0.7.8] - 2026-11-22
|
|
38
63
|
|
|
39
64
|
### 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 + 131 tests; current desktop still rc.3) |
|
|
159
|
+
| `0.2.2-rc.3` | ✅ current desktop (rc.3 types/deps + 131 tests; real runtime verified) |
|
|
160
|
+
| `0.2.2-rc.1` | ✅ compatible (0.2.2-rc.1 types/deps + 131 tests) |
|
|
161
|
+
| `0.2.1-rc.5` | ✅ compatible (rc.5 types/deps + 131 tests) |
|
|
162
|
+
| `0.2.1-rc.3` | ✅ compatible (rc.3 types/deps + 131 tests) |
|
|
163
|
+
| `0.2.1-rc.2` | ✅ current desktop runtime (131 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,14 +45,14 @@ 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
|
|
52
52
|
|
|
53
53
|
- Windows 桌面版:「设置 → MCviseron 插件 → 重启 / 关闭」子页提供重启与关闭按钮,点击后确认并重启/关闭桌面应用。
|
|
54
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)。
|
|
55
|
-
- 重启方式:Host
|
|
55
|
+
- 重启方式:Host 注册一个隐藏的 Task Scheduler PowerShell helper;helper 先等待旧 Electron 主进程与 Host PID 退出(最多 30 秒),再启动应用,避免单实例锁导致新进程直接退出。
|
|
56
56
|
- 会中断正在运行的任务(与托盘「退出」的提示一致),不会修改插件、配置或会话记录。
|
|
57
57
|
- 只在桌面版可用;`dsh web` 下状态接口返回不可用,设置行自动隐藏。
|
|
58
58
|
- **为什么不做成托盘菜单项**:DSH 的托盘菜单由 Electron 主进程的 `lib/main.js` 直接构建(`DesktopTray`),插件运行在独立的 Host 子进程里,官方没有提供托盘扩展点;因此本组件只能在设置页提供等价入口。
|
|
@@ -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 类型/依赖 + 131 项测试;当前桌面仍为 rc.3) |
|
|
254
|
+
| `0.2.2-rc.3` | ✅ 当前桌面安装(rc.3 类型/依赖 + 131 项测试;真实运行时验证) |
|
|
255
|
+
| `0.2.2-rc.1` | ✅ 兼容(0.2.2-rc.1 类型/依赖 + 131 项测试) |
|
|
256
|
+
| `0.2.1-rc.5` | ✅ 兼容(rc.5 类型/依赖 + 131 项测试) |
|
|
257
|
+
| `0.2.1-rc.3` | ✅ 兼容(rc.3 类型/依赖 + 131 项测试) |
|
|
258
|
+
| `0.2.1-rc.2` | ✅ 当前桌面运行版本(131 项测试 + 真实 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 + 131 项测试 + 构建
|
|
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/docs/release.md
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# 发布 dsh-mcviseron-plugin 到 npm
|
|
2
2
|
|
|
3
|
-
## 当前状态(2026-
|
|
3
|
+
## 当前状态(2026-12-06)
|
|
4
4
|
|
|
5
|
-
- 包名 **`dsh-mcviseron-plugin` 当前发布 0.
|
|
5
|
+
- 包名 **`dsh-mcviseron-plugin` 当前发布 0.8.4**;0.8.0、0.8.2 未发布,分别由 0.8.1、0.8.3 取代。0.8.4 修复 Windows 重启时旧进程未退出导致新实例不拉起的问题。
|
|
6
6
|
- npm 账号 `mcviseron` 已恢复正常,可执行首次手动发布。
|
|
7
7
|
- 本机全局 registry 指向 npmmirror,发布时必须显式指定 `--registry=https://registry.npmjs.org/`。
|
|
8
|
-
- 首次发布 **v0.6.1
|
|
9
|
-
-
|
|
8
|
+
- 首次发布 **v0.6.1 已手动完成**;此后由 `.github/workflows/publish.yml` 通过 OIDC Trusted Publishing 发布,tag 推送即发布。
|
|
9
|
+
- **0.8.0、0.8.2 跳过**:0.8.0 的 tag workflow 在 CI 阶段失败,0.8.2 只完成代码/文档准备;两者都未发布,npm 历史中不会出现。
|
|
10
|
+
|
|
11
|
+
## 版本节奏
|
|
12
|
+
|
|
13
|
+
- **bug 修复、兼容性、CI、文档**:直接递增 patch(例如 0.8.3 → 0.8.4),修完即打 tag 并发布,不等待用户再次要求。
|
|
14
|
+
- **新增功能、破坏性变更**:由用户明确要求后使用 minor/major(例如 0.9.0)。
|
|
15
|
+
- 已跳过的版本不在 npm 补发;用下一个版本直接取代。
|
|
10
16
|
|
|
11
17
|
## 首次发布(账号解冻后)
|
|
12
18
|
|
|
@@ -49,7 +55,7 @@
|
|
|
49
55
|
|
|
50
56
|
```powershell
|
|
51
57
|
npm view dsh-mcviseron-plugin version dist-tags.latest --registry=https://registry.npmjs.org/
|
|
52
|
-
curl.exe -sI https://registry.npmjs.org/dsh-mcviseron-plugin/-/dsh-mcviseron-plugin-0.
|
|
58
|
+
curl.exe -sI https://registry.npmjs.org/dsh-mcviseron-plugin/-/dsh-mcviseron-plugin-0.8.4.tgz | Select-Object -First 1
|
|
53
59
|
curl.exe -X PUT "https://registry.npmmirror.com/-/package/dsh-mcviseron-plugin/syncs"
|
|
54
60
|
```
|
|
55
61
|
|
|
@@ -77,7 +83,7 @@ Trusted Publisher 绑定后,**推送 `v*` tag 即直接发布**,不再需要
|
|
|
77
83
|
|
|
78
84
|
> `workflow_dispatch` 默认只做 `npm pack --dry-run`;要发布当前 `main` 的版本,取消勾选 `dry-run` 再运行。
|
|
79
85
|
>
|
|
80
|
-
>
|
|
86
|
+
> 最近版本:0.7.8 修复 Linux CI 临时目录;0.8.0/0.8.1 加入 Linux/Web/云重启与关闭并修复 CI;0.8.2 跳过;0.8.3 加入侧边栏重启快捷入口;0.8.4 修复 Windows 重启等待旧进程退出。
|
|
81
87
|
|
|
82
88
|
## 回滚与故障
|
|
83
89
|
|
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
|
});
|
|
@@ -12939,6 +12940,7 @@ __export(restart_exports, {
|
|
|
12939
12940
|
deriveDesktopAppPath: () => deriveDesktopAppPath,
|
|
12940
12941
|
inject: () => inject4,
|
|
12941
12942
|
launchRestart: () => launchRestart,
|
|
12943
|
+
makeRestartHelper: () => makeRestartHelper,
|
|
12942
12944
|
makeRestartRoutes: () => makeRestartRoutes,
|
|
12943
12945
|
makeTaskScript: () => makeTaskScript,
|
|
12944
12946
|
resolveProcessRestartTarget: () => resolveProcessRestartTarget,
|
|
@@ -13007,11 +13009,11 @@ var RESTART_DELAY_SECONDS = 6;
|
|
|
13007
13009
|
function restartLogPath() {
|
|
13008
13010
|
return join5(tmpdir4(), "dsh-mcviseron-restart.log");
|
|
13009
13011
|
}
|
|
13010
|
-
function makeTaskScript(target, taskName, delaySeconds) {
|
|
13012
|
+
function makeTaskScript(target, taskName, delaySeconds, helperPath = "") {
|
|
13011
13013
|
const quote = (value) => "'" + value.replace(/'/g, "''") + "'";
|
|
13012
13014
|
return [
|
|
13013
13015
|
"$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name",
|
|
13014
|
-
`$action = New-ScheduledTaskAction -Execute ${quote(target.exePath)} -WorkingDirectory ${quote(dirname(target.exePath))}`,
|
|
13016
|
+
helperPath === "" ? `$action = New-ScheduledTaskAction -Execute ${quote(target.exePath)} -WorkingDirectory ${quote(dirname(target.exePath))}` : `$action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument ${quote('-NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File "' + helperPath + '"')} -WorkingDirectory ${quote(dirname(target.exePath))}`,
|
|
13015
13017
|
`$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddSeconds(${delaySeconds})`,
|
|
13016
13018
|
"$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited",
|
|
13017
13019
|
`Register-ScheduledTask -TaskName ${quote(taskName)} -Action $action -Trigger $trigger -Principal $principal -Force | Out-Null`,
|
|
@@ -13083,16 +13085,35 @@ function closeDesktop(target) {
|
|
|
13083
13085
|
}
|
|
13084
13086
|
}, 300);
|
|
13085
13087
|
}
|
|
13088
|
+
function makeRestartHelper(target, logPath = restartLogPath()) {
|
|
13089
|
+
const quote = (value) => "'" + value.replace(/'/g, "''") + "'";
|
|
13090
|
+
return [
|
|
13091
|
+
'$ErrorActionPreference = "SilentlyContinue"',
|
|
13092
|
+
"$mainPid = " + String(target.mainPid ?? 0),
|
|
13093
|
+
"$hostPid = " + String(target.hostPid),
|
|
13094
|
+
"$deadline = (Get-Date).AddSeconds(30)",
|
|
13095
|
+
"while ((Get-Date) -lt $deadline) {",
|
|
13096
|
+
" if (-not (Get-Process -Id $mainPid -ErrorAction SilentlyContinue) -and -not (Get-Process -Id $hostPid -ErrorAction SilentlyContinue)) { break }",
|
|
13097
|
+
" Start-Sleep -Milliseconds 200",
|
|
13098
|
+
"}",
|
|
13099
|
+
"Start-Sleep -Milliseconds 700",
|
|
13100
|
+
"Start-Process -FilePath " + quote(target.exePath) + " -WorkingDirectory " + quote(dirname(target.exePath)) + " | Out-Null",
|
|
13101
|
+
"Add-Content -LiteralPath " + quote(logPath) + ' -Value ((Get-Date).ToString("o") + " helper: launched " + ' + quote(target.exePath.replace(/'/g, "''")) + ") -Encoding UTF8"
|
|
13102
|
+
].join("\n");
|
|
13103
|
+
}
|
|
13086
13104
|
function launchHelper(target) {
|
|
13087
13105
|
const logFile = restartLogPath();
|
|
13106
|
+
let helperPath = "";
|
|
13088
13107
|
try {
|
|
13108
|
+
helperPath = join5(tmpdir4(), "dsh-mcviseron-restart-helper.ps1");
|
|
13109
|
+
writeFileSync(helperPath, makeRestartHelper(target), "utf8");
|
|
13089
13110
|
execFileSync("powershell.exe", [
|
|
13090
13111
|
"-NoProfile",
|
|
13091
13112
|
"-NonInteractive",
|
|
13092
13113
|
"-WindowStyle",
|
|
13093
13114
|
"Hidden",
|
|
13094
13115
|
"-Command",
|
|
13095
|
-
makeTaskScript(target, RESTART_TASK_NAME, RESTART_DELAY_SECONDS)
|
|
13116
|
+
makeTaskScript(target, RESTART_TASK_NAME, RESTART_DELAY_SECONDS, helperPath)
|
|
13096
13117
|
], { windowsHide: true, timeout: 2e4, encoding: "utf8" });
|
|
13097
13118
|
appendFileSync4(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: scheduled ${target.exePath} in ${RESTART_DELAY_SECONDS}s
|
|
13098
13119
|
`, "utf8");
|
|
@@ -14175,6 +14196,34 @@ function suggestedTodoPayload(todos, matched) {
|
|
|
14175
14196
|
}));
|
|
14176
14197
|
return JSON.stringify({ todos: next });
|
|
14177
14198
|
}
|
|
14199
|
+
function latestTodos(session) {
|
|
14200
|
+
try {
|
|
14201
|
+
const events = session.snapshotEvents?.();
|
|
14202
|
+
if (!Array.isArray(events)) return null;
|
|
14203
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
14204
|
+
const event = events[index];
|
|
14205
|
+
if (event?.type !== "todo/write") continue;
|
|
14206
|
+
return readTodos(event.data);
|
|
14207
|
+
}
|
|
14208
|
+
} catch {
|
|
14209
|
+
}
|
|
14210
|
+
return null;
|
|
14211
|
+
}
|
|
14212
|
+
async function migrateStoredTodoList(session, config, ctx) {
|
|
14213
|
+
if (!config.translateTodoContent) return;
|
|
14214
|
+
const todos = latestTodos(session);
|
|
14215
|
+
if (todos === null || todos.length === 0) return;
|
|
14216
|
+
const context = noticeContext({ session }, config, ctx);
|
|
14217
|
+
if (!context.translate) return;
|
|
14218
|
+
const contents = todos.map((todo) => todo.content);
|
|
14219
|
+
const translated = await displayTodoContents(contents, context);
|
|
14220
|
+
if (!translated.some((value, index) => value !== contents[index])) return;
|
|
14221
|
+
if (typeof session.append !== "function") return;
|
|
14222
|
+
try {
|
|
14223
|
+
session.append("todo/write", { todos: translated.map((content, index) => ({ content, status: todos[index].status })) });
|
|
14224
|
+
} catch {
|
|
14225
|
+
}
|
|
14226
|
+
}
|
|
14178
14227
|
function installTaskGuard(ctx, input) {
|
|
14179
14228
|
const config = resolveConfig(input);
|
|
14180
14229
|
const bus = ctx;
|
|
@@ -14270,6 +14319,7 @@ function installTaskGuard(ctx, input) {
|
|
|
14270
14319
|
});
|
|
14271
14320
|
bus.on("agent/pre-step", async (payload, next) => {
|
|
14272
14321
|
const sessionId = sessionIdOf4(payload.agent);
|
|
14322
|
+
void migrateStoredTodoList(payload.agent.session, config, ctx);
|
|
14273
14323
|
if (sessionId !== "") intentBuffers.delete(sessionId);
|
|
14274
14324
|
const state = sessions.get(sessionId);
|
|
14275
14325
|
if (state !== void 0) {
|
|
@@ -14299,12 +14349,14 @@ function installTaskGuard(ctx, input) {
|
|
|
14299
14349
|
if (event.type === "turn/start" || event.type === "turn/end") {
|
|
14300
14350
|
sessions.delete(sessionId);
|
|
14301
14351
|
intentBuffers.delete(sessionId);
|
|
14352
|
+
void migrateStoredTodoList(session, config, ctx);
|
|
14302
14353
|
return;
|
|
14303
14354
|
}
|
|
14304
14355
|
if (event.type === "todo/write") {
|
|
14305
14356
|
const todos = readTodos(event.data);
|
|
14306
14357
|
if (todos !== null) resetState(sessions, sessionId, todos);
|
|
14307
14358
|
intentBuffers.delete(sessionId);
|
|
14359
|
+
void migrateStoredTodoList(session, config, ctx);
|
|
14308
14360
|
}
|
|
14309
14361
|
});
|
|
14310
14362
|
}
|
package/lib/restart.js
CHANGED
|
@@ -120,11 +120,11 @@ var RESTART_DELAY_SECONDS = 6;
|
|
|
120
120
|
function restartLogPath() {
|
|
121
121
|
return join(tmpdir(), "dsh-mcviseron-restart.log");
|
|
122
122
|
}
|
|
123
|
-
function makeTaskScript(target, taskName, delaySeconds) {
|
|
123
|
+
function makeTaskScript(target, taskName, delaySeconds, helperPath = "") {
|
|
124
124
|
const quote = (value) => "'" + value.replace(/'/g, "''") + "'";
|
|
125
125
|
return [
|
|
126
126
|
"$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name",
|
|
127
|
-
`$action = New-ScheduledTaskAction -Execute ${quote(target.exePath)} -WorkingDirectory ${quote(dirname(target.exePath))}`,
|
|
127
|
+
helperPath === "" ? `$action = New-ScheduledTaskAction -Execute ${quote(target.exePath)} -WorkingDirectory ${quote(dirname(target.exePath))}` : `$action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument ${quote('-NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File "' + helperPath + '"')} -WorkingDirectory ${quote(dirname(target.exePath))}`,
|
|
128
128
|
`$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddSeconds(${delaySeconds})`,
|
|
129
129
|
"$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited",
|
|
130
130
|
`Register-ScheduledTask -TaskName ${quote(taskName)} -Action $action -Trigger $trigger -Principal $principal -Force | Out-Null`,
|
|
@@ -196,16 +196,35 @@ function closeDesktop(target) {
|
|
|
196
196
|
}
|
|
197
197
|
}, 300);
|
|
198
198
|
}
|
|
199
|
+
function makeRestartHelper(target, logPath = restartLogPath()) {
|
|
200
|
+
const quote = (value) => "'" + value.replace(/'/g, "''") + "'";
|
|
201
|
+
return [
|
|
202
|
+
'$ErrorActionPreference = "SilentlyContinue"',
|
|
203
|
+
"$mainPid = " + String(target.mainPid ?? 0),
|
|
204
|
+
"$hostPid = " + String(target.hostPid),
|
|
205
|
+
"$deadline = (Get-Date).AddSeconds(30)",
|
|
206
|
+
"while ((Get-Date) -lt $deadline) {",
|
|
207
|
+
" if (-not (Get-Process -Id $mainPid -ErrorAction SilentlyContinue) -and -not (Get-Process -Id $hostPid -ErrorAction SilentlyContinue)) { break }",
|
|
208
|
+
" Start-Sleep -Milliseconds 200",
|
|
209
|
+
"}",
|
|
210
|
+
"Start-Sleep -Milliseconds 700",
|
|
211
|
+
"Start-Process -FilePath " + quote(target.exePath) + " -WorkingDirectory " + quote(dirname(target.exePath)) + " | Out-Null",
|
|
212
|
+
"Add-Content -LiteralPath " + quote(logPath) + ' -Value ((Get-Date).ToString("o") + " helper: launched " + ' + quote(target.exePath.replace(/'/g, "''")) + ") -Encoding UTF8"
|
|
213
|
+
].join("\n");
|
|
214
|
+
}
|
|
199
215
|
function launchHelper(target) {
|
|
200
216
|
const logFile = restartLogPath();
|
|
217
|
+
let helperPath = "";
|
|
201
218
|
try {
|
|
219
|
+
helperPath = join(tmpdir(), "dsh-mcviseron-restart-helper.ps1");
|
|
220
|
+
writeFileSync(helperPath, makeRestartHelper(target), "utf8");
|
|
202
221
|
execFileSync("powershell.exe", [
|
|
203
222
|
"-NoProfile",
|
|
204
223
|
"-NonInteractive",
|
|
205
224
|
"-WindowStyle",
|
|
206
225
|
"Hidden",
|
|
207
226
|
"-Command",
|
|
208
|
-
makeTaskScript(target, RESTART_TASK_NAME, RESTART_DELAY_SECONDS)
|
|
227
|
+
makeTaskScript(target, RESTART_TASK_NAME, RESTART_DELAY_SECONDS, helperPath)
|
|
209
228
|
], { windowsHide: true, timeout: 2e4, encoding: "utf8" });
|
|
210
229
|
appendFileSync(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} host: scheduled ${target.exePath} in ${RESTART_DELAY_SECONDS}s
|
|
211
230
|
`, "utf8");
|
|
@@ -318,6 +337,7 @@ export {
|
|
|
318
337
|
deriveDesktopAppPath,
|
|
319
338
|
inject,
|
|
320
339
|
launchRestart,
|
|
340
|
+
makeRestartHelper,
|
|
321
341
|
makeRestartRoutes,
|
|
322
342
|
makeTaskScript,
|
|
323
343
|
resolveProcessRestartTarget,
|
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.4",
|
|
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
|
}
|
package/src/restart/index.ts
CHANGED
|
@@ -182,11 +182,13 @@ function restartLogPath(): string {
|
|
|
182
182
|
* @param delaySeconds - how long the task waits before starting the application.
|
|
183
183
|
* @returns PowerShell registration script text.
|
|
184
184
|
*/
|
|
185
|
-
export function makeTaskScript(target: RestartTarget, taskName: string, delaySeconds: number): string {
|
|
185
|
+
export function makeTaskScript(target: RestartTarget, taskName: string, delaySeconds: number, helperPath = ""): string {
|
|
186
186
|
const quote = (value: string): string => "'" + value.replace(/'/g, "''") + "'"
|
|
187
187
|
return [
|
|
188
188
|
'$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name',
|
|
189
|
-
|
|
189
|
+
helperPath === ""
|
|
190
|
+
? `$action = New-ScheduledTaskAction -Execute ${quote(target.exePath)} -WorkingDirectory ${quote(dirname(target.exePath))}`
|
|
191
|
+
: `$action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument ${quote('-NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File "' + helperPath + '"')} -WorkingDirectory ${quote(dirname(target.exePath))}`,
|
|
190
192
|
`$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddSeconds(${delaySeconds})`,
|
|
191
193
|
'$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited',
|
|
192
194
|
`Register-ScheduledTask -TaskName ${quote(taskName)} -Action $action -Trigger $trigger -Principal $principal -Force | Out-Null`,
|
|
@@ -266,17 +268,38 @@ export function closeDesktop(target?: RestartTarget): void {
|
|
|
266
268
|
}, 300)
|
|
267
269
|
}
|
|
268
270
|
|
|
271
|
+
/** Build a Task Scheduler helper that waits for old processes before starting the app. */
|
|
272
|
+
export function makeRestartHelper(target: RestartTarget, logPath = restartLogPath()): string {
|
|
273
|
+
const quote = (value: string): string => "'" + value.replace(/'/g, "''") + "'"
|
|
274
|
+
return [
|
|
275
|
+
'$ErrorActionPreference = "SilentlyContinue"',
|
|
276
|
+
'$mainPid = ' + String(target.mainPid ?? 0),
|
|
277
|
+
'$hostPid = ' + String(target.hostPid),
|
|
278
|
+
'$deadline = (Get-Date).AddSeconds(30)',
|
|
279
|
+
'while ((Get-Date) -lt $deadline) {',
|
|
280
|
+
' if (-not (Get-Process -Id $mainPid -ErrorAction SilentlyContinue) -and -not (Get-Process -Id $hostPid -ErrorAction SilentlyContinue)) { break }',
|
|
281
|
+
' Start-Sleep -Milliseconds 200',
|
|
282
|
+
'}',
|
|
283
|
+
'Start-Sleep -Milliseconds 700',
|
|
284
|
+
'Start-Process -FilePath ' + quote(target.exePath) + ' -WorkingDirectory ' + quote(dirname(target.exePath)) + ' | Out-Null',
|
|
285
|
+
'Add-Content -LiteralPath ' + quote(logPath) + ' -Value ((Get-Date).ToString("o") + " helper: launched " + ' + quote(target.exePath.replace(/'/g, "''")) + ') -Encoding UTF8',
|
|
286
|
+
].join('\n')
|
|
287
|
+
}
|
|
288
|
+
|
|
269
289
|
/** Register the direct-launch task, then close the Electron main process. */
|
|
270
290
|
function launchHelper(target: RestartTarget): void {
|
|
271
291
|
const logFile = restartLogPath()
|
|
292
|
+
let helperPath = ''
|
|
272
293
|
try {
|
|
294
|
+
helperPath = join(tmpdir(), 'dsh-mcviseron-restart-helper.ps1')
|
|
295
|
+
writeFileSync(helperPath, makeRestartHelper(target), 'utf8')
|
|
273
296
|
execFileSync('powershell.exe', [
|
|
274
297
|
'-NoProfile',
|
|
275
298
|
'-NonInteractive',
|
|
276
299
|
'-WindowStyle',
|
|
277
300
|
'Hidden',
|
|
278
301
|
'-Command',
|
|
279
|
-
makeTaskScript(target, RESTART_TASK_NAME, RESTART_DELAY_SECONDS),
|
|
302
|
+
makeTaskScript(target, RESTART_TASK_NAME, RESTART_DELAY_SECONDS, helperPath),
|
|
280
303
|
], { windowsHide: true, timeout: 20_000, encoding: 'utf8' })
|
|
281
304
|
appendFileSync(logFile, `${new Date().toISOString()} host: scheduled ${target.exePath} in ${RESTART_DELAY_SECONDS}s\n`, 'utf8')
|
|
282
305
|
} catch (error) {
|