@deepseek-ai/dsh-tool-pwsh-persistent 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 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-persistent/README.md
5
- README.md: a57c940801606c2eef450f0e54fecb434c62a406
6
- README.zh.md: 75f6babfaffc79120f96441bdd5e08895b8e452f
5
+ README.md: 74bc23bcb583bb65cc4921d9ba01bb8796809dc8
6
+ README.zh.md: f5e170a2d58fd7eac0d7330764ae1ba61450b4b1
package/README.md CHANGED
@@ -1,18 +1,113 @@
1
+ ---
2
+ description: "The model-facing persistent pwsh tool for users and maintainers choosing, configuring, or debugging owner-scoped PowerShell state that survives across calls."
3
+ kind: "package-reference"
4
+ ---
5
+
1
6
  # @deepseek-ai/dsh-tool-pwsh-persistent
2
7
 
3
8
  English | [中文](README.zh.md)
4
9
 
5
- Model-facing `pwsh(command)` backed by one owner-scoped `ctx.terminals` shell. The package owns the tool contract and shell reuse; deployments select the terminal backend (a `terminal-bash` instance configured with `shellDialect: pwsh`) and sandbox policy. It is the Windows counterpart of `tool-bash-persistent`: same persistent-state contract, PowerShell dialect.
10
+ ## Summary
11
+
12
+ `dsh-tool-pwsh-persistent` gives the agent a `pwsh` tool whose PowerShell state persists across calls for the owning agent: cwd, `$env:` variables, functions, and background jobs survive between commands. It is the Windows counterpart of `dsh-tool-bash-persistent` — the same persistent-state contract in PowerShell dialect. Each agent gets its own shell backed by an owner-scoped PTY session with a pwsh-dialect backend, and commands for the same agent run one at a time. Configuration selects the backend and the wall-clock limit for one command; a timeout or an explicit `exit` closes the shell, and the next call starts fresh. Mount it with a pwsh-dialect terminal backend (Windows ConPTY or a POSIX pwsh) and the `ctx.terminals` service.
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 keep PowerShell state between commands — the persistent counterpart of `dsh-tool-pwsh` for work that needs cross-call state. It registers the `pwsh` tool and requires the `ctx.tools` and `ctx.terminals` services plus an owning agent session at execution time.
29
+
30
+ ### When to choose it
31
+
32
+ Choose the persistent tool when work depends on cross-call PowerShell state, and choose `dsh-tool-pwsh` when every command should start from a known, clean environment. Commands that need interactive stdin are unsupported here — a foreground child that reads input blocks until the command timeout, which resets the shell — so interactive work belongs to the terminal tools.
33
+
34
+ ### Minimal configuration
35
+
36
+ The default `shell` backend starts a PowerShell shell through a `dsh-terminal-bash` instance configured with `shellDialect: pwsh`; deployments may register another pwsh-dialect PTY backend and select it by name.
37
+
38
+ ```yaml
39
+ - name: '@deepseek-ai/dsh-terminal'
40
+ - name: '@deepseek-ai/dsh-terminal-bash'
41
+ config:
42
+ shellDialect: pwsh
43
+ - name: '@deepseek-ai/dsh-tool-pwsh-persistent'
44
+ ```
45
+
46
+ | Field | Default | Meaning |
47
+ |---|---|---|
48
+ | `backendType` | `shell` | Registered PTY backend used for each agent's shell |
49
+ | `timeoutMs` | `300,000` | Wall-clock limit for one command; timeout closes the shell |
50
+ | `maxOutputChars` | `16,000` | Maximum retained command-output characters; fixed diagnostics are added afterward |
51
+ | `description` | `Run commands in a persistent PowerShell shell. State, including the current directory and exported environment variables, persists across calls for this agent.` | Model-facing environment contract; deployments may describe their environment |
52
+
53
+ The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-tool-pwsh-persistent) is the exhaustive source for every accepted field and its JSDoc.
54
+
55
+ ### What the agent can rely on
56
+
57
+ Commands share one shell per agent, so cwd, `$env:` variables, functions, and background jobs persist across calls. Results exclude the private completion markers, the shell prompt, and the echoed input line. A non-zero wrapped command appends `[exit code: N]` — the exact native exit code when the command ran a native program, `1` for a terminating PowerShell error. A shell that exits before reporting that status instead appends `[shell exited: code N]`, `[shell killed by signal: SIG]`, or `[shell exited]` (Windows forced termination reports exit 1 without a signal), then resets and tells the agent the next call starts fresh. Long output keeps the earliest retained prefix plus a clipping notice; if the terminal has already dropped that prefix, the result says so explicitly.
58
+
59
+ ### What can go wrong
60
+
61
+ A call without an owning agent session fails with `pwsh requires an owning agent session`, and a composition without a pwsh-dialect PTY backend activates the tool but fails its first call with `no PTY backend registered for "shell"`. A model redefinition of the `prompt` function removes the readiness marker, and the shell then settles on the silence tier instead of the marker fast path. Raw ESC characters inside a command are consumed by PSReadLine before execution and are unsupported. A timeout or cancellation closes the uncertain shell, discards the result, and reports the reset.
62
+
63
+ -----
64
+
65
+ <a id="understand-the-implementation"></a>
66
+ ## Understand the implementation
6
67
 
7
- ## Config
68
+ <details>
69
+ <summary>Implementation internals — click to expand</summary>
8
70
 
9
- | Key | Default | Meaning |
10
- |---|---:|---|
11
- | `backendType` | `shell` | Registered terminal backend used for each Agent shell. |
12
- | `timeoutMs` | `300000` | Wall-clock limit for one command; timeout closes the shell. |
13
- | `maxOutputChars` | `16000` | Maximum retained command-output characters; fixed diagnostics are added afterward. |
14
- | `description` | Persistent-shell description | Model-facing environment contract. |
71
+ 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).
15
72
 
73
+ ### Design philosophy
74
+
75
+ - **A deliberate twin of `dsh-tool-bash-persistent`.** The session registry, polling loop, and reset contract mirror the persistent bash tool by design ([pwsh persistent PTY Agent Note](../../../.agents/notes/implemented/architecture/2026-08-11-pwsh-persistent-pty.md)).
76
+ - **Prompt-function readiness.** The tool installs its own `prompt` function that prints a BEL-terminated OSC marker plus a printable prompt; the OSC marker carries the last exit code and the printable prompt settles every command, so a model redefinition of `prompt` degrades readiness to the silence tier.
77
+ - **PSReadLine echo stripped by anchoring.** PowerShell renders submitted input back into the stream; the marker-anchored extraction and a wrapper-source strip remove the echo, and a wrapper that wraps across the terminal width may leave a partial echo in partial-output results.
78
+ - **Reset, never repair.** Any uncertain state — an explicit `exit`, a timeout, a send failure, an abort — closes the shell and starts the next call fresh.
79
+
80
+ ### Source map
81
+
82
+ | File | Role |
83
+ |---|---|
84
+ | [`src/index.ts`](src/index.ts) | Plugin entry: shell registry, prompt setup, command wrapping, scrollback polling, extraction and rendering |
85
+ | [`src/invariant.ts`](src/invariant.ts) | Invariant companion (no runtime invariant; shell reuse is observable through tool execution) |
86
+
87
+ ### Command flow
88
+
89
+ A first command spawns the shell through `ctx.terminals.spawn`, installs the `prompt` override, and waits for readiness. Each command is wrapped into one physical line — `Write-Output` of the start marker, the body escaped with backtick escapes into a double-quoted string, and `Write-Output` of the end marker plus the exit status — so PSReadLine's echo of a wrapped line cannot fabricate completion. The tool polls the scrollback in 1,000-line pages until the end marker or a completed prompt appears, extracts the span, strips the echoed wrapper and prompts, and renders it with any status marker. A timeout aborts the deadline, captures the partial output, and resets the shell.
90
+
91
+ </details>
92
+
93
+ -----
94
+
95
+ <a id="further-exploration"></a>
96
+ ## Further Exploration
97
+
98
+ Read these pages when the package-level contract is not enough. They move from the terminal family to the seam, the backends, and the design notes behind the persistent-shell design.
99
+
100
+ - [terminal package map](../../terminal/README.md) — the persistent PTY capability family.
101
+ - [terminal seam](../../terminal/terminal/README.md) — the `ctx.terminals` service behind the tool.
102
+ - [terminal-bash backend](../../terminal/terminal-bash/README.md) — the default backend, configured with `shellDialect: pwsh`.
103
+ - [pwsh persistent PTY Agent Note](../../../.agents/notes/implemented/architecture/2026-08-11-pwsh-persistent-pty.md) — the pwsh-side session design and its rationale.
104
+ - [Persistent PTY sessions Agent Note](../../../.agents/notes/implemented/feature/2026-07-16-persistent-pty-sessions.md) — the owner-scoped session design and its rationale.
105
+ - [Generated tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-pwsh-persistent) — the exact `pwsh` argument schema.
106
+ - [Generated configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-tool-pwsh-persistent) — every accepted config field and its source declaration.
107
+
108
+ -----
109
+
110
+ <a id="model-experience"></a>
16
111
  ## Model Experience
17
112
 
18
113
  ### Tool schema
@@ -45,11 +140,26 @@ Append-only tool results follow the reusable request prefix.
45
140
 
46
141
  ## Known Limitations and Deferred Work
47
142
 
48
- - The tool requires an owning Agent and a real terminal backend with a pwsh dialect (Windows ConPTY or a POSIX pwsh).
49
- - **Input echo is unavoidable**: PowerShell's PSReadLine renders submitted input back into the terminal stream, and there is no `stty -echo` equivalent. The marker-anchored extraction excludes the echo in complete results; the wrapper-source strip covers fallback paths, but a wrapper that wraps across the terminal width may leave a partial echo in partial-output results, bounded by `maxOutputChars`.
50
- - Raw ESC characters inside model commands are unsupported: PSReadLine consumes them before execution. The wrapper escapes the control bytes it needs (`[char]27`-built OSC markers, backtick escapes for the body).
51
- - A model redefinition of the `prompt` function removes the readiness marker; the shell then settles on the silence tier instead of the marker fast path.
52
- - There is no interactive stdin during a command: a foreground command that reads input blocks until the readiness timeout, which resets the shell.
53
- - SIGTSTP/SIGHUP are unavailable on Windows (backend-rejected); SIGINT is delivered as a console-wide Ctrl-C input write, which at a prompt cancels the pending line instead of signalling a process.
54
- - Under the Windows ACL sandbox's read-only mode, pwsh starts in ConstrainedLanguage, which may deny the bootstrap's `[Console]::` encoding pin and prompt marker. Commands can still settle through the printable prompt and silence tier, but non-ASCII output may follow the host code page.
55
- - The BEL-terminated OSC marker remains a readiness signal only; a BEL event channel to the model stays deferred, aligned with the current implementation.
143
+ <a id="known-limitations-and-deferred-work"></a>
144
+
145
+
146
+ These limits define when the tool is a poor fit or needs special care. They are current package constraints, not a task backlog.
147
+
148
+ - **The tool requires an owning Agent and a real terminal backend with a pwsh dialect** Windows ConPTY or a POSIX pwsh.
149
+ - **Input echo is unavoidable** — PowerShell's PSReadLine renders submitted input back into the terminal stream, and there is no `stty -echo` equivalent. The marker-anchored extraction excludes the echo in complete results; the wrapper-source strip covers fallback paths, but a wrapper that wraps across the terminal width may leave a partial echo in partial-output results, bounded by `maxOutputChars`.
150
+ - **Raw ESC characters inside model commands are unsupported** PSReadLine consumes them before execution. The wrapper escapes the control bytes it needs (`[char]27`-built OSC markers, backtick escapes for the body).
151
+ - **A model redefinition of the `prompt` function removes the readiness marker** — the shell then settles on the silence tier instead of the marker fast path.
152
+ - **There is no interactive stdin during a command** — a foreground command that reads input blocks until the command timeout, which resets the shell.
153
+ - **SIGTSTP/SIGHUP are unavailable on Windows** (backend-rejected); SIGINT is delivered as a console-wide Ctrl-C input write, which at a prompt cancels the pending line instead of signalling a process.
154
+ - **Under the Windows ACL sandbox's read-only mode, pwsh starts in ConstrainedLanguage**, which may deny the bootstrap's `[Console]::` encoding pin and prompt marker. Commands can still settle through the printable prompt and silence tier, but non-ASCII output may follow the host code page.
155
+ - **The BEL-terminated OSC marker remains a readiness signal only** — a BEL event channel to the model stays deferred, aligned with the current implementation.
156
+
157
+ <a id="dev-note"></a>
158
+ ### Dev Note
159
+
160
+ <details>
161
+ <summary>Working context for maintainers — click to expand</summary>
162
+
163
+ None.
164
+
165
+ </details>
package/README.zh.md CHANGED
@@ -1,55 +1,165 @@
1
+ ---
2
+ description: "面向模型的持久 pwsh 工具,供选择、配置或排查跨调用保留的按所有者隔离 PowerShell 状态的使用者与维护者阅读。"
3
+ kind: "package-reference"
4
+ ---
5
+
1
6
  # @deepseek-ai/dsh-tool-pwsh-persistent
2
7
 
3
8
  [English](README.md) | 中文
4
9
 
5
- 模型侧 `pwsh(command)`,由一个 owner 作用域的 `ctx.terminals` shell 支撑。本包拥有工具契约与 shell 复用;部署方选择 terminal backend(配置 `shellDialect: pwsh` 的 `terminal-bash` 实例)与沙箱策略。它是 `tool-bash-persistent` 的 Windows 对应物:相同的持久状态契约,PowerShell 方言。
10
+ ## 概述
11
+
12
+ `dsh-tool-pwsh-persistent` 为 agent 提供 `pwsh` 工具,其 PowerShell 状态对拥有它的 agent 跨调用保留:cwd、`$env:` 变量、函数与后台任务都会在命令之间存活。它是 `dsh-tool-bash-persistent` 的 Windows 对应物——相同的持久状态契约,PowerShell 方言。每个 agent 都有自己由按所有者隔离、带 pwsh 方言后端的 PTY 会话支撑的 shell,同一 agent 的命令逐个串行执行。配置选择后端与单条命令的墙钟上限;超时或显式 `exit` 会关闭 shell,下一次调用从全新状态开始。请与 pwsh 方言 terminal 后端(Windows ConPTY 或 POSIX pwsh)以及 `ctx.terminals` 服务一起挂载。
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 状态的任何组合中加载本插件——它是 `dsh-tool-pwsh` 的持久对应物,用于依赖跨调用状态的工作。它注册 `pwsh` 工具,需要 `ctx.tools` 与 `ctx.terminals` 服务,并在执行时需要拥有者 agent 会话。
29
+
30
+ ### 何时选择
31
+
32
+ 当工作依赖跨调用 PowerShell 状态时选择持久工具;当每条命令都应从已知、干净的环境开始时选择 `dsh-tool-pwsh`。这里不支持需要交互 stdin 的命令——读取输入的前台子进程会一直阻塞到命令超时,随后重置 shell——因此交互工作属于 terminal 工具。
33
+
34
+ ### 最小配置
35
+
36
+ 默认的 `shell` 后端通过配置了 `shellDialect: pwsh` 的 `dsh-terminal-bash` 实例启动 PowerShell shell;部署方可以注册其他 pwsh 方言 PTY 后端并按名称选择。
37
+
38
+ ```yaml
39
+ - name: '@deepseek-ai/dsh-terminal'
40
+ - name: '@deepseek-ai/dsh-terminal-bash'
41
+ config:
42
+ shellDialect: pwsh
43
+ - name: '@deepseek-ai/dsh-tool-pwsh-persistent'
44
+ ```
45
+
46
+ | 字段 | 默认值 | 含义 |
47
+ |---|---|---|
48
+ | `backendType` | `shell` | 用于每个 agent shell 的已注册 PTY 后端 |
49
+ | `timeoutMs` | `300,000` | 单条命令的墙钟上限;超时关闭 shell |
50
+ | `maxOutputChars` | `16,000` | 保留的命令输出字符上限;固定诊断信息在其后追加 |
51
+ | `description` | `Run commands in a persistent PowerShell shell. State, including the current directory and exported environment variables, persists across calls for this agent.` | 面向模型的环境约定;部署方可描述自己的环境 |
52
+
53
+ 生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-tool-pwsh-persistent)是每个受支持字段及其 JSDoc 的穷尽式真源。
54
+
55
+ ### agent 可以依赖什么
56
+
57
+ 命令共享每个 agent 一个 shell,因此 cwd、`$env:` 变量、函数与后台任务都会跨调用保留。结果排除私有完成标记、shell 提示词与回显的输入行。非零的包装命令追加 `[exit code: N]`——命令运行原生程序时给出确切原生退出码,PowerShell 终止错误则为 `1`。在报告该状态前就退出的 shell 改为追加 `[shell exited: code N]`、`[shell killed by signal: SIG]` 或 `[shell exited]`(Windows 强制终止报告 exit 1 且没有信号),然后重置并告诉 agent 下一次调用从全新状态开始。长输出保留最早的已保留前缀并附裁剪通知;若 terminal 已经丢弃该前缀,结果会明确说明。
58
+
59
+ ### 可能出什么问题
60
+
61
+ 没有拥有者 agent 会话的调用会以 `pwsh requires an owning agent session` 失败,没有 pwsh 方言 PTY 后端的组合会激活该工具,但首次调用以 `no PTY backend registered for "shell"` 失败。模型重定义 `prompt` 函数会移除就绪标记,shell 随后在静默层级而非标记快路径上结算。命令内的原始 ESC 字符会在执行前被 PSReadLine 消费,不受支持。超时或取消会关闭不确定的 shell、丢弃结果并报告重置。
62
+
63
+ -----
64
+
65
+ <a id="understand-the-implementation"></a>
66
+ ## 理解实现
6
67
 
7
- ## 配置
68
+ <details>
69
+ <summary>实现细节——点击展开</summary>
8
70
 
9
- | 键 | 默认值 | 含义 |
10
- |---|---:|---|
11
- | `backendType` | `shell` | 每个 Agent shell 使用的已注册 terminal backend。 |
12
- | `timeoutMs` | `300000` | 单条命令的墙钟上限;超时关闭 shell。 |
13
- | `maxOutputChars` | `16000` | 保留的命令输出字符上限;固定诊断文本在其后追加。 |
14
- | `description` | 持久 shell 描述 | 模型可见的环境契约。 |
71
+ 本节解释工具背后的设计决策,并指出实现它们的代码位置;可观察行为已在[使用本包](#use-this-package)中完整说明。
15
72
 
73
+ ### 设计理念
74
+
75
+ - **`dsh-tool-bash-persistent` 的刻意孪生。** 会话注册表、轮询循环与重置约定按设计镜像持久 bash 工具([pwsh 持久 PTY Agent Note](../../../.agents/notes/implemented/architecture/2026-08-11-pwsh-persistent-pty.zh.md))。
76
+ - **prompt 函数就绪。** 工具安装自己的 `prompt` 函数,打印 BEL 结尾的 OSC 标记加可打印提示词;OSC 标记携带最后的退出码,可打印提示词让每条命令都能结算,因此模型重定义 `prompt` 会把就绪降级到静默层级。
77
+ - **PSReadLine 回显靠锚定剥离。** PowerShell 会把提交的输入渲染回流中;标记锚定提取与包装源码剥离移除回显,而跨终端宽度换行的包装可能在部分输出结果中留下部分回显。
78
+ - **重置,而非修复。** 任何不确定状态——显式 `exit`、超时、发送失败、中止——都会关闭 shell 并让下一次调用从全新状态开始。
79
+
80
+ ### 源码地图
81
+
82
+ | 文件 | 职责 |
83
+ |---|---|
84
+ | [`src/index.ts`](src/index.ts) | 插件入口:shell 注册表、prompt 设置、命令包装、scrollback 轮询、提取与渲染 |
85
+ | [`src/invariant.ts`](src/invariant.ts) | 不变式伴生插件(无运行时不变式;shell 复用可通过工具执行观察) |
86
+
87
+ ### 命令流程
88
+
89
+ 首条命令通过 `ctx.terminals.spawn` 生成 shell,安装 `prompt` 覆盖,并等待就绪。随后每条命令都包装成一行物理文本——`Write-Output` 起始标记、用反引号转义进双引号字符串的命令体、`Write-Output` 结束标记加退出状态——因此 PSReadLine 对换行包装的回显无法伪造完成。工具以 1,000 行一页轮询 scrollback,直到出现结束标记或完成的提示词,提取区间、剥离回显的包装与提示词,并连同任何状态标记一起渲染。超时会中止截止时间、捕获部分输出并重置 shell。
90
+
91
+ </details>
92
+
93
+ -----
94
+
95
+ <a id="further-exploration"></a>
96
+ ## 进一步探索
97
+
98
+ 当包级约定不够用时阅读以下页面。它们从 terminal 家族逐步进入 seam、后端,以及持久 shell 设计背后的设计笔记。
99
+
100
+ - [terminal 包映射](../../terminal/README.zh.md)——持久 PTY 能力家族。
101
+ - [terminal seam](../../terminal/terminal/README.zh.md)——工具背后的 `ctx.terminals` 服务。
102
+ - [terminal-bash 后端](../../terminal/terminal-bash/README.zh.md)——默认后端,配置 `shellDialect: pwsh`。
103
+ - [pwsh 持久 PTY Agent Note](../../../.agents/notes/implemented/architecture/2026-08-11-pwsh-persistent-pty.zh.md)——pwsh 侧会话设计及其理由。
104
+ - [持久 PTY 会话 Agent Note](../../../.agents/notes/implemented/feature/2026-07-16-persistent-pty-sessions.zh.md)——按所有者会话的设计及其理由。
105
+ - [生成的工具目录](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-pwsh-persistent)——`pwsh` 参数 schema 的确切内容。
106
+ - [生成的配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-tool-pwsh-persistent)——每个受支持配置字段及其源声明。
107
+
108
+ -----
109
+
110
+ <a id="model-experience"></a>
16
111
  ## 模型体验
17
112
 
18
113
  ### 工具 schema
19
114
 
20
115
  #### 模型看到什么
21
116
 
22
- 生成的 [`pwsh` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-pwsh-persistent),含配置的 `description`。本插件不贡献独立的 system-prompt 段落;persona 与环境指引由部署方负责。
117
+ 生成的 [`pwsh` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-pwsh-persistent),包括配置的 `description`。本插件不贡献独立的系统提示词区段;人设与环境指引由部署方负责。
23
118
 
24
119
  #### Token 影响
25
120
 
26
- `pwsh` 可见期间每个请求有固定的 schema 成本。
121
+ `pwsh` 可见期间产生固定 schema 开销。
27
122
 
28
123
  #### KV Cache 影响
29
124
 
30
- 配置的 description 与 schema 不变时前缀稳定。
125
+ 只要配置的描述与 schema 不变,前缀就保持稳定。
31
126
 
32
127
  ### 工具结果
33
128
 
34
129
  #### 模型看到什么
35
130
 
36
- 命令共享每个 Agent 的一个 shell,因此 cwd、`$env:` 变量、函数和后台任务跨调用保留。结果排除私有完成标记、shell 提示符与回显的输入行(PSReadLine 会把提交的输入渲染回输出流;marker 锚定提取与包装器原文剥离将其移除)。非零包装命令追加 `[exit code: N]` —— 命令运行原生程序时是精确的原生退出码,PowerShell 终止性错误为 `1`。shell 在报告状态前退出的,改为追加 `[shell exited: code N]`、`[shell killed by signal: SIG]` `[shell exited]`(backend 两者都没有时;Windows 强杀按无 signal 的 exit 1 报告),然后重置并告知模型下一次调用从全新 shell 开始。长输出保留最早的前缀并附裁剪提示;若 PTY 已丢弃该前缀,结果会明确说明。超时返回有界的部分输出、关闭不确定的 shell 并报告重置。
131
+ 命令共享每个 Agent 一个 shell,因此 cwd、`$env:` 变量、函数与后台任务都会跨调用保留。结果排除私有完成标记、shell 提示词与回显的输入行(PSReadLine 会把提交的输入渲染回流中;标记锚定提取与包装源码剥离会移除它)。非零的包装命令追加 `[exit code: N]`——命令运行原生程序时给出确切原生退出码,PowerShell 终止错误则为 `1`。在报告该状态前就退出的 shell 改为追加 `[shell exited: code N]`、`[shell killed by signal: SIG]`,或后端两者都未提供时的 `[shell exited]`(Windows 强制终止报告 exit 1 且没有信号),然后重置并告诉模型下一次调用从全新状态开始。长输出保留最早的已保留前缀并附裁剪通知;若 terminal 已经丢弃该前缀,结果会明确说明。超时返回有界部分输出、关闭不确定的 shell 并报告重置。
37
132
 
38
133
  #### Token 影响
39
134
 
40
- 数据相关。`maxOutputChars` 限制保留的命令输出;固定裁剪、前缀丢失、状态、超时与重置诊断可能扩展结果。
135
+ 依数据而定。`maxOutputChars` 限制保留的命令输出;固定的裁剪、丢失前缀、状态、超时与重置诊断可能延长结果。
41
136
 
42
137
  #### KV Cache 影响
43
138
 
44
- 追加式工具结果跟随可复用的请求前缀。
139
+ 仅追加的工具结果位于可复用请求前缀之后。
140
+
141
+ ## 已知限制与延期工作
142
+
143
+ <a id="known-limitations-and-deferred-work"></a>
144
+
145
+
146
+ 这些限制说明工具何时不合适或需要特别小心。它们是当前包约束,不是任务积压。
147
+
148
+ - **工具需要拥有者 Agent 与带 pwsh 方言的真实 terminal 后端**——Windows ConPTY 或 POSIX pwsh。
149
+ - **输入回显不可避免**——PowerShell 的 PSReadLine 会把提交的输入渲染回终端流,而且没有 `stty -echo` 等价物。标记锚定提取在完整结果中排除回显;包装源码剥离覆盖回退路径,但跨终端宽度换行的包装可能在部分输出结果中留下部分回显,受 `maxOutputChars` 设界。
150
+ - **模型命令内的原始 ESC 字符不受支持**——PSReadLine 会在执行前消费它们。包装器会转义它需要的控制字节(`[char]27` 构造的 OSC 标记、正文的反引号转义)。
151
+ - **模型重定义 `prompt` 函数会移除就绪标记**——shell 随后在静默层级而非标记快路径上结算。
152
+ - **命令期间没有交互 stdin**——读取输入的前台命令会一直阻塞到命令超时,随后重置 shell。
153
+ - **Windows 上 SIGTSTP/SIGHUP 不可用**(后端拒绝);SIGINT 以控制台级 Ctrl-C 输入写入投递,在提示词处会取消待处理行而不是向进程发信号。
154
+ - **在 Windows ACL 沙箱的只读模式下,pwsh 以 ConstrainedLanguage 启动**,可能拒绝引导的 `[Console]::` 编码固定与 prompt 标记。命令仍可通过可打印提示词与静默层级结算,但非 ASCII 输出可能跟随宿主代码页。
155
+ - **BEL 结尾的 OSC 标记目前只是就绪信号**——通向模型的 BEL 事件通道仍被推迟,与当前实现保持一致。
156
+
157
+ <a id="dev-note"></a>
158
+ ### 开发备注
159
+
160
+ <details>
161
+ <summary>维护者的工作上下文——点击展开</summary>
45
162
 
46
- ## 已知限制与延后工作
163
+ 无。
47
164
 
48
- - 工具需要拥有 Agent 与一个真实支持 pwsh 方言的 terminal backend(Windows ConPTY 或 POSIX 上的 pwsh)。
49
- - **输入回显不可避免**:PowerShell 的 PSReadLine 会把提交的输入渲染回终端流,且没有 `stty -echo` 的对应物。完整结果中 marker 锚定提取排除回显;包装器原文剥离覆盖回退路径,但跨越终端宽度的包装器折行可能在部分输出结果中残留片段回显,受 `maxOutputChars` 约束。
50
- - 模型命令中的裸 ESC 字符不受支持:PSReadLine 会在执行前吞掉它们。包装器转义它需要的控制字节(`[char]27` 构造的 OSC 标记、body 的反引号转义)。
51
- - 模型重定义 `prompt` 函数会移除就绪标记;shell 随后退化为静默档而非 marker 快路径。
52
- - 命令执行期间没有交互 stdin:读取输入的前台命令会阻塞到就绪超时,随后重置 shell。
53
- - SIGTSTP/SIGHUP 在 Windows 不可用(backend 拒绝);SIGINT 以控制台级 Ctrl-C 输入写入投递,在提示符处取消当前行而非向进程发信号。
54
- - 在 Windows ACL 沙箱的只读模式下,pwsh 以 ConstrainedLanguage 启动,可能拒绝引导代码通过 `[Console]::` 固定编码并写入 prompt marker。命令仍可通过可打印提示符和静默档结算,但非 ASCII 输出可能沿用宿主代码页。
55
- - BEL 终结的 OSC 标记仍只是就绪信号;面向模型的 BEL 事件通道保持延后,与当前实现对齐。
165
+ </details>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tool-pwsh-persistent",
3
3
  "description": "Model-facing owner-scoped persistent PowerShell tool backed by the Harness PTY service",
4
- "version": "0.1.1-rc.2",
4
+ "version": "0.1.2-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,32 +31,33 @@
31
31
  ],
32
32
  "license": "MIT",
33
33
  "peerDependencies": {
34
- "@deepseek-ai/dsh-agent": "^0.1.1-rc.2",
35
- "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
36
- "@deepseek-ai/dsh-terminal": "^0.1.1-rc.2",
37
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
38
- "@deepseek-ai/dsh-timeout": "^0.1.1-rc.2",
39
- "@deepseek-ai/cordis": "^4.0.1"
34
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
35
+ "@deepseek-ai/dsh-terminal": "^0.1.2-alpha.2",
36
+ "@deepseek-ai/dsh-timeout": "^0.1.2-alpha.2",
37
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
38
+ "@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
39
+ "@deepseek-ai/cordis": "^4.0.2"
40
40
  },
41
41
  "dependencies": {
42
- "@deepseek-ai/schemastery": "^3.18.1"
42
+ "@deepseek-ai/schemastery": "^3.18.2"
43
43
  },
44
44
  "devDependencies": {
45
- "@deepseek-ai/cordis-plugin-include": "^1.0.6",
46
- "@deepseek-ai/cordis-plugin-loader": "^1.0.2",
47
- "@deepseek-ai/dsh-agent": "^0.1.1-rc.2",
48
- "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
49
- "@deepseek-ai/dsh-llm": "^0.1.1-rc.2",
50
- "@deepseek-ai/dsh-terminal-bash": "^0.1.1-rc.2",
51
- "@deepseek-ai/dsh-pwsh-local": "^0.1.1-rc.2",
52
- "@deepseek-ai/dsh-sandbox": "^0.1.1-rc.2",
53
- "@deepseek-ai/dsh-terminal": "^0.1.1-rc.2",
54
- "@deepseek-ai/dsh-sandbox-policy": "^0.1.1-rc.2",
55
- "@deepseek-ai/dsh-session": "^0.1.1-rc.2",
56
- "@deepseek-ai/dsh-subprocess-local": "^0.1.1-rc.2",
57
- "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.2",
58
- "@deepseek-ai/dsh-timeout": "^0.1.1-rc.2",
59
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
60
- "@deepseek-ai/cordis": "^4.0.1"
45
+ "@deepseek-ai/cordis-plugin-include": "^1.0.7",
46
+ "@deepseek-ai/cordis-plugin-loader": "^1.0.3",
47
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
48
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
49
+ "@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
50
+ "@deepseek-ai/dsh-terminal": "^0.1.2-alpha.2",
51
+ "@deepseek-ai/dsh-terminal-bash": "^0.1.2-alpha.2",
52
+ "@deepseek-ai/dsh-pwsh-local": "^0.1.2-alpha.2",
53
+ "@deepseek-ai/dsh-sandbox-policy": "^0.1.2-alpha.2",
54
+ "@deepseek-ai/dsh-session": "^0.1.2-alpha.2",
55
+ "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.2",
56
+ "@deepseek-ai/dsh-subprocess-local": "^0.1.2-alpha.2",
57
+ "@deepseek-ai/dsh-system-prompt": "^0.1.2-alpha.2",
58
+ "@deepseek-ai/dsh-timeout": "^0.1.2-alpha.2",
59
+ "@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
60
+ "@deepseek-ai/cordis": "^4.0.2",
61
+ "@deepseek-ai/dsh-sandbox": "^0.1.2-alpha.2"
61
62
  }
62
63
  }