pandashere/dsh-self-control-guard ↗★ 1
self-control-guard
Self-control guard for DeepSeek Harness: intercept host-kill attempts from bash, teach the controlled exit/restart tools, run token-confirmed graceful exit/restart, and write the restart recovery roster.
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:pandashere/dsh-self-control-guard说明文档
阅读完整 README ↗self-control-guard
English | 中文
针对 DeepSeek Harness 宿主进程的自控守卫插件。
为什么需要它
开发 DSH 插件时,agent 经常误触自杀——一条失手或意图错误的命令(pkill dsh、kill -9 、kill $PPID、killall dsh)直接杀死了自己的宿主进程。会话中途崩溃、工作丢失、无审计轨迹。本插件用于防止 agent 自杀:从 bash 工具拦截高置信度的宿主终止尝试、硬性拒绝、引导模型使用受控退出工具,并留下审计轨迹。
它做三件事:
- 拦截 从
bash工具终止宿主的高置信度尝试(规范形式kill、kill $PPID、pkill dsh、killall dsh),单调硬拒——任何后续pre-execute监听器都无法 force-allow。 - 引导 模型使用受控工具——
dsh_self_exit恒有,dsh_self_restart仅在restartEnabled: true时(默认隐藏——TBD,见 Known Limitations):在拦截后的下一条消息注入固定引导文案。工具启动即注册但隐藏(hidden: true使其不进schemas()),未受指导的模型无法枚举发现;但按名可调用,任何从工具列表之外获知名字的调用方(守卫拒绝文案、用户指令、其他工具)都能立即调用。 - 执行 token 确认的优雅退出/重启,走 launcher 既有缝:一次性模式用 headless runner 的
ctx.headlessIo.exit(code)(精确退出码),长驻面(web)复用 launcher 的SIGTERM优雅关闭。
定位:UX/拦截层,不是安全边界。 matcher 在有界 shell 命令列表里按简单命令粒度识别规范 kill 形式(; && || | |& &、换行、注释、引号、( list ) / { list; } 分组、重定向(目标词不透明));动态构造($VAR、$(...)、反引号、通配符、heredoc)、shell 函数、不支持的复合语法以及解析器资源上限失败一律 abstain。变量拼接、编码、解释器、进程组信号、PTY、MCP、Code Runtime、cordis_mount 与直接系统调用都在文档化的漏报面内(见拦截覆盖与 Known Limitations)。OS 总能杀死宿主;守卫的职责是让模型改用受控工具,并在发生时留下审计轨迹。
安装
前置条件:Node.js 22 或更高版本,以及 @deepseek-ai/dsh@0.1.0-rc.6。插件以独立 bundle 形式安装进任意 DSH profile。
在插件目录内构建、校验并打包:
npm install
npm run check
npm pack
把生成的 tarball 安装进 DSH profile,然后重启 dsh web。不要把源码目录作为 link 安装,因为宿主 peer 依赖由 DSH profile 提供:
npx @deepseek-ai/dsh@0.1.0-rc.6 plugin --profile web add ./self-control-guard-0.1.0.tgz
npx @deepseek-ai/dsh@0.1.0-rc.6 web