@deepseek-ai/dsh-pwsh-local 0.1.2-alpha.5 → 0.1.3-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 +3 -3
- package/README.zh.md +3 -3
- package/lib/index.js +17 -11
- package/lib/types/index.d.ts +4 -4
- package/package.json +10 -10
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/pwsh-local/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 1d6872ec6b342f415b1632f87be5a485c4dfa270
|
|
6
|
+
README.zh.md: 2594ecc1623fec9ea8022f92d1c38941f643d979
|
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
|
|
|
66
66
|
|
|
67
67
|
### Background processes
|
|
68
68
|
|
|
69
|
-
Call `start` to run a command in the background; it returns a handle immediately and no timeout applies. `readOutput()` merges the stream deltas into one consuming read, marking stderr under a `[stderr]` section; `kill()`
|
|
69
|
+
Call `start` to run a command in the background; it returns a handle immediately and no timeout applies. `readOutput()` merges the stream deltas into one consuming read, marking stderr under a `[stderr]` section; `kill()` terminates the provider-managed range; `done` settles when the direct command closes and never rejects. Job ids, ownership, polling, and notices belong to the generic `ctx.jobs` runtime, which the tool layer registers the handle with.
|
|
70
70
|
|
|
71
71
|
<a id="adjusting-budgets-at-runtime"></a>
|
|
72
72
|
### Adjusting budgets at runtime
|
|
@@ -85,7 +85,7 @@ This section explains the design of the executor and points at the code that rea
|
|
|
85
85
|
|
|
86
86
|
### Design concept
|
|
87
87
|
|
|
88
|
-
The executor is the PowerShell Service Provider for the `ctx.shell` seam built on the subprocess capability: it owns everything pwsh-shaped — executable resolution, command defaulting and caps, deadline fusion and cause classification, UTF-8 output pinning, the model-friendly terminal environment, and the background read merge — while
|
|
88
|
+
The executor is the PowerShell Service Provider for the `ctx.shell` seam built on the subprocess capability: it owns everything pwsh-shaped — executable resolution, command defaulting and caps, deadline fusion and cause classification, UTF-8 output pinning, the model-friendly terminal environment, and the background read merge — while managed-range mechanics (bounded spill-backed output, credential scrub, termination escalation, quiescence, and disposal) belong to the subprocess service. Every call spawns a fresh non-interactive `pwsh -Command` with `-NoLogo -NoProfile -NonInteractive`, so commands are deterministic and profile state never leaks between calls.
|
|
89
89
|
|
|
90
90
|
### Source map
|
|
91
91
|
|
|
@@ -143,7 +143,7 @@ These limits define when this executor is a poor fit. They are current package c
|
|
|
143
143
|
- **Unconfined by itself** — commands run with the harness process's authority; deployments needing confinement compose a sandboxing executor or policy instead.
|
|
144
144
|
- **No persistent shell or PTY** — every call starts a fresh `pwsh -Command`.
|
|
145
145
|
- **The command string is PowerShell text** — the `-Command` domain has no shell-quoting layer, but a model-facing command is parsed by PowerShell itself, so PowerShell syntax errors are command failures, not launch failures.
|
|
146
|
-
- **A background
|
|
146
|
+
- **A background provider-failure note is single-delivery** — `SubprocessHandle.done` can reject before or after target execution begins, so the executor injects the stage-neutral `subprocess failed before reporting an outcome: …` into exactly one `readOutput()` delta; a reader that discards that delta cannot recover it.
|
|
147
147
|
- **Windows termination reports no signal** — a force-killed process settles as exit 1 with `signal: null`, so signal-based status classification does not apply on Windows; `kill()`-initiated stops still stamp `killed` directly.
|
|
148
148
|
- **The encoding preamble precedes the command** — PowerShell requires `param(...)`, `#requires`, and `using` statements at the very top of a script, so a command whose first statement is one of those cannot run under the UTF-8 output preamble; wrap a `param(...)` script in `& { … }`, and run `using`/`#requires` scripts from a file instead.
|
|
149
149
|
- **Non-ASCII stdin under Windows PowerShell 5.1 may be mis-decoded** — the preamble pins output encoding only; `[Console]::InputEncoding` stays at the host default because setting it under redirected stdin throws; pwsh 7 defaults to UTF-8 and is unaffected.
|
package/README.zh.md
CHANGED
|
@@ -66,7 +66,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
|
|
|
66
66
|
|
|
67
67
|
### 后台进程
|
|
68
68
|
|
|
69
|
-
调用 `start` 即可在后台运行命令;它立即返回句柄,且不应用任何超时。`readOutput()` 把流增量合并为一次消费式读取,并在 `[stderr]` 分段下标记 stderr;`kill()`
|
|
69
|
+
调用 `start` 即可在后台运行命令;它立即返回句柄,且不应用任何超时。`readOutput()` 把流增量合并为一次消费式读取,并在 `[stderr]` 分段下标记 stderr;`kill()` 终止由提供方管理的 range;`done` 在 direct command 关闭时结算且绝不 reject。job id、所有权、轮询与通知属于通用 `ctx.jobs` 运行时,工具层会把句柄注册进去。
|
|
70
70
|
|
|
71
71
|
<a id="adjusting-budgets-at-runtime"></a>
|
|
72
72
|
### 运行时调整预算
|
|
@@ -85,7 +85,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
|
|
|
85
85
|
|
|
86
86
|
### 设计概念
|
|
87
87
|
|
|
88
|
-
本执行器是基于 subprocess 能力的 `ctx.shell` seam 的 PowerShell Service Provider:它负责所有 pwsh 层职责——可执行文件解析、命令默认化与上限、deadline 融合与原因分类、UTF-8
|
|
88
|
+
本执行器是基于 subprocess 能力的 `ctx.shell` seam 的 PowerShell Service Provider:它负责所有 pwsh 层职责——可执行文件解析、命令默认化与上限、deadline 融合与原因分类、UTF-8 输出固定、面向模型的终端环境,以及后台读取合并——而 managed-range 机制(有界 spill 输出、凭据清除、终止升级、完全停稳与 dispose(资源释放))属于 subprocess 服务。每次调用都 spawn 全新的非交互 `pwsh -Command`,并带 `-NoLogo -NoProfile -NonInteractive`,因此命令是确定性的,profile 状态绝不会在调用之间泄漏。
|
|
89
89
|
|
|
90
90
|
### 源码地图
|
|
91
91
|
|
|
@@ -143,7 +143,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
|
|
|
143
143
|
- **自身不提供隔离**——命令以 harness 进程的权限运行;需要隔离的部署组合沙箱执行器或策略。
|
|
144
144
|
- **没有持久 shell 或 PTY**——每次调用都启动全新的 `pwsh -Command`。
|
|
145
145
|
- **命令字符串是 PowerShell 文本**——`-Command` 域没有 shell 引号层,但面向模型的命令由 PowerShell 自己解析,因此 PowerShell 语法错误是命令失败,而非启动失败。
|
|
146
|
-
- **后台
|
|
146
|
+
- **后台 provider failure 提示只交付一次**——`SubprocessHandle.done` 可能在 target 开始执行前或后 reject,因此执行器把不声明失败阶段的 `subprocess failed before reporting an outcome: …` 注入恰好一个 `readOutput()` 增量;丢弃了该增量的读取方无法再恢复它。
|
|
147
147
|
- **Windows 终止不报告信号**——被强制终止的进程以退出码 1、`signal: null` 结算,因此基于信号的状态分类在 Windows 上不适用;`kill()` 发起的停止仍会直接标记为 `killed`。
|
|
148
148
|
- **编码 preamble 位于命令之前**——PowerShell 要求 `param(...)`、`#requires` 与 `using` 语句位于脚本最顶部,因此以其中一种开头的命令无法在 UTF-8 输出 preamble 下运行;`param(...)` 脚本请包进 `& { … }`,`using`/`#requires` 脚本请改从文件运行。
|
|
149
149
|
- **Windows PowerShell 5.1 下的非 ASCII stdin 可能被错误解码**——preamble 只固定输出编码;`[Console]::InputEncoding` 保持主机默认,因为在重定向 stdin 下设置它会抛出异常;pwsh 7 默认 UTF-8,不受影响。
|
package/lib/index.js
CHANGED
|
@@ -191,7 +191,7 @@ function assertServiceablePwshConfig(config) {
|
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
193
|
* Local PowerShell executor over `ctx.subprocess`. Bounded output, spill
|
|
194
|
-
* files, and
|
|
194
|
+
* files, and managed-range termination are the subprocess service's mechanics;
|
|
195
195
|
* this executor supplies their configured budgets per spawn.
|
|
196
196
|
*/
|
|
197
197
|
var PwshLocalExecutor = class PwshLocalExecutor extends ShellExecutor {
|
|
@@ -351,10 +351,10 @@ var PwshLocalExecutor = class PwshLocalExecutor extends ShellExecutor {
|
|
|
351
351
|
startArgv(spec, argv) {
|
|
352
352
|
const running = this.ctx.subprocess.spawn(this.spawnSpec(spec, this.config.maxOutputBytes, spec.signal, argv));
|
|
353
353
|
const collected = PwshLocalExecutor.collected(running);
|
|
354
|
-
let
|
|
355
|
-
const
|
|
356
|
-
const note =
|
|
357
|
-
|
|
354
|
+
let providerFailureNote;
|
|
355
|
+
const consumeProviderFailure = () => {
|
|
356
|
+
const note = providerFailureNote ?? "";
|
|
357
|
+
providerFailureNote = void 0;
|
|
358
358
|
return note;
|
|
359
359
|
};
|
|
360
360
|
let stdoutOffset = 0;
|
|
@@ -370,15 +370,21 @@ var PwshLocalExecutor = class PwshLocalExecutor extends ShellExecutor {
|
|
|
370
370
|
this.onProcessDone(proc, collected.stderr.readFrom(0).text, false);
|
|
371
371
|
}, (error) => {
|
|
372
372
|
proc.status = "killed";
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
let detail = "unprintable provider failure";
|
|
374
|
+
try {
|
|
375
|
+
detail = String(error);
|
|
376
|
+
} catch {}
|
|
377
|
+
providerFailureNote = `subprocess failed before reporting an outcome: ${detail}`;
|
|
378
|
+
this.onProcessDone(proc, providerFailureNote, true, error);
|
|
375
379
|
}),
|
|
376
380
|
readOutput: () => {
|
|
377
381
|
const out = collected.stdout.readFrom(stdoutOffset);
|
|
378
382
|
const err = collected.stderr.readFrom(stderrOffset);
|
|
379
383
|
stdoutOffset = out.nextOffset;
|
|
380
384
|
stderrOffset = err.nextOffset;
|
|
381
|
-
const
|
|
385
|
+
const providerFailure = consumeProviderFailure();
|
|
386
|
+
const failureSeparator = err.text.length > 0 && !err.text.endsWith("\n") ? "\n" : "";
|
|
387
|
+
const errText = err.text + (providerFailure.length > 0 ? `${failureSeparator}${providerFailure}` : "");
|
|
382
388
|
const separator = out.text.length > 0 && !out.text.endsWith("\n") ? "\n" : "";
|
|
383
389
|
return {
|
|
384
390
|
delta: out.text + (errText.length > 0 ? `${separator}[stderr]\n${errText}` : ""),
|
|
@@ -403,10 +409,10 @@ var PwshLocalExecutor = class PwshLocalExecutor extends ShellExecutor {
|
|
|
403
409
|
* pwsh-confining consumer is `@deepseek-ai/dsh-pwsh-sandbox`.
|
|
404
410
|
* @param _proc - the settled process handle.
|
|
405
411
|
* @param _stderr - the process's retained stderr tail used by subclasses for settlement classification.
|
|
406
|
-
* @param
|
|
407
|
-
* @param
|
|
412
|
+
* @param _providerRejected - whether the subprocess promise rejected without a direct outcome.
|
|
413
|
+
* @param _providerError - the provider rejection reason, which may itself be undefined.
|
|
408
414
|
*/
|
|
409
|
-
onProcessDone(_proc, _stderr,
|
|
415
|
+
onProcessDone(_proc, _stderr, _providerRejected, _providerError) {}
|
|
410
416
|
};
|
|
411
417
|
//#endregion
|
|
412
418
|
export { ENCODING_PREAMBLE, ENV_OVERRIDES, PwshLocalExecutor, PwshLocalExecutor as default, assertServiceablePwshConfig, candidatePwshPaths, resolvePwshPath };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export { candidatePwshPaths, resolvePwshPath } from './resolve.ts';
|
|
|
71
71
|
export declare function assertServiceablePwshConfig(config: Config): void;
|
|
72
72
|
/**
|
|
73
73
|
* Local PowerShell executor over `ctx.subprocess`. Bounded output, spill
|
|
74
|
-
* files, and
|
|
74
|
+
* files, and managed-range termination are the subprocess service's mechanics;
|
|
75
75
|
* this executor supplies their configured budgets per spawn.
|
|
76
76
|
*/
|
|
77
77
|
export declare class PwshLocalExecutor extends ShellExecutor {
|
|
@@ -118,10 +118,10 @@ export declare class PwshLocalExecutor extends ShellExecutor {
|
|
|
118
118
|
* pwsh-confining consumer is `@deepseek-ai/dsh-pwsh-sandbox`.
|
|
119
119
|
* @param _proc - the settled process handle.
|
|
120
120
|
* @param _stderr - the process's retained stderr tail used by subclasses for settlement classification.
|
|
121
|
-
* @param
|
|
122
|
-
* @param
|
|
121
|
+
* @param _providerRejected - whether the subprocess promise rejected without a direct outcome.
|
|
122
|
+
* @param _providerError - the provider rejection reason, which may itself be undefined.
|
|
123
123
|
*/
|
|
124
|
-
protected onProcessDone(_proc: ShellProcess, _stderr: string,
|
|
124
|
+
protected onProcessDone(_proc: ShellProcess, _stderr: string, _providerRejected: boolean, _providerError?: unknown): void;
|
|
125
125
|
}
|
|
126
126
|
export default PwshLocalExecutor;
|
|
127
127
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-pwsh-local",
|
|
3
3
|
"description": "Local PowerShell implementation of the DeepSeek Harness bash executor seam",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@deepseek-ai/dsh-
|
|
30
|
+
"@deepseek-ai/dsh-shell": "^0.1.3-alpha.2",
|
|
31
|
+
"@deepseek-ai/dsh-timeout": "^0.1.3-alpha.2",
|
|
31
32
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
32
|
-
"@deepseek-ai/dsh-
|
|
33
|
-
"@deepseek-ai/dsh-
|
|
34
|
-
"@deepseek-ai/dsh-shell": "^0.1.2-alpha.5"
|
|
33
|
+
"@deepseek-ai/dsh-settings": "^0.1.3-alpha.2",
|
|
34
|
+
"@deepseek-ai/dsh-subprocess": "^0.1.3-alpha.2"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@deepseek-ai/dsh-shell": "^0.1.
|
|
41
|
-
"@deepseek-ai/dsh-subprocess": "^0.1.
|
|
42
|
-
"@deepseek-ai/dsh-subprocess
|
|
43
|
-
"@deepseek-ai/dsh-timeout": "^0.1.
|
|
40
|
+
"@deepseek-ai/dsh-shell": "^0.1.3-alpha.2",
|
|
41
|
+
"@deepseek-ai/dsh-subprocess-local": "^0.1.3-alpha.2",
|
|
42
|
+
"@deepseek-ai/dsh-subprocess": "^0.1.3-alpha.2",
|
|
43
|
+
"@deepseek-ai/dsh-timeout": "^0.1.3-alpha.2",
|
|
44
44
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
45
|
-
"@deepseek-ai/dsh-settings": "^0.1.
|
|
45
|
+
"@deepseek-ai/dsh-settings": "^0.1.3-alpha.2"
|
|
46
46
|
}
|
|
47
47
|
}
|