@deepseek-ai/dsh-sandbox-local 0.1.5-rc.1 → 0.1.6-alpha.1

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/sandbox/sandbox-local/README.md
5
- README.md: 33853b68407c2d3294ad1323e47b5473419b0e12
6
- README.zh.md: 8d62c20c65e2d7555844a1ba81e13694c5c6a8df
5
+ README.md: 15da8baaa3ab7ce476f5c45c6207657915fd7815
6
+ README.zh.md: 0e55553e1ff18ae6e91563c34eb30f4dab61f45c
package/README.md CHANGED
@@ -54,7 +54,7 @@ With the provider mounted, a command runs under the mode you resolve per call. E
54
54
 
55
55
  ### Failures and recovery
56
56
 
57
- An unsupported platform or an unusable runner fails closed: `confine()` throws `SANDBOX_UNAVAILABLE` and names the runner options for the platform, and the consumer surfaces that error rather than running the command unconfined. A runner that starts but refuses its profile is identified by its fatal stderr signature and exit code, so a broken sandbox is not mistaken for a denied command. The `runnerCommand` override is an operator assertion: it skips functional probes and assumes the configured runner implements the bwrap-compatible profile honestly.
57
+ An unsupported platform or an unusable runner fails closed: `confine()` rejects with `SANDBOX_UNAVAILABLE` and names the runner options for the platform, and the consumer surfaces that error rather than running the command unconfined. A runner that starts but refuses its profile is identified by its fatal stderr signature and exit code, so a broken sandbox is not mistaken for a denied command. The `runnerCommand` override is an operator assertion: it skips functional probes and assumes the configured runner implements the bwrap-compatible profile honestly.
58
58
 
59
59
  -----
60
60
 
@@ -80,6 +80,8 @@ The Seatbelt profile is allow-default with `(deny file-write*)` plus write allow
80
80
 
81
81
  The Windows rung keeps one deterministic write SID and standing ACE per workspace, while every live session/workspace pair gets a random private temp directory with a distinct SID and revocable ACE — sessions sharing a workspace share its intended write authority without inheriting one another's temp authority. A fresh provider always chooses a new temp path and SID, so crash residue cannot block or authorize a resumed session. The rung reports `partial` enforcement because the restricted token must retain Everyone and NTFS hard links alias one file object across paths.
82
82
 
83
+ When the built ACL runner is absent, source launch pins the `tsx/esm/api` loader and TypeScript path mapping to this installation. The command's working directory and ambient `TSX_TSCONFIG_PATH` cannot select the runner's source dependencies.
84
+
83
85
  ### Denial and runner-failure dialects
84
86
 
85
87
  Each runner's kernel speaks its own denial dialect, carried on every wrap as `denialSignatures`, and `runnerFailureRules` give each runner's fatal signature, so consumers classify a runner refusal before checking denial signatures. The exact strings and exit codes live in [`src/index.ts`](src/index.ts).
package/README.zh.md CHANGED
@@ -25,7 +25,7 @@ kind: "package-reference"
25
25
  <a id="use-this-package"></a>
26
26
  ## 使用本包
27
27
 
28
- 在 `ctx.sandbox` 后挂载此提供方并配一个受限执行器,执行器 spawn 的每条命令都会在你解析的策略下受限运行。随附的 [base bundle](../../bundle/base/cordis.patch.yml)拥有默认策略与执行器接线。
28
+ 在 `ctx.sandbox` 后挂载此提供方并配一个受限执行器,执行器 spawn 的每条命令都会在你解析的策略下受限运行。随附的[基础组合包](../../bundle/base/cordis.patch.yml)拥有默认策略与执行器接线。
29
29
 
30
30
  ### 何时选择
31
31
 
@@ -54,7 +54,7 @@ kind: "package-reference"
54
54
 
55
55
  ### 失败与恢复
56
56
 
57
- 不受支持的平台或不可用的 runner 会快速失败:`confine()` 抛出 `SANDBOX_UNAVAILABLE` 并列出该平台的 runner 选项,消费方会呈现该错误,而不是让命令不受限制地运行。启动后拒绝自身 profile 的 runner 由其致命 stderr 签名与退出码识别,因此损坏的沙箱不会被误认为被拒绝的命令。`runnerCommand` 覆盖是操作方断言:它跳过功能探测,并假定配置的 runner 诚实实现与 bwrap 兼容的 profile。
57
+ 不受支持的平台或不可用的 runner 会拒绝执行:`confine()` 以 `SANDBOX_UNAVAILABLE` 拒绝 并列出该平台的 runner 选项,消费方会呈现该错误,而不是让命令不受限制地运行。启动后拒绝自身 profile 的 runner 由其致命 stderr 签名与退出码识别,因此损坏的沙箱不会被误认为被拒绝的命令。`runnerCommand` 覆盖是操作方断言:它跳过功能探测,并假定配置的 runner 诚实实现与 bwrap 兼容的 profile。
58
58
 
59
59
  -----
60
60
 
@@ -68,7 +68,7 @@ kind: "package-reference"
68
68
 
69
69
  ### runner 选择
70
70
 
71
- 选择按平台优先、探测其次:每个平台都有 runner 链(`linux`:`bwrap` 再 Landlock;`darwin`:Seatbelt;`win32`:ACL 受限令牌 runner)。唯一候选直接选择、不探测;竞争候选按链序各执行一次功能探测,首个可用结论在提供方生命周期内缓存。没有链的平台、或链上所有探测都失败时,平台不可用,并在 `confine()` 处快速失败。
71
+ 选择按平台优先、探测其次:每个平台都有 runner 链(`linux`:`bwrap` 再 Landlock;`darwin`:Seatbelt;`win32`:ACL 受限令牌 runner)。唯一候选直接选择、不探测;竞争候选按链序各执行一次功能探测,首个可用结论在提供方生命周期内缓存。没有链的平台、或链上所有探测都失败时,平台不可用,`confine()` 会拒绝执行。
72
72
 
73
73
  ### 平台 profile
74
74
 
@@ -80,6 +80,8 @@ Seatbelt profile 默认允许,带 `(deny file-write*)` 与来自共享 `writab
80
80
 
81
81
  Windows 档为每个工作区保留一个确定性写入 SID 和常驻 ACE,同时为每个活跃的会话/工作区对分配一个随机私有临时目录,以及不同的 SID 和可撤销 ACE——共享工作区的会话共享其预期写权限,却不会继承彼此的临时目录权限。新的提供方总会选择新的临时路径和 SID,因此崩溃残留既无法阻止恢复的会话,也无法向其授权。该档报告 `partial` 强制执行,因为受限令牌必须保留 Everyone,且 NTFS 硬链接会把同一文件对象别名为多个路径。
82
82
 
83
+ 构建后的 ACL runner 缺失时,源码启动将 `tsx/esm/api` 加载器和 TypeScript 路径映射固定到本安装目录。命令的工作目录和环境中的 `TSX_TSCONFIG_PATH` 无法选择 runner 的源码依赖。
84
+
83
85
  ### 拒绝与 runner 失败方言
84
86
 
85
87
  每个 runner 的内核都有自己的拒绝方言,随每次包装以 `denialSignatures` 携带,`runnerFailureRules` 则给出每个 runner 的致命签名,因此消费方先分类 runner 拒绝,再检查拒绝签名。精确的字符串与退出码位于 [`src/index.ts`](src/index.ts)。
@@ -90,7 +92,7 @@ Windows 档为每个工作区保留一个确定性写入 SID 和常驻 ACE,同
90
92
  |---|---|
91
93
  | [`src/index.ts`](src/index.ts) | 插件入口:runner 链选择、功能探测、逐调用包装、ACL 授权生命周期 |
92
94
  | [`src/profiles.ts`](src/profiles.ts) | 各平台 profile 构建器:bwrap 挂载、Landlock 授权、Seatbelt SBPL |
93
- | — | 不发布运行时不变式伴生入口;故障关闭约定在包装边界强制执行。 |
95
+ | — | 不发布运行时不变式伴生入口;除所属 seam 强制执行的约定外,本包不公开独立的事件序列或可变数据关系。 |
94
96
 
95
97
  </details>
96
98
 
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ import { join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { LAUNCHER_BIN, LAUNCHER_FAILURE_EXIT, grantArgs, launcherPath, probe } from "@deepseek-ai/node-addon-system/landlock-run";
7
7
  import z from "@deepseek-ai/schemastery";
8
- import { SandboxProvider, SandboxUnavailableError, writableRoots } from "@deepseek-ai/dsh-sandbox";
8
+ import { SandboxProvider, SandboxUnavailableError, canonicalPath, writableRoots } from "@deepseek-ai/dsh-sandbox";
9
9
  import { AclWriteGrant, assertTempRootOutsideWorkspace, tempWriteSid, workspaceWriteSid } from "@deepseek-ai/dsh-sandbox-windows-acl";
10
10
  import { assertNever } from "@deepseek-ai/dsh-util-values";
11
11
  //#region lib/types/profiles.js
@@ -209,7 +209,8 @@ const DENIAL_SIGNATURES = {
209
209
  "windows-acl": [
210
210
  "access is denied",
211
211
  "access to the path",
212
- "permission denied"
212
+ "permission denied",
213
+ "operation not permitted"
213
214
  ],
214
215
  runnerCommand: ["read-only file system", "permission denied"]
215
216
  };
@@ -291,12 +292,18 @@ var LocalSandboxProvider = class extends SandboxProvider {
291
292
  *
292
293
  * @param argv - the exact argv the caller is about to spawn.
293
294
  * @param policy - the file-effect policy this execution runs under.
295
+ * @param signal - cancellation before policy resolution or grant creation.
294
296
  * @returns the wrapped argv plus the selected backend's enforcement completeness, denial
295
297
  * signatures, and structured runner-failure rules; throws the fail-closed
296
298
  * `SANDBOX_UNAVAILABLE` error when the platform has no usable runner.
297
299
  */
298
- confine(argv, policy) {
299
- if (this.runnerCommand !== void 0) return {
300
+ async confine(argv, policy, signal) {
301
+ signal?.throwIfAborted();
302
+ policy = {
303
+ ...policy,
304
+ workspaceRoot: canonicalPath(policy.workspaceRoot)
305
+ };
306
+ if (this.runnerCommand !== void 0) return Promise.resolve({
300
307
  argv: [
301
308
  ...this.runnerCommand,
302
309
  ...bwrapProfileArgs(policy),
@@ -306,18 +313,19 @@ var LocalSandboxProvider = class extends SandboxProvider {
306
313
  enforcement: "full",
307
314
  denialSignatures: DENIAL_SIGNATURES.runnerCommand,
308
315
  runnerFailureRules: [{ fatalSignatures: this.configuredRunnerFailureSignatures }]
309
- };
316
+ });
310
317
  const selected = this.selectRunner(policy.mode);
311
- return {
318
+ const runnerArgv = this.runnerArgv(selected.runner, policy);
319
+ return Promise.resolve({
312
320
  argv: [
313
- ...this.runnerArgv(selected.runner, policy),
321
+ ...runnerArgv,
314
322
  "--",
315
323
  ...argv
316
324
  ],
317
325
  enforcement: selected.enforcement,
318
326
  denialSignatures: DENIAL_SIGNATURES[selected.runner],
319
327
  runnerFailureRules: RUNNER_FAILURE_RULES[selected.runner]
320
- };
328
+ });
321
329
  }
322
330
  /** The selected rung's runner invocation (program + profile arguments) for one policy. */
323
331
  runnerArgv(runner, policy) {
@@ -518,6 +526,8 @@ var LocalSandboxProvider = class extends SandboxProvider {
518
526
  /**
519
527
  * The windows-acl runner argv prefix: the built lib/runner.js entry when
520
528
  * present (production), else the package source through tsx (development).
529
+ * Pin the source loader and TypeScript paths to this installation, independently
530
+ * of target cwd or environment overrides.
521
531
  * The prefix stays `[node, runner, ...]` — a future native-exe runner keeps
522
532
  * the same argv contract and only swaps these entries.
523
533
  */
@@ -527,10 +537,12 @@ var LocalSandboxProvider = class extends SandboxProvider {
527
537
  const builtEntry = this.internals.windowsAclRunnerEntry ?? fileURLToPath(import.meta.resolve("@deepseek-ai/dsh-sandbox-windows-acl/runner"));
528
538
  if (existsSync(builtEntry)) return [process.execPath, builtEntry];
529
539
  const sourceEntry = fileURLToPath(import.meta.resolve("@deepseek-ai/dsh-sandbox-windows-acl/src/runner.ts"));
540
+ const sourceConfig = fileURLToPath(new URL("../../../../tsconfig.base.json", import.meta.url));
541
+ const registration = `import { register } from ${JSON.stringify(import.meta.resolve("tsx/esm/api"))}; register({ tsconfig: ${JSON.stringify(sourceConfig)} });`;
530
542
  return [
531
543
  process.execPath,
532
544
  "--import",
533
- "tsx/esm",
545
+ `data:text/javascript,${encodeURIComponent(registration)}`,
534
546
  sourceEntry
535
547
  ];
536
548
  }
@@ -110,11 +110,12 @@ export declare class LocalSandboxProvider extends SandboxProvider {
110
110
  *
111
111
  * @param argv - the exact argv the caller is about to spawn.
112
112
  * @param policy - the file-effect policy this execution runs under.
113
+ * @param signal - cancellation before policy resolution or grant creation.
113
114
  * @returns the wrapped argv plus the selected backend's enforcement completeness, denial
114
115
  * signatures, and structured runner-failure rules; throws the fail-closed
115
116
  * `SANDBOX_UNAVAILABLE` error when the platform has no usable runner.
116
117
  */
117
- confine(argv: readonly string[], policy: SandboxPolicy): ConfinedArgv;
118
+ confine(argv: readonly string[], policy: SandboxPolicy, signal?: AbortSignal): Promise<ConfinedArgv>;
118
119
  /** The selected rung's runner invocation (program + profile arguments) for one policy. */
119
120
  private runnerArgv;
120
121
  /**
@@ -175,6 +176,8 @@ export declare class LocalSandboxProvider extends SandboxProvider {
175
176
  /**
176
177
  * The windows-acl runner argv prefix: the built lib/runner.js entry when
177
178
  * present (production), else the package source through tsx (development).
179
+ * Pin the source loader and TypeScript paths to this installation, independently
180
+ * of target cwd or environment overrides.
178
181
  * The prefix stays `[node, runner, ...]` — a future native-exe runner keeps
179
182
  * the same argv contract and only swaps these entries.
180
183
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-sandbox-local",
3
3
  "description": "Local process-sandbox backends for the DeepSeek Harness sandbox seam: bwrap, the npm-distributed landlock-run launcher, macOS Seatbelt, or the Windows ACL restricted-token runner — functionally probed, fail-closed",
4
- "version": "0.1.5-rc.1",
4
+ "version": "0.1.6-alpha.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -28,20 +28,20 @@
28
28
  "license": "MIT",
29
29
  "peerDependencies": {
30
30
  "@deepseek-ai/cordis": "^4.0.2",
31
- "@deepseek-ai/dsh-llm": "^0.1.5-rc.1",
32
- "@deepseek-ai/dsh-sandbox": "^0.1.5-rc.1",
33
- "@deepseek-ai/dsh-session": "^0.1.5-rc.1"
31
+ "@deepseek-ai/dsh-llm": "^0.1.6-alpha.1",
32
+ "@deepseek-ai/dsh-sandbox": "^0.1.6-alpha.1",
33
+ "@deepseek-ai/dsh-session": "^0.1.6-alpha.1"
34
34
  },
35
35
  "dependencies": {
36
- "@deepseek-ai/dsh-util-values": "^0.1.5-rc.1",
37
- "@deepseek-ai/dsh-sandbox-windows-acl": "^0.1.5-rc.1",
36
+ "@deepseek-ai/dsh-sandbox-windows-acl": "^0.1.6-alpha.1",
37
+ "@deepseek-ai/dsh-util-values": "^0.1.6-alpha.1",
38
38
  "@deepseek-ai/node-addon-system": "^0.1.2",
39
39
  "@deepseek-ai/schemastery": "^3.18.2"
40
40
  },
41
41
  "devDependencies": {
42
+ "@deepseek-ai/dsh-llm": "^0.1.6-alpha.1",
42
43
  "@deepseek-ai/cordis": "^4.0.2",
43
- "@deepseek-ai/dsh-llm": "^0.1.5-rc.1",
44
- "@deepseek-ai/dsh-session": "^0.1.5-rc.1",
45
- "@deepseek-ai/dsh-sandbox": "^0.1.5-rc.1"
44
+ "@deepseek-ai/dsh-sandbox": "^0.1.6-alpha.1",
45
+ "@deepseek-ai/dsh-session": "^0.1.6-alpha.1"
46
46
  }
47
47
  }