@deepseek-ai/dsh-sandbox 0.1.6-alpha.1 → 0.1.6-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 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/README.md
5
- README.md: 88e873428115eb7a3880253b668a4de5b42d6e6d
6
- README.zh.md: b0144d12395cf01667ef7c2045a1d5f722936a4d
5
+ README.md: 56cdd87c274cc8d951d4bc4e1388d7e985aa4a28
6
+ README.zh.md: c09d7e31fca4825e370636a4c5d9648e145f6a54
package/README.md CHANGED
@@ -63,7 +63,7 @@ Enforcement is reported per call: `full` means the backend governs every promise
63
63
 
64
64
  ### Denied calls and escalation
65
65
 
66
- When a confined call is denied, the operation reports a denial marker naming the mode — `[sandbox: file access denied under <mode> mode]` — and, when the composition advertises escalation, an escalation hint. The model may retry the exact call once with `sandbox_permissions` (the narrowest wider mode that suffices) plus a `justification`; the user sees one approval prompt and can allow once, reject, or cancel. The escalation must be strictly wider than the call's effective mode, and it applies to that one call only.
66
+ When a confined call is denied, the operation reports a denial marker naming the mode — `[sandbox: file access denied under <mode> mode]` — and, when the composition advertises escalation, an escalation hint. The model may retry the exact call once with `sandbox_permissions` (the narrowest wider mode that suffices) plus a `justification`; the user sees one approval prompt and can allow once, reject, or cancel. A wider mode requires approval and applies to that one call only. Repeating the call's effective mode succeeds without approval; narrower targets remain invalid.
67
67
 
68
68
  ### Fail-closed behavior
69
69
 
@@ -97,7 +97,7 @@ This section explains the design decisions behind the contract and points at the
97
97
 
98
98
  ### Escalation choreography
99
99
 
100
- The ladder is a closed table — `read-only` may escalate to `workspace-write` or `danger-full-access`, `workspace-write` only to `danger-full-access` — checked at execution, never baked into a tool schema, whose enum stays the closed target vocabulary. [`approveEscalation`](src/escalation.ts) validates the `sandbox_permissions`/`justification` pairing, rejects non-widening requests without prompting a human, and maps every approval outcome to its own error before anything executes.
100
+ The ladder is a closed table — `read-only` may escalate to `workspace-write` or `danger-full-access`, `workspace-write` only to `danger-full-access` — checked at execution, never baked into a tool schema, whose enum stays the closed target vocabulary. [`approveEscalation`](src/escalation.ts) returns the current mode without approval when it is repeated, rejects narrower or unsupported targets, and requests approval for wider modes. Callers validate the `sandbox_permissions`/`justification` pairing first.
101
101
 
102
102
  ### Writable roots
103
103
 
package/README.zh.md CHANGED
@@ -63,7 +63,7 @@ kind: "package-reference"
63
63
 
64
64
  ### 被拒绝的调用与升权
65
65
 
66
- 受限调用被拒绝时,操作会报告指明模式的拒绝标记——`[sandbox: file access denied under <mode> mode]`——组合声明升权能力时还会给出升权提示。模型可以用 `sandbox_permissions`(足以放行的最窄更宽模式)加 `justification` 重试一次完全相同的调用;用户会看到一次审批提示,可以选择允许一次、拒绝或取消。升权必须严格宽于调用的生效模式,且只作用于该次调用。
66
+ 受限调用被拒绝时,操作会报告指明模式的拒绝标记——`[sandbox: file access denied under <mode> mode]`——组合声明升权能力时还会给出升权提示。模型可以用 `sandbox_permissions`(足以放行的最窄更宽模式)加 `justification` 重试一次完全相同的调用;用户会看到一次审批提示,可以选择允许一次、拒绝或取消。更宽的模式需要审批,且只作用于该次调用。重复指定调用的生效模式无需审批即可成功;更窄的目标仍然无效。
67
67
 
68
68
  ### 故障关闭行为
69
69
 
@@ -97,7 +97,7 @@ kind: "package-reference"
97
97
 
98
98
  ### 升权编排
99
99
 
100
- 阶梯是封闭表——`read-only` 可升权到 `workspace-write` 或 `danger-full-access`,`workspace-write` 只能升权到 `danger-full-access`——在执行时检查,绝不写入工具 schema,schema 的枚举保持封闭的目标词汇。[`approveEscalation`](src/escalation.ts) 校验 `sandbox_permissions`/`justification` 配对、不提示人类就拒绝非加宽请求,并在任何执行前把每个审批结果映射到各自的错误。
100
+ 阶梯是封闭表——`read-only` 可升权到 `workspace-write` 或 `danger-full-access`,`workspace-write` 只能升权到 `danger-full-access`——在执行时检查,绝不写入工具 schema,schema 的枚举保持封闭的目标词汇。[`approveEscalation`](src/escalation.ts) 在请求重复当前模式时无需审批就返回该模式,拒绝更窄或不支持的目标,并为更宽模式请求审批。调用方先校验 `sandbox_permissions`/`justification` 配对。
101
101
 
102
102
  ### 可写根目录
103
103
 
package/lib/index.js CHANGED
@@ -77,21 +77,18 @@ function escalationHintMarker(subject) {
77
77
  return `[sandbox: escalation available — retry this exact ${subject} once with sandbox_permissions (the narrowest wider mode that suffices) + justification; the approval prompt asks the user]`;
78
78
  }
79
79
  /**
80
- * Resolve a sandbox-escalation request BEFORE anything executes: check strict
81
- * widening against the call's effective mode, then resolve the approval
82
- * channel, then map every outcome — the ordered fail-closed sequence both
83
- * enforcing families share. Returns the granted mode to stamp onto exactly
84
- * this call; throws the distinct verbatim text for every other path (a
85
- * non-widening request, a missing approval service, an agent-less execution,
86
- * a rejection, a cancellation, an unanswerable ask) — the tool registry turns
87
- * the throw into the call's isError result, and nothing has run. A
88
- * non-widening request never prompts a human.
80
+ * Resolve a sandbox permission request before execution. Repeating the call's
81
+ * effective mode returns it without approval. A strictly wider mode requires
82
+ * approval and applies only to this call. Narrower or unsupported targets,
83
+ * missing approval services or agents for widening, and non-grant outcomes
84
+ * throw before execution.
89
85
  * @param request - the escalation to judge (see {@link EscalationRequest}).
90
86
  * @param approval - the approval ingredients the tool holds (see {@link EscalationApproval}).
91
87
  * @returns the granted mode, consumed by the one call that asked.
92
88
  */
93
89
  async function approveEscalation(request, approval) {
94
90
  const { requestedMode: mode, effectiveMode, justification, subject } = request;
91
+ if (mode === effectiveMode) return effectiveMode;
95
92
  if (!(WIDER_MODES[effectiveMode] ?? []).includes(mode)) throw new Error(`sandbox escalation to "${mode}" is not strictly wider than this call's current "${effectiveMode}" mode`);
96
93
  if (approval.approver === void 0) throw new Error(`sandbox escalation to "${mode}" requires approval, but no approval service is composed`);
97
94
  if (approval.agent === void 0) throw new Error(`sandbox escalation to "${mode}" requires approval, but the call has no agent to route it through`);
@@ -112,21 +112,17 @@ export interface EscalationRequest {
112
112
  requestedMode: string;
113
113
  /** The model's one-sentence reason, shown verbatim to the user inside the audit reason. */
114
114
  justification: string;
115
- /** The call's effective mode (session override ?? composition default) the request must strictly widen. */
115
+ /** The call's effective mode (session override ?? composition default); repeating it needs no approval. */
116
116
  effectiveMode: SandboxMode;
117
117
  /** The family's noun for the escalated action in user-facing texts (`command` for bash, `operation` for fs). */
118
118
  subject: string;
119
119
  }
120
120
  /**
121
- * Resolve a sandbox-escalation request BEFORE anything executes: check strict
122
- * widening against the call's effective mode, then resolve the approval
123
- * channel, then map every outcome — the ordered fail-closed sequence both
124
- * enforcing families share. Returns the granted mode to stamp onto exactly
125
- * this call; throws the distinct verbatim text for every other path (a
126
- * non-widening request, a missing approval service, an agent-less execution,
127
- * a rejection, a cancellation, an unanswerable ask) — the tool registry turns
128
- * the throw into the call's isError result, and nothing has run. A
129
- * non-widening request never prompts a human.
121
+ * Resolve a sandbox permission request before execution. Repeating the call's
122
+ * effective mode returns it without approval. A strictly wider mode requires
123
+ * approval and applies only to this call. Narrower or unsupported targets,
124
+ * missing approval services or agents for widening, and non-grant outcomes
125
+ * throw before execution.
130
126
  * @param request - the escalation to judge (see {@link EscalationRequest}).
131
127
  * @param approval - the approval ingredients the tool holds (see {@link EscalationApproval}).
132
128
  * @returns the granted mode, consumed by the one call that asked.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-sandbox",
3
3
  "description": "Abstract process-sandbox seam (ctx.sandbox) for the DeepSeek Harness: same-world confinement vocabulary and the SandboxProvider contract",
4
- "version": "0.1.6-alpha.1",
4
+ "version": "0.1.6-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,16 +27,16 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "peerDependencies": {
30
- "@deepseek-ai/dsh-llm": "^0.1.6-alpha.1",
31
30
  "@deepseek-ai/cordis": "^4.0.2",
32
- "@deepseek-ai/dsh-session": "^0.1.6-alpha.1"
31
+ "@deepseek-ai/dsh-llm": "^0.1.6-alpha.2",
32
+ "@deepseek-ai/dsh-session": "^0.1.6-alpha.2"
33
33
  },
34
34
  "devDependencies": {
35
+ "@deepseek-ai/dsh-llm": "^0.1.6-alpha.2",
35
36
  "@deepseek-ai/cordis": "^4.0.2",
36
- "@deepseek-ai/dsh-llm": "^0.1.6-alpha.1",
37
- "@deepseek-ai/dsh-session": "^0.1.6-alpha.1"
37
+ "@deepseek-ai/dsh-session": "^0.1.6-alpha.2"
38
38
  },
39
39
  "dependencies": {
40
- "@deepseek-ai/dsh-util-values": "^0.1.6-alpha.1"
40
+ "@deepseek-ai/dsh-util-values": "^0.1.6-alpha.2"
41
41
  }
42
42
  }