@deepseek-ai/dsh-pwsh-sandbox 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":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAgBjE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,MAAM,GACd,OAAO,CAUT;AAED,sEAAsE;AACtE,UAAU,kBAAkB;IAC1B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE7F;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,iBAAiB,EAAE,GAClC,kBAAkB,GAAG,SAAS,CAkBhC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAIhH"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAwB;AACxB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CA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E,CAAC,YAAY,IAAI,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC;gBACxF,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1C,CAAA;QACH,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAA;IACpE,CAAC;IAED;;;;;;;;OAQG;IACK,OAAO,CAAC,IAAmB,EAAE,MAAqB,EAAE,MAAoB;QAC9E,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAClE,CAAC;;AAEH,sBAAsB;AAEtB,eAAe,mBAAmB,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-pwsh-sandbox",
3
3
  "description": "Sandbox-consuming implementation of the DeepSeek Harness PowerShell executor seam (confines every command via ctx.sandbox, reports denial/enforcement result facts)",
4
- "version": "0.2.2-alpha.3",
4
+ "version": "0.2.2-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,24 +25,27 @@
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-pwsh-local": "0.2.2-alpha.3",
34
- "@deepseek-ai/dsh-sandbox": "0.2.2-alpha.3",
35
- "@deepseek-ai/dsh-sandbox-policy": "0.2.2-alpha.3",
36
- "@deepseek-ai/cordis": "~4.0.6-alpha.2"
35
+ "@deepseek-ai/dsh-shell": "0.2.2-rc.2",
36
+ "@deepseek-ai/dsh-pwsh-local": "0.2.2-rc.2",
37
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
38
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.2",
39
+ "@deepseek-ai/cordis": "~4.1.0"
37
40
  },
38
41
  "devDependencies": {
39
- "@deepseek-ai/dsh-shell": "0.2.2-alpha.3",
40
- "@deepseek-ai/dsh-pwsh-local": "0.2.2-alpha.3",
41
- "@deepseek-ai/dsh-sandbox": "0.2.2-alpha.3",
42
- "@deepseek-ai/dsh-sandbox-local": "0.2.2-alpha.3",
43
- "@deepseek-ai/dsh-sandbox-policy": "0.2.2-alpha.3",
44
- "@deepseek-ai/dsh-session-projection": "0.2.2-alpha.3",
45
- "@deepseek-ai/dsh-subprocess-local": "0.2.2-alpha.3",
46
- "@deepseek-ai/cordis": "~4.0.6-alpha.2"
42
+ "@deepseek-ai/dsh-shell": "0.2.2-rc.2",
43
+ "@deepseek-ai/dsh-pwsh-local": "0.2.2-rc.2",
44
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
45
+ "@deepseek-ai/dsh-sandbox-local": "0.2.2-rc.2",
46
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.2",
47
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
48
+ "@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.2",
49
+ "@deepseek-ai/cordis": "~4.1.0"
47
50
  }
48
51
  }
package/src/helpers.ts ADDED
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Internal sandbox-result classification helpers — deliberate call-for-call
3
+ * mirror of `@deepseek-ai/dsh-bash-sandbox/src/helpers.ts` (the pwsh twin of
4
+ * the bash consumer shares the identical classification dialect).
5
+ *
6
+ * @module @deepseek-ai/dsh-pwsh-sandbox/helpers
7
+ */
8
+
9
+ /* jscpd:ignore-start */
10
+ import { accessSync, constants, statSync } from 'node:fs'
11
+ import type { ShellRunResult } from '@deepseek-ai/dsh-shell'
12
+ import type { RunnerFailureRule } from '@deepseek-ai/dsh-sandbox'
13
+
14
+ /** Node-local spawn codes proven to identify executable resolution or permission failure. */
15
+ const EXECUTABLE_SPAWN_CODES = new Set(['EACCES', 'ENOENT'])
16
+
17
+ /** Whether the caller-owned spawn cwd can be entered. */
18
+ function isUsableWorkdir(path: string): boolean {
19
+ try {
20
+ if (!statSync(path).isDirectory()) return false
21
+ accessSync(path, constants.X_OK)
22
+ return true
23
+ } catch {
24
+ return false
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Attribute only Node ENOENT/EACCES failures whose path or syscall identifies argv[0]
30
+ * after independently ruling out the caller-owned cwd. A supplied error path
31
+ * must exactly identify the runner; without one, the syscall must. With a
32
+ * usable cwd, these codes describe resolution or execute permission for that
33
+ * argv[0] or its shebang interpreter.
34
+ * The workdir is checked at classification time, not atomically with spawn;
35
+ * concurrent path replacement may change attribution but cannot permit an
36
+ * unconfined execution.
37
+ * @param error - the original spawn rejection.
38
+ * @param runnerProgram - provider argv[0], the executable that establishes confinement.
39
+ * @param workdir - the caller-owned spawn cwd, checked independently for usability.
40
+ * @returns whether the rejection has executable-specific runner evidence.
41
+ */
42
+ export function isRunnerSpawnFailure(
43
+ error: unknown,
44
+ runnerProgram: string | undefined,
45
+ workdir: string,
46
+ ): boolean {
47
+ if (runnerProgram === undefined || !isUsableWorkdir(workdir)) return false
48
+ if (typeof error !== 'object' || error === null) return false
49
+ const { code, path, syscall } = error as { code?: unknown; path?: unknown; syscall?: unknown }
50
+ if (typeof code !== 'string' || !EXECUTABLE_SPAWN_CODES.has(code)) return false
51
+ if (typeof syscall !== 'string') return false
52
+ const exactSyscall = `spawn ${runnerProgram}`
53
+ if (path === undefined) return syscall === exactSyscall
54
+ if (typeof path !== 'string' || path.length === 0 || path !== runnerProgram) return false
55
+ return syscall === 'spawn' || syscall === exactSyscall
56
+ }
57
+
58
+ /** Fatal runner evidence retained for infrastructure-error detail. */
59
+ interface RunnerFailureMatch {
60
+ /** The original stderr line that matched a fatal signature. */
61
+ detail: string
62
+ }
63
+
64
+ /**
65
+ * Classify a failed run against the selected backend's denial dialect.
66
+ * @param result - settled foreground run.
67
+ * @param signatures - case-insensitive denial substrings from the active wrap.
68
+ * @returns whether the failed run matches that denial dialect.
69
+ */
70
+ export function classifyDenial(result: ShellRunResult, signatures: readonly string[]): boolean {
71
+ return matchesSignature(result.exitCode, result.stderr.text, signatures)
72
+ }
73
+
74
+ /**
75
+ * Classify one settled process against the selected backend's structured
76
+ * runner-failure rules. Each rule requires a nonzero exit, its optional
77
+ * exit-code gate, and a fatal signature on one stderr line after exact
78
+ * informational lines are excluded.
79
+ * @param exitCode - process exit code; null means signal termination.
80
+ * @param stderr - collected stderr text, left unchanged.
81
+ * @param rules - structured runner-failure rules from the active wrap.
82
+ * @returns the first matching fatal line, or undefined when evidence is insufficient.
83
+ */
84
+ export function classifyRunnerFailure(
85
+ exitCode: number | null,
86
+ stderr: string,
87
+ rules: readonly RunnerFailureRule[],
88
+ ): RunnerFailureMatch | undefined {
89
+ if (exitCode === null || exitCode === 0) return undefined
90
+ const lines = stderr.split(/\r?\n/)
91
+ for (const rule of rules) {
92
+ if (rule.allowedExitCodes !== undefined && !rule.allowedExitCodes.includes(exitCode)) continue
93
+ const informationalLines = new Set((rule.informationalLines ?? []).map(line => line.toLowerCase()))
94
+ // An empty or whitespace-only substring is not meaningful runner evidence.
95
+ // Ignore it while keeping any valid signatures beside it active.
96
+ const fatalSignatures = rule.fatalSignatures
97
+ .filter(signature => signature.trim().length > 0)
98
+ .map(signature => signature.toLowerCase())
99
+ for (const line of lines) {
100
+ const lowered = line.toLowerCase()
101
+ if (informationalLines.has(lowered)) continue
102
+ if (fatalSignatures.some(signature => lowered.includes(signature))) return { detail: line }
103
+ }
104
+ }
105
+ return undefined
106
+ }
107
+
108
+ /**
109
+ * Match a non-zero exit against case-insensitive stderr signatures.
110
+ * @param exitCode - process exit code; null means signal termination.
111
+ * @param stderr - collected stderr text.
112
+ * @param signatures - substrings identifying the selected backend's dialect.
113
+ * @returns whether this is a non-zero exit whose stderr matches a signature.
114
+ */
115
+ export function matchesSignature(exitCode: number | null, stderr: string, signatures: readonly string[]): boolean {
116
+ if (exitCode === null || exitCode === 0) return false
117
+ const lowered = stderr.toLowerCase()
118
+ return signatures.some(signature => lowered.includes(signature.toLowerCase()))
119
+ }
120
+ /* jscpd:ignore-end */
package/src/index.ts ADDED
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Sandbox-consuming PowerShell executor — the pwsh twin of
3
+ * `@deepseek-ai/dsh-bash-sandbox`. It wraps the exact local pwsh argv through
4
+ * `ctx.sandbox` (which on Windows resolves to the ACL restricted-token runner
5
+ * chain), inherits local process mechanics, and reports the selected mode,
6
+ * enforcement, and denial facts. Positive runner-executable evidence
7
+ * identifies a broken confinement runner: foreground calls throw
8
+ * `SANDBOX_UNAVAILABLE`, while background processes carry `runnerFailed`;
9
+ * other provider rejections retain stage-neutral local-executor semantics. The
10
+ * tool layer owns the escalation approval flow through `ctx.approval`; this
11
+ * executor reports the sandbox facts the tool renders.
12
+ * @module @deepseek-ai/dsh-pwsh-sandbox
13
+ */
14
+
15
+ import { Context } from '@deepseek-ai/cordis'
16
+ import type { ShellExecRequest, ShellExecSpec, ShellExecution, ShellProcess, ShellRunResult } from '@deepseek-ai/dsh-shell'
17
+ import { SandboxUnavailableError } from '@deepseek-ai/dsh-sandbox'
18
+ import type {
19
+ ConfinedArgv,
20
+ ConfinedSandboxMode,
21
+ RunnerFailureRule,
22
+ SandboxEnforcement,
23
+ SandboxExecutionPolicy,
24
+ SandboxMode,
25
+ SandboxPolicy,
26
+ } from '@deepseek-ai/dsh-sandbox'
27
+ import type {} from '@deepseek-ai/dsh-sandbox-policy'
28
+ import { PwshLocalExecutor } from '@deepseek-ai/dsh-pwsh-local'
29
+ import type { Config as LocalConfig } from '@deepseek-ai/dsh-pwsh-local'
30
+ import { classifyDenial, classifyRunnerFailure, isRunnerSpawnFailure, matchesSignature } from './helpers.ts'
31
+
32
+ /**
33
+ * Plugin config: the local executor's knobs, verbatim. The sandbox policy —
34
+ * the default mode and fallback `workspace-write` root — is NOT here: it lives
35
+ * on `ctx.sandboxPolicy` (`@deepseek-ai/dsh-sandbox-policy`), which resolves
36
+ * each calling session's mode and cwd for every enforcing capability. The
37
+ * runner choice is likewise the `ctx.sandbox` provider's config, not this
38
+ * executor's.
39
+ */
40
+ export type Config = LocalConfig
41
+
42
+ /**
43
+ * Registers as `ctx.shell` in place of the local pwsh executor and requires a
44
+ * `ctx.sandbox` provider plus `ctx.sandboxPolicy`; the tool layer carries the
45
+ * sandbox denial rendering and escalation surface (see the
46
+ * pwsh-tool-and-executor Agent Note). Tool calls pass the calling session's
47
+ * resolved policy; direct calls fall back to deployment policy.
48
+ * `result.sandbox` reports the mode, enforcement, and denial facts the tool
49
+ * renders.
50
+ */
51
+ /* jscpd:ignore-start -- deliberate call-for-call mirror of bash-sandbox's executor (pwsh-tool-and-executor Agent Note) */
52
+ export class SandboxPwshExecutor extends PwshLocalExecutor {
53
+ static override inject = ['subprocess', 'sandbox', 'sandboxPolicy']
54
+
55
+ // No own Config: the sandbox default (mode + workspaceRoot) moved to
56
+ // ctx.sandboxPolicy, so this executor inherits PwshLocalExecutor's Config
57
+ // verbatim (the config catalog walks the inherited static).
58
+
59
+ private readonly mode: SandboxMode
60
+ /**
61
+ * Per-process confinement facts retained until settlement. Providers may
62
+ * vary enforcement and diagnostic dialect between overlapping calls, so a
63
+ * shared latest-wrap value would classify a process against the wrong facts.
64
+ * Unconfined processes have no entry.
65
+ */
66
+ private readonly processFacts = new Map<ShellProcess, {
67
+ mode: ConfinedSandboxMode
68
+ enforcement: SandboxEnforcement
69
+ denialSignatures: readonly string[]
70
+ runnerFailureRules: readonly RunnerFailureRule[]
71
+ runnerProgram: string | undefined
72
+ workdir: string
73
+ }>()
74
+
75
+ constructor(ctx: Context, config: Config) {
76
+ super(ctx, config)
77
+ // The default mode is the capability fact used for schema advertisement;
78
+ // actual tool executions carry their resolved per-call policy.
79
+ this.mode = ctx.sandboxPolicy.defaultMode
80
+ }
81
+
82
+ /** The configured default mode — the capability fact the tool layer reads. */
83
+ override get sandboxMode(): SandboxMode {
84
+ return this.mode
85
+ }
86
+
87
+ /**
88
+ * Stamp a complete per-call policy onto the spec. Tool calls supply the
89
+ * calling session's resolved mode and root; lower-level callers fall back to
90
+ * the deployment policy.
91
+ */
92
+ override resolve(request: ShellExecRequest): ShellExecSpec {
93
+ return { ...super.resolve(request), sandboxPolicy: request.sandboxPolicy ?? this.ctx.sandboxPolicy.resolve() }
94
+ }
95
+
96
+ override async execute(spec: ShellExecSpec): Promise<ShellExecution> {
97
+ const policy = spec.sandboxPolicy as SandboxExecutionPolicy
98
+ const { mode } = policy
99
+ if (mode === 'danger-full-access') {
100
+ return SandboxPwshExecutor.decorateResult(
101
+ await super.execute(spec),
102
+ result => ({ ...result, sandbox: { mode, denied: false } }),
103
+ )
104
+ }
105
+ let confined: ConfinedArgv | undefined
106
+ const ex = await this.executeArgv(spec, async (signal) => {
107
+ const prepared = await this.confine(spec, { ...policy, mode }, signal)
108
+ signal.throwIfAborted()
109
+ confined = prepared
110
+ return prepared.argv
111
+ }, (process) => {
112
+ const facts = confined as ConfinedArgv
113
+ this.processFacts.set(process, {
114
+ mode,
115
+ enforcement: facts.enforcement,
116
+ denialSignatures: facts.denialSignatures,
117
+ runnerFailureRules: facts.runnerFailureRules,
118
+ runnerProgram: facts.argv[0],
119
+ workdir: spec.workdir,
120
+ })
121
+ })
122
+ return SandboxPwshExecutor.decorateResult(ex, (result) => {
123
+ if (confined === undefined) return { ...result, sandbox: { mode, denied: false } }
124
+ const { enforcement, denialSignatures, runnerFailureRules } = confined
125
+ // Runner failure outranks denial because the command did not run. Carry
126
+ // the matched fatal line, not an informational line that preceded it.
127
+ const runnerFailure = classifyRunnerFailure(result.exitCode, result.stderr.text, runnerFailureRules)
128
+ if (runnerFailure !== undefined) {
129
+ throw new SandboxUnavailableError(mode, runnerFailure.detail)
130
+ }
131
+ return { ...result, sandbox: { mode, denied: classifyDenial(result, denialSignatures), enforcement } }
132
+ }, (error) => {
133
+ // An upstream abort remains cancellation even when it prevents spawn.
134
+ if (spec.signal?.aborted === true) spec.signal.throwIfAborted()
135
+ if (confined !== undefined && isRunnerSpawnFailure(error, confined.argv[0], spec.workdir)) {
136
+ throw new SandboxUnavailableError(mode, String(error))
137
+ }
138
+ throw error
139
+ })
140
+ }
141
+
142
+ /**
143
+ * Decorate the handle's foreground projection in place, memoized once. The
144
+ * handle keeps its identity (never wrapped in a second object) because the
145
+ * per-process facts and `onProcessDone` key on the exact instance.
146
+ */
147
+ private static decorateResult(
148
+ ex: ShellExecution,
149
+ map: (result: ShellRunResult) => ShellRunResult,
150
+ mapError?: (error: unknown) => never,
151
+ ): ShellExecution {
152
+ const base = ex.result.bind(ex)
153
+ let decorated: Promise<ShellRunResult> | undefined
154
+ ex.result = () => {
155
+ decorated ??= base().then(map, mapError)
156
+ return decorated
157
+ }
158
+ return ex
159
+ }
160
+
161
+ /**
162
+ * Stamp per-process sandbox facts before `done` settles. Full-access
163
+ * processes have no facts; signal deaths are not denials.
164
+ */
165
+ protected override onProcessDone(proc: ShellProcess, stderr: string, providerRejected: boolean, providerError?: unknown): void {
166
+ const facts = this.processFacts.get(proc)
167
+ if (facts !== undefined) {
168
+ this.processFacts.delete(proc)
169
+ // A provider rejection exposes no public failure stage. Attribute it to
170
+ // the confinement runner only when the error independently names argv[0].
171
+ // Otherwise settled runner failure outranks denial-like diagnostics.
172
+ const runnerFailed = providerRejected
173
+ ? isRunnerSpawnFailure(providerError, facts.runnerProgram, facts.workdir)
174
+ : classifyRunnerFailure(proc.exitCode, stderr, facts.runnerFailureRules) !== undefined
175
+ proc.sandbox = {
176
+ mode: facts.mode,
177
+ denied: !runnerFailed && matchesSignature(proc.exitCode, stderr, facts.denialSignatures),
178
+ enforcement: facts.enforcement,
179
+ ...(runnerFailed ? { runnerFailed } : {}),
180
+ }
181
+ }
182
+ super.onProcessDone(proc, stderr, providerRejected, providerError)
183
+ }
184
+
185
+ /**
186
+ * Wrap one pwsh invocation via the `ctx.sandbox` provider. Provider errors
187
+ * propagate unchanged; the returned argv is handed directly to the local
188
+ * executor's subprocess path.
189
+ * @param spec - resolved execution spec whose pwsh argv is confined.
190
+ * @param policy - resolved confined execution policy.
191
+ * @param signal - cancellation of confinement preparation.
192
+ * @returns the provider's exact argv and settlement-classification facts.
193
+ */
194
+ private confine(spec: ShellExecSpec, policy: SandboxPolicy, signal?: AbortSignal): Promise<ConfinedArgv> {
195
+ return this.ctx.sandbox.confine(this.argv(spec), policy, signal)
196
+ }
197
+ }
198
+ /* jscpd:ignore-end */
199
+
200
+ export default SandboxPwshExecutor