dsh-container-lifecycle: Hosting the Profile Execution Plane in a Digest-Locked Docker Container

前言

在 DeepSeek Harness(DSH)里,智能体的 shell、文件系统与沙箱默认跑在宿主进程侧。若你希望命令与文件操作落在隔离的 Linux 环境里,同时工作区仍能以同路径挂载进会话,就需要把「执行世界」迁到容器里,并自己管镜像、SSH 通道与信任链。社区插件 dsh-container-lifecycle(维护者 FAKE0704,分类 admin-security)做这件事:把一个 Profile 转成由插件端到端拥有的容器执行世界,上游 dsh-ssh 传输包不改、不做代理。

下文按定位、能力、安装、用法与限制说明;事实以 GitHub README 与 SkillHub 目录页 为准。插件标注为 experimental(Stage A),独立社区作品,未经 DeepSeek Harness 官方审阅或背书。

这是什么

dsh-container-lifecycle 是 DSH 社区插件(MIT,0.1.0),engines.dsh 要求运行时 >=0.2.2-rc.2 <0.2.2-rc.3。它让 Profile 的 shell、fs、sandbox 不再在宿主机上直接执行,而是在插件创建并管理的 Docker 容器内运行:镜像按 digest 锁定,容器带标签(sshd、同路径 bind mount、仅回环端口、宿主 uid 映射),helper 注入并做入口 SHA-256 校验,临时 host key 写入插件自有的 known_hosts,并托管 ~/.ssh/config 块,在运行时插入原版 dsh-ssh 连接行。不改动上游接缝,不代理流量。

核心功能

经过上面的定义,插件在资料中写明的能力包括:

  1. 同路径工作区:宿主路径(例如 /Users/you/work)在容器内仍是同一路径,便于工具与路径假设一致。
  2. 重启后可接纳(adopt):容器带标签,宿主机重启后可重新接纳;临时 host key 自动重新锁定。
  3. 拒绝漂移的信任链:拉取或本地构建后按 digest(或本地 image ID)固定镜像;同 tag 下重建的镜像会被拒绝,并给出双 digest 与显式 rebind 路径。helper 入口每次加载重新校验;容器内安装的 closure 与版本严格对齐。
  4. 首次自动构建:若镜像 tag 不存在,插件用自带的 docker/Dockerfile 构建(aptMirror 可配),并锁定结果。
  5. 两个只读为主工具:container-status(镜像/容器/helper/ssh 块等事实)、container-dispose(经审批门控的拆除)。
  6. 会话内验证:README 中的实测显示,bash/fs 在 Debian bookworm 容器内执行,而 pwd 仍可显示宿主风格的挂载路径——这是同路径投影,不是跑在 macOS 宿主机上。

安装与启用

资料给出的已验证路径是无头 CLI(macOS + Docker Desktop;DSH_HOME 默认 ~/.dsh)。先做 Profile 引导,再安装插件。

1 — 引导名为 headless 的 Profile(一次粘贴;声明 bundles、构建姿态与模型接线):

mkdir -p "$DSH_HOME/profiles/headless" && cd "$DSH_HOME/profiles/headless"
cat > package.json <<'EOF'
{
  "name": "dsh-profile-headless",
  "private": true,
  "dependencies": {
    "dsh-container-lifecycle": "github:FAKE0704/dsh-container-lifecycle"
  },
  "dsh": { "profile": { "bundles": [
    "@deepseek-ai/dsh-base",
    "@deepseek-ai/dsh-headless",
    "dsh-container-lifecycle"
  ] } }
}
EOF
cat > pnpm-workspace.yaml <<'EOF'
packages:
  - .

nodeLinker: hoisted
autoInstallPeers: false
allowBuilds:
  node-pty: false
  koffi: false
  "@deepseek-ai/dsh-subprocess-local": false
EOF
cat > cordis.patch.yml <<'EOF'
# Model wiring: bring your own provider. The container world itself needs no
# profile rows — it comes from the plugin's own bundle patch.
- id: agent-default-model
  name: "@deepseek-ai/dsh-agent-default-model"
  config:
    provider: <your-provider>
    model: <your-model>
EOF

allowBuilds: false 是有意为之:原生 helper 模块(node-pty、koffi、dsh-subprocess-local)只在容器内构建,不在宿主机构建,否则 pnpm 11 可能把被阻断的构建脚本当成安装失败。

2 — 安装插件(README 原文命令):

dsh plugin --profile headless add dsh-container-lifecycle

若 git ls-remote 超时或 HTTP/2 异常,可按 README 建议改用 SSH URL 映射或强制 HTTP/1.1;验证记录约为 2¼ 分钟 exit 0。

3 — 在容器世界中跑会话:

cd /your/workspace && dsh --profile headless "uname -a && head -2 /etc/os-release"

首次启动会构建镜像(需可拉取 node:24-bookworm-slim 基础镜像)、创建容器、在容器内安装 helper closure 并写入 ssh 配置块,耗时可到数分钟,仅首次。

配置项

在 Profile 的 cordis.patch.yml 中按 id 覆盖(默认值如下):

- id: dsh-container-lifecycle
  config:
    alias: dsh-container      # container name + ssh Host alias
    image: dsh-container-sshd:a1
    port: 2223                # loopback host port for sshd
    aptMirror: ""             # e.g. mirrors.tuna.tsinghua.edu.cn (first-use build only)
    workspace: ""             # default: process working directory (bind-mounted at the identical path)
    imageRebind: false        # one-shot deliberate re-pin after an intentional rebuild

端口冲突会以具名错误指出对应配置项。 intentional 重建镜像后需将 imageRebind 设为 true 一次以采纳新 digest(容器会重建)。

典型用法与宿主限制

除上文的 uname / os-release 探测外,README 还给出了在 Electron/BoringSSL 无法承载 dsh-ssh 流时的变通:用自带 plain-OpenSSL 的 Node 启动无头 CLI,而非 Desktop 的 Electron 载体:

node /path/to/extracted/dsh/node_modules/@deepseek-ai/dsh-desktop-host/lib/cli.js --profile headless "<task>"

须在真实终端启动(勿在沙箱化的 DSH 会话内启动,否则继承沙箱会导致 ~/.ssh 写入失败)。

当前 README 写明:DSH Desktop 与以其为载体的 CLI 因 Electron BoringSSL 缺少 TLS 1.2 PSK 套件,容器世界会与任何 dsh-ssh 用法一样降级;已验证宿主为 plain-OpenSSL Node 驱动的无头 CLI。上游若补齐套件,Desktop 侧无需改插件即可工作(参见 upstream discussion #9120)。

适用场景与注意

适合:需要在 digest 锁定、可审计的信任链下,让智能体工具在 Debian 容器内执行,同时保持工作区同路径映射;愿意使用 Docker,并接受 Stage A 实验性质与窄版本钉扎(ssh 族 exact 0.2.2-rc.2)。

务必注意:

  • 插件以当前 dsh 进程权限运行,会写 Docker、ssh 配置与 known_hosts;安装前请阅读源码与 MIT 许可证。
  • 社区目录 SkillHub 与 GitHub 为独立信息源,与 DeepSeek / 幻方无官方从属关系。
  • 星标与受众规模资料未作营销表述;仅以 README 测试记录(如 macOS arm64 + Docker Desktop、0.2.2-rc.1 / 0.2.2-rc.2)为据。

结尾

dsh-container-lifecycle 把 Profile 的执行面收拢到插件自管的 digest 锁定容器与未改动的 dsh-ssh 链路上,强调同路径挂载与拒绝镜像/helper 漂移。若你的环境满足无头 CLI + Docker,可按 README 三步引导 Profile、安装插件并首次构建验证。

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

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

Xiaoye