前言¶
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