description: "The model-facing pwsh tool for users and maintainers choosing, configuring, or debugging one-shot PowerShell execution, background jobs, and sandbox escalation on Windows."
English | 中文
dsh-tool-pwsh gives the agent a pwsh tool that runs PowerShell commands through the mounted shell executor — the Windows counterpart of dsh-tool-bash, mirroring it call-for-call. Each call runs in a fresh pwsh process, so no state survives; run_in_background turns long-running commands into background jobs. Commands are PowerShell-dialect: native C:\... paths and $env:NAME variables, with no dialect translation. Every call runs with the managed DSH_* environment, and under a sandboxing executor the tool teaches and enforces the Windows-specific language-mode and named-pipe contracts. Mount it with a PowerShell executor such as dsh-pwsh-local and the dsh-shell-env plugin.
Load this plugin in any composition where the agent should run PowerShell commands — typically a Windows composition whose ctx.shell is backed by a PowerShell executor. It registers the pwsh tool once the executor provider and the dsh-shell-env registry are mounted.
Choose the pwsh tool when commands must be written in PowerShell — native paths and $env: variables — or when the deployment is Windows-native. Choose dsh-tool-bash when the command set is bash-dialect; there is no translation between the two. When work needs cross-call state (cwd, variables), the persistent counterpart dsh-tool-pwsh-persistent keeps one owner-scoped shell alive.
The common path is a PowerShell executor provider, the environment registry, and this tool.
- name: '@deepseek-ai/dsh-pwsh-local'
- name: '@deepseek-ai/dsh-shell-env'
- name: '@deepseek-ai/dsh-tool-pwsh'
The single config field toggles background support.
| Field | Default | Meaning |
|---|---|---|
enableRunInBackground |
true |
Expose run_in_background; when false, forced background calls are rejected |
The generated configuration catalog is the exhaustive source for every accepted field and its JSDoc; the generated tool catalog carries the full argument schema.
The tool executes pwsh -Command <command> and returns the combined output. Commands run in a fresh pwsh process every call, so state never persists — pass workdir instead of cd. Paths use native Windows form and environment variables are read with $env:NAME. A non-zero exit is reported as [exit code: N]; on Windows a force-killed command settles as [exit code: 1] without a signal marker, so the agent treats a bare exit 1 after an interruption as a termination, not a command failure. Background runs, output truncation, and the description/timeoutMs/workdir arguments behave exactly as in dsh-tool-bash.
Under a sandboxing executor, denied commands report [sandbox: file access denied under <mode> mode], and the same one-shot escalation path applies: retry the exact command once with sandbox_permissions plus a justification through user approval. The tool also teaches two Windows-restricted-token contracts in its description: read-only pwsh runs in ConstrainedLanguage (.NET static calls, Add-Type, COM, and reflection fail with "only core types" errors), and in both confined modes programs cannot open named pipes, so a command that captures another program's output through piped stdio fails with EPERM — escalate the exact command once or restructure it to avoid capturing output.
A composition with no PowerShell executor never activates the tool, and the injected services (tools, shell, systemPrompt, shellEnv) must all exist. Background calls without the job runtime fail with background jobs unavailable: load @deepseek-ai/dsh-jobs and @deepseek-ai/dsh-tool-jobs, and sandbox_permissions without a sandboxing executor fails with sandbox_permissions is not available in this composition (no sandboxing executor to escalate).
Read these pages when the package-level contract is not enough. They move from the shell family to the executor seam and the design notes behind the Windows behavior.
DSH_* environment every call receives.job_output, job_list, and job_kill controls for background runs.pwsh argument schema.Every request in this plugin's registration scope contains the pwsh guidance below at first-party order 1010. Scoped tool restrictions can hide the schema without removing this independently registered section.
Non-zero exits are reported as `[exit code: N]` markers; investigate failures before moving on. On Windows a killed process settles as `[exit code: 1]` without a signal marker; treat a bare exit 1 after an interruption as a termination, not a command failure.
Small fixed input cost per request while the plugin is active.
Prefix-stable while the registration scope and prompt text are unchanged. Plugin activation or disposal may invalidate reuse from this prompt section.
The model sees the generated pwsh schema. Agent-scoped tool restrictions can remove the definition for that agent.
Fixed schema cost on every request where the tool is visible.
Prefix-stable while visibility and the tool definition are unchanged. A restriction or config change may invalidate reuse from the first changed token.
The renderer emits the data-dependent stdout tail, then optional [stderr] and the stderr tail. Conditional lines are exactly [output truncated; full output: <path-or-(unavailable)>], [sandbox: file access denied under <mode> mode] plus the escalation hint [sandbox: escalation available — …] (only when the composition advertises escalation), [timed out after <timeoutMs>ms], [killed by signal: <signal>], and [exit code: <exitCode>] (nonzero exits only); an empty body renders as (no output).
Zero result tokens before a call. Output is bounded per stream, while each emitted line remains in history until compaction.
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
A background start renders exactly started background job <id>; subsequent reads and status flow through the generic job_output/job_kill tools, including the lossy-read spill notice when in-memory truncation dropped unread bytes.
The ack is a fixed short line; job output is bounded per read.
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
Validation and infrastructure failures are normalized as Error: <message>. This package's stable messages are invalid command: expected a non-empty string, invalid description: expected a non-empty string, invalid timeoutMs: expected a positive number, got <value>, the escalation pairing failures, sandbox_permissions is not available in this composition (no sandboxing executor to escalate), the shared escalation failures (not strictly wider / no approval service / no agent to route / no approval channel / user rejected / was cancelled), run_in_background is disabled for this deployment (enableRunInBackground: false), background jobs unavailable: load @deepseek-ai/dsh-jobs and @deepseek-ai/dsh-tool-jobs, and tool call aborted.
Only the failing call adds these retained tokens; an aborted call adds no command output.
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
These limits define when the tool is a poor fit or needs special care. They are current package constraints, not a task backlog.
Add-Type, non-core .NET statics ([System.IO.*]::, [math]::), COM objects, and reflection fail with "only core types" errors, and the mode cannot be lifted from inside. Workspace-write's private temp lets the probe complete, so it stays in FullLanguage unless host policy says otherwise. Both confined modes deny named-pipe opens, so a piped-stdio spawn inside a confined command fails with EPERM. The tool description teaches both contracts to the model; the backend README owns the full limitations.pwsh -Command; the persistent-shell counterpart is @deepseek-ai/dsh-tool-pwsh-persistent, which keeps one owner-scoped pwsh alive across calls.$env: variables), not bash; there is no dialect translation.