@deepseek-ai/dsh-pwsh-local 0.2.2-alpha.3 → 0.2.2-rc.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAmB,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAoC,MAAM,wBAAwB,CAAA;AAO9J;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;CAIhB,CAAA;AAEV;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,qIACsG,CAAA;AAQpI,gEAAgE;AAChE,MAAM,WAAW,MAAM;IACrB,uEAAuE;IACvE,GAAG,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACjC,kDAAkD;IAClD,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC3B,kDAAkD;IAClD,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC9B,uEAAuE;IACvE,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAChC,kFAAkF;IAClF,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC/B,0FAA0F;IAC1F,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACzB;;;;;OAKG;IACH,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACvC;AAID,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cA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,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAA;IAC5F,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,SAAiB;IACxC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC,CAAA;QACjC,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,cAAc,EAAE,CAAA;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,0EAA0E;QAC1E,wEAAwE;QACxE,iCAAiC;QACjC,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAmB,EACnB,MAAyB,OAAO,CAAC,GAAG,EACpC,WAA4B,OAAO,CAAC,QAAQ;IAE5C,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,UAAU,CAAA;IACxE,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,KAAK,MAAM,SAAS,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;YAChD,IAAI,eAAe,CAAC,SAAS,CAAC;gBAAE,OAAO,SAAS,CAAA;QAClD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
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.2.2-alpha.3",
4
+ "version": "0.2.2-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,23 +25,26 @@
25
25
  "files": [
26
26
  "locale/*.json",
27
27
  "lib/index.js",
28
- "lib/types/**/*.d.ts"
28
+ "lib/types/**/*.d.ts",
29
+ "lib/types/**/*.d.ts.map",
30
+ "lib/**/*.js.map",
31
+ "src"
29
32
  ],
30
33
  "license": "MIT",
31
34
  "peerDependencies": {
32
- "@deepseek-ai/dsh-shell": "0.2.2-alpha.3",
33
- "@deepseek-ai/dsh-subprocess": "0.2.2-alpha.3",
34
- "@deepseek-ai/dsh-timeout": "0.2.2-alpha.3",
35
- "@deepseek-ai/cordis": "~4.0.6-alpha.2"
35
+ "@deepseek-ai/dsh-shell": "0.2.2-rc.2",
36
+ "@deepseek-ai/dsh-subprocess": "0.2.2-rc.2",
37
+ "@deepseek-ai/dsh-timeout": "0.2.2-rc.2",
38
+ "@deepseek-ai/cordis": "~4.1.0"
36
39
  },
37
40
  "dependencies": {
38
- "@deepseek-ai/schemastery": "~3.18.6-alpha.2"
41
+ "@deepseek-ai/schemastery": "~3.19.0"
39
42
  },
40
43
  "devDependencies": {
41
- "@deepseek-ai/dsh-shell": "0.2.2-alpha.3",
42
- "@deepseek-ai/dsh-subprocess": "0.2.2-alpha.3",
43
- "@deepseek-ai/dsh-subprocess-local": "0.2.2-alpha.3",
44
- "@deepseek-ai/dsh-timeout": "0.2.2-alpha.3",
45
- "@deepseek-ai/cordis": "~4.0.6-alpha.2"
44
+ "@deepseek-ai/dsh-shell": "0.2.2-rc.2",
45
+ "@deepseek-ai/dsh-subprocess": "0.2.2-rc.2",
46
+ "@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.2",
47
+ "@deepseek-ai/dsh-timeout": "0.2.2-rc.2",
48
+ "@deepseek-ai/cordis": "~4.1.0"
46
49
  }
47
50
  }
package/src/index.ts ADDED
@@ -0,0 +1,449 @@
1
+ /**
2
+ * Local PowerShell Service Provider for the bash capability seam. Each command runs
3
+ * as `pwsh -NoLogo -NoProfile -NonInteractive -Command <command>` in a managed
4
+ * process spawned through `ctx.subprocess`; the executor owns command
5
+ * defaulting, deadlines and cause classification, the model-friendly terminal
6
+ * environment, and the model-facing stdout/stderr merge for background reads.
7
+ *
8
+ * The command string is passed as ONE argv element to `-Command`: PowerShell
9
+ * itself parses the text, and no intermediate shell exists, so there is no
10
+ * shell-quoting layer to escape (the `bash -c` string domain has no
11
+ * equivalent here). Native Win32 paths (`C:\...`) pass through unchanged.
12
+ *
13
+ * @module @deepseek-ai/dsh-pwsh-local
14
+ */
15
+
16
+ /* jscpd:ignore-start -- this executor mirrors dsh-bash-local call-for-call by
17
+ design (see this package's README), so the two import the same seam surface */
18
+ import type { Volatile } from '@deepseek-ai/cordis'
19
+ import { Context } from '@deepseek-ai/cordis'
20
+ import z from '@deepseek-ai/schemastery'
21
+ import { ShellExecutor } from '@deepseek-ai/dsh-shell'
22
+ import type { CollectedOutput, ShellExecRequest, ShellExecSpec, ShellExecution, ShellProcess, ShellProcessRead, ShellRunResult } from '@deepseek-ai/dsh-shell'
23
+ import type { SubprocessCollect, SubprocessHandle, SubprocessOutputReader, SubprocessSpawnSpec } from '@deepseek-ai/dsh-subprocess'
24
+ import { clampTimeout, deadline, MAX_TIMER_DELAY_MS, timeoutOf } from '@deepseek-ai/dsh-timeout'
25
+ /* jscpd:ignore-end */
26
+ import { resolvePwshPath } from './resolve.ts'
27
+
28
+ /* jscpd:ignore-start -- deliberate call-for-call mirror of dsh-bash-local (Agent Note: pwsh-tool-and-executor). */
29
+ /**
30
+ * Model-friendly environment overrides for PowerShell: disable colors and
31
+ * pagers that would garble tool output. `TERM=dumb` is a POSIX concept and is
32
+ * deliberately absent; `NO_COLOR` is honored by modern pwsh renderers.
33
+ */
34
+ export const ENV_OVERRIDES = {
35
+ NO_COLOR: '1',
36
+ PAGER: 'cat',
37
+ GIT_PAGER: 'cat',
38
+ } as const
39
+
40
+ /**
41
+ * UTF-8 output pinning prepended to every command. The subprocess collector
42
+ * decodes output bytes as UTF-8, but Windows PowerShell 5.1 (the last-resort
43
+ * executable fallback) writes the console/OEM code page by default, which
44
+ * garbles non-ASCII output; pwsh 7 defaults to UTF-8 and is unaffected. The
45
+ * statements ride on line 1 after `; ` separators so PowerShell error line
46
+ * numbers stay accurate.
47
+ */
48
+ export const ENCODING_PREAMBLE =
49
+ '[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false); $OutputEncoding = [System.Text.UTF8Encoding]::new($false); '
50
+
51
+ /** Default SIGTERM→SIGKILL grace period (the `graceMs` config). */
52
+ const DEFAULT_GRACE_MS = 3_000
53
+
54
+ /** Default per-stream spill cap (the `maxSpillBytes` config). */
55
+ const DEFAULT_MAX_SPILL_BYTES = 64 * 1024 * 1024
56
+
57
+ /** Validated plugin configuration with live command budgets. */
58
+ export interface Config {
59
+ /** Default working directory for commands (default: process.cwd()). */
60
+ cwd: Volatile<string | undefined>
61
+ /** Default foreground timeout in milliseconds. */
62
+ timeoutMs: Volatile<number>
63
+ /** Upper bound for per-call timeout overrides. */
64
+ maxTimeoutMs: Volatile<number>
65
+ /** Per-stream in-memory output cap; overflow spills to a temp file. */
66
+ maxOutputBytes: Volatile<number>
67
+ /** Per-stream spill-file cap; larger streams retain only their in-memory tail. */
68
+ maxSpillBytes: Volatile<number>
69
+ /** Grace period for kill escalation and inherited pipes; at most `MAX_TIMER_DELAY_MS`. */
70
+ graceMs: Volatile<number>
71
+ /**
72
+ * Explicit pwsh executable. When omitted, well-known Windows install
73
+ * locations and PATH entries are probed in order (PowerShell 7 install,
74
+ * PATH entries such as the Microsoft Store install, then Windows
75
+ * PowerShell 5.1), falling back to a bare `pwsh` resolved through PATH.
76
+ */
77
+ pwshPath: Volatile<string | undefined>
78
+ }
79
+
80
+ // Resolution lives in its own dependency-free module so the repository's
81
+ // coverage-gate probe shares the exact definition the suites use.
82
+ export { candidatePwshPaths, resolvePwshPath } from './resolve.ts'
83
+
84
+ /** Project a settled collect-mode reader into the final CollectedOutput shape. */
85
+ function finalOutput(reader: SubprocessOutputReader): CollectedOutput {
86
+ const read = reader.readFrom(0)
87
+ return {
88
+ text: read.text,
89
+ truncated: read.lossy,
90
+ ...read.spillPath !== undefined ? { spillPath: read.spillPath } : {},
91
+ }
92
+ }
93
+
94
+ function assertPositiveFinite(name: string, value: number): void {
95
+ if (!Number.isFinite(value) || value <= 0) {
96
+ throw new Error(`pwsh-local: ${name} must be a positive finite number`)
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Reject a resolved section this executor could not run with. The schema
102
+ * expresses neither "positive and finite" nor the timer bound `graceMs` has to
103
+ * fit, so a stored value that cannot be used fails at the next command.
104
+ * @param config - the live configuration, schema-valid by construction.
105
+ * @throws Error naming the field that cannot be used.
106
+ */
107
+ export function assertServiceablePwshConfig(config: Config): void {
108
+ assertPositiveFinite('timeoutMs', config.timeoutMs.get())
109
+ assertPositiveFinite('maxTimeoutMs', config.maxTimeoutMs.get())
110
+ assertPositiveFinite('maxOutputBytes', config.maxOutputBytes.get())
111
+ assertPositiveFinite('maxSpillBytes', config.maxSpillBytes.get())
112
+ assertPositiveFinite('graceMs', config.graceMs.get())
113
+ if (config.graceMs.get() > MAX_TIMER_DELAY_MS) {
114
+ throw new Error(`pwsh-local: graceMs must be no greater than ${MAX_TIMER_DELAY_MS}`)
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Local PowerShell executor over `ctx.subprocess`. Bounded output, spill
120
+ * files, and managed-range termination are the subprocess service's mechanics;
121
+ * this executor supplies their configured budgets per spawn.
122
+ */
123
+ export class PwshLocalExecutor extends ShellExecutor {
124
+ static inject = ['subprocess']
125
+
126
+ static Config = z.object({
127
+ cwd: z.string().volatile(),
128
+ timeoutMs: z.number().default(120_000).volatile(),
129
+ maxTimeoutMs: z.number().default(600_000).volatile(),
130
+ maxOutputBytes: z.number().default(64_000).volatile(),
131
+ maxSpillBytes: z.number().default(DEFAULT_MAX_SPILL_BYTES).volatile(),
132
+ graceMs: z.number().default(DEFAULT_GRACE_MS).volatile(),
133
+ pwshPath: z.string().volatile(),
134
+ })
135
+
136
+ /** The declared executable the current {@link pwshPath} was resolved from. */
137
+ private declaredPwshPath: string | undefined
138
+
139
+ /** The pwsh executable resolved from the current config. */
140
+ private resolvedPwshPath: string
141
+
142
+ /** The pwsh executable every command runs through; a changed declared path is probed again on the next read. */
143
+ get pwshPath(): string {
144
+ const declared = this.config.pwshPath.get()
145
+ if (declared !== this.declaredPwshPath) {
146
+ this.resolvedPwshPath = resolvePwshPath(declared)
147
+ this.declaredPwshPath = declared
148
+ }
149
+ return this.resolvedPwshPath
150
+ }
151
+
152
+ constructor(ctx: Context, readonly config: Config) {
153
+ super(ctx)
154
+ this.declaredPwshPath = config.pwshPath.get()
155
+ this.resolvedPwshPath = resolvePwshPath(this.declaredPwshPath)
156
+ }
157
+
158
+ /**
159
+ * Resolve a request into a fully-specified spec: fill `workdir` from
160
+ * `config.cwd` (else `process.cwd()`), and `timeoutMs` from
161
+ * `config.timeoutMs`, capped at `config.maxTimeoutMs`.
162
+ */
163
+ resolve(request: ShellExecRequest): ShellExecSpec {
164
+ assertServiceablePwshConfig(this.config)
165
+ const timeoutMs = clampTimeout(
166
+ request.timeoutMs,
167
+ this.config.timeoutMs.get(),
168
+ this.config.maxTimeoutMs.get(),
169
+ 'pwsh-local: request.timeoutMs',
170
+ )
171
+ const stdoutMaxBytes = request.stdoutMaxBytes ?? this.config.maxOutputBytes.get()
172
+ assertPositiveFinite('request.stdoutMaxBytes', stdoutMaxBytes)
173
+ return {
174
+ command: request.command,
175
+ workdir: request.workdir ?? this.config.cwd.get() ?? process.cwd(),
176
+ timeoutMs,
177
+ onExpiry: request.onExpiry ?? 'kill',
178
+ stdoutMaxBytes,
179
+ ...request.signal ? { signal: request.signal } : {},
180
+ ...request.stdin !== undefined ? { stdin: request.stdin } : {},
181
+ ...request.env !== undefined ? { env: request.env } : {},
182
+ ...request.dshEnv !== undefined ? { dshEnv: request.dshEnv } : {},
183
+ sandboxPolicy: request.sandboxPolicy,
184
+ }
185
+ }
186
+
187
+ /**
188
+ * The pwsh invocation argv for one resolved spec — the argv-level seam a
189
+ * confining subclass wraps through `ctx.sandbox.confine` (the pwsh twin of
190
+ * `dsh-bash-local`'s `executeArgv` hook; see
191
+ * `@deepseek-ai/dsh-pwsh-sandbox`).
192
+ */
193
+ protected argv(spec: ShellExecSpec): string[] {
194
+ return [this.pwshPath, '-NoLogo', '-NoProfile', '-NonInteractive', '-Command', `${ENCODING_PREAMBLE}${spec.command}`]
195
+ }
196
+
197
+ /** Map one resolved spec plus its argv onto a fully-specified subprocess spawn. */
198
+ private spawnSpec(
199
+ spec: ShellExecSpec,
200
+ stdoutMaxBytes: number,
201
+ signal: AbortSignal | undefined,
202
+ argv: readonly string[],
203
+ ): SubprocessSpawnSpec {
204
+ const collect = (maxBytes: number): SubprocessCollect =>
205
+ ({ maxBytes, spill: { maxBytes: this.config.maxSpillBytes.get() } })
206
+ return {
207
+ argv: [...argv],
208
+ cwd: spec.workdir,
209
+ stdio: {
210
+ stdin: spec.stdin !== undefined ? { data: spec.stdin } : 'ignore',
211
+ stdout: collect(stdoutMaxBytes),
212
+ stderr: collect(this.config.maxOutputBytes.get()),
213
+ },
214
+ graceMs: this.config.graceMs.get(),
215
+ signal,
216
+ env: { ...ENV_OVERRIDES, ...spec.env, ...spec.dshEnv },
217
+ }
218
+ }
219
+
220
+ /** The collect-mode readers the executor itself requested (present by construction). */
221
+ private static collected(handle: SubprocessHandle): { stdout: SubprocessOutputReader; stderr: SubprocessOutputReader } {
222
+ const { stdout, stderr } = handle.collected
223
+ /* v8 ignore start -- collect dispositions expose both readers by the seam contract; defensive. */
224
+ if (stdout === undefined || stderr === undefined) {
225
+ throw new Error('pwsh-local: subprocess implementation dropped a requested collect stream')
226
+ }
227
+ /* v8 ignore stop */
228
+ return { stdout, stderr }
229
+ }
230
+
231
+ async execute(spec: ShellExecSpec): Promise<ShellExecution> {
232
+ return this.executeArgv(spec, this.argv(spec))
233
+ }
234
+
235
+ /**
236
+ * Execute an explicit argv with the lifecycle, environment, output,
237
+ * deadline, and cancellation semantics of this executor. Subclasses use this
238
+ * after replacing the public command's shell argv at an execution boundary.
239
+ * @param spec - resolved execution settings and caller-owned command metadata.
240
+ * @param argvOrPrepare - exact argv, or preparation using the execution cancellation signal.
241
+ * @param onStarted - installs provider facts synchronously before the handle can settle.
242
+ * @returns the live execution handle; spawn rejection settles the handle as
243
+ * killed while `result()` carries the same failure as its rejection.
244
+ */
245
+ protected async executeArgv(
246
+ spec: ShellExecSpec,
247
+ argvOrPrepare: readonly string[] | ((signal: AbortSignal) => Promise<readonly string[]>),
248
+ onStarted?: (process: ShellExecution) => void,
249
+ ): Promise<ShellExecution> {
250
+ // Deadline wiring by expiry policy. Each arm supplies the spawn signal,
251
+ // the result projection's first-cause classification, and the disarm the
252
+ // settlement continuation runs. `ShellExpiryPolicy` has exactly these two
253
+ // members, so the `else` arm is `'none'`.
254
+ let spawnSignal: AbortSignal | undefined
255
+ let classify: () => { timedOut: boolean; aborted: boolean }
256
+ let disarm = (): void => {}
257
+ if (spec.onExpiry === 'kill') {
258
+ // One fused deadline combines timeout and upstream cancellation; only
259
+ // this executor's timeout reason counts as timedOut, outer deadlines as aborts.
260
+ const d = deadline(spec.signal, spec.timeoutMs, 'BASH_TIMEOUT')
261
+ spawnSignal = d.signal
262
+ classify = () => {
263
+ const timedOut = timeoutOf(d.signal, 'BASH_TIMEOUT') !== undefined
264
+ return { timedOut, aborted: d.signal.aborted && !timedOut }
265
+ }
266
+ disarm = () => { d[Symbol.dispose]() }
267
+ } else {
268
+ // No deadline: callers stop the process through kill() or spec.signal.
269
+ spawnSignal = spec.signal
270
+ classify = () => ({ timedOut: false, aborted: spec.signal?.aborted === true })
271
+ }
272
+
273
+ let argv: readonly string[] = []
274
+ let preparationTimedOut = false
275
+ if (typeof argvOrPrepare === 'function') {
276
+ const signal = spawnSignal ?? new AbortController().signal
277
+ const cancelled = Promise.withResolvers<never>()
278
+ const abort = (): void => { cancelled.reject(signal.reason) }
279
+ signal.addEventListener('abort', abort, { once: true })
280
+ try {
281
+ argv = await Promise.race([
282
+ Promise.resolve().then(() => { signal.throwIfAborted(); return argvOrPrepare(signal) }),
283
+ cancelled.promise,
284
+ ])
285
+ signal.throwIfAborted()
286
+ } catch (error) {
287
+ if (!classify().timedOut) {
288
+ disarm()
289
+ throw error
290
+ }
291
+ preparationTimedOut = true
292
+ } finally { signal.removeEventListener('abort', abort) }
293
+ } else { argv = argvOrPrepare }
294
+
295
+ // A synchronous spawn throw (pre-aborted signal, alternative subprocess
296
+ // implementations) is contained into the same settled-killed shape as an
297
+ // asynchronous spawn rejection, so execute() itself never throws for a
298
+ // spawn problem and result() carries the failure uniformly.
299
+ let running: SubprocessHandle | undefined
300
+ let syncSpawnError: { error: unknown } | undefined
301
+ try {
302
+ if (!preparationTimedOut) {
303
+ running = this.ctx.subprocess.spawn(this.spawnSpec(spec, spec.stdoutMaxBytes, spawnSignal, argv))
304
+ }
305
+ } catch (error) {
306
+ syncSpawnError = { error }
307
+ }
308
+ const emptyReader: SubprocessOutputReader = {
309
+ readFrom: () => ({ text: '', lossy: false, nextOffset: 0 }),
310
+ }
311
+ const collected = running !== undefined
312
+ ? PwshLocalExecutor.collected(running)
313
+ : { stdout: emptyReader, stderr: emptyReader }
314
+ const spawnThrow = (): unknown => (syncSpawnError as { error: unknown }).error
315
+ const spawned = preparationTimedOut
316
+ ? Promise.resolve({ exitCode: null, signal: null })
317
+ : running !== undefined ? running.done
318
+ // The original throw is preserved for callers even when it was not an Error.
319
+ // eslint-disable-next-line prefer-promise-reject-errors
320
+ : Promise.reject(spawnThrow())
321
+
322
+ // A provider rejection produces no process output, so the subprocess
323
+ // service has nothing to buffer: once the provider rejected, its
324
+ // stage-neutral note is the whole stderr stream for every reader. The
325
+ // observed reader serves it at offset 0, the consuming read folds it in
326
+ // exactly once, and the retained error is the result() projection's
327
+ // rejection.
328
+ let providerFailure: { error: unknown; note: string } | undefined
329
+ let providerFailureReported = false
330
+ const consumeProviderFailure = (): string => {
331
+ if (providerFailure === undefined || providerFailureReported) return ''
332
+ providerFailureReported = true
333
+ return providerFailure.note
334
+ }
335
+ const observedStderr: SubprocessOutputReader = {
336
+ readFrom: (fromByte) => {
337
+ if (providerFailure === undefined) return collected.stderr.readFrom(fromByte)
338
+ const note = Buffer.from(providerFailure.note, 'utf8')
339
+ return { text: note.subarray(Math.min(fromByte, note.length)).toString('utf8'), nextOffset: note.length, lossy: false }
340
+ },
341
+ }
342
+
343
+ let stdoutOffset = 0
344
+ let stderrOffset = 0
345
+ let resultPromise: Promise<ShellRunResult> | undefined
346
+ const proc: ShellExecution = {
347
+ status: 'running',
348
+ exitCode: null,
349
+ signal: null,
350
+ observed: { stdout: collected.stdout, stderr: observedStderr },
351
+ done: spawned.then((outcome) => {
352
+ // Any signal termination is killed, including a command signaling itself.
353
+ if (proc.status === 'running') {
354
+ proc.status = spawnSignal?.aborted === true || outcome.signal !== null ? 'killed' : 'completed'
355
+ }
356
+ proc.exitCode = outcome.exitCode
357
+ proc.signal = outcome.signal
358
+ this.onProcessDone(proc, collected.stderr.readFrom(0).text, false)
359
+ disarm()
360
+ }, (error: unknown) => {
361
+ // A live handle whose rejection follows this execution's own
362
+ // termination — kill() or the spawn signal's abort — reports its
363
+ // terminal outcome: a provider that terminated the range before the
364
+ // target started has no exit to report and rejects with the
365
+ // cancellation reason instead. The result projection classifies it
366
+ // from the deadline wiring; nothing is a provider failure. A
367
+ // synchronous spawn throw never produced a handle and stays a failure.
368
+ if (running !== undefined && (proc.status === 'killed' || spawnSignal?.aborted === true)) {
369
+ proc.status = 'killed'
370
+ this.onProcessDone(proc, collected.stderr.readFrom(0).text, false)
371
+ disarm()
372
+ return
373
+ }
374
+ // Provider failures settle the handle as killed and surface on stderr for every reader.
375
+ proc.status = 'killed'
376
+ let detail = 'unprintable provider failure'
377
+ try {
378
+ detail = String(error)
379
+ } catch {
380
+ // Provider-owned rejection values cannot make ShellProcess.done reject.
381
+ }
382
+ providerFailure = { error, note: `subprocess failed before reporting an outcome: ${detail}` }
383
+ this.onProcessDone(proc, providerFailure.note, true, error)
384
+ disarm()
385
+ }),
386
+ readOutput: (): ShellProcessRead => {
387
+ const out = collected.stdout.readFrom(stdoutOffset)
388
+ const err = collected.stderr.readFrom(stderrOffset)
389
+ stdoutOffset = out.nextOffset
390
+ stderrOffset = err.nextOffset
391
+
392
+ const providerFailure = consumeProviderFailure()
393
+ const failureSeparator = err.text.length > 0 && !err.text.endsWith('\n') ? '\n' : ''
394
+ const errText = err.text
395
+ + (providerFailure.length > 0 ? `${failureSeparator}${providerFailure}` : '')
396
+ // Single newline between sections: stdout chunks usually end with one
397
+ // already; add it only when missing.
398
+ const separator = out.text.length > 0 && !out.text.endsWith('\n') ? '\n' : ''
399
+ const delta = out.text
400
+ + (errText.length > 0 ? `${separator}[stderr]\n${errText}` : '')
401
+ return {
402
+ delta,
403
+ lossy: out.lossy || err.lossy,
404
+ ...out.spillPath !== undefined ? { stdoutSpillPath: out.spillPath } : {},
405
+ ...err.spillPath !== undefined ? { stderrSpillPath: err.spillPath } : {},
406
+ }
407
+ },
408
+ kill: (): boolean => {
409
+ if (proc.status !== 'running') return false
410
+ proc.status = 'killed'
411
+ running?.terminate()
412
+ return true
413
+ },
414
+ result: (): Promise<ShellRunResult> => {
415
+ resultPromise ??= proc.done.then(() => {
416
+ // Infrastructure-failure parity with the historical foreground path:
417
+ // a spawn that never produced a process rejects the projection.
418
+ if (providerFailure !== undefined) throw providerFailure.error
419
+ return {
420
+ exitCode: proc.exitCode,
421
+ signal: proc.signal,
422
+ ...classify(),
423
+ timeoutMs: spec.timeoutMs,
424
+ stdout: finalOutput(collected.stdout),
425
+ stderr: finalOutput(collected.stderr),
426
+ }
427
+ })
428
+ return resultPromise
429
+ },
430
+ }
431
+ if (!preparationTimedOut) onStarted?.(proc)
432
+ return proc
433
+ }
434
+
435
+ /**
436
+ * Settlement hook for subclasses that attach execution facts to a process.
437
+ * The base implementation is intentionally empty. Mirrored from
438
+ * `dsh-bash-local` (whose sandboxing subclass consumes the same hook); the
439
+ * pwsh-confining consumer is `@deepseek-ai/dsh-pwsh-sandbox`.
440
+ * @param _proc - the settled process handle.
441
+ * @param _stderr - the process's retained stderr tail used by subclasses for settlement classification.
442
+ * @param _providerRejected - whether the subprocess promise rejected without a direct outcome.
443
+ * @param _providerError - the provider rejection reason, which may itself be undefined.
444
+ */
445
+ protected onProcessDone(_proc: ShellProcess, _stderr: string, _providerRejected: boolean, _providerError?: unknown): void {}
446
+ }
447
+ /* jscpd:ignore-end */
448
+
449
+ export default PwshLocalExecutor
package/src/resolve.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * PowerShell executable resolution, dependency-free so non-package consumers
3
+ * (the repository's coverage-gate probe in `vitest.config.ts`) can share the
4
+ * ONE resolution definition with the executor and its suites — a probe that
5
+ * resolved differently from the code under test could exempt a file whose
6
+ * suites actually run.
7
+ *
8
+ * @module @deepseek-ai/dsh-pwsh-local/resolve
9
+ */
10
+
11
+ import { lstatSync } from 'node:fs'
12
+ import { join } from 'node:path'
13
+
14
+ /**
15
+ * Well-known Windows PowerShell install locations plus PATH entries, newest
16
+ * first. Explicitly parameterized (env) so resolution is a pure function of
17
+ * its inputs on every platform.
18
+ * @param env - the environment to probe; defaults to the process environment.
19
+ * @returns candidate `pwsh` executable paths in resolution order.
20
+ */
21
+ export function candidatePwshPaths(env: NodeJS.ProcessEnv = process.env): string[] {
22
+ const programFiles = env.ProgramFiles ?? 'C:\\Program Files'
23
+ const systemRoot = env.SystemRoot ?? 'C:\\Windows'
24
+ const candidates = [
25
+ join(programFiles, 'PowerShell', '7', 'pwsh.exe'),
26
+ ]
27
+ // Microsoft Store installs (and any user-added location) live on PATH;
28
+ // entries may carry surrounding quotes from `setx`-style definitions.
29
+ for (const entry of (env.PATH ?? '').split(';')) {
30
+ const trimmed = entry.trim().replace(/^"|"$/g, '')
31
+ if (trimmed.length === 0) continue
32
+ candidates.push(join(trimmed, 'pwsh.exe'))
33
+ }
34
+ // Windows PowerShell 5.1 remains the last-resort fallback on legacy hosts.
35
+ candidates.push(join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe'))
36
+ return candidates
37
+ }
38
+
39
+ /**
40
+ * Whether a candidate can be spawned. lstat opens the entry itself instead of
41
+ * following reparse points, so it sees the Store app execution alias where
42
+ * stat hits the target's ACL (EACCES); Node reports that alias as a symlink
43
+ * on current releases and as a plain file on older ones, and CreateProcess
44
+ * resolves either shape. A real directory never matches.
45
+ */
46
+ function candidateExists(candidate: string): boolean {
47
+ try {
48
+ const stat = lstatSync(candidate)
49
+ return stat.isFile() || stat.isSymbolicLink()
50
+ } catch {
51
+ // ENOENT (the candidate vanished between listing and probing) is the only
52
+ // expected failure; any other error names an unspawnable path, so false
53
+ // is the safe answer for it too.
54
+ return false
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Resolve the pwsh executable this executor spawns.
60
+ * @param configured - an explicit `pwshPath` config value, trusted as-is.
61
+ * @param env - the environment to probe on Windows; defaults to the process environment.
62
+ * @param platform - the platform to resolve for; defaults to the process platform.
63
+ * @returns the first existing well-known location on Windows (PowerShell 7
64
+ * install, a PATH entry such as the Microsoft Store install, then Windows
65
+ * PowerShell 5.1), else `pwsh` for PATH resolution.
66
+ */
67
+ export function resolvePwshPath(
68
+ configured?: string,
69
+ env: NodeJS.ProcessEnv = process.env,
70
+ platform: NodeJS.Platform = process.platform,
71
+ ): string {
72
+ if (configured !== undefined && configured.length > 0) return configured
73
+ if (platform === 'win32') {
74
+ for (const candidate of candidatePwshPaths(env)) {
75
+ if (candidateExists(candidate)) return candidate
76
+ }
77
+ }
78
+ return 'pwsh'
79
+ }