Files
deepseek-harness/packages/bash/bash
imccyu ec601ca13d build(vendor): rescope the vendored Cordis packages into @deepseek-ai
Machine-produced by `pnpm run rescope-vendor --apply` plus the regeneration it
prints: `pnpm install` for the lockfile, `pnpm run gen-third-party-notices`,
`verify-translation-pairing --write` for the touched bilingual pairs,
`gen-doc-graphs`, and one typert snapshot whose ids embed character offsets.
`pnpm run rescope-vendor --check` verifies the result.

Renames nine vendored packages (cordis, cosmokit, schemastery and the six
@cordisjs plugins) and every reference that resolves them: manifest names and
dependency keys, module specifiers including declare-module merges, cordis.yml
plugin names, tsconfig paths, every Markdown fence, and `docs/` prose.
Directory names, upstream versions, and dependency ranges are unchanged, so
vendor/README.md still reads as an upstream snapshot; its manifest table gains
an upstream-name column so THIRD_PARTY_NOTICES keeps MIT attribution pointed
at each fork's origin.

The tutorial tier follows the rename end to end: its yaml fences named plugins
the Loader can no longer resolve, its `ts ignore-check` fences disagreed with
the compiled fences beside them, and its prose quoted both. The contracts that
told readers to keep upstream names — the root convention and the vendoring
cookbook's tree comment and manifest invariant — now say to rescope instead.

Two rules read `@deepseek-ai/` as "another workspace plugin": the client bundle
purity gate now names the vendored libraries a browser bundle inlines, and the
files where a bare `cordis` is an agent-preset id keep that product data.
2026-08-10 22:04:13 +08:00
..

@deepseek-ai/dsh-bash

English | 中文

The BashExecutor (ctx.bash) defines WHAT a bash backend does — run foreground commands and start background processes — without saying HOW. Task ids, ownership, collection, cancellation, and notices belong to the generic ctx.tasks runtime.

This package owns the Service Definition role of the bash capability, split so each role can evolve (and be swapped) independently:

Package Role
@deepseek-ai/dsh-bash (this) Service Definition: abstract service + vocabulary types
@deepseek-ai/dsh-bash-local Service provider: local subprocesses
@deepseek-ai/dsh-bash-sandbox Service provider: dsh-bash-local's mechanics with every spawn confined via ctx.sandbox, denials reported as result facts
@deepseek-ai/dsh-tool-bash the model-facing tool schemas over ctx.bash

The split is a standard capability seam (capability-seams Agent Note): dsh-bash-sandbox is a sandboxing executor behind the same Service Definition — the Consumer detects its sandboxMode capability and adds escalation fields without importing the provider — and a containerized or remote executor slots in the same way.

Service API (ctx.bash)

Member Semantics
run(spec) Foreground execution. Resolves when the command finishes. Rejects only for infrastructure failures (unusable workdir, missing shell, pre-aborted signal); nonzero exits, timeout kills, and abort kills resolve with a descriptive BashRunResult.
start(spec) Background execution. Returns a task-free BashProcess handle immediately; no timeout applies. The caller may adapt it into ctx.tasks.
sandboxMode The capability fact for the tool layer: the default mode a SANDBOXING executor confines under (undefined in the base class — "this executor does not sandbox"). dsh-tool-bash reads it at registration to advertise the escalation fields only when the composition honors them.
BashProcess.readOutput() Incremental output read — consecutive reads never re-deliver. Reads that lost data to buffer bounds flag lossy and point at full-stream spill files.
BashProcess.kill() Kill the process group. Returns false when it already finished.

Implementations subclass BashExecutor and implement the abstract methods. Disposal must kill every running process and await its exit.

Vocabulary

BashExecRequest (command, workdir?, timeoutMs?, stdoutMaxBytes?, signal?, stdin?, env?, dshEnv?, sandboxPolicy?) resolves to BashExecSpec (command, workdir, timeoutMs, stdoutMaxBytes, signal?, stdin?, env?, dshEnv?, sandboxPolicy) before execution. stdoutMaxBytes is a trusted foreground-run capture budget for consumers that must parse complete bounded stdout; the model-facing bash tool does not expose it. sandboxPolicy is optional on the request and required-but-nullable on the resolved spec: it carries the complete per-call mode and workspace root. The sandbox tool path resolves it from the calling session through ctx.sandboxPolicy; a direct sandbox-executor caller falls back to deployment policy, while a non-sandboxing executor carries the field and confines nothing.

The per-session sandbox-mode override vocabulary (the 'sandbox/mode' event, the effectiveSandboxMode(events) fold, and the setSandboxMode(session, mode) write path) is NOT here — it is policy state shared by every enforcing family, owned by @deepseek-ai/dsh-sandbox-policy. run() returns BashRunResult; start() returns BashProcess, whose incremental read and kill methods are adapted by dsh-tool-bash into a generic task registration. A sandboxing executor stamps BashSandboxInfo on foreground results and settled process handles. See src/types.ts and subsystems/bash.md.

stdin and ordinary env are set by in-process plugins (the hooks bridges, native plugins) to feed a hook command its JSON payload and CLAUDE_PROJECT_DIR/CLAUDE_PLUGIN_ROOT values. dshEnv is a separate trusted overlay restricted by type to managed keys; the exported DSH_ENV_PREFIX is the single source for that namespace, its DshEnvironmentKey template type, executor scrubbing, registry validation, derived built-in names, and model guidance. Model bash uses the current snapshot collected by ctx.bashEnv. Implementations remove inherited managed keys, then merge dshEnv after ordinary env, so an omitted current fact cannot fall back to stale ambient state and an env entry cannot displace a managed value. The model-facing tool exposes none of these as parameters. All three remain optional on the resolved spec; absent means no input/overlay. See the bash-stdin-env Agent Note and the session environment Agent Note.

The exported parseExitStatus (with ParsedExitStatus) is the shared rendering contract half of the shell tools: the inverse of the [exit code: N] / [killed by signal: X] markers dsh-tool-bash's renderResult and dsh-tool-pwsh's renderPwshResult append. Both tools' presentResult use it to split the rendered text into the terminal card's output body and its exit-status pill; it lives with the Service Definition so the two tools never drift on the marker contract.

Model Experience

Indirectly, through dsh-tool-bash, which turns executor output and sandbox facts into guidance and retained tool-result tokens.

KV Cache effect

No direct invalidation; the named consumer owns any request-prefix changes.

Known Limitations and Deferred Work

  • No interactive-input vocabularystdin is written once at spawn and closed; the seam has no channel to feed a running task and no PTY session concept.
  • Foreground timeouts are always executor-owned — a caller-owned-deadline mode on the seam is explicitly deferred by the tool-call timeout-policy Agent Note.