Skip to content
dsh.fish
Bundle

dsh-power

Power controls for the DeepSeek Harness Web GUI: shut down or restart DSH from the browser sidebar

Source
jcfung1122
License
MIT
Updated
Updated 2 days ago

Readme

# dsh-power

[![License](https://img.shields.io/badge/license-MIT-2da44e)](LICENSE)
[![DSH](https://img.shields.io/badge/dsh-%3E%3D0.1.0--rc.6-1f6feb)](https://github.com/deepseek-ai/deepseek-harness)

[English](README.en.md) | 中文

给 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Web 界面加一个**电源按钮**:在侧边栏「设置」上方悬停,即可**关闭 DSH** 或**重启 Web UI**。

## 特性

- 🚫 **绝不误关其他浏览器窗口** —— 页面通过 `window.close()` 自行关闭,宿主进程从不杀 Chrome。
- 🧭 **环境自适应** —— 无硬编码路径或端口。重启命令由当前进程重建,重开地址跟随实际监听端口。
- 🌍 **跨平台** —— Windows(无窗口 `wscript` 辅助进程)、macOS(`open`)、Linux(`xdg-open`)。
- ⚡ **零配置** —— 装完即可用。

## 快速安装

需要 DeepSeek Harness `web` profile(`@deepseek-ai/dsh >= 0.1.0-rc.6`)。

```bash
dsh plugin --profile web add "github:jcfung1122/dsh-power"
```

重启已经在跑的 `dsh web`,浏览器硬刷新,侧边栏「设置」上方就会出现电源图标。

卸载:

```bash
dsh plugin --profile web remove dsh-power
```

## 用法

悬停电源图标,选择:

![电源按钮悬浮菜单](screenshot.png)

- **关闭 DSH** —— 只关闭本页面并优雅停止服务,其他浏览器窗口不受影响。
- **重启 Web UI** —— 重新拉起服务并自动重新打开页面。

每一项都先弹确认,确认后才执行。

## 配置

通常不需要任何配置。需要覆盖时写进 `cordis.patch.yml`:

```yaml
- id: power
  config:
    restartWaitMs: 7000     # 重新拉起前等待旧进程释放端口的时长(毫秒)
    restartCommand: ""      # supervisor 管理的部署可填完整重启命令
    reopenUrl: ""           # 覆盖自动推导的重开地址
```

| 键 | 默认值 | 说明 |
| --- | --- | --- |
| `restartWaitMs` | `7000` | 等待旧进程释放端口后再拉起。 |
| `restartCommand` | *(自动)* | 完整重启命令;默认从当前进程重建。 |
| `reopenUrl` | *(自动)* | 重开地址;默认 `http://127.0.0.1:<端口>`。 |

## 工作原理

宿主半边注册两个仅限回环的 POST 接口:`/api/power/shutdown` 与
`/api/power/restart`。`shutdown` 请求启动器提供的 `appExit` 优雅退出;`restart`
先从 `process.argv` 重建启动命令、读 `webServer.port` 得到重开地址,再 detach 一个
跨平台辅助进程(Windows 用无窗口 VBS 脱离父进程 job,macOS/Linux 用 `sh` +
`open`/`xdg-open`)后退出。浏览器收到确认后 `window.close()` 关闭本页。

## 隐私与安全

- 两个接口都是 **exact 路由**,位于 RPC 信任边界之外,处理器自己设防:仅 POST、仅回环 peer 地址。
- 不读取任何会话、提示词或模型数据。

## 开发

```bash
npm test           # 纯 JS,无构建步骤;浏览器半边也能在 Node 里物化和测试
npm pack --dry-run
```

浏览器半边没有构建步骤:它是一个手写的 `__ModuleLoader__` bundle,React 由宿主作为
peer 提供。

## License

[MIT](LICENSE)

Install

dsh plugin --profile web add github:jcfung1122/dsh-power

Profile: web

  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source