Tools & Capabilities

dsh-exit-bash

12362566/dsh-exit-bash · ★ 1

12362566

An Exit-Bash button plus a /exit-bash command to fix: after a persistent bash session has run, the sandbox mode can no longer be switched (cannot change sandbox mode ... while persistent terminal sessions are open or being created).

README body is shown in Chinese.

License
Unknown
Added
2026-08-16
Maintenance
active
Install kind
github
Manifest details
Manifest status
Declared
Manifest path
package.json#dsh
Manifest checked
2026-08-19
Lifecycle scripts
None found

Static manifest checks report declarations only; they are not compatibility or security review.

安装

dsh plugin --profile web add github:12362566/dsh-exit-bash

GitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试

For install and environment setup, plus plugin development tutorials, see DSH community docs ↗

README

Source README · body: zh · Read Chinese README

Table of contents
  1. 原理
  2. 安装
  3. 使用
  4. 已知行为
  5. 配套补丁(重要)

一个「退出 Bash」按钮 + /exit-bash 命令,用来解决:会话里已经跑过持久 bash 后无法切换沙箱模式(cannot change sandbox mode ... while persistent terminal sessions are open or being created)。

原理

  • 持久 bash 工具(dsh-tool-bash-persistent)的 PTY shell 在任务结束后仍存活;
  • dsh-terminal-bash 在每次 sandbox/mode 事件提交前检查该 agent 是否还有活的 PTY(hasOwnerActivity),有就拒绝切换;
  • 本插件的宿主半边注册 /exit-bash 命令:先给 shell 发 exit(宽限 graceMs 毫秒),再 terminals.kill 移除 PTY 记录,并中止仍在创建中的 spawn;
  • 浏览器半边在会话头(agent preset 标签旁)放一个按钮,点击直接通过 remote.commands.execute 执行 /exit-bash(不经过 commandUi,避免 commandUi 内部拿不到 remote.commands 导致按钮无效)。命令结果以流程节点显示在对话里。

安装

dsh plugin --profile web add /path/to/dsh-exit-bash
# 重启 profile 使新的 bundle 层与客户端插件清单生效:
dsh web   # 重新启动你的 web profile

客户端插件清单(dsh.client 扫描)在启动时缓存,必须重启进程;宿主命令本身在 cordis 层支持热重载,但一次重启即可两者兼得。

使用

  1. 任务跑完后,点击会话头部的 退出 Bash 按钮(或在输入框执行 /exit-bash);
  2. 看到「已关闭 N 个持久终端」的流程节点后,再用输入框的权限选择器切换沙箱模式即可成功。

已知行为

  • 会话没有持久终端(如 standard preset 的一次性 bash)时,命令返回「无需关闭」。
  • 关闭后 agent 下一次调用 bash 会重新创建一个终端,且新终端按切换后的沙箱模式隔离运行——这正是期望行为。
  • 若在 agent 正在执行 bash 命令时点击按钮,正在进行的工具调用会被终止(等同用户强制关闭终端)。

配套补丁(重要)

dsh-tool-bash-persistent 会缓存每个 agent 的 PTY id;外部用 /exit-bash 直接 terminals.kill 后,工具缓存仍指向旧 id,下一次 bash 调用会先报一次 unknown PTY session ... 再自愈。为了让「退出 Bash」后下一次调用直接成功,需要给 @deepseek-ai/dsh-tool-bash-persistent 打上本包附带的补丁:

# 在 web profile 目录执行(请先确保该目录可写)
cd ~/.dsh/profiles/web
cp /path/to/dsh-exit-bash/patches/@deepseek-ai__dsh-tool-bash-persistent.patch patches/

然后在 pnpm-workspace.yaml 的 patchedDependencies 中加入:

patchedDependencies:
  '@deepseek-ai/dsh-tool-bash-persistent': patches/@deepseek-ai__dsh-tool-bash-persistent.patch

再执行:

pnpm install
dsh web

补丁会让 persistentShells.get() 在复用缓存的 PTY id 前先确认该 id 仍存在于 terminals 注册表;已被 /exit-bash 关闭时自动丢弃旧缓存并创建新终端,不再把 unknown PTY session 暴露给模型。