@deepseek-ai/dsh-tool-pwsh 0.1.1-rc.2 → 0.1.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +113 -26
- package/README.zh.md +135 -48
- package/lib/index.js +1 -1
- package/package.json +34 -31
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/shell/tool-pwsh/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: f4de57c2c30df4f0af5d396f7e0ba0a4c2fa37c8
|
|
6
|
+
README.zh.md: ef002f055813e99ab39a655282a8c4b1dd15621d
|
package/README.md
CHANGED
|
@@ -1,52 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
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."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# @deepseek-ai/dsh-tool-pwsh
|
|
2
7
|
|
|
3
8
|
English | [中文](README.zh.md)
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
`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.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Model Experience](#model-experience)
|
|
20
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
21
|
+
- [Dev Note](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## Use this package
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
### When to choose it
|
|
6
31
|
|
|
7
|
-
|
|
32
|
+
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`](../tool-pwsh-persistent/README.md) keeps one owner-scoped shell alive.
|
|
8
33
|
|
|
9
|
-
|
|
34
|
+
### Minimal configuration
|
|
10
35
|
|
|
11
|
-
The
|
|
36
|
+
The common path is a PowerShell executor provider, the environment registry, and this tool.
|
|
12
37
|
|
|
13
|
-
|
|
38
|
+
```yaml
|
|
39
|
+
- name: '@deepseek-ai/dsh-pwsh-local'
|
|
40
|
+
- name: '@deepseek-ai/dsh-shell-env'
|
|
41
|
+
- name: '@deepseek-ai/dsh-tool-pwsh'
|
|
42
|
+
```
|
|
14
43
|
|
|
15
|
-
|
|
44
|
+
The single config field toggles background support.
|
|
16
45
|
|
|
17
|
-
|
|
|
46
|
+
| Field | Default | Meaning |
|
|
18
47
|
|---|---|---|
|
|
19
|
-
| `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
48
|
+
| `enableRunInBackground` | `true` | Expose `run_in_background`; when `false`, forced background calls are rejected |
|
|
49
|
+
|
|
50
|
+
The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-tool-pwsh) is the exhaustive source for every accepted field and its JSDoc; the generated [tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-pwsh) carries the full argument schema.
|
|
51
|
+
|
|
52
|
+
### Running a command
|
|
53
|
+
|
|
54
|
+
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`.
|
|
55
|
+
|
|
56
|
+
### Windows-specific sandbox behavior
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
### What can go wrong
|
|
61
|
+
|
|
62
|
+
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)`.
|
|
26
63
|
|
|
27
|
-
|
|
64
|
+
-----
|
|
28
65
|
|
|
29
|
-
|
|
66
|
+
<a id="understand-the-implementation"></a>
|
|
67
|
+
## Understand the implementation
|
|
30
68
|
|
|
31
|
-
|
|
69
|
+
<details>
|
|
70
|
+
<summary>Implementation internals — click to expand</summary>
|
|
32
71
|
|
|
33
|
-
|
|
72
|
+
This section explains the design decisions behind the tool and points at the code that realizes them; the observable behavior is fully covered in [Use this package](#use-this-package).
|
|
34
73
|
|
|
35
|
-
|
|
74
|
+
### Design philosophy
|
|
36
75
|
|
|
37
|
-
|
|
76
|
+
- **A deliberate twin of `dsh-tool-bash`.** Foreground and background execution, the managed environment, the sandbox escalation surface, and the marker/truncation rendering mirror the bash tool call-for-call, so consumers of one accept the other's wire shape ([pwsh tool and executor Agent Note](../../../.agents/notes/implemented/feature/2026-08-01-pwsh-tool-and-executor.md)).
|
|
77
|
+
- **PowerShell-dialect contract.** The tool contract is PowerShell: native paths and `$env:` variables, executed via `pwsh -Command` with no intermediate shell.
|
|
78
|
+
- **Windows sandbox facts taught in the description.** The ConstrainedLanguage and named-pipe contracts are Windows-restricted-token behavior; the gate for teaching them is "any confining executor is mounted", which is safe because every shipped pairing is win32-only.
|
|
79
|
+
- **Non-zero exits are reported, not errored.** Only infrastructure failures (spawn errors, aborts) surface as tool errors, matching the bash story.
|
|
38
80
|
|
|
39
|
-
|
|
81
|
+
### Source map
|
|
40
82
|
|
|
41
|
-
|
|
83
|
+
| File | Role |
|
|
84
|
+
|---|---|
|
|
85
|
+
| [`src/index.ts`](src/index.ts) | Plugin entry: tool registration, prompt section, arg validation, escalation, request assembly |
|
|
86
|
+
| [`src/background.ts`](src/background.ts) | Map a settled background process onto generic job outcome vocabulary |
|
|
87
|
+
| [`src/render.ts`](src/render.ts) | Model-facing result text: streams, markers, truncation notices (bash twin) |
|
|
88
|
+
| [`src/invariant.ts`](src/invariant.ts) | Invariant companion (no runtime invariant; execution relations are owned by the capability seam) |
|
|
42
89
|
|
|
90
|
+
### Rendering and exit markers
|
|
91
|
+
|
|
92
|
+
The renderer shares the bash tool's structure and the `parseExitStatus` marker contract from `dsh-shell`: a clean exit (0, no signal) produces no marker; the UI card consumes the exit marker as its exit-status pill. Windows forced termination settles as exit 1 without a signal, so `[killed by signal: …]` is POSIX-only there. The `tool:pwsh` prompt section (first-party order 1010) teaches the exit-marker convention and the Windows exit-1-after-interruption reading.
|
|
93
|
+
|
|
94
|
+
</details>
|
|
95
|
+
|
|
96
|
+
-----
|
|
97
|
+
|
|
98
|
+
<a id="further-exploration"></a>
|
|
99
|
+
## Further Exploration
|
|
100
|
+
|
|
101
|
+
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.
|
|
102
|
+
|
|
103
|
+
- [shell package map](../README.md) — the bash capability family and its roles.
|
|
104
|
+
- [Bash executor subsystem](../../../docs/subsystems/shell.md) — request/spec vocabulary, results, and background processes.
|
|
105
|
+
- [shell-env](../shell-env/README.md) — the managed `DSH_*` environment every call receives.
|
|
106
|
+
- [tool-jobs](../../jobs/tool-jobs/README.md) — `job_output`, `job_list`, and `job_kill` controls for background runs.
|
|
107
|
+
- [pwsh tool and executor Agent Note](../../../.agents/notes/implemented/feature/2026-08-01-pwsh-tool-and-executor.md) — why the tool mirrors the bash tool and how the Windows sandbox gates its description.
|
|
108
|
+
- [Windows ACL restricted-token sandbox Agent Note](../../../.agents/notes/implemented/feature/2026-08-08-windows-acl-restricted-token-sandbox.md) — the language-mode and named-pipe contracts.
|
|
109
|
+
- [Generated tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-pwsh) — the exact `pwsh` argument schema.
|
|
110
|
+
- [Generated configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-tool-pwsh) — every accepted config field and its source declaration.
|
|
111
|
+
|
|
112
|
+
-----
|
|
113
|
+
|
|
114
|
+
<a id="model-experience"></a>
|
|
43
115
|
## Model Experience
|
|
44
116
|
|
|
45
117
|
### System prompt
|
|
46
118
|
|
|
47
119
|
#### What the model sees
|
|
48
120
|
|
|
49
|
-
Every request in this plugin's registration scope contains the pwsh guidance below. Scoped tool restrictions can hide the schema without removing this independently registered section.
|
|
121
|
+
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.
|
|
50
122
|
|
|
51
123
|
##### Pwsh guidance
|
|
52
124
|
|
|
@@ -80,7 +152,7 @@ Prefix-stable while visibility and the tool definition are unchanged. A restrict
|
|
|
80
152
|
|
|
81
153
|
#### What the model sees
|
|
82
154
|
|
|
83
|
-
The renderer emits the data-dependent stdout tail, then optional `[stderr]` and the stderr tail. Conditional lines are exactly `[output truncated; full output: <path>]`, `[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)`.
|
|
155
|
+
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)`.
|
|
84
156
|
|
|
85
157
|
#### Token effect
|
|
86
158
|
|
|
@@ -108,7 +180,7 @@ Append-only; newly visible content follows the reusable request prefix and does
|
|
|
108
180
|
|
|
109
181
|
#### What the model sees
|
|
110
182
|
|
|
111
|
-
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>`,
|
|
183
|
+
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`.
|
|
112
184
|
|
|
113
185
|
#### Token effect
|
|
114
186
|
|
|
@@ -120,7 +192,22 @@ Append-only; newly visible content follows the reusable request prefix and does
|
|
|
120
192
|
|
|
121
193
|
## Known Limitations and Deferred Work
|
|
122
194
|
|
|
195
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
These limits define when the tool is a poor fit or needs special care. They are current package constraints, not a task backlog.
|
|
199
|
+
|
|
123
200
|
- **Language mode and named-pipe capture under the Windows sandbox** — under the [Windows ACL sandbox](../../sandbox/sandbox-windows-acl/README.md), read-only pwsh starts in ConstrainedLanguage because its temp write denial makes PowerShell's AppLocker probe fail closed: `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.
|
|
124
|
-
- **No persistent shell** — every call starts a fresh `pwsh -Command`; the persistent-shell counterpart is [`@deepseek-ai/dsh-tool-pwsh-persistent`](../tool-pwsh-persistent/README.md), which keeps one owner-scoped pwsh alive across calls
|
|
201
|
+
- **No persistent shell** — every call starts a fresh `pwsh -Command`; the persistent-shell counterpart is [`@deepseek-ai/dsh-tool-pwsh-persistent`](../tool-pwsh-persistent/README.md), which keeps one owner-scoped pwsh alive across calls.
|
|
125
202
|
- **PowerShell-dialect contract** — the model must write PowerShell (native paths, `$env:` variables), not bash; there is no dialect translation.
|
|
126
203
|
- **Session-cwd identity is not canonicalized** — the workdir base is the session header cwd as-is, unlike the bash tool's sandbox-root-canonicalized identity. Under a confining executor the policy's workspace root IS canonicalized (by the shared policy service), so the workdir and the confinement root can diverge when the raw session cwd differs from its canonical form — a parity gap deferred to the shared shell-tool base extraction.
|
|
204
|
+
|
|
205
|
+
<a id="dev-note"></a>
|
|
206
|
+
### Dev Note
|
|
207
|
+
|
|
208
|
+
<details>
|
|
209
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
210
|
+
|
|
211
|
+
None.
|
|
212
|
+
|
|
213
|
+
</details>
|
package/README.zh.md
CHANGED
|
@@ -1,54 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "面向模型的 pwsh 工具,供选择、配置或排查 Windows 上一次性 PowerShell 执行、后台任务与沙箱升权的使用者与维护者阅读。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# @deepseek-ai/dsh-tool-pwsh
|
|
2
7
|
|
|
3
8
|
[English](README.md) | 中文
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
`dsh-tool-pwsh` 为 agent 提供 `pwsh` 工具,通过已挂载的 shell 执行器运行 PowerShell 命令——它是 `dsh-tool-bash` 的 Windows 对应物,逐调用镜像。每次调用都运行在全新 pwsh 进程中,因此状态不会保留;`run_in_background` 把长时间运行的命令变成后台任务。命令是 PowerShell 方言:原生 `C:\...` 路径与 `$env:NAME` 变量,不做方言翻译。每次调用都运行在受管 `DSH_*` 环境中;在沙箱执行器下,工具会教授并执行 Windows 特有的语言模式与命名管道约定。请与 `dsh-pwsh-local` 等 PowerShell 执行器以及 `dsh-shell-env` 插件一起挂载。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与延期工作](#known-limitations-and-deferred-work)
|
|
21
|
+
- [开发备注](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## 使用本包
|
|
27
|
+
|
|
28
|
+
在 agent 需要运行 PowerShell 命令的任何组合中加载本插件——通常是 `ctx.shell` 由 PowerShell 执行器支撑的 Windows 组合。一旦挂载执行器提供方与 `dsh-shell-env` 注册表,它就注册 `pwsh` 工具。
|
|
29
|
+
|
|
30
|
+
### 何时选择
|
|
6
31
|
|
|
7
|
-
|
|
32
|
+
当命令必须用 PowerShell 编写——原生路径与 `$env:` 变量——或部署是 Windows 原生时,选择 pwsh 工具。当命令集是 bash 方言时选择 `dsh-tool-bash`;两者之间没有翻译。当工作依赖跨调用状态(cwd、变量)时,持久对应物 [`dsh-tool-pwsh-persistent`](../tool-pwsh-persistent/README.zh.md) 会保持一个按所有者隔离的 shell 存活。
|
|
8
33
|
|
|
9
|
-
|
|
34
|
+
### 最小配置
|
|
10
35
|
|
|
11
|
-
|
|
36
|
+
常用路径是 PowerShell 执行器提供方、环境注册表与本工具。
|
|
12
37
|
|
|
13
|
-
|
|
38
|
+
```yaml
|
|
39
|
+
- name: '@deepseek-ai/dsh-pwsh-local'
|
|
40
|
+
- name: '@deepseek-ai/dsh-shell-env'
|
|
41
|
+
- name: '@deepseek-ai/dsh-tool-pwsh'
|
|
42
|
+
```
|
|
14
43
|
|
|
15
|
-
|
|
44
|
+
唯一的配置字段用于开关后台支持。
|
|
16
45
|
|
|
17
|
-
|
|
|
46
|
+
| 字段 | 默认值 | 含义 |
|
|
18
47
|
|---|---|---|
|
|
19
|
-
| `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
48
|
+
| `enableRunInBackground` | `true` | 暴露 `run_in_background`;为 `false` 时拒绝强制后台调用 |
|
|
49
|
+
|
|
50
|
+
生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-tool-pwsh)是每个受支持字段及其 JSDoc 的穷尽式真源;生成的[工具目录](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-pwsh)携带完整参数 schema。
|
|
51
|
+
|
|
52
|
+
### 运行命令
|
|
53
|
+
|
|
54
|
+
工具执行 `pwsh -Command <command>` 并返回合并后的输出。命令每次调用都运行在全新 pwsh 进程中,因此状态从不保留——请传 `workdir` 而不是 `cd`。路径使用原生 Windows 形式,环境变量用 `$env:NAME` 读取。非零退出以 `[exit code: N]` 报告;在 Windows 上,强制终止的命令以 `[exit code: 1]` 结算且没有信号标记,因此 agent 把中断后的裸 exit 1 当作终止而非命令失败。后台运行、输出截断以及 `description`/`timeoutMs`/`workdir` 参数的行为与 `dsh-tool-bash` 完全一致。
|
|
55
|
+
|
|
56
|
+
### Windows 特有的沙箱行为
|
|
57
|
+
|
|
58
|
+
在沙箱执行器下,被拒绝的命令会报告 `[sandbox: file access denied under <mode> mode]`,并适用相同的单次升权路径:用 `sandbox_permissions` 加一句 `justification`,经用户审批后重试完全相同的命令一次。工具还会在其描述中教授两条 Windows 受限令牌约定:只读 pwsh 运行在 ConstrainedLanguage 中(`.NET` 静态调用、`Add-Type`、COM 与反射会以 "only core types" 错误失败);两种受限模式下程序都无法打开命名管道,因此通过管道 stdio 捕获另一程序输出的命令会以 EPERM 失败——请升权该确切命令一次,或重构命令以避免捕获输出。
|
|
59
|
+
|
|
60
|
+
### 可能出什么问题
|
|
61
|
+
|
|
62
|
+
没有 PowerShell 执行器的组合永远不会激活该工具,且注入的服务(`tools`、`shell`、`systemPrompt`、`shellEnv`)必须全部存在。没有任务运行时的后台调用会以 `background jobs unavailable: load @deepseek-ai/dsh-jobs and @deepseek-ai/dsh-tool-jobs` 失败;没有沙箱执行器时的 `sandbox_permissions` 会以 `sandbox_permissions is not available in this composition (no sandboxing executor to escalate)` 失败。
|
|
26
63
|
|
|
27
|
-
|
|
64
|
+
-----
|
|
28
65
|
|
|
29
|
-
|
|
66
|
+
<a id="understand-the-implementation"></a>
|
|
67
|
+
## 理解实现
|
|
30
68
|
|
|
31
|
-
|
|
69
|
+
<details>
|
|
70
|
+
<summary>实现细节——点击展开</summary>
|
|
32
71
|
|
|
33
|
-
|
|
72
|
+
本节解释工具背后的设计决策,并指出实现它们的代码位置;可观察行为已在[使用本包](#use-this-package)中完整说明。
|
|
34
73
|
|
|
35
|
-
|
|
74
|
+
### 设计理念
|
|
36
75
|
|
|
37
|
-
|
|
76
|
+
- **`dsh-tool-bash` 的刻意孪生。** 前台与后台执行、受管环境、沙箱升权面以及标记/截断渲染都逐调用镜像 bash 工具,因此其中之一的消费方也能接受另一个的协议形状([pwsh 工具与执行器 Agent Note](../../../.agents/notes/implemented/feature/2026-08-01-pwsh-tool-and-executor.zh.md))。
|
|
77
|
+
- **PowerShell 方言约定。** 工具约定是 PowerShell:原生路径与 `$env:` 变量,经由 `pwsh -Command` 执行,没有中间 shell。
|
|
78
|
+
- **Windows 沙箱事实写进描述。** ConstrainedLanguage 与命名管道约定是 Windows 受限令牌行为;教授它们的条件是「已挂载任意约束执行器」,之所以安全,是因为每个已发布的配对都是 win32-only。
|
|
79
|
+
- **非零退出只报告、不失败。** 只有基础设施故障(spawn 错误、中止)才会作为工具错误暴露,与 bash 的故事一致。
|
|
38
80
|
|
|
39
|
-
|
|
81
|
+
### 源码地图
|
|
40
82
|
|
|
41
|
-
|
|
83
|
+
| 文件 | 职责 |
|
|
84
|
+
|---|---|
|
|
85
|
+
| [`src/index.ts`](src/index.ts) | 插件入口:工具注册、提示词区段、参数校验、升权、请求组装 |
|
|
86
|
+
| [`src/background.ts`](src/background.ts) | 把已结算的后台进程映射为通用任务结果词汇 |
|
|
87
|
+
| [`src/render.ts`](src/render.ts) | 模型侧结果文本:流、标记、截断通知(bash 孪生) |
|
|
88
|
+
| [`src/invariant.ts`](src/invariant.ts) | 不变式伴生插件(无运行时不变式;执行关系归能力 seam 所有) |
|
|
42
89
|
|
|
90
|
+
### 渲染与退出标记
|
|
91
|
+
|
|
92
|
+
renderer 共享 bash 工具的结构与来自 `dsh-shell` 的 `parseExitStatus` 标记约定:干净退出(0、无信号)不产生标记;UI 卡片把退出标记消费为退出状态 pill。Windows 强制终止以 exit 1 结算且没有信号,因此 `[killed by signal: …]` 在那里只存在于 POSIX。`tool:pwsh` 提示词区段(first-party 顺序 1010)教授退出标记约定与「中断后 exit 1」的 Windows 解读。
|
|
93
|
+
|
|
94
|
+
</details>
|
|
95
|
+
|
|
96
|
+
-----
|
|
97
|
+
|
|
98
|
+
<a id="further-exploration"></a>
|
|
99
|
+
## 进一步探索
|
|
100
|
+
|
|
101
|
+
当包级约定不够用时阅读以下页面。它们从 shell 家族逐步进入执行器 seam,以及 Windows 行为背后的设计笔记。
|
|
102
|
+
|
|
103
|
+
- [shell 包映射](../README.zh.md)——bash 能力家族及其角色。
|
|
104
|
+
- [Bash 执行器子系统](../../../docs/subsystems/shell.zh.md)——请求/spec 词汇、结果与后台进程。
|
|
105
|
+
- [shell-env](../shell-env/README.zh.md)——每次调用都会收到的受管 `DSH_*` 环境。
|
|
106
|
+
- [tool-jobs](../../jobs/tool-jobs/README.zh.md)——后台运行的 `job_output`、`job_list` 与 `job_kill` 控制。
|
|
107
|
+
- [pwsh 工具与执行器 Agent Note](../../../.agents/notes/implemented/feature/2026-08-01-pwsh-tool-and-executor.zh.md)——为什么工具镜像 bash 工具,以及 Windows 沙箱如何门控其描述。
|
|
108
|
+
- [Windows ACL 受限令牌沙箱 Agent Note](../../../.agents/notes/implemented/feature/2026-08-08-windows-acl-restricted-token-sandbox.zh.md)——语言模式与命名管道约定。
|
|
109
|
+
- [生成的工具目录](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-pwsh)——`pwsh` 参数 schema 的确切内容。
|
|
110
|
+
- [生成的配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-tool-pwsh)——每个受支持配置字段及其源声明。
|
|
111
|
+
|
|
112
|
+
-----
|
|
113
|
+
|
|
114
|
+
<a id="model-experience"></a>
|
|
43
115
|
## 模型体验
|
|
44
116
|
|
|
45
117
|
### 系统提示词
|
|
46
118
|
|
|
47
|
-
####
|
|
119
|
+
#### 模型看到什么
|
|
48
120
|
|
|
49
|
-
|
|
121
|
+
该插件注册 scope 中的每次请求都在 first-party 顺序 1010 处包含以下 pwsh 指引。按 scope 限制工具可以隐藏 schema,却不会移除这个独立注册的区段。
|
|
50
122
|
|
|
51
|
-
##### Pwsh
|
|
123
|
+
##### Pwsh 指引
|
|
52
124
|
|
|
53
125
|
```markdown
|
|
54
126
|
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.
|
|
@@ -56,71 +128,86 @@ Non-zero exits are reported as `[exit code: N]` markers; investigate failures be
|
|
|
56
128
|
|
|
57
129
|
#### Token 影响
|
|
58
130
|
|
|
59
|
-
|
|
131
|
+
插件激活期间,每次请求都会产生少量固定的输入 token 开销。
|
|
60
132
|
|
|
61
133
|
#### KV Cache 影响
|
|
62
134
|
|
|
63
|
-
|
|
135
|
+
只要注册 scope 与提示词文本不变,前缀就保持稳定。插件激活或释放可能使从该提示词区段起的复用失效。
|
|
64
136
|
|
|
65
137
|
### 工具 schema
|
|
66
138
|
|
|
67
|
-
####
|
|
139
|
+
#### 模型看到什么
|
|
68
140
|
|
|
69
|
-
|
|
141
|
+
模型会看到生成的 [`pwsh` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-pwsh)。按 agent(智能体)scope 限制工具可以移除该 agent 的定义。
|
|
70
142
|
|
|
71
143
|
#### Token 影响
|
|
72
144
|
|
|
73
|
-
|
|
145
|
+
工具可见的每个请求都会产生固定 schema 开销。
|
|
74
146
|
|
|
75
147
|
#### KV Cache 影响
|
|
76
148
|
|
|
77
|
-
|
|
149
|
+
只要可见性与工具定义不变,前缀就保持稳定。限制或配置变化可能从首个变化的 token 开始使复用失效。
|
|
78
150
|
|
|
79
151
|
### 前台结果
|
|
80
152
|
|
|
81
|
-
####
|
|
153
|
+
#### 模型看到什么
|
|
82
154
|
|
|
83
|
-
|
|
155
|
+
renderer 输出依数据而定的 stdout 尾部,再输出可选的 `[stderr]` 和 stderr 尾部。条件行精确为 `[output truncated; full output: <path-or-(unavailable)>]`、`[sandbox: file access denied under <mode> mode]` 加升权提示 `[sandbox: escalation available — …]`(仅在组合声明升权时)、`[timed out after <timeoutMs>ms]`、`[killed by signal: <signal>]` 与 `[exit code: <exitCode>]`(仅非零退出);空正文渲染为 `(no output)`。
|
|
84
156
|
|
|
85
157
|
#### Token 影响
|
|
86
158
|
|
|
87
|
-
|
|
159
|
+
调用前的结果 token 为零。输出按流设界,而每行已发出的内容在压缩(compaction)前保留于历史。
|
|
88
160
|
|
|
89
161
|
#### KV Cache 影响
|
|
90
162
|
|
|
91
|
-
|
|
163
|
+
仅追加;新可见内容位于可复用请求前缀之后,不会使现有 KV-cache 条目失效。
|
|
92
164
|
|
|
93
165
|
### 后台结果
|
|
94
166
|
|
|
95
|
-
####
|
|
167
|
+
#### 模型看到什么
|
|
96
168
|
|
|
97
|
-
后台启动精确渲染为 `started background job <id
|
|
169
|
+
后台启动精确渲染为 `started background job <id>`;随后的读取与状态经由通用 `job_output`/`job_kill` 工具流转,包括内存截断丢弃未读字节时的有损读取 spill 通知。
|
|
98
170
|
|
|
99
171
|
#### Token 影响
|
|
100
172
|
|
|
101
|
-
|
|
173
|
+
确认是一行固定的短文本;任务输出按每次读取设界。
|
|
102
174
|
|
|
103
175
|
#### KV Cache 影响
|
|
104
176
|
|
|
105
|
-
|
|
177
|
+
仅追加;新可见内容位于可复用请求前缀之后,不会使现有 KV-cache 条目失效。
|
|
106
178
|
|
|
107
179
|
### 工具错误
|
|
108
180
|
|
|
109
|
-
####
|
|
181
|
+
#### 模型看到什么
|
|
110
182
|
|
|
111
|
-
|
|
183
|
+
验证与基础设施失败统一为 `Error: <message>`。本包的稳定消息包括 `invalid command: expected a non-empty string`、`invalid description: expected a non-empty string`、`invalid timeoutMs: expected a positive number, got <value>`、升权配对失败、`sandbox_permissions is not available in this composition (no sandboxing executor to escalate)`、共享升权失败(未严格加宽/无审批服务/无 agent 可路由/无审批通道/用户拒绝/已取消)、`run_in_background is disabled for this deployment (enableRunInBackground: false)`、`background jobs unavailable: load @deepseek-ai/dsh-jobs and @deepseek-ai/dsh-tool-jobs`,以及 `tool call aborted`。
|
|
112
184
|
|
|
113
185
|
#### Token 影响
|
|
114
186
|
|
|
115
|
-
|
|
187
|
+
只有失败调用会增加这些保留 token;被中止的调用不会添加命令输出。
|
|
116
188
|
|
|
117
189
|
#### KV Cache 影响
|
|
118
190
|
|
|
119
|
-
|
|
191
|
+
仅追加;新可见内容位于可复用请求前缀之后,不会使现有 KV-cache 条目失效。
|
|
192
|
+
|
|
193
|
+
## 已知限制与延期工作
|
|
194
|
+
|
|
195
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
这些限制说明工具何时不合适或需要特别小心。它们是当前包约束,不是任务积压。
|
|
199
|
+
|
|
200
|
+
- **Windows 沙箱下的语言模式与命名管道捕获**——在 [Windows ACL 沙箱](../../sandbox/sandbox-windows-acl/README.zh.md)下,只读 pwsh 以 ConstrainedLanguage 启动,因为其临时目录写拒绝让 PowerShell 的 AppLocker 探测失败关闭:`Add-Type`、非核心 .NET 静态调用(`[System.IO.*]::`、`[math]::`)、COM 对象与反射会以 "only core types" 错误失败,且该模式无法从内部解除。workspace-write 的私有临时目录让探测完成,因此除非宿主策略另有规定,它保持 FullLanguage。两种受限模式都拒绝命名管道打开,因此受限命令内部的管道 stdio spawn 会以 EPERM 失败。工具描述把两条约定都教给模型;完整限制以后端 README 为准。
|
|
201
|
+
- **没有持久 shell**——每次调用都启动全新的 `pwsh -Command`;持久 shell 对应物是 [`@deepseek-ai/dsh-tool-pwsh-persistent`](../tool-pwsh-persistent/README.zh.md),它跨调用保持一个按所有者隔离的 pwsh 存活。
|
|
202
|
+
- **PowerShell 方言约定**——模型必须编写 PowerShell(原生路径、`$env:` 变量),而不是 bash;没有方言翻译。
|
|
203
|
+
- **会话 cwd 身份未规范化**——workdir 基准就是会话头部 cwd 原样,不像 bash 工具那样以沙箱根规范化身份为准。在约束执行器下,策略的 workspace root 确实被规范化(由共享策略服务完成),因此当原始会话 cwd 与其规范形式不同时,workdir 与约束根可能分叉——这是推迟到共享 shell 工具基座抽取的对齐差距。
|
|
204
|
+
|
|
205
|
+
<a id="dev-note"></a>
|
|
206
|
+
### 开发备注
|
|
207
|
+
|
|
208
|
+
<details>
|
|
209
|
+
<summary>维护者的工作上下文——点击展开</summary>
|
|
120
210
|
|
|
121
|
-
|
|
211
|
+
无。
|
|
122
212
|
|
|
123
|
-
|
|
124
|
-
- **无持久 shell** — 每次调用都启动全新的 `pwsh -Command`;持久 shell 对应物是 [`@deepseek-ai/dsh-tool-pwsh-persistent`](../tool-pwsh-persistent/README.zh.md),它在 Windows(ConPTY)以及装有 pwsh 的 POSIX 主机上跨调用保持一个 owner 作用域的 pwsh 存活。
|
|
125
|
-
- **PowerShell 方言约定** — 模型必须写 PowerShell(原生路径、`$env:` 变量),而不是 bash;没有方言翻译。
|
|
126
|
-
- **会话 cwd 身份不做规范化** — workdir 基座直接取会话头 cwd 原值,不同于 bash 工具经 sandbox-root 规范化的身份。在隔离执行器下,策略的工作区根**会**被规范化(由共享的策略服务完成),因此当原始会话 cwd 与其规范化形态不同时,workdir 与隔离根可能不一致——这一 parity 差距留待共享 shell 工具基座提取时解决。
|
|
213
|
+
</details>
|
package/lib/index.js
CHANGED
|
@@ -227,7 +227,7 @@ function apply(ctx, config = {}) {
|
|
|
227
227
|
};
|
|
228
228
|
ctx.systemPrompt.section({
|
|
229
229
|
name: "tool:pwsh",
|
|
230
|
-
order:
|
|
230
|
+
order: ctx.systemPrompt.getSectionOrder("TOOL_PWSH"),
|
|
231
231
|
text: "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."
|
|
232
232
|
});
|
|
233
233
|
ctx.tools.register(defineTool({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-tool-pwsh",
|
|
3
3
|
"description": "Model-facing pwsh tool over the bash executor seam",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -32,39 +32,42 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/dsh-agent": "^0.1.
|
|
36
|
-
"@deepseek-ai/dsh-
|
|
37
|
-
"@deepseek-ai/dsh-
|
|
38
|
-
"@deepseek-ai/dsh-
|
|
39
|
-
"@deepseek-ai/dsh-
|
|
40
|
-
"@deepseek-ai/dsh-sandbox": "^0.1.
|
|
41
|
-
"@deepseek-ai/dsh-
|
|
42
|
-
"@deepseek-ai/
|
|
43
|
-
"@deepseek-ai/dsh-
|
|
44
|
-
"@deepseek-ai/dsh-
|
|
45
|
-
"@deepseek-ai/dsh-
|
|
46
|
-
"@deepseek-ai/
|
|
35
|
+
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
|
|
36
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
|
|
37
|
+
"@deepseek-ai/dsh-jobs": "^0.1.2-alpha.2",
|
|
38
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
|
|
39
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.2-alpha.2",
|
|
40
|
+
"@deepseek-ai/dsh-sandbox-policy": "^0.1.2-alpha.2",
|
|
41
|
+
"@deepseek-ai/dsh-shell": "^0.1.2-alpha.2",
|
|
42
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
43
|
+
"@deepseek-ai/dsh-shell-env": "^0.1.2-alpha.2",
|
|
44
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.2-alpha.2",
|
|
45
|
+
"@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
|
|
46
|
+
"@deepseek-ai/dsh-user-approval": "^0.1.2-alpha.2"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
49
|
+
"@deepseek-ai/schemastery": "^3.18.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@deepseek-ai/
|
|
53
|
-
"@deepseek-ai/dsh-
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
56
|
-
"@deepseek-ai/dsh-
|
|
57
|
-
"@deepseek-ai/dsh-
|
|
58
|
-
"@deepseek-ai/dsh-
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/dsh-
|
|
64
|
-
"@deepseek-ai/dsh-
|
|
65
|
-
"@deepseek-ai/dsh-
|
|
66
|
-
"@deepseek-ai/dsh-
|
|
67
|
-
"@deepseek-ai/dsh-
|
|
68
|
-
"@deepseek-ai/
|
|
52
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
53
|
+
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
|
|
54
|
+
"@deepseek-ai/dsh-agent-loop": "^0.1.2-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-app-boot": "^0.1.2-alpha.2",
|
|
56
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
|
|
57
|
+
"@deepseek-ai/dsh-jobs": "^0.1.2-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-jobs-local": "^0.1.2-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
|
|
60
|
+
"@deepseek-ai/dsh-loader-smoke": "^0.1.2-alpha.2",
|
|
61
|
+
"@deepseek-ai/dsh-pwsh-local": "^0.1.2-alpha.2",
|
|
62
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.2-alpha.2",
|
|
63
|
+
"@deepseek-ai/dsh-sandbox-policy": "^0.1.2-alpha.2",
|
|
64
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.2",
|
|
65
|
+
"@deepseek-ai/dsh-shell": "^0.1.2-alpha.2",
|
|
66
|
+
"@deepseek-ai/dsh-shell-env": "^0.1.2-alpha.2",
|
|
67
|
+
"@deepseek-ai/dsh-subprocess-local": "^0.1.2-alpha.2",
|
|
68
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.2-alpha.2",
|
|
69
|
+
"@deepseek-ai/dsh-tool-jobs": "^0.1.2-alpha.2",
|
|
70
|
+
"@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
|
|
71
|
+
"@deepseek-ai/dsh-user-approval": "^0.1.2-alpha.2"
|
|
69
72
|
}
|
|
70
73
|
}
|