TokenLedger
zh667
Relay-site attributed token usage for DeepSeek Harness — zero config, no credentials
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:kaixinyujue/dsh-shell-wsl
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English · 中文
A real-Linux bash execution environment for DeepSeek Harness (dsh) on Windows: every bash tool call is routed into a disposable Docker container (Docker Desktop / WSL2 backend), with the workspace bind-mounted for two-way file sharing and automatic integration with the official permission presets.
docker run --rm --name dsh-exec-<pid>-<seq> -i
-v <session workspace>:/workspace[:ro] -w /workspace/<rel> -e ... ubuntu:24.04 bash -c <command>
The model keeps using the official bash tool (no new tools, no tool-layer changes); commands genuinely run in a container on the WSL2 Linux kernel. The executor declares the official sandboxMode capability bit (workspace-write), so permission presets (read-only / workspace-write / danger-full-access) integrate automatically — read-only sessions mount the workspace :ro, everything else mounts read-write.
See the design document: dsh-shell-wsl-design.md (checked line-by-line against the @deepseek-ai/dsh 0.1.0-rc.6 source contracts).
On Windows, dsh exposes only pwsh by default (the official tool-bash is disabled on win32). The common community approaches to getting bash back each come with trade-offs:
| dsh-shell-wsl (this plugin) | Git Bash (MSYS2) approaches | WSL distro-direct approaches | |
|---|---|---|---|
| Runtime | Real Linux: WSL2 kernel + Ubuntu 24.04 userspace | MSYS2 emulation layer, not Linux | Real Linux, but tied to a specific installed distro |
| Isolation | Disposable container, destroyed via --rm after every call |
No container isolation; runs as a host process | Distro lives forever; state accumulates across sessions |
| Permission-preset linkage | Native: read-only automatically mounts :ro |
Most implementations require danger-full-access, or fail to start inside the sandbox | Common implementations let bash bypass the DSH file policy |
| Prerequisite | Docker Desktop only | Git for Windows | WSL2 + at least one distro |
| State & reproducibility | Stateless; every call starts from a pinned image | Stateless | Stateful; easy to pollute with earlier commands |
The trade-off: one container cold start per command buys you real Linux, isolation, and permission linkage. If you want a zero-dependency, millisecond-start POSIX-ish environment, a Git Bash approach fits better. If you want a stateful Linux environment deeply tied to your distro, a WSL-direct approach fits better. If you want a clean, reproducible, permission-constrained real-Linux execution environment inside a Windows session, this plugin is exactly that.
cd, variables, or apt installsbash tool; nothing new to learndocker CLI available on Windows:docker version # both client and server sections must print
docker context show # desktop-linux
docker pull ubuntu:24.04
docker run --rm -v E:\your\workspace:/workspace -w /workspace ubuntu:24.04 bash -c "uname -a && pwd && ls"
Expected: Linux ... microsoft-standard-WSL2, /workspace, and ls showing your Windows-side files.
wsl transport (the default docker-cli transport needs none):
in that case also run wsl --install -d Ubuntu and enable WSL integration for that distro in Docker Desktop.Note: run the commands above in your own terminal. An agent's tool sandbox may block
docker/WSL probing (E_ACCESSDENIED / named pipes); the plugin itself runs in the host process and is not affected.
dsh plugin --profile web add dsh-shell-wsl
This adds the package to ~/.dsh/profiles/web/package.json and writes dsh.profile.bundles;
the dsh.bundle.patch bundle metadata brings cordis.patch.yml into the patch stack
(layer order: bundle layer → profile layer → $DSH_HOME/cordis.patch.yml → --patch layer).
The patch does two things: inserts the shell-wsl row (auto-disabled outside win32, stays
portable), and sets the host pwsh-sandbox row disabled: true (ctx.shell can only have
one provider — duplicate service registration fails loud).
Git-hosted plugins need the prepare script allowed in the profile's pnpm-workspace.yaml
under allowBuilds, per pnpm's prompt.
Under the web surface the host tool rows are disabled by dsh-web-app and tools come from agent presets, so enable the preset after installing the plugin:
powershell -ExecutionPolicy Bypass -File <plugin dir>\scripts\install-preset.ps1 -SetDefault
Or manually: copy presets/wsl-container/ to ~/.dsh/.agent-presets/wsl-container/ and switch
the default preset to WSL 容器模式 on the Web settings page. The preset changes exactly two
rows relative to standard: tool-bash → disabled: false and tool-pwsh → disabled: true
(the latter is mandatory — tool-pwsh also consumes ctx.shell, and leaving it enabled would
run PowerShell command strings through the container executor, which makes no sense).
For tui/headless, the agent plane lives in the host (base patch: tool-bash disabled on win32,
tool-pwsh enabled). Flip the rows in the profile patch (not the bundle patch — under web
that would double-register the bash tool name against the preset):
# ~/.dsh/profiles/<profile>/cordis.patch.yml
- id: tool-bash
disabled: false
- id: tool-pwsh
disabled: true
| Field | Default | Description |
|---|---|---|
transport |
docker-cli |
docker-cli (Windows-side CLI) or wsl (wsl.exe -d <distro> -- docker) |
distro |
Ubuntu |
Used only by the wsl transport |
image |
ubuntu:24.04 |
Must include bash (alpine/busybox don't — that surfaces as a runner failure) |
workspaceMount |
/workspace |
Mount point inside the container |
workspaceRoot |
none (fallback) | Fixed workspace root; normally the per-call policy's workspaceRoot is used |
containerPrefix |
dsh-exec |
Container name prefix: <prefix>-<pid>-<seq>, ≤63 chars |
# Example: switch images (rewrite the row config in the profile patch — patch replaces the
# whole row config, so restate every field)
- id: shell-wsl
config:
transport: docker-cli
image: debian:bookworm-slim
# ~/.dsh/settings.yaml
bash:
timeoutMs: 120000
maxTimeoutMs: 600000
maxOutputBytes: 64000
maxSpillBytes: 67108864
graceMs: 3000
Environment identity fields (transport/image/…) must not go into settings.yaml — the base
constructor registers the bash settings namespace with the base schema, and unknown keys are
rejected by the schema.
--rm is trusted; no additional docker command is spawned.taskkill /T /F on the Windows
side, then a best-effort docker rm -f <name> is appended; the lazy reaper is armed.docker ps -a prefix scan force-removes
every leftover container not in the live-handle table. The reaper never runs during normal operation.WslContainerUnavailableError (isError, the model stops
retrying); a command's own nonzero exit stays an ordinary [exit code: N].:ro; writing /workspace inside the container is an ordinary EROFS-class
command error. workspace-write / danger-full-access: both mount read-write (a container
executor cannot grant host-wide access, so danger-full-access is equivalent to workspace-write)./workspace/<rel> by case-insensitive prefix match
against the workspace root; container paths already under /workspace pass through; paths
outside the workspace fall back to /workspace with a one-line stderr warning (non-blocking).ENV_OVERRIDES (NO_COLOR/TERM/PAGER/GITPAGER) + spec.env + spec.dshEnv materialize as
-e KEY=VALUE (passed as argv parameters, no quoting issues), and LANG=C.UTF-8 is forced.
Under the wsl transport, Windows paths in `DSH*are translated to/mnt/docker run -i keeps stdin open, so hooks' stdin data channel works.[exit code: N] marker contract
are all inherited from LocalBashExecutor / ctx.subprocess — zero reimplementation.cd and variables don't survive across calls).
If you need a persistent shell / PTY, extend via the official terminal capability family —
this plugin deliberately keeps the one-shot semantics.docker pull (see §1).rm -rf inside the mount is not blocked by ACL: the container can only see the mounted
volume and has no write access to the system drive — the same risk surface as workspace-write mode.docker / wsl.exe inside the container, on purpose: do Docker/WSL troubleshooting
in the user's own terminal (probing from inside the agent sandbox is unreliable too).LANG=C.UTF-8; rendering is normal.This plugin has completed a full acceptance round: the runtime chain (tool table / real Linux / mount / workdir mapping / two-way file sharing / background jobs / timeout / no orphan containers / read-only mount enforcement / file-tool regression) and the unit + integration test suites all pass. The checklist below is kept for re-verification and regression runs.
bash tool appears; uname -s → Linux.workdir set to E:\…\sub, pwd inside the container → /workspace/sub; files are visible in both directions.run_in_background + job_output / job_kill work end-to-end.docker ps -a --filter name=dsh-exec- is empty; also empty after normal runs.wsl-container preset there is only bash, no pwsh.npm test is fully green (6 test files, 49 cases); $env:DSH_WSL_INTEGRATION="1"; npm run test:integration is fully green (9 cases, requires Docker Desktop running).# One-time environment prep: junction the deps to the local DSH install's node_modules
# (avoids installing peer dependencies)
New-Item -ItemType Directory -Force node_modules | Out-Null
cmd /c mklink /J node_modules\@deepseek-ai "$env:APPDATA\npm\node_modules\@deepseek-ai\dsh\node_modules\@deepseek-ai"
cmd /c mklink /J node_modules\@types "$env:APPDATA\npm\node_modules\@deepseek-ai\dsh\node_modules\@types"
# TypeScript lives outside the plugin dir (npm reify ELOOPs on junctioned node_modules)
npm install --prefix ..\.dsh-dev-tools --no-save --no-package-lock typescript
npm run build # tsc → lib/
npm test # unit tests (pure functions + executor tests with a fake subprocess)
$env:DSH_WSL_INTEGRATION = "1"
npm run test:integration # real-docker integration tests (requires Docker Desktop running)
Layout: src/ (pure functions: paths/env/naming/classify/argv + the executor index) → compiled to
lib/; tests/ (unit + optional integration); cordis.patch.yml (bundle patch layer);
presets/wsl-container/ (web preset); scripts/install-preset.ps1.
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: docker。