README来源: main@9156bb33
dsh-web-restart — DSH Web 一键重启插件对
为 DeepSeek Harness(DSH)Web GUI 提供一键重启服务的能力,由两个插件组成:
| 包 | 角色 | 作用 |
|---|---|---|
dsh-web-restart |
host 插件 | 注册 POST /api/dsh-restart,以 detached 方式执行 ~/.dsh/restart-dsh-web.sh 重启 GUI 进程(仅接受本机回环请求) |
dsh-web-restart-client |
client 插件 | 在浏览器注入一个可拖拽的「重启服务」悬浮按钮;拖拽位置自动记忆(localStorage) |
特性
- 🖱️ 可拖拽按钮:按住拖动即可改变位置,自动避开聊天输入框的发送按钮;位置跨刷新/重启记忆
- 🔒 安全:
POST /api/dsh-restart仅接受127.0.0.1/::1回环请求,非本机返回 403;单实例保护,同一时间只允许一次重启 - 🧩 零配置挂载:host 包通过
dsh.bundle.patch(cordis.patch.yml)自动挂载客户端插件,无需手动改 cordis 配置 - ⚡ 重启脚本不存在时返回明确错误(
500),避免静默失败 - 🔍 纯本地:不向云端发送任何数据,无 API Key,无外部依赖
架构
浏览器(DSH Web GUI)
└─ dsh-web-restart-client ── 悬浮按钮(可拖拽)
│ 点击 → POST /api/dsh-restart
▼
dsh-web-restart (host, 注入 webServer)
│ spawn("bash", ["~/.dsh/restart-dsh-web.sh"], { detached: true })
▼
~/.dsh/restart-dsh-web.sh
│ 杀旧进程(端口 3080) → 以原方式拉起 `dsh web` → 健康检查(≤90s)
▼
DSH Web 重启完成 → 浏览器刷新页面即可
安装
方式一:DSH 插件市场(推荐)
仓库已打 dsh-plugin topic,被 DSH 插件市场 自动收录后,在 Web GUI 设置 → DSH插件市场 搜索 dsh-web-restart 一键安装。
也可用 dsh CLI 直接安装:
dsh plugin --profile web install Xiaojing-511/dsh-web-restart
方式二:手动安装(无需发布 npm)
git clone https://github.com/Xiaojing-511/dsh-web-restart.git /tmp/dsh-web-restart
cd ~/.dsh/profiles/web # 换成你要挂载的 profile
npm i /tmp/dsh-web-restart/dsh-web-restart
然后把 dsh-web-restart 加入 profile 的 bundles(~/.dsh/profiles/web/package.json):
{
"dependencies": {
"dsh-web-restart": "file:/tmp/dsh-web-restart/dsh-web-restart"
},
"dsh": {
"profile": {
"bundles": [
"@deepseek-ai/dsh-base",
"@deepseek-ai/dsh-web-app",
"dsh-web-restart" // ← 加入
]
}
}
}
重启 DSH Web 后生效。host 包会自动把客户端插件(dsh-web-restart-client)一并挂载。
前提:需要
~/.dsh/restart-dsh-web.sh存在(见下方「重启脚本」),否则接口返回 500。
只使用客户端按钮
cd ~/.dsh/profiles/web
npm i /tmp/dsh-web-restart/dsh-web-restart-client
并在 bundles 中加入 dsh-web-restart-client。此时需要你自己提供一个 POST /api/dsh-restart 接口。
重启脚本
host 插件依赖 ~/.dsh/restart-dsh-web.sh。仓库提供了通用模板:
cp scripts/restart-dsh-web.sh.example ~/.dsh/restart-dsh-web.sh
# 然后编辑脚本,把 NODE / DSH_BIN / PORT 改成你机器上的实际值
chmod +x ~/.dsh/restart-dsh-web.sh
脚本职责:杀掉占用端口的旧进程 → 以与原进程等价的方式重新启动 dsh web → 健康检查(最多 90 秒)→ 日志写入 ~/.dsh/web-restart.log。
使用
- 打开 DSH Web GUI(如
http://127.0.0.1:3080),左下角出现「重启服务」按钮(默认位置,可拖走) - 拖动按钮到任意位置(位置自动保存);点击触发重启
- 确认后调用
POST /api/dsh-restart,页面显示「已触发,即将断开…」→「请刷新页面」 - 重启会中断运行中的会话/任务;会话历史持久化在
~/.dsh/sessions,刷新后可在历史中恢复
API
POST /api/dsh-restart(仅本机回环可访问)
| 状态码 | 含义 |
|---|---|
200 |
已触发重启({ ok: true, message, script }) |
403 |
非本机回环请求 |
405 |
非 POST 方法 |
409 |
已有一次重启在进行中 |
500 |
重启脚本缺失或 spawn 失败({ error }) |
安全与数据披露
- 云端依赖:无(
cloud: false)。插件纯本地运行,不向任何外部服务器发送数据 - 网络:仅监听本机回环(
127.0.0.1/::1),无出站连接 - 凭据:不读取、不存储任何 API Key / Token
- 文件系统:读取
~/.dsh/restart-dsh-web.sh(不存在时返回 500);重启脚本按你的配置写日志 - 数据保留:无服务端数据;客户端仅把按钮位置存入浏览器
localStorage - 完整披露字段见两个包的
package.json→disclosure(DISCLOSURE v0.2 契约)
开发
# 客户端插件
cd dsh-web-restart-client && npm i
# host 插件(依赖客户端,file: 方式本地关联)
cd dsh-web-restart && npm i
还没有评论,来写第一条。