前言¶
DeepSeek Harness 在運行任務時,可能會調用文件、子進程、Bash、終端等操作。如果這些操作直接在宿主環境執行,工作目錄、路徑權限和憑據邊界都依賴宿主進程。
dsh-tensorlake-sandbox 提供了一個可選執行層:將 DeepSeek Harness 的文件、子進程、Bash、終端和 LSP 操作移入一個短命 Tensorlake 微型虛擬機中。
這是什麼¶
@tensorlakeai/dsh-sandbox 是 Tensorlake 爲 DeepSeek Harness 提供的沙箱執行插件,許可證爲 MIT。
它作爲可安裝的 dsh bundle 提供,不要求修改 Harness 安裝。啓用後,插件會在 profile 啓動時創建臨時沙箱,並在 dsh 退出時終止沙箱。
核心功能¶
- 將 DeepSeek Harness 的文件、子進程、Bash、終端和 LSP 操作移入一個短命 Tensorlake 微型虛擬機。
- 以 dsh bundle 形式安裝,不需要修改 Harness 安裝。
- 在 profile 啓動時啓動臨時沙箱,在 dsh 退出時終止沙箱。
- 提供三個 Loader 入口:
@tensorlakeai/dsh-sandbox/runtime@tensorlakeai/dsh-sandbox/filesystem@tensorlakeai/dsh-sandbox/subprocess- 驗證配置 cwd 可寫,並在必要時使用受管鏡像的無密碼
sudo創建和交接受保護路徑。 - 不將
TENSORLAKE_API_KEY、DEEPSEEK_API_KEY、其他憑證類環境變量或DSH_*變量複製到沙箱進程。 - 在
danger-full-access模式下保留bash-sandbox,並讓 Harness 的沙箱感知 Bash 執行器直接委派到 Tensorlake subprocess 提供者。
安裝與啓用¶
前置要求:
- Node.js
^22.19.0或>=24.0.0 @deepseek-ai/dsh0.1.0-rc.6或兼容版本- 宿主環境中設置
TENSORLAKE_API_KEY - 宿主環境中設置
DEEPSEEK_API_KEY
憑據應保存在環境變量或 secret manager 中,不要提交到 profile 或倉庫。
先安裝 dsh,再把插件加入要運行的 profile:
npm install --global @deepseek-ai/dsh
dsh plugin --profile headless add @tensorlakeai/dsh-sandbox
安裝完成後,可以用 headless 方式啓動一個任務:
TENSORLAKE_API_KEY=... DEEPSEEK_API_KEY=... dsh --profile headless "build and test this repo"
如果是在本地開發目錄中安裝,先在插件目錄裏完成構建,再添加本地包:
npm install
npm run build
dsh plugin --profile headless add .
典型用法¶
普通任務示例:
TENSORLAKE_API_KEY=... DEEPSEEK_API_KEY=... dsh --profile headless "build and test this repo"
如果希望顯式指定工作目錄,可以傳入 DSH_TENSORLAKE_CWD:
DSH_TENSORLAKE_CWD=/workspace/project dsh --profile headless "build and test this repo"
下面這個示例會同時觸發 Bash、文件創建、文件讀取和結果彙報:
dsh --profile headless \
"Use Bash to run pwd and id. Create smoke-test.txt containing hello, read it back, and report the results."
配置¶
runtime 可接受的配置字段包括:
apiKeycwdtimeoutSecscpusmemoryMbdiskMb
其中 cwd 默認值爲 /home/tl-user/workspace。
如果要修改工作目錄,可以先通過環境變量方式傳入:
DSH_TENSORLAKE_CWD=/workspace/project dsh --profile headless "build and test this repo"
如果直接在 profile 的 cordis.patch.yml 中修改配置,需要注意 patch 會替換完整配置,需要重寫所有需要的非默認字段。
運行時要求¶
Tensorlake 鏡像需要提供:
bash- Node.js
- GNU
base64 catchmodenvfindgreplnmkdirmktempmvpsrealpathrmstattee
受管 Ubuntu 鏡像會提供這些工具。runtime 會驗證配置的 cwd 是否可寫,並在必要時使用受管鏡像的無密碼 sudo 創建和交接受保護路徑。
適用場景與注意¶
適合在宿主環境已有 Tensorlake 項目、且需要把 DeepSeek Harness 的文件、子進程、Bash 和終端操作移入獨立沙箱的場景。
使用前注意:
- 插件通過 dsh profile 加載,宿主進程仍負責啓動插件和提供必要憑據;插件以當前 dsh 進程的權限上下文運行,安裝前應檢查源碼、許可證和依賴。
TENSORLAKE_API_KEY、DEEPSEEK_API_KEY等憑據應保存在環境變量或 secret manager 中,不要提交到 profile 或倉庫。- 沙箱鏡像必須提供前文列出的
bash、Node.js 和 GNU 工具。 - 已知限制:
tensorlake@0.5.103鎖定undici@8.3.0和nanoid@3.3.11,npm audit --omit=dev會報告高嚴重度通告。用於生產前,應審查這些上游通告。 - LSP 操作也會移入沙箱,但本文不展開其具體能力邊界,建議結合實際任務驗證。
參考¶
- GitHub:https://github.com/tensorlakeai/dsh-tensorlake-sandbox
- 插件目錄頁:https://www.skillhub.cn/plugins/tensorlakeai/dsh-tensorlake-sandbox