dsh-shells:爲 Agent 提供跨平臺持久後臺 Shell

前言

在 DeepSeek Harness(DSH)裏讓 Agent 跑命令,通常走官方終端工具鏈:打開會話、發 stdin、讀輸出、發信號、關閉、列舉。POSIX 上官方已有 bash 後端;Windows 上還需要 cmd、Git Bash、pwsh 等環境,且長任務往往希望 shell 在後臺持續存在,而不是每次工具調用都起新進程。

dsh-shells 是在官方 @deepseek-ai/dsh-tool-terminal 六工具之上做組合與擴展的客戶端插件:爲 Agent 註冊多種 shell 後端,並在 DSH Web 界面側邊欄提供只讀 PTY 流面板,便於對照模型所見輸出。

這是什麼

  • 名稱:dsh-shells(GitHub:liu-zhengdong/dsh-shells)
  • 維護者:liu-zhengdong
  • 分類:客戶端(Web 注入側邊欄與 Remote)
  • 當前版本(package.json):0.1.3,許可證 MIT

插件不重新實現 PTY 會話機,而是複用官方 BashTerminalBackend(readiness、scrollback、sanitizer、read 分頁等),僅通過 spawnTerminal 改寫環境或發現可執行路徑;模型側仍使用 terminal_open / terminal_send / terminal_read 等官方工具名與參數形態。

核心功能

模型面

與官方 @deepseek-ai/dsh-tool-terminal 對齊,Agent 可用六工具:terminal_open、terminal_send、terminal_read、terminal_signal、terminal_close、terminal_list。本插件負責在後端層掛載多種 shell 類型。

Shell 後端

環境 類型 說明
POSIX bash 官方 dsh-terminal-bash,backendType 爲 shell
POSIX zsh 本插件註冊;通過 PS1 注入 prompt 標記,-f 跳過 rc 防覆蓋
Windows cmd 通過 PROMPT 環境變量注入同樣標記
Windows gitbash 自動發現 git-bash.exe
Windows pwsh 官方 dialect;路徑找不到時註冊 stub 後端並給出清晰報錯

README 註明:Windows 後端在維護者本機無法驗證,屬實驗性能力。

側邊欄「後臺 Shell」

客戶端經 Cordis 注入 sidebarRight / sidebarRightTabs 等槽位,提供「後臺 Shell」面板:

  • 只讀跟隨當前 Agent 會話的 PTY 流(與模型所見一致,經 sanitizer 清洗後的純文本)
  • Remote 命名空間 dshShellsPanel(list / attach stream),按 record.owner.session.id 過濾當前會話終端
  • 約 300ms 輪詢、非破壞式 read()

組合層(cordis.patch.yml)掛載:dsh-terminal + dsh-terminal-bash + @deepseek-ai/dsh-tool-terminal + dsh-shells。

安裝與啓用

包直接發佈 src/ 下 JS,無需構建。安裝命令以 README 爲準:

# 從 GitHub
dsh plugin --profile <profile> add github:liu-zhengdong/dsh-shells

本地開發時可指向 checkout 目錄:

dsh plugin --profile <profile> add /abs/path/to/dsh-shells

依賴包括 @deepseek-ai/dsh-tool-terminal、@deepseek-ai/dsh-terminal、@deepseek-ai/dsh-terminal-bash(均爲 0.2.1-rc.2)以及 @deepseek-ai/schemastery(約 ~3.18.4)。若安裝後報 failed to import,README 建議檢查 @deepseek-ai/schemastery 是否已安裝——在 autoInstallPeers: false 的 profile 裏,若它被聲明爲 peer 可能不會自動安裝。

典型用法(Agent 側)

打開 zsh 會話、發送命令並讀取輸出示例(來自 README):

terminal_open { "type": "zsh", "name": "watcher", "cwd": "/tmp" }
terminal_send { "id": "...", "stdin": "htop\n", "wait": "stdin_read" }
terminal_read { "id": "..." }

將 "type" 換成已註冊的後端(如 cmd、gitbash、pwsh 等,以當前環境實際註冊爲準),id 由 terminal_open 返回後填入後續調用。

適用場景與注意

適合:需要在 DSH Agent 工作流裏使用 zsh 或 Windows 多種 shell、並希望後臺會話持久、同時在 UI 裏對照 PTY 輸出的開發者。

注意:

  1. 插件與 DSH 進程同權限運行;安裝前應自行查看源碼與 MIT 許可證,確認符合你的安全策略。
  2. Windows 後端標註爲實驗性,生產環境使用前應在目標機器上實測。
  3. DSH 生態理念是「一切皆插件」;社區目錄 SkillHub 插件頁 爲獨立站點,與 DeepSeek / 幻方無官方從屬關係。

結尾

dsh-shells 把官方終端工具鏈與多 shell 後端、側邊欄 PTY 監視拼在一起,減少 Agent 跨平臺 shell 場景的膠水代碼。進一步瞭解可訪問 SkillHub 目錄頁 與 GitHub 倉庫。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜