@deepseek-ai/dsh-sandbox-local 0.1.1-rc.1 → 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 +2 -2
- package/README.md +115 -11
- package/README.zh.md +120 -16
- package/lib/index.js +3 -3
- package/package.json +14 -13
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:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 563ceb649d17045936f92709e76ae32aa7e75407
|
|
6
|
+
README.zh.md: fc72d8766da04dee379c17e0a43fe7aac36bc6ee
|
package/README.md
CHANGED
|
@@ -1,42 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Local per-platform sandbox backends for users and maintainers choosing, configuring, or debugging process confinement on Linux, macOS, or Windows."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# @deepseek-ai/dsh-sandbox-local
|
|
2
7
|
|
|
3
8
|
English | [中文](README.zh.md)
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
`dsh-sandbox-local` provides the platform confinement backends behind `ctx.sandbox`: Linux runs commands under `bwrap` when that works, otherwise under the Landlock launcher; macOS uses Seatbelt (`sandbox-exec`); Windows uses the ACL restricted-token runner. It selects one runner per host, so every command — and everything it spawns — runs confined. When no runner is usable the provider fails closed with `SANDBOX_UNAVAILABLE` — a command never silently runs unconfined. Each wrap reports how completely the backend enforces the mode (`full` or `partial`) plus the backend's denial signatures, so consumers can tell a broken sandbox apart from a denied command. Mount it behind `ctx.sandbox` with a confined executor to give every bash or pwsh call a confined default.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
6
15
|
|
|
7
|
-
|
|
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)
|
|
8
22
|
|
|
9
|
-
|
|
23
|
+
-----
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## Use this package
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
Mount this provider behind `ctx.sandbox` and a confined executor, and every command the executor spawns runs confined under the policy you resolve. The shipped [base bundle](../../bundle/base/cordis.patch.yml) owns the default policy and executor wiring.
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
### When to choose it
|
|
16
31
|
|
|
17
|
-
|
|
32
|
+
Choose it when commands must run confined on the host: it is the default backend for Linux, macOS, and Windows compositions that mount `ctx.sandbox`. Choose a different mechanism when the process must run in an isolated environment — a container or remote executor replaces whole capabilities, and this provider shares the host kernel and filesystem.
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
### Minimal configuration
|
|
35
|
+
|
|
36
|
+
Load the sandbox service and mount the provider; the defaults below are the selection policy.
|
|
20
37
|
|
|
21
38
|
```yaml
|
|
22
39
|
- id: sandbox
|
|
23
40
|
name: '@deepseek-ai/dsh-sandbox-local'
|
|
24
41
|
```
|
|
25
42
|
|
|
26
|
-
|
|
43
|
+
| Field | Default | Meaning |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `runnerCommand` | `[]` | Custom runner argv; bwrap-compatible profile arguments are appended, full enforcement is asserted, and built-in selection and probes are skipped |
|
|
46
|
+
| `runnerFailureSignatures` | `[]` | Case-insensitive stderr substrings identifying the custom runner's own failure dialect; required with `runnerCommand` |
|
|
47
|
+
| `probeTimeoutMs` | `5,000` | Timeout for each functional probe of a competing runner candidate |
|
|
48
|
+
|
|
49
|
+
The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-sandbox-local) is the exhaustive source for every accepted field and its JSDoc.
|
|
50
|
+
|
|
51
|
+
### Confined execution and enforcement
|
|
52
|
+
|
|
53
|
+
With the provider mounted, a command runs under the mode you resolve per call. Enforcement is a reported fact, not a promise: `full` means the backend governs every promised file effect, while `partial` means it governs only a subset — the Windows ACL rung (Everyone and hard-link boundaries) and older Landlock ABIs are the current partial cases, so a consumer that requires an absolute boundary can reject or surface them. Denied file effects surface through the backend's denial dialect, and a runner that fails before executing the command reports a structured runner-failure signature.
|
|
54
|
+
|
|
55
|
+
### Failures and recovery
|
|
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.
|
|
58
|
+
|
|
59
|
+
-----
|
|
60
|
+
|
|
61
|
+
<a id="understand-the-implementation"></a>
|
|
62
|
+
## Understand the implementation
|
|
63
|
+
|
|
64
|
+
<details>
|
|
65
|
+
<summary>Implementation internals — click to expand</summary>
|
|
66
|
+
|
|
67
|
+
This section explains runner selection, the per-platform profiles, and the failure dialects; the observable behavior is fully covered in [Use this package](#use-this-package).
|
|
68
|
+
|
|
69
|
+
### Runner selection
|
|
70
|
+
|
|
71
|
+
Selection is by platform first, probes second: each platform has a runner chain (`linux`: `bwrap` then Landlock; `darwin`: Seatbelt; `win32`: the ACL restricted-token runner). A sole candidate is selected without a probe; competing candidates are functionally probed once in chain order, and the first usable verdict is cached for the provider's lifetime. A platform with no chain, or a chain where every probe fails, is unavailable and fails closed at `confine()`.
|
|
72
|
+
|
|
73
|
+
### Platform profiles
|
|
74
|
+
|
|
75
|
+
The bwrap profile combines a read-only host root, a fresh `/dev`, and `/proc` from a private PID namespace — commands manage their descendants but cannot see host processes, so procfs magic links cannot bypass the mounts; `workspace-write` adds an ephemeral `/tmp` and a writable workspace bind. The [private-PID note](../../../.agents/notes/implemented/bug-fix/2026-08-06-bwrap-private-pid-namespace.md) records the boundary.
|
|
76
|
+
|
|
77
|
+
The Landlock launcher ships as an npm-distributed native addon (`@deepseek-ai/node-addon-landlock-run`) that supplies the platform launcher, functional probe, and grant vocabulary; this provider maps mode to grants only, keeping path resolution and probe parsing with the versioned binary.
|
|
78
|
+
|
|
79
|
+
The Seatbelt profile is allow-default with `(deny file-write*)` plus write allow-lists derived from the shared `writableRoots` helper, so exactly the mode's promised file effects are governed; every root is canonicalized because Seatbelt matches resolved paths (`/tmp` IS `/private/tmp`).
|
|
80
|
+
|
|
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.
|
|
27
82
|
|
|
83
|
+
### Denial and runner-failure dialects
|
|
84
|
+
|
|
85
|
+
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).
|
|
86
|
+
|
|
87
|
+
### Source map
|
|
88
|
+
|
|
89
|
+
| File | Role |
|
|
90
|
+
|---|---|
|
|
91
|
+
| [`src/index.ts`](src/index.ts) | Plugin entry: runner chain selection, functional probes, per-call wrap, ACL grant lifecycle |
|
|
92
|
+
| [`src/profiles.ts`](src/profiles.ts) | Per-platform profile builders: bwrap mounts, Landlock grants, Seatbelt SBPL |
|
|
93
|
+
| [`src/invariant.ts`](src/invariant.ts) | Invariant companion (no runtime invariant; fail-closed contracts are enforced at the wrap boundary) |
|
|
94
|
+
|
|
95
|
+
</details>
|
|
96
|
+
|
|
97
|
+
-----
|
|
98
|
+
|
|
99
|
+
<a id="further-exploration"></a>
|
|
100
|
+
## Further Exploration
|
|
101
|
+
|
|
102
|
+
Start with the subsystem reference for the shared vocabulary, then the seam contract, the consumers, and the win32 rung.
|
|
103
|
+
|
|
104
|
+
- [Process sandbox subsystem](../../../docs/subsystems/sandbox.md) — modes, per-call policy, and classification dialects.
|
|
105
|
+
- [Sandbox seam package](../sandbox/README.md) — the service contract this provider implements.
|
|
106
|
+
- [Bash sandbox executor](../../shell/bash-sandbox/README.md) — the confined bash consumer.
|
|
107
|
+
- [Windows ACL restricted-token rung](../sandbox-windows-acl/README.md) — the win32 backend this provider mounts.
|
|
108
|
+
- [The subprocess sandbox decision](../../../.agents/notes/implemented/feature/2026-07-06-sandbox.md) — capability boundary and runner selection semantics.
|
|
109
|
+
|
|
110
|
+
-----
|
|
111
|
+
|
|
112
|
+
<a id="model-experience"></a>
|
|
28
113
|
## Model Experience
|
|
29
114
|
|
|
30
|
-
Indirectly, through [`dsh-bash-sandbox`](../../shell/bash-sandbox/README.md) and [`dsh-tool-bash`](../../shell/tool-bash/README.md), which render this provider's enforcement and denial facts while the [`dsh-sandbox`](../sandbox/README.md) seam owns the `SANDBOX_UNAVAILABLE` text and runner selection and profiles stay outside context.
|
|
115
|
+
Indirectly, through [`dsh-bash-sandbox`](../../shell/bash-sandbox/README.md) and [`dsh-tool-bash`](../../shell/tool-bash/README.md), which render this provider's enforcement and denial facts, while the [`dsh-sandbox`](../sandbox/README.md) seam owns the `SANDBOX_UNAVAILABLE` text and this provider owns runner selection, and profiles stay outside context.
|
|
31
116
|
|
|
32
117
|
#### KV Cache effect
|
|
33
118
|
|
|
34
|
-
No direct invalidation; the named
|
|
119
|
+
No direct invalidation; the named consumers own any request-prefix changes.
|
|
35
120
|
|
|
36
121
|
## Known Limitations and Deferred Work
|
|
37
122
|
|
|
123
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
These limits define when the provider is a poor fit or needs special operational care. They are current package constraints, not a general platform comparison or a task backlog.
|
|
127
|
+
|
|
38
128
|
- **Windows ACL enforcement is partial** — the restricted token must retain Everyone for process initialization, so external objects granting Everyone write access remain writable; NTFS hard links also alias one file object across workspace and external paths. The provider reports `enforcement: 'partial'` rather than overstating that boundary as full.
|
|
39
129
|
- **Landlock may be partial** — older supported kernel ABIs confine only the access classes they expose, reported as `enforcement: 'partial'` rather than overstated as full.
|
|
40
130
|
- **Seatbelt depends on deprecated `sandbox-exec`** — macOS still ships it, but this provider cannot replace or probe that private policy engine if Apple removes it.
|
|
41
131
|
- **Runner selection is cached for the provider lifetime** — installing, removing, or repairing a runner requires reloading the plugin before selection changes.
|
|
42
132
|
- **`runnerCommand` is an operator assertion** — a configured custom runner skips functional probes and is assumed to implement the bwrap-compatible profile honestly; if it is itself a Bash script, its interpreter startup runs before that script applies confinement.
|
|
133
|
+
|
|
134
|
+
<a id="dev-note"></a>
|
|
135
|
+
### Dev Note
|
|
136
|
+
|
|
137
|
+
<details>
|
|
138
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
139
|
+
|
|
140
|
+
This Dev Note is working context for maintainers: undecided directions and open questions. It is explicitly non-authoritative — shipped behavior, limits, and accepted rationale live in the sections above, the package code, and the linked Agent Notes.
|
|
141
|
+
|
|
142
|
+
#### Future: environment-coherent groups
|
|
143
|
+
|
|
144
|
+
The [sandbox decision](../../../.agents/notes/implemented/feature/2026-07-06-sandbox.md) lists an environment-coherent capability group example (for example bash plus fs against one container) as a deferred phase; it is not decided.
|
|
145
|
+
|
|
146
|
+
</details>
|
package/README.zh.md
CHANGED
|
@@ -1,42 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "面向 Linux、macOS 或 Windows 上选择、配置或排查进程隔离的用户与维护者的本地各平台沙箱后端。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# @deepseek-ai/dsh-sandbox-local
|
|
2
7
|
|
|
3
8
|
[English](README.md) | 中文
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
`dsh-sandbox-local` 提供 `ctx.sandbox` 背后的平台隔离后端:Linux 在 `bwrap` 可用时用其运行命令,否则使用 Landlock launcher;macOS 使用 Seatbelt(`sandbox-exec`);Windows 使用 ACL 受限令牌 runner。它每台主机选择一个 runner,因此每条命令及其派生的所有进程都在限制下运行。没有可用 runner 时,提供方以 `SANDBOX_UNAVAILABLE` 快速失败——命令绝不会静默无限制运行。每次包装都会报告后端对模式的强制执行完整度(`full` 或 `partial`)及后端的拒绝签名,因此消费方可以区分损坏的沙箱与被拒绝的命令。在 `ctx.sandbox` 后挂载它并配一个受限执行器,即可让每次 bash 或 pwsh 调用都有受限默认值。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
6
15
|
|
|
7
|
-
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与延期工作](#known-limitations-and-deferred-work)
|
|
21
|
+
- [开发备注](#dev-note)
|
|
8
22
|
|
|
9
|
-
|
|
23
|
+
-----
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## 使用本包
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
在 `ctx.sandbox` 后挂载此提供方并配一个受限执行器,执行器 spawn 的每条命令都会在你解析的策略下受限运行。随附的 [base bundle](../../bundle/base/cordis.patch.yml)拥有默认策略与执行器接线。
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
### 何时选择
|
|
16
31
|
|
|
17
|
-
|
|
32
|
+
当命令必须在宿主机上受限运行时选择它:它是挂载 `ctx.sandbox` 的 Linux、macOS 与 Windows 组合的默认后端。当进程必须在隔离环境中运行时请另选机制——容器或远程执行器会替换整个能力,而此提供方与宿主共享内核和文件系统。
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
### 最小配置
|
|
35
|
+
|
|
36
|
+
加载沙箱服务并挂载提供方;以下默认值即选择策略。
|
|
20
37
|
|
|
21
38
|
```yaml
|
|
22
39
|
- id: sandbox
|
|
23
40
|
name: '@deepseek-ai/dsh-sandbox-local'
|
|
24
41
|
```
|
|
25
42
|
|
|
26
|
-
|
|
43
|
+
| 字段 | 默认值 | 含义 |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `runnerCommand` | `[]` | 自定义 runner argv;会追加 bwrap 兼容的 profile 参数,断言完全强制执行,并跳过内置选择与探测 |
|
|
46
|
+
| `runnerFailureSignatures` | `[]` | 识别自定义 runner 自身失败方言的不区分大小写 stderr 子串;与 `runnerCommand` 搭配必需 |
|
|
47
|
+
| `probeTimeoutMs` | `5,000` | 每次竞争 runner 候选功能探测的超时时间 |
|
|
48
|
+
|
|
49
|
+
生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-sandbox-local)是每个受支持字段及其 JSDoc 的穷尽式真源。
|
|
50
|
+
|
|
51
|
+
### 受限执行与强制执行
|
|
52
|
+
|
|
53
|
+
挂载提供方后,命令在你逐调用解析的模式下运行。强制执行是报告的事实,而非承诺:`full` 表示后端管辖模式承诺的每个文件操作,`partial` 表示它只管辖子集——Windows ACL 档(Everyone 与硬链接边界)与较旧的 Landlock ABI 是当前的部分强制执行情形,因此需要绝对边界的消费方可以拒绝或向上暴露它们。被拒绝的文件操作通过后端的拒绝方言呈现,执行命令前失败的 runner 会报告结构化的 runner 失败签名。
|
|
54
|
+
|
|
55
|
+
### 失败与恢复
|
|
56
|
+
|
|
57
|
+
不受支持的平台或不可用的 runner 会快速失败:`confine()` 抛出 `SANDBOX_UNAVAILABLE` 并列出该平台的 runner 选项,消费方会呈现该错误,而不是让命令不受限制地运行。启动后拒绝自身 profile 的 runner 由其致命 stderr 签名与退出码识别,因此损坏的沙箱不会被误认为被拒绝的命令。`runnerCommand` 覆盖是操作方断言:它跳过功能探测,并假定配置的 runner 诚实实现与 bwrap 兼容的 profile。
|
|
58
|
+
|
|
59
|
+
-----
|
|
60
|
+
|
|
61
|
+
<a id="understand-the-implementation"></a>
|
|
62
|
+
## 理解实现
|
|
63
|
+
|
|
64
|
+
<details>
|
|
65
|
+
<summary>实现细节——点击展开</summary>
|
|
66
|
+
|
|
67
|
+
本节解释 runner 选择、各平台 profile 与失败方言;可观察行为已在[使用本包](#use-this-package)中完整说明。
|
|
68
|
+
|
|
69
|
+
### runner 选择
|
|
70
|
+
|
|
71
|
+
选择按平台优先、探测其次:每个平台都有 runner 链(`linux`:`bwrap` 再 Landlock;`darwin`:Seatbelt;`win32`:ACL 受限令牌 runner)。唯一候选直接选择、不探测;竞争候选按链序各执行一次功能探测,首个可用结论在提供方生命周期内缓存。没有链的平台、或链上所有探测都失败时,平台不可用,并在 `confine()` 处快速失败。
|
|
72
|
+
|
|
73
|
+
### 平台 profile
|
|
74
|
+
|
|
75
|
+
bwrap profile 组合只读宿主根目录、全新 `/dev` 与私有 PID 命名空间中的 `/proc`——命令可管理其后代,但看不到宿主进程,因此 procfs 魔法链接无法绕过挂载;`workspace-write` 另加临时的 `/tmp` 与可写工作区绑定挂载。[私有 PID 笔记](../../../.agents/notes/implemented/bug-fix/2026-08-06-bwrap-private-pid-namespace.zh.md)记录该边界。
|
|
76
|
+
|
|
77
|
+
Landlock launcher 以 npm 分发的原生插件(`@deepseek-ai/node-addon-landlock-run`)提供平台 launcher、功能探测与授权词汇;此提供方只做模式到授权的映射,把路径解析与探测解析保留在带版本的 binary 中。
|
|
78
|
+
|
|
79
|
+
Seatbelt profile 默认允许,带 `(deny file-write*)` 与来自共享 `writableRoots` 辅助函数的写入 allow-list,因此恰好管辖模式承诺的文件操作;每个根目录都经过规范化,因为 Seatbelt 匹配解析后的路径(`/tmp` 就是 `/private/tmp`)。
|
|
80
|
+
|
|
81
|
+
Windows 档为每个工作区保留一个确定性写入 SID 和常驻 ACE,同时为每个活跃的会话/工作区对分配一个随机私有临时目录,以及不同的 SID 和可撤销 ACE——共享工作区的会话共享其预期写权限,却不会继承彼此的临时目录权限。新的提供方总会选择新的临时路径和 SID,因此崩溃残留既无法阻止恢复的会话,也无法向其授权。该档报告 `partial` 强制执行,因为受限令牌必须保留 Everyone,且 NTFS 硬链接会把同一文件对象别名为多个路径。
|
|
27
82
|
|
|
83
|
+
### 拒绝与 runner 失败方言
|
|
84
|
+
|
|
85
|
+
每个 runner 的内核都有自己的拒绝方言,随每次包装以 `denialSignatures` 携带,`runnerFailureRules` 则给出每个 runner 的致命签名,因此消费方先分类 runner 拒绝,再检查拒绝签名。精确的字符串与退出码位于 [`src/index.ts`](src/index.ts)。
|
|
86
|
+
|
|
87
|
+
### 源码地图
|
|
88
|
+
|
|
89
|
+
| 文件 | 职责 |
|
|
90
|
+
|---|---|
|
|
91
|
+
| [`src/index.ts`](src/index.ts) | 插件入口:runner 链选择、功能探测、逐调用包装、ACL 授权生命周期 |
|
|
92
|
+
| [`src/profiles.ts`](src/profiles.ts) | 各平台 profile 构建器:bwrap 挂载、Landlock 授权、Seatbelt SBPL |
|
|
93
|
+
| [`src/invariant.ts`](src/invariant.ts) | 不变式伴生插件(无运行时不变式;故障关闭约定在包装边界强制执行) |
|
|
94
|
+
|
|
95
|
+
</details>
|
|
96
|
+
|
|
97
|
+
-----
|
|
98
|
+
|
|
99
|
+
<a id="further-exploration"></a>
|
|
100
|
+
## 进一步探索
|
|
101
|
+
|
|
102
|
+
先从子系统参考文档了解共享词汇,再看 seam 约定、消费方与 win32 档。
|
|
103
|
+
|
|
104
|
+
- [进程沙箱子系统](../../../docs/subsystems/sandbox.zh.md)——模式、逐调用策略与分类方言。
|
|
105
|
+
- [沙箱 seam 包](../sandbox/README.zh.md)——本提供方实现的服务约定。
|
|
106
|
+
- [Bash 沙箱执行器](../../shell/bash-sandbox/README.zh.md)——受限的 bash 消费方。
|
|
107
|
+
- [Windows ACL 受限令牌档](../sandbox-windows-acl/README.zh.md)——本提供方挂载的 win32 后端。
|
|
108
|
+
- [子进程沙箱决策](../../../.agents/notes/implemented/feature/2026-07-06-sandbox.zh.md)——能力边界与 runner 选择语义。
|
|
109
|
+
|
|
110
|
+
-----
|
|
111
|
+
|
|
112
|
+
<a id="model-experience"></a>
|
|
28
113
|
## 模型体验
|
|
29
114
|
|
|
30
|
-
通过 [`dsh-bash-sandbox`](../../shell/bash-sandbox/README.zh.md) 和 [`dsh-tool-bash`](../../shell/tool-bash/README.zh.md)
|
|
115
|
+
通过 [`dsh-bash-sandbox`](../../shell/bash-sandbox/README.zh.md) 和 [`dsh-tool-bash`](../../shell/tool-bash/README.zh.md) 间接影响;它们渲染此提供方的强制执行与拒绝事实,而 [`dsh-sandbox`](../sandbox/README.zh.md) seam 拥有 `SANDBOX_UNAVAILABLE` 文本、本提供方拥有 runner 选择,profile 不进入上下文。
|
|
31
116
|
|
|
32
117
|
#### KV Cache 影响
|
|
33
118
|
|
|
34
119
|
不会直接使 KV Cache 失效;请求前缀变更由上述消费方负责。
|
|
35
120
|
|
|
36
|
-
##
|
|
121
|
+
## 已知限制与延期工作
|
|
122
|
+
|
|
123
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
这些限制说明提供方何时不合适,或何时需要特别运维。它们是当前包约束,不是通用平台对比或任务积压。
|
|
127
|
+
|
|
128
|
+
- **Windows ACL 只能实现部分强制执行**——受限令牌必须保留 Everyone 以完成进程初始化,因此授予 Everyone 写访问的外部对象仍可写;NTFS 硬链接也会使工作区路径与外部路径指向同一个文件对象。提供方报告 `enforcement: 'partial'`,而不会把该边界夸大为完整强制执行。
|
|
129
|
+
- **Landlock 可能只实现部分强制执行**——较旧且受支持的内核 ABI 只能限制自身公开的访问类别,因此报告 `enforcement: 'partial'`,不会夸大为完整强制执行。
|
|
130
|
+
- **Seatbelt 依赖已弃用的 `sandbox-exec`**——macOS 仍会提供它,但若 Apple 移除该私有策略引擎,该提供方无法替换或探测。
|
|
131
|
+
- **runner 选择在提供方生命周期内缓存**——安装、移除或修复 runner 后,必须重载插件才能改变选择。
|
|
132
|
+
- **`runnerCommand` 是操作方断言**——配置的自定义 runner 会跳过功能探测,并假定它诚实实现与 bwrap 兼容的 profile;如果它本身是 Bash 脚本,其解释器启动发生在该脚本施加约束之前。
|
|
133
|
+
|
|
134
|
+
<a id="dev-note"></a>
|
|
135
|
+
### 开发备注
|
|
136
|
+
|
|
137
|
+
<details>
|
|
138
|
+
<summary>维护者的工作上下文——点击展开</summary>
|
|
139
|
+
|
|
140
|
+
本开发备注是维护者的工作上下文:未决方向与开放问题。它明确不具权威性——已交付的行为、限制与既定理由以上文、包代码和相关 Agent Note 为准。
|
|
141
|
+
|
|
142
|
+
#### 未来:环境一致的能力组
|
|
143
|
+
|
|
144
|
+
[沙箱决策](../../../.agents/notes/implemented/feature/2026-07-06-sandbox.zh.md)把环境一致的能力组示例(例如 bash 加 fs 针对同一个容器)列为延期阶段;该方向尚未决定。
|
|
37
145
|
|
|
38
|
-
|
|
39
|
-
- **Landlock 可能只实现部分强制执行**:较旧且受支持的内核 ABI 只能限制自身公开的访问类别,因此报告 `enforcement: 'partial'`,不会夸大为完整强制执行。
|
|
40
|
-
- **Seatbelt 依赖已弃用的 `sandbox-exec`**:macOS 仍会提供它,但若 Apple 移除该私有策略引擎,该提供方无法替换或探测。
|
|
41
|
-
- **runner 选择在提供方生命周期内缓存**:安装、移除或修复 runner 后,必须重载插件才能改变选择。
|
|
42
|
-
- **`runnerCommand` 是操作方断言**:配置的自定义 runner 会跳过功能探测,并假定它诚实实现与 bwrap 兼容的 profile;如果它本身是 Bash 脚本,其解释器启动发生在该脚本施加约束之前。
|
|
146
|
+
</details>
|
package/lib/index.js
CHANGED
|
@@ -5,9 +5,9 @@ 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-landlock-run";
|
|
7
7
|
import z from "@deepseek-ai/schemastery";
|
|
8
|
-
import { assertNever } from "@deepseek-ai/dsh-llm";
|
|
9
8
|
import { SandboxProvider, SandboxUnavailableError, writableRoots } from "@deepseek-ai/dsh-sandbox";
|
|
10
9
|
import { AclWriteGrant, assertTempRootOutsideWorkspace, tempWriteSid, workspaceWriteSid } from "@deepseek-ai/dsh-sandbox-windows-acl";
|
|
10
|
+
import { assertNever } from "@deepseek-ai/dsh-util-values";
|
|
11
11
|
//#region lib/types/profiles.js
|
|
12
12
|
/**
|
|
13
13
|
* Internal platform-profile builders for the local sandbox provider.
|
|
@@ -178,7 +178,7 @@ const PLATFORM_CHAINS = {
|
|
|
178
178
|
* Enforcement completeness a rung claims when selected WITHOUT a probe (a
|
|
179
179
|
* chain of one). `bwrap` and Seatbelt govern every promised file effect by
|
|
180
180
|
* construction, so the claim is a profile fact; `landlock` is listed for the
|
|
181
|
-
* table's totality but is unreachable
|
|
181
|
+
* table's totality but is unreachable without a probe (the Linux chain has
|
|
182
182
|
* two rungs, so it is only ever selected through its probe, whose report is
|
|
183
183
|
* what distinguishes full from per-ABI-partial — and the launcher additionally
|
|
184
184
|
* self-reports partial enforcement on stderr at every confined run).
|
|
@@ -224,7 +224,7 @@ const DENIAL_SIGNATURES = {
|
|
|
224
224
|
* cleanup failure reported on a non-zero child exit) is never misclassified
|
|
225
225
|
* as "the command did not run". Keep the Landlock tuple aligned with the
|
|
226
226
|
* assembled snapshot fixture at
|
|
227
|
-
* `
|
|
227
|
+
* `packages/test-support/session-snapshot/tests/fixtures/partial-landlock-sandbox.ts`.
|
|
228
228
|
*/
|
|
229
229
|
const RUNNER_FAILURE_RULES = {
|
|
230
230
|
bwrap: [{ fatalSignatures: ["bwrap: "] }],
|
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.
|
|
4
|
+
"version": "0.1.2-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -32,22 +32,23 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/
|
|
36
|
-
"@deepseek-ai/dsh-
|
|
37
|
-
"@deepseek-ai/dsh-
|
|
38
|
-
"@deepseek-ai/dsh-
|
|
39
|
-
"@deepseek-ai/
|
|
35
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
36
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
|
|
37
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
|
|
38
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.2-alpha.2",
|
|
39
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.2"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@deepseek-ai/dsh-sandbox-windows-acl": "^0.1.1-rc.1",
|
|
43
42
|
"@deepseek-ai/node-addon-landlock-run": "^0.1.1",
|
|
44
|
-
"@deepseek-ai/
|
|
43
|
+
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.2",
|
|
44
|
+
"@deepseek-ai/schemastery": "^3.18.2",
|
|
45
|
+
"@deepseek-ai/dsh-sandbox-windows-acl": "^0.1.2-alpha.2"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@deepseek-ai/
|
|
48
|
-
"@deepseek-ai/dsh-
|
|
49
|
-
"@deepseek-ai/dsh-
|
|
50
|
-
"@deepseek-ai/
|
|
51
|
-
"@deepseek-ai/dsh-
|
|
48
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
49
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
|
|
50
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
|
|
51
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.2-alpha.2",
|
|
52
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.2"
|
|
52
53
|
}
|
|
53
54
|
}
|