@songtonyli/dsh-cli 0.1.63 → 0.1.64
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.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-api-remotes/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.i18n.yaml +17 -14
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.md +17 -7
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.zh.md +17 -7
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/lib/index.js +37 -3
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/package.json +1 -0
- package/node_modules/@deepseek-ai/dsh-permission-presets/README.i18n.yaml +8 -8
- package/node_modules/@deepseek-ai/dsh-permission-presets/README.md +4 -4
- package/node_modules/@deepseek-ai/dsh-permission-presets/README.zh.md +4 -4
- package/node_modules/@deepseek-ai/dsh-permission-presets/lib/index.js +42 -4
- package/node_modules/@deepseek-ai/dsh-permission-presets/lib/typert.host.js +9 -2
- package/node_modules/@deepseek-ai/dsh-permission-presets/lib/typert.remote-client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-permission-presets/lib/types/index.js +48 -4
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/lib/index.js +16 -0
- package/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +13 -1
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +4 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +4 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +31 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ workspace and no build step. Native packages that ship one build per platform
|
|
|
26
26
|
ripgrep, the PTY backend's addons, sharp, koffi, and the Landlock launcher — are
|
|
27
27
|
ordinary optional dependencies, so npm resolves the right one for your machine.
|
|
28
28
|
|
|
29
|
-
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.
|
|
29
|
+
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.64; `dsh --version`
|
|
30
30
|
also reports the harness build the package was assembled from.
|
|
31
31
|
|
|
32
32
|
## License
|
package/bin/dsh.mjs
CHANGED
|
@@ -18,7 +18,7 @@ const argv = process.argv.slice(2)
|
|
|
18
18
|
// version this package publishes. Reporting only one of the two would make an
|
|
19
19
|
// ordinary `npm install @songtonyli/dsh-cli@x` look like it installed something else.
|
|
20
20
|
if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-V')) {
|
|
21
|
-
console.log('@songtonyli/dsh-cli 0.1.
|
|
21
|
+
console.log('@songtonyli/dsh-cli 0.1.64 (deepseek-harness 0.2.1-alpha.1)')
|
|
22
22
|
process.exit(0)
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -9994,7 +9994,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
9994
9994
|
},
|
|
9995
9995
|
sourceLocation: {
|
|
9996
9996
|
"file": "packages/interaction/permission-presets/src/index.ts",
|
|
9997
|
-
"line":
|
|
9997
|
+
"line": 305,
|
|
9998
9998
|
"column": 3
|
|
9999
9999
|
}
|
|
10000
10000
|
}]
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"micromark-util-sanitize-uri": "^2.0.1",
|
|
49
49
|
"simple-icons": "16.31.0",
|
|
50
50
|
"@deepseek-ai/dsh-client-store": "0.2.1-alpha.1",
|
|
51
|
-
"@deepseek-ai/
|
|
51
|
+
"@deepseek-ai/dsh-util-code-language": "0.2.1-alpha.1",
|
|
52
52
|
"@deepseek-ai/dsh-util-workspace-path": "0.2.1-alpha.1",
|
|
53
|
-
"@deepseek-ai/
|
|
53
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
54
54
|
},
|
|
55
55
|
"files": [
|
|
56
56
|
"lib/index.js",
|
|
@@ -167,7 +167,7 @@ window.__ModuleLoader__.load({
|
|
|
167
167
|
const SCROLLBAR_LINGER_MS = 2e3;
|
|
168
168
|
/** Format complete-build metadata for the local brand badge. */
|
|
169
169
|
function localBuildVersion() {
|
|
170
|
-
return `0.2.1-alpha.1-
|
|
170
|
+
return `0.2.1-alpha.1-6fd4f9d` + ({}.DSH_CLIENT_GIT_DIRTY === "true" ? "-dirty" : "");
|
|
171
171
|
}
|
|
172
172
|
/** Each panel row subscribes only to its own selection state. */
|
|
173
173
|
function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/react": "~18.3.1",
|
|
27
|
-
"@deepseek-ai/
|
|
28
|
-
"@deepseek-ai/
|
|
27
|
+
"@deepseek-ai/dsh-client-store": "0.2.1-alpha.1",
|
|
28
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"lib/index.js",
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
# After editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/experimental/auto-review/README.md
|
|
5
5
|
/:
|
|
6
|
-
en:
|
|
7
|
-
zh:
|
|
6
|
+
en: 69a05f8df88e7a24
|
|
7
|
+
zh: d278a12427f2c62b
|
|
8
8
|
/deepseek-ai-dsh-experimental-auto-review:
|
|
9
9
|
en: 566562e610f1b52b
|
|
10
10
|
zh: 88796a19ab0b98b8
|
|
11
11
|
/deepseek-ai-dsh-experimental-auto-review/summary:
|
|
12
|
-
en:
|
|
13
|
-
zh:
|
|
12
|
+
en: 7b1dc0cab49753bb
|
|
13
|
+
zh: 8858beb0b56a6f53
|
|
14
14
|
/deepseek-ai-dsh-experimental-auto-review/table-of-contents:
|
|
15
15
|
en: d152484eb41ac6b4
|
|
16
16
|
zh: 09388d293f9be9cb
|
|
@@ -21,11 +21,14 @@
|
|
|
21
21
|
en: 63f8f1baa0fb2655
|
|
22
22
|
zh: 6bc64160f6d02114
|
|
23
23
|
/deepseek-ai-dsh-experimental-auto-review/use-this-package/what-you-get:
|
|
24
|
-
en:
|
|
25
|
-
zh:
|
|
24
|
+
en: 2f4f6cbeca07708e
|
|
25
|
+
zh: 4fbdf5ad81271b77
|
|
26
|
+
/deepseek-ai-dsh-experimental-auto-review/use-this-package/auto-on-the-container-backend:
|
|
27
|
+
en: b441182c5bcf944e
|
|
28
|
+
zh: 9f53b679e51832d6
|
|
26
29
|
/deepseek-ai-dsh-experimental-auto-review/understand-the-implementation:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
30
|
+
en: 428319935e5f7216
|
|
31
|
+
zh: 246955f3c88b18a9
|
|
29
32
|
/deepseek-ai-dsh-experimental-auto-review/further-exploration:
|
|
30
33
|
en: 8b81d32ea370ecd3
|
|
31
34
|
zh: dc53ff4da78232ac
|
|
@@ -36,14 +39,14 @@
|
|
|
36
39
|
en: 7ec217b1012cd8fa
|
|
37
40
|
zh: 6188796b4990f2ef
|
|
38
41
|
/deepseek-ai-dsh-experimental-auto-review/model-experience/per-call-reviewer/what-the-model-sees:
|
|
39
|
-
en:
|
|
40
|
-
zh:
|
|
42
|
+
en: 2837073770a73ca9
|
|
43
|
+
zh: c39eade00f7a6ecd
|
|
41
44
|
/deepseek-ai-dsh-experimental-auto-review/model-experience/per-call-reviewer/token-effect:
|
|
42
45
|
en: 0477fcb8eda9767f
|
|
43
46
|
zh: 76d5b56acb2942da
|
|
44
47
|
/deepseek-ai-dsh-experimental-auto-review/model-experience/per-call-reviewer/kv-cache-effect:
|
|
45
|
-
en:
|
|
46
|
-
zh:
|
|
48
|
+
en: ca7e68720f506d52
|
|
49
|
+
zh: adb123d889a725d7
|
|
47
50
|
/deepseek-ai-dsh-experimental-auto-review/model-experience/tool-denial:
|
|
48
51
|
en: f9b4d7b686f14fc5
|
|
49
52
|
zh: a2fac9a8eaf5e2a3
|
|
@@ -57,8 +60,8 @@
|
|
|
57
60
|
en: 8da1089dee147f94
|
|
58
61
|
zh: 87361347bfd10c6c
|
|
59
62
|
/deepseek-ai-dsh-experimental-auto-review/known-limitations-and-deferred-work:
|
|
60
|
-
en:
|
|
61
|
-
zh:
|
|
63
|
+
en: 2a0d03dcf6f443ae
|
|
64
|
+
zh: d55b56f6d143c6cd
|
|
62
65
|
/deepseek-ai-dsh-experimental-auto-review/known-limitations-and-deferred-work/dev-note:
|
|
63
66
|
en: e67f633dc6fe7773
|
|
64
67
|
zh: 3bb0c20c93f16f98
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Add experimental per-call Auto review, using the current agent's model before tools execute with Full access."
|
|
2
|
+
description: "Add experimental per-call Auto review, using the current agent's model before tools execute with Full access, or confined where the sandbox backend confines reads."
|
|
3
3
|
kind: "package-bundle"
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
|
|
9
9
|
|
|
10
10
|
## Summary
|
|
11
11
|
|
|
12
|
-
Add Auto review to the current-session permission pickers. Before each native or PTC inner tool call, the current agent's provider and model assess the pending action; an allowed call executes with Full access, and a denied call asks the user. The shipped TUI profile includes this layer. Default Web keeps its three permission modes until it is switched on from the Web sidebar's Plugins page or installed explicitly. Auto review is experimental: it can allow unsafe actions, deny useful work, and spend additional tokens.
|
|
12
|
+
Add Auto review to the current-session permission pickers. Before each native or PTC inner tool call, the current agent's provider and model assess the pending action; an allowed call executes with Full access, or confined in the container while the session runs on the Apple container backend, and a denied call asks the user. The shipped TUI profile includes this layer. Default Web keeps its three permission modes until it is switched on from the Web sidebar's Plugins page or installed explicitly. Auto review is experimental: it can allow unsafe actions, deny useful work, and spend additional tokens.
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
@@ -47,6 +47,12 @@ Auto reviews every supported call once before its body, including each started P
|
|
|
47
47
|
|
|
48
48
|
A final denial uses the ordinary tool card. The collapsed row identifies Auto review; expanded output states that the body did not execute and displays the optional reason. [The Web permission package](../../client/ui-permission-presets/README.md) owns picker interaction, and [the tool UI](../../client/ui-tool/README.md) owns reason display.
|
|
49
49
|
|
|
50
|
+
### Auto on the container backend
|
|
51
|
+
|
|
52
|
+
While a session runs on the [Apple container backend](../../sandbox/sandbox-apple-container/README.md), Auto keeps the sandbox: selecting it writes `workspace-write` instead of `danger-full-access`, so allowed commands run confined in the container. A call that has to leave the container, such as the model's one-shot `sandbox_permissions` escalation or a read outside the workspace, is decided by the reviewer instead of the user: an allowed call answers every approval it raises while it runs. A call the reviewer denied still asks the user about the call itself, and any approval it then raises reaches the user as well. The outer `run_code` transport is not reviewed, so an escalation of its own process still asks the user.
|
|
53
|
+
|
|
54
|
+
A session recorded while Auto always wrote `danger-full-access` is confined at its next call once its backend confines reads. A backend switch never widens a confined Auto session, so after `/sandbox local` select Auto again to return to Full access on the host. Backends that confine writes alone keep Auto at Full access.
|
|
55
|
+
|
|
50
56
|
-----
|
|
51
57
|
|
|
52
58
|
<a id="understand-the-implementation"></a>
|
|
@@ -55,11 +61,13 @@ A final denial uses the ordinary tool card. The collapsed row identifies Auto re
|
|
|
55
61
|
<details>
|
|
56
62
|
<summary>Implementation internals — click to expand</summary>
|
|
57
63
|
|
|
58
|
-
[`cordis.patch.yml`](cordis.patch.yml) inserts the package itself as the `auto-review` row. [`src/index.ts`](src/index.ts) requires the approval, LLM, permission, Session, and tools services, then installs the preset contribution and prepended pre-execute listener in one effect. After the review settles, a denial reads the Session's approval policy: under `never` it is final; under `ask` the listener delegates to later pre-execute listeners and returns the tools pipeline's `ask` decision only when they allow the call, so a later denial, cancellation, or `ask` (with its own reason) takes precedence. The `ask` decision carries an English audited reason and localized prompt text that keeps the raw reviewer reason. The [permission owner](../../interaction/permission-presets/README.md) supplies the current identity and process catalog; Auto
|
|
64
|
+
[`cordis.patch.yml`](cordis.patch.yml) inserts the package itself as the `auto-review` row. [`src/index.ts`](src/index.ts) requires the approval, LLM, permission, Session, and tools services, then installs the preset contribution and prepended pre-execute listener in one effect. After the review settles, a denial reads the Session's approval policy: under `never` it is final; under `ask` the listener delegates to later pre-execute listeners and returns the tools pipeline's `ask` decision only when they allow the call, so a later denial, cancellation, or `ask` (with its own reason) takes precedence. The `ask` decision carries an English audited reason and localized prompt text that keeps the raw reviewer reason. The [permission owner](../../interaction/permission-presets/README.md) supplies the current identity and process catalog; Auto writes the `ask` approval policy with Full access's sandbox value, or with `workspace-write` while the session's backend confines reads, and does not change tool definitions.
|
|
65
|
+
|
|
66
|
+
Two more listeners keep Auto on a confining backend. Before any call body, the pre-execute listener calls the preset service's `confineAuto(session)`, which narrows a session that still has `danger-full-access` while its backend confines reads by appending only the sandbox mode, so the approval policy a delegated child pins is unchanged; it runs for the unreviewed `run_code` transport too, and a rejected change, such as the persistent-terminal fence, fails the call instead of running it under the stale mode. A prepended `approval/request` listener answers `allowed-once` for a request that names a call the reviewer allowed, that is still running, in a session still in Auto; a downstream listener's own ask for that call is not covered, and `tools/post-execute` forgets the call when it settles.
|
|
59
67
|
|
|
60
68
|
The reviewer reconstructs five sections from the current Session surface and pending execution: fixed policy, cwd-only environment, sourced project constraints, filtered sourced history, and the complete pending action. Native schema comes from the latest request header. A PTC binding freezes its schema and carries it through the scheduler into transient execution metadata; start and settle events never serialize description or parameters. Main-agent `system/message` nodes, assistant text and reasoning, and tool results are excluded. The outer review input is a frozen `RequestUserInput` without durable identity or source; retained history keeps its original source attribution in the review text. [The decision record](../../../.agents/notes/implemented/feature/2026-08-28-auto-review.md) owns authority, lifecycle, and child-inheritance rationale.
|
|
61
69
|
|
|
62
|
-
Unloading closes selection and review admission, migrates live Auto Sessions
|
|
70
|
+
Unloading closes selection and review admission, migrates live Auto Sessions through the existing preset writer, then aborts and drains reviews before withdrawing the listener and contribution. A session at `danger-full-access` becomes Full access, which writes the `never` approval policy through the Session writer without queuing a policy-change notice; a session at `workspace-write` becomes Workspace Write, which writes the `ask` approval policy only when the session does not have it already. The model sees the new policy in the next runtime-context snapshot. Each session keeps its sandbox value, and persistent terminals survive the migration. A persisted Auto Session cannot publish without the complete integration; reopening it after installation is an explicit user action. Reinstalling the layer restores the option but does not switch live Sessions back to Auto.
|
|
63
71
|
|
|
64
72
|
</details>
|
|
65
73
|
|
|
@@ -82,7 +90,7 @@ Unloading closes selection and review admission, migrates live Auto Sessions to
|
|
|
82
90
|
|
|
83
91
|
#### What the model sees
|
|
84
92
|
|
|
85
|
-
The reviewer uses the latest `request/header.config` provider and model with the shipped adapter's default reasoning. The `temperature` setting accepts numbers from `0` through `2` or `provider-default`, which omits the request parameter; the plugin defaults to `0`, while the bundle selects `provider-default` only for the `tui` profile so providers that reject temperature can review calls. Its fixed `REVIEW_POLICY` replaces human approval for exactly one action: allow executes immediately with
|
|
93
|
+
The reviewer uses the latest `request/header.config` provider and model with the shipped adapter's default reasoning. The `temperature` setting accepts numbers from `0` through `2` or `provider-default`, which omits the request parameter; the plugin defaults to `0`, while the bundle selects `provider-default` only for the `tui` profile so providers that reject temperature can review calls. Its fixed `REVIEW_POLICY` replaces human approval for exactly one action: allow executes immediately, worded as with full host access even when the session keeps the container, so the reviewer judges every call as if it had that access. The other four sections contain only the retained facts described above. It returns one strict JSON text object with `risk` and `decision`; deny may include a string `reason`. Reasoning blocks may precede that single text block. Only `low + allow`, `medium + allow/deny`, and `high + deny` are valid.
|
|
86
94
|
|
|
87
95
|
#### Token effect
|
|
88
96
|
|
|
@@ -90,7 +98,7 @@ One additional model request per supported call. When a completed text response
|
|
|
90
98
|
|
|
91
99
|
#### KV Cache effect
|
|
92
100
|
|
|
93
|
-
The fixed reviewer policy can share a prefix; retained history and the pending action vary per call. Auto adds no dedicated runtime context or mode-switch prompt to the main agent.
|
|
101
|
+
The fixed reviewer policy can share a prefix; retained history and the pending action vary per call. Auto adds no dedicated runtime context or mode-switch prompt to the main agent. Selecting Auto on the container backend, or confining a session recorded at full access, changes the existing sandbox policy and backend contributions once; the new snapshot is appended after retained history, so the cached prefix is unchanged.
|
|
94
102
|
|
|
95
103
|
### Tool denial
|
|
96
104
|
|
|
@@ -111,7 +119,9 @@ The denial appends an ordinary tool result; it does not rewrite earlier context
|
|
|
111
119
|
<a id="known-limitations-and-deferred-work"></a>
|
|
112
120
|
|
|
113
121
|
- The shipped TUI profile includes Auto review. Default Web, Headless, General settings, and new-session defaults omit it until this layer is switched on.
|
|
114
|
-
- Auto provides no file sandbox. The outer `run_code` transport and direct Node effects inside a PTC program do not pass through inner-tool review.
|
|
122
|
+
- Auto provides no file sandbox of its own. On a backend that confines reads it keeps that backend's `workspace-write` confinement, and elsewhere it runs with Full access. The outer `run_code` transport and direct Node effects inside a PTC program do not pass through inner-tool review.
|
|
123
|
+
- The fixed reviewer policy words every allow as full host access and the reviewer is not told the session's sandbox mode, so it can deny a call the container would have contained.
|
|
124
|
+
- A reviewer allow that answers an approval is logged as an ordinary `approval/decided` event with the `allowed-once` outcome. The audit trail does not record that the reviewer, not the user, granted it, and the reviewer's risk and decision are not persisted.
|
|
115
125
|
- Model classification can be wrong. There are no deterministic tool exemptions, persistent grants, or configurable policy. Formatting retries cannot correct a valid but mistaken classification.
|
|
116
126
|
- In-process Auto children review their own calls. Out-of-process children retain their native permission systems after the parent delegation call is allowed.
|
|
117
127
|
- The reviewer reads the Session action history through the deprecated synchronous `snapshotEvents()` reader under a line-scoped waiver. Prior calls, PTC starts, and the direct parent's initial prompt have no projection or paged reader yet, so the migration stays deferred by [the synchronous-read decision](../../../.agents/notes/implemented/architecture/2026-09-09-deprecate-synchronous-session-event-reads.md).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "添加实验性逐调用 Auto review,在工具以 Full access 执行前使用当前 agent
|
|
2
|
+
description: "添加实验性逐调用 Auto review,在工具以 Full access 执行前使用当前 agent 的模型审查;沙箱后端限制读取时则在受限状态下执行。"
|
|
3
3
|
kind: "package-bundle"
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ kind: "package-bundle"
|
|
|
9
9
|
|
|
10
10
|
## 概述
|
|
11
11
|
|
|
12
|
-
为当前会话权限选择器添加 Auto review。每次原生或 PTC inner 工具调用前,当前 agent 的 provider 与模型会评估待执行动作;获准调用以 Full access
|
|
12
|
+
为当前会话权限选择器添加 Auto review。每次原生或 PTC inner 工具调用前,当前 agent 的 provider 与模型会评估待执行动作;获准调用以 Full access 执行,会话运行在 Apple container 后端时则在容器内受限执行,被拒绝调用会请求用户审批。随附的 TUI profile 包含此层。在 Web 侧栏插件页开启或显式安装之前,默认 Web 保持三种权限模式。Auto review 是实验功能:它可能误放行不安全动作、误拒绝有用操作,并消耗额外 token。
|
|
13
13
|
|
|
14
14
|
## 目录
|
|
15
15
|
|
|
@@ -47,6 +47,12 @@ Auto 在每个受支持调用的 body 执行前审查一次,包括每个已开
|
|
|
47
47
|
|
|
48
48
|
最终拒绝使用普通工具卡片。折叠行标识 Auto review;展开输出说明 body 未执行,并显示可选理由。[Web 权限包](../../client/ui-permission-presets/README.zh.md)拥有选择器交互,[工具 UI](../../client/ui-tool/README.zh.md)拥有理由展示。
|
|
49
49
|
|
|
50
|
+
### Auto 在容器后端上
|
|
51
|
+
|
|
52
|
+
会话运行在 [Apple container 后端](../../sandbox/sandbox-apple-container/README.zh.md)时,Auto 会保留沙箱:选择它写入 `workspace-write` 而不是 `danger-full-access`,因此获准的命令在容器内受限运行。必须离开容器的调用,例如模型发起的一次性 `sandbox_permissions` 提权或读取工作区之外的内容,由 reviewer 而不是用户决定:获准的调用在运行期间提出的每一项审批都由它代为应答。被 reviewer 拒绝的调用仍会就该调用本身请求用户审批,其随后提出的任何审批也会交给用户。外层 `run_code` transport 不经过审查,因此对其自身进程的提权仍会请求用户审批。
|
|
53
|
+
|
|
54
|
+
在 Auto 一律写入 `danger-full-access` 时记录的会话,一旦其后端限制读取,就会在下一次调用时被限制。切换后端绝不会放宽已受限的 Auto 会话,因此执行 `/sandbox local` 后,需要再次选择 Auto 才能回到宿主机上的 Full access。只限制写入的后端让 Auto 保持 Full access。
|
|
55
|
+
|
|
50
56
|
-----
|
|
51
57
|
|
|
52
58
|
<a id="understand-the-implementation"></a>
|
|
@@ -55,11 +61,13 @@ Auto 在每个受支持调用的 body 执行前审查一次,包括每个已开
|
|
|
55
61
|
<details>
|
|
56
62
|
<summary>实现内部机制——点击展开</summary>
|
|
57
63
|
|
|
58
|
-
[`cordis.patch.yml`](cordis.patch.yml)把本包自身插入为 `auto-review` 行。[`src/index.ts`](src/index.ts)要求 approval、LLM、permission、Session 与 tools 服务,然后在同一个 effect 中安装 preset contribution 和置前的 pre-execute listener。Review 结束后,拒绝会读取 Session 的审批策略:`never` 下为最终拒绝;`ask` 下 listener 先交给后续 pre-execute listener,只有它们放行调用时才返回 tools 流水线的 `ask` 决定,因此后续的拒绝、取消或 `ask`(带自己的理由)优先。`ask` 决定携带英文审计理由,以及保留原始 reviewer 理由的本地化提示文本。[权限 owner](../../interaction/permission-presets/README.zh.md)提供当前身份和进程目录;Auto
|
|
64
|
+
[`cordis.patch.yml`](cordis.patch.yml)把本包自身插入为 `auto-review` 行。[`src/index.ts`](src/index.ts)要求 approval、LLM、permission、Session 与 tools 服务,然后在同一个 effect 中安装 preset contribution 和置前的 pre-execute listener。Review 结束后,拒绝会读取 Session 的审批策略:`never` 下为最终拒绝;`ask` 下 listener 先交给后续 pre-execute listener,只有它们放行调用时才返回 tools 流水线的 `ask` 决定,因此后续的拒绝、取消或 `ask`(带自己的理由)优先。`ask` 决定携带英文审计理由,以及保留原始 reviewer 理由的本地化提示文本。[权限 owner](../../interaction/permission-presets/README.zh.md)提供当前身份和进程目录;Auto 写入 `ask` 审批策略,搭配 Full access 的沙箱值;会话的后端限制读取时则搭配 `workspace-write`;它不改变工具定义。
|
|
65
|
+
|
|
66
|
+
另有两个 listener 让 Auto 留在受限后端上。在任何调用 body 之前,pre-execute listener 会调用权限预设服务的 `confineAuto(session)`,它在后端限制读取时收窄仍为 `danger-full-access` 的会话,只追加沙箱模式,因此委派子会话所固定的审批策略不变;它对未经审查的 `run_code` transport 同样运行,被拒绝的变更(例如持久终端的沙箱模式限制)会使调用失败,而不是让它在陈旧的模式下运行。置前的 `approval/request` listener 对满足以下条件的请求应答 `allowed-once`:请求指向 reviewer 已放行、仍在运行的调用,且会话仍处于 Auto;下游 listener 针对该调用自己发起的审批不在其覆盖范围内,调用结算时 `tools/post-execute` 会让它忘记该调用。
|
|
59
67
|
|
|
60
68
|
Reviewer 从当前 Session surface 与待执行调用重建五个分区:固定策略、仅 cwd 的环境、带来源的项目约束、过滤后带来源的历史,以及完整待审动作。原生 schema 来自最新 request header。PTC binding 冻结其 schema,经由调度器传入临时执行元数据;开始与结算事件都不序列化描述或参数 schema。主 agent 的 `system/message` 节点、assistant 正文与 reasoning、tool results 全部排除。外层评审输入是冻结的 `RequestUserInput`,不含持久身份或来源;保留历史在评审文本中仍携带原始来源。[决策记录](../../../.agents/notes/implemented/feature/2026-08-28-auto-review.zh.md)拥有权威、生命周期与 child 继承的理由。
|
|
61
69
|
|
|
62
|
-
卸载时先关闭选择与 review admission,经由既有 preset writer
|
|
70
|
+
卸载时先关闭选择与 review admission,经由既有 preset writer 迁移存活 Auto Session,再中止并等待在途 review 结清,最后撤回 listener 与 contribution。处于 `danger-full-access` 的会话变为 Full access,通过 Session writer 写入 `never` 审批策略,不排入策略变更通知;处于 `workspace-write` 的会话变为 Workspace Write,仅当会话尚无 `ask` 审批策略时才写入它。模型在下一次 runtime-context 快照中看到新策略。每个会话保留自己的沙箱值,持久终端在迁移中保持不变。持久 Auto Session 缺少完整 integration 时不能发布;安装后重新打开需要用户显式操作。重装只恢复选项,不把存活 Session 切回 Auto。
|
|
63
71
|
|
|
64
72
|
</details>
|
|
65
73
|
|
|
@@ -82,7 +90,7 @@ Reviewer 从当前 Session surface 与待执行调用重建五个分区:固定
|
|
|
82
90
|
|
|
83
91
|
#### 模型看到什么
|
|
84
92
|
|
|
85
|
-
Reviewer 使用最新 `request/header.config` 的 provider 与模型,并沿用 shipped adapter 默认 reasoning。`temperature` 设置接受 `0` 到 `2` 的数值或 `provider-default`;后者省略请求参数。插件默认值为 `0`,bundle 仅在 `tui` profile 中选择 `provider-default`,使不接受 temperature 的 provider 也能审查调用。固定 `REVIEW_POLICY` 替代恰好一个动作的人工审批:allow
|
|
93
|
+
Reviewer 使用最新 `request/header.config` 的 provider 与模型,并沿用 shipped adapter 默认 reasoning。`temperature` 设置接受 `0` 到 `2` 的数值或 `provider-default`;后者省略请求参数。插件默认值为 `0`,bundle 仅在 `tui` profile 中选择 `provider-default`,使不接受 temperature 的 provider 也能审查调用。固定 `REVIEW_POLICY` 替代恰好一个动作的人工审批:allow 后立即执行,措辞上视为拥有完整宿主机访问权限,即使会话保留着容器也是如此,因此 reviewer 会把每个调用都当作拥有该权限来评判。其余四个分区只包含上文列出的保留事实。响应为一个严格 JSON text 对象,包含 `risk` 与 `decision`;deny 可附字符串 `reason`。Reasoning blocks 可以位于这唯一 text block 之前。只有 `low + allow`、`medium + allow/deny` 和 `high + deny` 合法。
|
|
86
94
|
|
|
87
95
|
#### Token 影响
|
|
88
96
|
|
|
@@ -90,7 +98,7 @@ Reviewer 使用最新 `request/header.config` 的 provider 与模型,并沿用
|
|
|
90
98
|
|
|
91
99
|
#### KV Cache 影响
|
|
92
100
|
|
|
93
|
-
固定 reviewer policy 可以共享前缀;保留历史与待审动作随调用变化。Auto 不向主 agent 增加专门 runtime context
|
|
101
|
+
固定 reviewer policy 可以共享前缀;保留历史与待审动作随调用变化。Auto 不向主 agent 增加专门 runtime context 或模式切换提示词。在容器后端上选择 Auto,或限制一个按完全访问记录的会话,会让既有的沙箱策略与后端贡献变化一次;新快照追加在保留历史之后,因此缓存前缀不变。
|
|
94
102
|
|
|
95
103
|
### 工具拒绝
|
|
96
104
|
|
|
@@ -111,7 +119,9 @@ Reviewer 使用最新 `request/header.config` 的 provider 与模型,并沿用
|
|
|
111
119
|
<a id="known-limitations-and-deferred-work"></a>
|
|
112
120
|
|
|
113
121
|
- 随附的 TUI profile 包含 Auto review。默认 Web、Headless、通用设置与新会话默认值在开启此层之前都不包含它。
|
|
114
|
-
- Auto
|
|
122
|
+
- Auto 自身不提供文件沙箱。在限制读取的后端上,它保留该后端的 `workspace-write` 限制,其他后端上以 Full access 运行。外层 `run_code` transport 及 PTC 程序内直接 Node 效果不经过 inner-tool review。
|
|
123
|
+
- 固定 reviewer policy 把每次 allow 都表述为完整宿主机访问,且不会告知 reviewer 会话的沙箱模式,因此它可能拒绝容器本可限制住的调用。
|
|
124
|
+
- 应答审批的 reviewer allow 会记录为普通的 `approval/decided` 事件,结果为 `allowed-once`。审计轨迹不会记录这次授权来自 reviewer 而非用户,reviewer 的 risk 与 decision 也不持久化。
|
|
115
125
|
- 模型分类可能出错。不提供确定性工具豁免、持久 grant 或可配置策略。格式重试无法纠正有效但错误的分类。
|
|
116
126
|
- 进程内 Auto child 独立审查自身调用。进程外 child 在父委派调用获准后保留原生权限系统。
|
|
117
127
|
- reviewer 在带行级豁免的情况下,通过已废弃的同步 `snapshotEvents()` 读取 Session 动作历史。此前的调用、PTC start 与直接父级的初始 prompt 目前都没有投影或分页读取方,因此迁移按[同步读取决策](../../../.agents/notes/implemented/architecture/2026-09-09-deprecate-synchronous-session-event-reads.zh.md)继续延期。
|
|
@@ -11,6 +11,11 @@ import { RUN_CODE_NAME } from "@deepseek-ai/dsh-tools";
|
|
|
11
11
|
* Under the `ask` approval policy a reviewer denial asks the user; under
|
|
12
12
|
* `never` it is final.
|
|
13
13
|
*
|
|
14
|
+
* An allowed call also answers the approvals it raises while it runs, such as a
|
|
15
|
+
* one-shot sandbox escalation, so the reviewer decides instead of the user. On a
|
|
16
|
+
* backend that confines reads, Auto keeps the sandbox: its mode is
|
|
17
|
+
* `workspace-write`, and only such an escalation leaves it.
|
|
18
|
+
*
|
|
14
19
|
* @module @deepseek-ai/dsh-experimental-auto-review
|
|
15
20
|
*/
|
|
16
21
|
/** Structured error name persisted for every final reviewer denial. */
|
|
@@ -486,17 +491,33 @@ function failed(exec, error) {
|
|
|
486
491
|
reason: `Auto review of tool "${exec.name}" failed; its body was not executed: ${message}`
|
|
487
492
|
};
|
|
488
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* The preset a live Auto session migrates to when the integration unloads: it
|
|
496
|
+
* keeps the session's sandbox mode, so migration neither widens it nor trips the
|
|
497
|
+
* persistent-terminal mode fence.
|
|
498
|
+
*/
|
|
499
|
+
function migrationPreset(ctx, session) {
|
|
500
|
+
return ctx.get("sandboxPolicy")?.overrideOf(session) === "workspace-write" ? "workspace-write" : "danger-full-access";
|
|
501
|
+
}
|
|
489
502
|
/** Install the Auto preset and its prepended per-call review gate. */
|
|
490
503
|
function apply(ctx, config) {
|
|
491
504
|
const permissionPresets = ctx.permissionPresets;
|
|
492
505
|
let accepting = true;
|
|
493
506
|
const active = /* @__PURE__ */ new Set();
|
|
494
507
|
const lifecycle = new AbortController();
|
|
508
|
+
const allowedCalls = /* @__PURE__ */ new WeakMap();
|
|
509
|
+
const allowCall = (agent, callId) => {
|
|
510
|
+
const calls = allowedCalls.get(agent) ?? /* @__PURE__ */ new Set();
|
|
511
|
+
calls.add(callId);
|
|
512
|
+
allowedCalls.set(agent, calls);
|
|
513
|
+
};
|
|
495
514
|
ctx.effect(function* () {
|
|
496
515
|
yield ctx.on("tools/pre-execute", async (exec, next) => {
|
|
497
516
|
const agent = exec.agent;
|
|
498
|
-
if (agent === void 0
|
|
517
|
+
if (agent === void 0) return next();
|
|
499
518
|
if (permissionPresets.current(agent.session) !== AUTO_PRESET) return next();
|
|
519
|
+
if (accepting) permissionPresets.confineAuto(agent.session);
|
|
520
|
+
if (exec.parent === void 0 && exec.name === RUN_CODE_NAME) return next();
|
|
500
521
|
if (!accepting || lifecycle.signal.aborted) return { kind: "cancel" };
|
|
501
522
|
const completed = Promise.withResolvers();
|
|
502
523
|
active.add(completed.promise);
|
|
@@ -514,13 +535,26 @@ function apply(ctx, config) {
|
|
|
514
535
|
if (decision.decision === "deny" && ctx.approval.overrideOf(agent.session) === "never") return denied(exec, decision.reason);
|
|
515
536
|
const downstream = await next();
|
|
516
537
|
if (isAborted(lifecycle.signal)) return { kind: "cancel" };
|
|
517
|
-
if (decision.decision === "allow"
|
|
538
|
+
if (decision.decision === "allow") {
|
|
539
|
+
if (downstream.kind === "allow") allowCall(agent, exec.callId);
|
|
540
|
+
return downstream;
|
|
541
|
+
}
|
|
542
|
+
if (downstream.kind !== "allow") return downstream;
|
|
518
543
|
return askUser(exec, decision.reason);
|
|
519
544
|
} finally {
|
|
520
545
|
active.delete(completed.promise);
|
|
521
546
|
completed.resolve();
|
|
522
547
|
}
|
|
523
548
|
}, { prepend: true });
|
|
549
|
+
yield ctx.on("approval/request", (request, next) => {
|
|
550
|
+
if (request.callId === void 0 || allowedCalls.get(request.agent)?.has(request.callId) !== true) return next();
|
|
551
|
+
if (permissionPresets.current(request.agent.session) !== AUTO_PRESET) return next();
|
|
552
|
+
return Promise.resolve("allowed-once");
|
|
553
|
+
}, { prepend: true });
|
|
554
|
+
yield ctx.on("tools/post-execute", (exec, _result, next) => {
|
|
555
|
+
if (exec.agent !== void 0) allowedCalls.get(exec.agent)?.delete(exec.callId);
|
|
556
|
+
return next();
|
|
557
|
+
}, { prepend: true });
|
|
524
558
|
yield permissionPresets.registerAuto(() => {
|
|
525
559
|
if (!accepting) throw new Error("auto-review: integration is closing");
|
|
526
560
|
});
|
|
@@ -529,7 +563,7 @@ function apply(ctx, config) {
|
|
|
529
563
|
try {
|
|
530
564
|
for (const session of ctx.sessions.list()) {
|
|
531
565
|
if (permissionPresets.current(session) !== AUTO_PRESET) continue;
|
|
532
|
-
permissionPresets.set(session,
|
|
566
|
+
permissionPresets.set(session, migrationPreset(ctx, session));
|
|
533
567
|
}
|
|
534
568
|
} finally {
|
|
535
569
|
lifecycle.abort(/* @__PURE__ */ new Error("auto-review integration disposed"));
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"@deepseek-ai/dsh-permission-presets": "0.2.1-alpha.1",
|
|
61
61
|
"@deepseek-ai/dsh-ptc-runtime-node": "0.2.1-alpha.1",
|
|
62
62
|
"@deepseek-ai/dsh-sandbox": "0.2.1-alpha.1",
|
|
63
|
+
"@deepseek-ai/dsh-sandbox-apple-container": "0.2.0-rc.2",
|
|
63
64
|
"@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.1",
|
|
64
65
|
"@deepseek-ai/dsh-session": "0.2.1-alpha.1",
|
|
65
66
|
"@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
en: 3b3fe69be228870a
|
|
22
22
|
zh: af3f146f86615ad4
|
|
23
23
|
/deepseek-ai-dsh-permission-presets/use-this-package/switching-presets:
|
|
24
|
-
en:
|
|
25
|
-
zh:
|
|
24
|
+
en: 3004d00a18c56e0c
|
|
25
|
+
zh: 9d6d536017a85b50
|
|
26
26
|
/deepseek-ai-dsh-permission-presets/use-this-package/what-users-see:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
27
|
+
en: d7a2005199968758
|
|
28
|
+
zh: 05141e093c4d05e0
|
|
29
29
|
/deepseek-ai-dsh-permission-presets/use-this-package/session-defaults:
|
|
30
30
|
en: 88218998b169a203
|
|
31
31
|
zh: 7a3646ff0ca28549
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
en: 172f5c8af5705ada
|
|
37
37
|
zh: b424834e38adb25d
|
|
38
38
|
/deepseek-ai-dsh-permission-presets/understand-the-implementation/write-path:
|
|
39
|
-
en:
|
|
40
|
-
zh:
|
|
39
|
+
en: 795fbc41a089f6fe
|
|
40
|
+
zh: f239cc3e060d44f1
|
|
41
41
|
/deepseek-ai-dsh-permission-presets/understand-the-implementation/read-side-and-custom:
|
|
42
|
-
en:
|
|
43
|
-
zh:
|
|
42
|
+
en: 92b52102237657ac
|
|
43
|
+
zh: f2e2c091ef82cdd9
|
|
44
44
|
/deepseek-ai-dsh-permission-presets/understand-the-implementation/session-pinning-and-blank-reuse:
|
|
45
45
|
en: 893cea88bce22903
|
|
46
46
|
zh: 2431e19ced670511
|
|
@@ -53,11 +53,11 @@ The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-a
|
|
|
53
53
|
|
|
54
54
|
### Switching presets
|
|
55
55
|
|
|
56
|
-
Switching to Auto first runs its synchronous admission check; every preset switch then changes only the knobs whose effective value differs, and selecting the preset already in effect changes nothing. The current value resolves as the still-matching last recorded selection, including a recorded Auto selection under
|
|
56
|
+
Switching to Auto first runs its synchronous admission check; every preset switch then changes only the knobs whose effective value differs, and selecting the preset already in effect changes nothing. The current value resolves as the still-matching last recorded selection, including a recorded Auto selection under either approval policy and either sandbox value Auto writes, else the first matching configured entry, else `custom`. Users switch through the `/permission` command: a bare invocation reports the current preset and every available entry, and a preset argument switches to it.
|
|
57
57
|
|
|
58
58
|
### What users see
|
|
59
59
|
|
|
60
|
-
Clients render selectable entries from the process catalog: configured presets in table order followed by Auto while its integration is live. They join that snapshot with the Session's current value; an unmatched `custom` value may label the current control but never appears as a selectable catalog row. Auto's identity and knob bundle
|
|
60
|
+
Clients render selectable entries from the process catalog: configured presets in table order followed by Auto while its integration is live. They join that snapshot with the Session's current value; an unmatched `custom` value may label the current control but never appears as a selectable catalog row. Auto's identity and knob bundle are fixed inside this service: the `ask` approval policy with the Full access sandbox, or with `workspace-write` while the session's sandbox backend also confines reads, so Auto keeps the Apple container. A recorded Auto selection also matches either sandbox value and the `never` policy that delegated children pin. The shipped client locale dictionaries own Auto's label and description, while configured presets retain Host-supplied presentation. Callers cannot publish another preset through a generic contribution API, and they can switch away from `custom` but cannot select or persist a named custom preset through this service.
|
|
61
61
|
|
|
62
62
|
### Session defaults
|
|
63
63
|
|
|
@@ -82,11 +82,11 @@ The observable behavior is covered in [Use this package](#use-this-package); thi
|
|
|
82
82
|
|
|
83
83
|
### Write path
|
|
84
84
|
|
|
85
|
-
`set()` resolves the preset and synchronously runs Auto admission when applicable. Transitions append `permission/preset` only when the effective preset changes, then write each changed knob through its canonical setter — `setSandboxMode` from `dsh-sandbox-policy` and `setApprovalPolicy` from `dsh-user-approval`. The selection event therefore preserves user intent when two presets share a bundle. Switching between Auto and Full access records the new identity and the changed approval policy. A net-zero selection appends nothing.
|
|
85
|
+
`set()` resolves the preset and synchronously runs Auto admission when applicable. For Auto it resolves the sandbox value from `ctx.sandboxPolicy.confinesReads(session)`: `workspace-write` on a backend that confines reads, otherwise `danger-full-access`. The value is logged like any knob, so a backend switch never rewrites it and selecting Auto again resolves it anew. Transitions append `permission/preset` only when the effective preset changes, then write each changed knob through its canonical setter — `setSandboxMode` from `dsh-sandbox-policy` and `setApprovalPolicy` from `dsh-user-approval`. The selection event therefore preserves user intent when two presets share a bundle. Switching between Auto and Full access records the new identity and the changed approval policy, and also the sandbox mode when the session's backend confines reads. A net-zero selection appends nothing. `confineAuto(session)` is the one other write: it narrows an Auto session that still has `danger-full-access` to `workspace-write` when its backend confines reads, appending only `sandbox/mode`. It never widens a confined session and leaves the identity and the approval policy a delegated child pins unchanged.
|
|
86
86
|
|
|
87
87
|
### Read side and `custom`
|
|
88
88
|
|
|
89
|
-
`current(session)` reads the required `permissions` projection, whose unit folds the three whole-value knob events over the composition defaults (`ctx.shell.sandboxMode` and the approval config). The host state also retains whether `session/end-seed` has occurred, so session pinning distinguishes an explicitly empty restored seed from a genuinely fresh session without rescanning the log. A still-matching last selection wins shared-bundle ties, and a recorded Auto selection also matches
|
|
89
|
+
`current(session)` reads the required `permissions` projection, whose unit folds the three whole-value knob events over the composition defaults (`ctx.shell.sandboxMode` and the approval config). The host state also retains whether `session/end-seed` has occurred, so session pinning distinguishes an explicitly empty restored seed from a genuinely fresh session without rescanning the log. A still-matching last selection wins shared-bundle ties, and a recorded Auto selection also matches either approval policy and either sandbox value Auto writes; otherwise the first configured match wins; otherwise the derived `CUSTOM_PRESET` is returned. A missing projection key fails explicitly.
|
|
90
90
|
|
|
91
91
|
`optionOf(name)` returns a configured entry, the live Auto entry, or the display-only `custom` entry. It throws only when the name matches none of those; a withdrawn Auto entry is unavailable.
|
|
92
92
|
|
|
@@ -53,11 +53,11 @@ kind: "package-reference"
|
|
|
53
53
|
|
|
54
54
|
### 切换预设
|
|
55
55
|
|
|
56
|
-
切换到 Auto 时,服务先同步执行其准入检查;每次预设切换随后只改变实际值不同的旋钮,再次选择当前已生效的预设不会产生任何变化。当前值解析顺序为:仍匹配的最近一次记录选择(已记录的 Auto
|
|
56
|
+
切换到 Auto 时,服务先同步执行其准入检查;每次预设切换随后只改变实际值不同的旋钮,再次选择当前已生效的预设不会产生任何变化。当前值解析顺序为:仍匹配的最近一次记录选择(已记录的 Auto 选择在任一审批策略、且沙箱值为 Auto 会写入的两种之一时也匹配),其次是配置表中的第一个匹配项,否则为 `custom`。用户通过 `/permission` 命令切换:不带参数调用时报告当前预设与所有可用条目,带预设参数时切换过去。
|
|
57
57
|
|
|
58
58
|
### 用户看到什么
|
|
59
59
|
|
|
60
|
-
客户端从进程级目录渲染可选条目:先按表顺序列出配置预设,再在 Auto integration 存活时列出 Auto。客户端把这份快照与 Session 当前值合并;不匹配的 `custom` 值可以标记当前控件,但绝不会成为可选目录行。Auto
|
|
60
|
+
客户端从进程级目录渲染可选条目:先按表顺序列出配置预设,再在 Auto integration 存活时列出 Auto。客户端把这份快照与 Session 当前值合并;不匹配的 `custom` 值可以标记当前控件,但绝不会成为可选目录行。Auto 的身份与旋钮组合固定在本服务内部:`ask` 审批策略搭配 Full access 沙箱,当会话的沙箱后端同时限制读取时则搭配 `workspace-write`,因此 Auto 会保留 Apple container。已记录的 Auto 选择也匹配这两种沙箱值,以及委派子会话固定的 `never` 策略。shipped 客户端的 locale 字典拥有 Auto 的 label 与 description,而配置预设保留 Host 提供的展示信息。调用方不能通过通用 contribution API 发布其他预设;他们可以从 `custom` 切换出去,但不能通过此服务选中或持久化一个具名 custom 预设。
|
|
61
61
|
|
|
62
62
|
### 会话默认值
|
|
63
63
|
|
|
@@ -82,11 +82,11 @@ kind: "package-reference"
|
|
|
82
82
|
|
|
83
83
|
### 写入路径
|
|
84
84
|
|
|
85
|
-
`set()` 解析预设,并在适用时同步执行 Auto
|
|
85
|
+
`set()` 解析预设,并在适用时同步执行 Auto 准入检查。对于 Auto,它根据 `ctx.sandboxPolicy.confinesReads(session)` 解析沙箱值:后端限制读取时为 `workspace-write`,否则为 `danger-full-access`。该值像任何旋钮一样写入日志,因此切换后端不会改写它,再次选择 Auto 会重新解析。切换仅在有效预设变化时追加 `permission/preset`,再通过各自的权威 setter——`dsh-sandbox-policy` 的 `setSandboxMode` 与 `dsh-user-approval` 的 `setApprovalPolicy`——写入每个变化的旋钮。因此,两个预设共享同一组取值时,选择事件仍会保留用户意图。Auto 与 Full access 之间切换时,记录新的身份与变化的审批策略,会话的后端限制读取时还会记录沙箱模式。净变化为零的选择不追加任何内容。`confineAuto(session)` 是另一个写入入口:当后端限制读取时,它把仍为 `danger-full-access` 的 Auto 会话收窄为 `workspace-write`,只追加 `sandbox/mode`。它绝不放宽已受限的会话,并保持身份以及委派子会话所固定的审批策略不变。
|
|
86
86
|
|
|
87
87
|
### 读取侧与 `custom`
|
|
88
88
|
|
|
89
|
-
`current(session)` 读取必需的 `permissions` 投影;该单元在组合默认值(`ctx.shell.sandboxMode` 与审批配置)之上折叠三个全量值旋钮事件。host 状态还会保留 `session/end-seed` 是否已经出现,使会话固定无需重扫日志即可区分显式为空的恢复 seed 与真正的新会话。仍匹配的最近选择在共享捆绑时胜出,已记录的 Auto
|
|
89
|
+
`current(session)` 读取必需的 `permissions` 投影;该单元在组合默认值(`ctx.shell.sandboxMode` 与审批配置)之上折叠三个全量值旋钮事件。host 状态还会保留 `session/end-seed` 是否已经出现,使会话固定无需重扫日志即可区分显式为空的恢复 seed 与真正的新会话。仍匹配的最近选择在共享捆绑时胜出,已记录的 Auto 选择在任一审批策略、且沙箱值为 Auto 会写入的两种之一时也匹配;否则配置表中的第一个匹配项胜出;否则返回推导出的 `CUSTOM_PRESET`。投影 key 缺失时会显式失败。
|
|
90
90
|
|
|
91
91
|
`optionOf(name)` 返回配置条目、存活的 Auto 条目或仅供显示的 `custom` 条目。只有名称不匹配这三者时才抛错;已撤回的 Auto 条目不可用。
|
|
92
92
|
|
|
@@ -53,12 +53,21 @@ const AUTO_PRESET = "auto";
|
|
|
53
53
|
/**
|
|
54
54
|
* Fixed execution bundle for the live Auto integration. `ask` routes reviewer
|
|
55
55
|
* denials to the user; a stored Auto identity also matches `never`, which a
|
|
56
|
-
* delegated child pins so its reviewer denials stay final.
|
|
56
|
+
* delegated child pins so its reviewer denials stay final. `sandbox` applies
|
|
57
|
+
* unless the session's backend confines reads, which keeps
|
|
58
|
+
* {@link CONFINED_AUTO_SANDBOX}.
|
|
57
59
|
*/
|
|
58
60
|
const AUTO_PRESET_SPEC = {
|
|
59
61
|
sandbox: "danger-full-access",
|
|
60
62
|
approval: "ask"
|
|
61
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* The sandbox mode Auto writes while the session's backend also confines
|
|
66
|
+
* reads (see `SandboxPolicyService.confinesReads`): the backend keeps
|
|
67
|
+
* confining commands and the review gate replaces the approval prompts for
|
|
68
|
+
* leaving it.
|
|
69
|
+
*/
|
|
70
|
+
const CONFINED_AUTO_SANDBOX = "workspace-write";
|
|
62
71
|
const permissionStateSchema = z$1.object({
|
|
63
72
|
preset: z$1.string().nullable(),
|
|
64
73
|
sandbox: z$1.union([
|
|
@@ -299,7 +308,7 @@ let PermissionPresetService = (() => {
|
|
|
299
308
|
if (state.preset !== null) {
|
|
300
309
|
const spec = this.specOf(state.preset);
|
|
301
310
|
if (spec !== void 0 && matches(spec)) return state.preset;
|
|
302
|
-
if (state.preset === "auto" && spec
|
|
311
|
+
if (state.preset === "auto" && spec !== void 0 && (sandbox === AUTO_PRESET_SPEC.sandbox || sandbox === CONFINED_AUTO_SANDBOX)) return AUTO_PRESET;
|
|
303
312
|
}
|
|
304
313
|
for (const [name, spec] of Object.entries(this.presets)) if (matches(spec)) return name;
|
|
305
314
|
return CUSTOM_PRESET;
|
|
@@ -307,7 +316,9 @@ let PermissionPresetService = (() => {
|
|
|
307
316
|
/**
|
|
308
317
|
* Resolve an available preset's knob bundle.
|
|
309
318
|
* @param name - the preset name to resolve.
|
|
310
|
-
* @returns the configured bundle
|
|
319
|
+
* @returns the configured bundle; for Auto, the bundle of a session whose
|
|
320
|
+
* backend does not confine reads. `set` writes `workspace-write` instead
|
|
321
|
+
* for a session whose backend confines reads.
|
|
311
322
|
* @throws when `name` is neither configured nor the currently live Auto preset.
|
|
312
323
|
*/
|
|
313
324
|
resolve(name) {
|
|
@@ -346,9 +357,36 @@ let PermissionPresetService = (() => {
|
|
|
346
357
|
setApprovalPolicy(session, policy);
|
|
347
358
|
});
|
|
348
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Narrow an Auto session that still has full access to the confined mode its
|
|
362
|
+
* backend keeps: a Session recorded before Auto kept the container, or one
|
|
363
|
+
* whose backend switched to it afterwards. Writes only the sandbox mode, so
|
|
364
|
+
* the preset identity and the approval policy a delegated child pins stay as
|
|
365
|
+
* they are. Never widens a confined session.
|
|
366
|
+
* @param session - the session to narrow.
|
|
367
|
+
* @returns whether the session's sandbox mode changed.
|
|
368
|
+
*/
|
|
369
|
+
confineAuto(session) {
|
|
370
|
+
if (this.current(session) !== "auto") return false;
|
|
371
|
+
if ((this.permissionState(session).sandbox ?? this.ctx.shell.sandboxMode) !== AUTO_PRESET_SPEC.sandbox || this.autoSandbox(session) !== CONFINED_AUTO_SANDBOX) return false;
|
|
372
|
+
setSandboxMode(session, CONFINED_AUTO_SANDBOX);
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* The sandbox mode an Auto selection writes for `session`: the confined mode
|
|
377
|
+
* while its backend also confines reads, otherwise full access. The mode is
|
|
378
|
+
* logged like any preset knob, so a later backend switch never rewrites it.
|
|
379
|
+
*/
|
|
380
|
+
autoSandbox(session) {
|
|
381
|
+
return this.ctx.get("sandboxPolicy")?.confinesReads(session) === true ? CONFINED_AUTO_SANDBOX : AUTO_PRESET_SPEC.sandbox;
|
|
382
|
+
}
|
|
349
383
|
/** Apply one preset through its durable identity and canonical knob setters. */
|
|
350
384
|
apply(session, name, setApproval) {
|
|
351
|
-
const
|
|
385
|
+
const resolved = this.resolve(name);
|
|
386
|
+
const spec = name === "auto" ? {
|
|
387
|
+
...resolved,
|
|
388
|
+
sandbox: this.autoSandbox(session)
|
|
389
|
+
} : resolved;
|
|
352
390
|
if (name === "auto") this.autoAdmit?.();
|
|
353
391
|
const current = this.current(session);
|
|
354
392
|
const knobs = this.permissionState(session);
|
|
@@ -35,7 +35,7 @@ export const TYPERT = {
|
|
|
35
35
|
typeSymbol: '@deepseek-ai/dsh-permission-presets/client#PermissionCatalog',
|
|
36
36
|
create: _deepseek_ai_dsh_permission_presets_permissionPresets_catalog_result$schema,
|
|
37
37
|
},
|
|
38
|
-
sourceLocation: {"file":"packages/interaction/permission-presets/src/index.ts","line":
|
|
38
|
+
sourceLocation: {"file":"packages/interaction/permission-presets/src/index.ts","line":305,"column":3},
|
|
39
39
|
},
|
|
40
40
|
],
|
|
41
41
|
model: {
|
|
@@ -88,7 +88,7 @@ export const TYPERT = {
|
|
|
88
88
|
"name": "resolve",
|
|
89
89
|
"signature": "resolve(name: string): PresetSpec",
|
|
90
90
|
"summary": "Resolve an available preset's knob bundle.",
|
|
91
|
-
"jsDoc": "/**\n * Resolve an available preset's knob bundle.\n * @param name - the preset name to resolve.\n * @returns the configured bundle.\n * @throws when `name` is neither configured nor the currently live Auto preset.\n */"
|
|
91
|
+
"jsDoc": "/**\n * Resolve an available preset's knob bundle.\n * @param name - the preset name to resolve.\n * @returns the configured bundle; for Auto, the bundle of a session whose\n * backend does not confine reads. `set` writes `workspace-write` instead\n * for a session whose backend confines reads.\n * @throws when `name` is neither configured nor the currently live Auto preset.\n */"
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
"kind": "method",
|
|
@@ -103,6 +103,13 @@ export const TYPERT = {
|
|
|
103
103
|
"signature": "set(session: Session, name: string): void",
|
|
104
104
|
"summary": "Record a changed preset, then update each changed knob through its own setter.",
|
|
105
105
|
"jsDoc": "/**\n * Record a changed preset, then update each changed knob through its own\n * setter. Selecting the effective preset again appends nothing.\n * @param session - the session the switch belongs to.\n * @param name - the preset to switch to; unknown names throw.\n */"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"kind": "method",
|
|
109
|
+
"name": "confineAuto",
|
|
110
|
+
"signature": "confineAuto(session: Session): boolean",
|
|
111
|
+
"summary": "Narrow an Auto session that still has full access to the confined mode its backend keeps: a Session recorded before Auto kept the container, or one whose backend switched to it afterwards.",
|
|
112
|
+
"jsDoc": "/**\n * Narrow an Auto session that still has full access to the confined mode its\n * backend keeps: a Session recorded before Auto kept the container, or one\n * whose backend switched to it afterwards. Writes only the sandbox mode, so\n * the preset identity and the approval policy a delegated child pins stay as\n * they are. Never widens a confined session.\n * @param session - the session to narrow.\n * @returns whether the session's sandbox mode changed.\n */"
|
|
106
113
|
}
|
|
107
114
|
],
|
|
108
115
|
"types": [
|
|
@@ -32,7 +32,7 @@ export const TYPERT_REMOTE = {
|
|
|
32
32
|
typeSymbol: '@deepseek-ai/dsh-permission-presets/client#PermissionCatalog',
|
|
33
33
|
create: _deepseek_ai_dsh_permission_presets_permissionPresets_catalog_result$schema,
|
|
34
34
|
},
|
|
35
|
-
sourceLocation: {"file":"packages/interaction/permission-presets/src/index.ts","line":
|
|
35
|
+
sourceLocation: {"file":"packages/interaction/permission-presets/src/index.ts","line":305,"column":3},
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
38
|
}
|
|
@@ -48,12 +48,21 @@ export const AUTO_PRESET = 'auto';
|
|
|
48
48
|
/**
|
|
49
49
|
* Fixed execution bundle for the live Auto integration. `ask` routes reviewer
|
|
50
50
|
* denials to the user; a stored Auto identity also matches `never`, which a
|
|
51
|
-
* delegated child pins so its reviewer denials stay final.
|
|
51
|
+
* delegated child pins so its reviewer denials stay final. `sandbox` applies
|
|
52
|
+
* unless the session's backend confines reads, which keeps
|
|
53
|
+
* {@link CONFINED_AUTO_SANDBOX}.
|
|
52
54
|
*/
|
|
53
55
|
const AUTO_PRESET_SPEC = {
|
|
54
56
|
sandbox: 'danger-full-access',
|
|
55
57
|
approval: 'ask',
|
|
56
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* The sandbox mode Auto writes while the session's backend also confines
|
|
61
|
+
* reads (see `SandboxPolicyService.confinesReads`): the backend keeps
|
|
62
|
+
* confining commands and the review gate replaces the approval prompts for
|
|
63
|
+
* leaving it.
|
|
64
|
+
*/
|
|
65
|
+
const CONFINED_AUTO_SANDBOX = 'workspace-write';
|
|
57
66
|
const permissionStateSchema = zod.object({
|
|
58
67
|
preset: zod.string().nullable(),
|
|
59
68
|
sandbox: zod.union([
|
|
@@ -268,7 +277,11 @@ let PermissionPresetService = (() => {
|
|
|
268
277
|
const spec = this.specOf(state.preset);
|
|
269
278
|
if (spec !== undefined && matches(spec))
|
|
270
279
|
return state.preset;
|
|
271
|
-
|
|
280
|
+
// A stored Auto selection keeps its identity under either approval policy
|
|
281
|
+
// and either sandbox mode it can write, so a session recorded before Auto
|
|
282
|
+
// kept the container still resolves to Auto and its review gate.
|
|
283
|
+
if (state.preset === AUTO_PRESET && spec !== undefined
|
|
284
|
+
&& (sandbox === AUTO_PRESET_SPEC.sandbox || sandbox === CONFINED_AUTO_SANDBOX))
|
|
272
285
|
return AUTO_PRESET;
|
|
273
286
|
}
|
|
274
287
|
for (const [name, spec] of Object.entries(this.presets)) {
|
|
@@ -280,7 +293,9 @@ let PermissionPresetService = (() => {
|
|
|
280
293
|
/**
|
|
281
294
|
* Resolve an available preset's knob bundle.
|
|
282
295
|
* @param name - the preset name to resolve.
|
|
283
|
-
* @returns the configured bundle
|
|
296
|
+
* @returns the configured bundle; for Auto, the bundle of a session whose
|
|
297
|
+
* backend does not confine reads. `set` writes `workspace-write` instead
|
|
298
|
+
* for a session whose backend confines reads.
|
|
284
299
|
* @throws when `name` is neither configured nor the currently live Auto preset.
|
|
285
300
|
*/
|
|
286
301
|
resolve(name) {
|
|
@@ -313,9 +328,38 @@ let PermissionPresetService = (() => {
|
|
|
313
328
|
set(session, name) {
|
|
314
329
|
this.apply(session, name, (policy) => { setApprovalPolicy(session, policy); });
|
|
315
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Narrow an Auto session that still has full access to the confined mode its
|
|
333
|
+
* backend keeps: a Session recorded before Auto kept the container, or one
|
|
334
|
+
* whose backend switched to it afterwards. Writes only the sandbox mode, so
|
|
335
|
+
* the preset identity and the approval policy a delegated child pins stay as
|
|
336
|
+
* they are. Never widens a confined session.
|
|
337
|
+
* @param session - the session to narrow.
|
|
338
|
+
* @returns whether the session's sandbox mode changed.
|
|
339
|
+
*/
|
|
340
|
+
confineAuto(session) {
|
|
341
|
+
if (this.current(session) !== AUTO_PRESET)
|
|
342
|
+
return false;
|
|
343
|
+
const standing = this.permissionState(session).sandbox ?? this.ctx.shell.sandboxMode;
|
|
344
|
+
if (standing !== AUTO_PRESET_SPEC.sandbox || this.autoSandbox(session) !== CONFINED_AUTO_SANDBOX)
|
|
345
|
+
return false;
|
|
346
|
+
setSandboxMode(session, CONFINED_AUTO_SANDBOX);
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The sandbox mode an Auto selection writes for `session`: the confined mode
|
|
351
|
+
* while its backend also confines reads, otherwise full access. The mode is
|
|
352
|
+
* logged like any preset knob, so a later backend switch never rewrites it.
|
|
353
|
+
*/
|
|
354
|
+
autoSandbox(session) {
|
|
355
|
+
return this.ctx.get('sandboxPolicy')?.confinesReads(session) === true
|
|
356
|
+
? CONFINED_AUTO_SANDBOX
|
|
357
|
+
: AUTO_PRESET_SPEC.sandbox;
|
|
358
|
+
}
|
|
316
359
|
/** Apply one preset through its durable identity and canonical knob setters. */
|
|
317
360
|
apply(session, name, setApproval) {
|
|
318
|
-
const
|
|
361
|
+
const resolved = this.resolve(name);
|
|
362
|
+
const spec = name === AUTO_PRESET ? { ...resolved, sandbox: this.autoSandbox(session) } : resolved;
|
|
319
363
|
if (name === AUTO_PRESET)
|
|
320
364
|
this.autoAdmit?.();
|
|
321
365
|
const current = this.current(session);
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
en: fe0f7d5ac6160763
|
|
28
28
|
zh: 4e1455a8559d46ca
|
|
29
29
|
/deepseek-ai-dsh-sandbox-apple-container/use-this-package/what-confinement-covers:
|
|
30
|
-
en:
|
|
31
|
-
zh:
|
|
30
|
+
en: 01b66f4de3beaaa2
|
|
31
|
+
zh: b416302045f030e2
|
|
32
32
|
/deepseek-ai-dsh-sandbox-apple-container/use-this-package/failures-and-recovery:
|
|
33
33
|
en: 79782500f91b1f06
|
|
34
34
|
zh: a132d680acb85edc
|
|
@@ -73,7 +73,7 @@ The fields of `@deepseek-ai/dsh-sandbox-local` also apply to the `local` backend
|
|
|
73
73
|
| A command plants a Git hook or config the host later runs | `.git` is read-only under `workspace-write`; writes fail with `Read-only file system` and use the normal escalation |
|
|
74
74
|
| A command writes outside the workspace | The write lands in the container's own disk and never reaches the host |
|
|
75
75
|
|
|
76
|
-
`danger-full-access` bypasses `confine`, so it runs on the host under either backend.
|
|
76
|
+
`danger-full-access` bypasses `confine`, so it runs on the host under either backend. The Auto permission does not write it while a session runs on this backend: it writes `workspace-write`, and the reviewer, not a prompt, approves a one-shot escalation that leaves the container ([Auto review](../../experimental/auto-review/README.md)). On the `local` backend Auto still writes `danger-full-access`.
|
|
77
77
|
|
|
78
78
|
### Failures and recovery
|
|
79
79
|
|
|
@@ -73,7 +73,7 @@ kind: "package-reference"
|
|
|
73
73
|
| 命令植入宿主机之后会执行的 Git hook 或配置 | 在 `workspace-write` 下 `.git` 为只读;写入以 `Read-only file system` 失败,并走常规提权流程 |
|
|
74
74
|
| 命令写入工作区之外 | 写入落在容器自己的磁盘上,永远不会到达宿主机 |
|
|
75
75
|
|
|
76
|
-
`danger-full-access` 绕过 `confine
|
|
76
|
+
`danger-full-access` 绕过 `confine`,因此在任一后端下都在宿主机上运行。会话运行在此后端时,Auto 权限不会写入它:而是写入 `workspace-write`,并由 reviewer 而不是提示批准离开容器的一次性提权([Auto review](../../experimental/auto-review/README.zh.md))。在 `local` 后端上,Auto 仍写入 `danger-full-access`。
|
|
77
77
|
|
|
78
78
|
### 失败与恢复
|
|
79
79
|
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
en: 2d560aa6681fcfb8
|
|
34
34
|
zh: e1c6361a6fa40c63
|
|
35
35
|
/deepseek-ai-dsh-sandbox-policy/understand-the-implementation/resolution-precedence:
|
|
36
|
-
en:
|
|
37
|
-
zh:
|
|
36
|
+
en: bc1dde4568efb44f
|
|
37
|
+
zh: 9e07b10b57e0717d
|
|
38
38
|
/deepseek-ai-dsh-sandbox-policy/understand-the-implementation/the-per-session-store:
|
|
39
39
|
en: d13dabff02f2acfd
|
|
40
40
|
zh: f593888b4ffddf36
|
|
@@ -69,7 +69,7 @@ This section explains policy resolution, the per-session store, and the model-vi
|
|
|
69
69
|
|
|
70
70
|
### Resolution precedence
|
|
71
71
|
|
|
72
|
-
`readScope(request)` asks the mounted `ctx.sandbox` provider what confined processes can read under the resolved policy, and `canRead(path, request)` checks a canonicalized path against it; model-facing file tools call `canRead` before reading. `resolve({ session, mode })` returns one complete per-call policy: an approved explicit mode outranks the session's last `sandbox/mode` event, which outranks the deployment default. The session's immutable `cwd` supplies the workspace root; otherwise the configured fallback applies. Absolute execution-world spelling is preserved. Enforcing providers canonicalize the root on their own filesystem, so remote `symlink/..` paths are never resolved on the Harness host.
|
|
72
|
+
`readScope(request)` asks the mounted `ctx.sandbox` provider what confined processes can read under the resolved policy, and `canRead(path, request)` checks a canonicalized path against it; model-facing file tools call `canRead` before reading. `confinesReads(session)` reports whether that scope exists under `workspace-write`, that is, whether the session's backend confines reads as well as writes; the Auto permission reads it to keep the sandbox on such a backend. `resolve({ session, mode })` returns one complete per-call policy: an approved explicit mode outranks the session's last `sandbox/mode` event, which outranks the deployment default. The session's immutable `cwd` supplies the workspace root; otherwise the configured fallback applies. Absolute execution-world spelling is preserved. Enforcing providers canonicalize the root on their own filesystem, so remote `symlink/..` paths are never resolved on the Harness host.
|
|
73
73
|
|
|
74
74
|
### The per-session store
|
|
75
75
|
|
|
@@ -69,7 +69,7 @@ kind: "package-reference"
|
|
|
69
69
|
|
|
70
70
|
### 解析优先级
|
|
71
71
|
|
|
72
|
-
`readScope(request)` 询问已挂载的 `ctx.sandbox` 提供方在解析出的策略下受限进程能读取什么,`canRead(path, request)` 用规范化后的路径对照该范围检查;面向模型的文件工具在读取前调用 `canRead`。`resolve({ session, mode })` 返回一份完整的逐调用策略:已批准的显式模式优先于会话最后一条 `sandbox/mode` 事件,后者又优先于部署默认值。会话的不可变 `cwd` 提供工作区根目录;否则使用配置的回退值。执行环境中的绝对路径写法保持不变。执行限制的提供方在自己的文件系统上规范化根目录,因此远端 `symlink/..` 路径绝不会在 Harness 主机上解析。
|
|
72
|
+
`readScope(request)` 询问已挂载的 `ctx.sandbox` 提供方在解析出的策略下受限进程能读取什么,`canRead(path, request)` 用规范化后的路径对照该范围检查;面向模型的文件工具在读取前调用 `canRead`。`confinesReads(session)` 报告在 `workspace-write` 下该范围是否存在,也就是会话的后端是否不仅限制写入、也限制读取;Auto 权限据此在这类后端上保留沙箱。`resolve({ session, mode })` 返回一份完整的逐调用策略:已批准的显式模式优先于会话最后一条 `sandbox/mode` 事件,后者又优先于部署默认值。会话的不可变 `cwd` 提供工作区根目录;否则使用配置的回退值。执行环境中的绝对路径写法保持不变。执行限制的提供方在自己的文件系统上规范化根目录,因此远端 `symlink/..` 路径绝不会在 Harness 主机上解析。
|
|
73
73
|
|
|
74
74
|
### 逐会话存储
|
|
75
75
|
|
|
@@ -170,6 +170,22 @@ var SandboxPolicyService = class extends Service {
|
|
|
170
170
|
return scope === void 0 || isReadableIn(path, scope);
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
|
+
* Whether the mounted provider confines a session's host reads as well as
|
|
174
|
+
* its writes under `workspace-write`, as the Apple container backend does
|
|
175
|
+
* while the session runs on it. Commands of such a session cannot read or
|
|
176
|
+
* change host files outside the workspace, so a policy that would otherwise
|
|
177
|
+
* bypass the sandbox can keep it at the cost of workspace-bound work only.
|
|
178
|
+
* Providers that confine writes alone report false.
|
|
179
|
+
* @param session - the session whose backend applies.
|
|
180
|
+
* @returns true when confined commands of `session` cannot read host files outside the read scope.
|
|
181
|
+
*/
|
|
182
|
+
confinesReads(session) {
|
|
183
|
+
return this.readScope({
|
|
184
|
+
session,
|
|
185
|
+
mode: "workspace-write"
|
|
186
|
+
}) !== void 0;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
173
189
|
* Read the session override without applying the deployment default.
|
|
174
190
|
* @param session - session whose log supplies the override.
|
|
175
191
|
* @returns the last logged mode, or `undefined` without one.
|
|
@@ -1587,7 +1587,7 @@ export const SERVICE_API = [
|
|
|
1587
1587
|
signature: 'resolve(name: string): PresetSpec',
|
|
1588
1588
|
description: 'Resolve an available preset\'s knob bundle.',
|
|
1589
1589
|
parameters: [{ name: 'name', description: 'the preset name to resolve.' }],
|
|
1590
|
-
returns: 'the configured bundle.',
|
|
1590
|
+
returns: 'the configured bundle; for Auto, the bundle of a session whose backend does not confine reads. `set` writes `workspace-write` instead for a session whose backend confines reads.',
|
|
1591
1591
|
throws: ['when `name` is neither configured nor the currently live Auto preset.'],
|
|
1592
1592
|
},
|
|
1593
1593
|
{
|
|
@@ -1602,6 +1602,12 @@ export const SERVICE_API = [
|
|
|
1602
1602
|
description: 'Record a changed preset, then update each changed knob through its own setter. Selecting the effective preset again appends nothing.',
|
|
1603
1603
|
parameters: [{ name: 'session', description: 'the session the switch belongs to.' }, { name: 'name', description: 'the preset to switch to; unknown names throw.' }],
|
|
1604
1604
|
},
|
|
1605
|
+
{
|
|
1606
|
+
signature: 'confineAuto(session: Session): boolean',
|
|
1607
|
+
description: 'Narrow an Auto session that still has full access to the confined mode its backend keeps: a Session recorded before Auto kept the container, or one whose backend switched to it afterwards. Writes only the sandbox mode, so the preset identity and the approval policy a delegated child pins stay as they are. Never widens a confined session.',
|
|
1608
|
+
parameters: [{ name: 'session', description: 'the session to narrow.' }],
|
|
1609
|
+
returns: 'whether the session\'s sandbox mode changed.',
|
|
1610
|
+
},
|
|
1605
1611
|
],
|
|
1606
1612
|
},
|
|
1607
1613
|
{
|
|
@@ -1862,6 +1868,12 @@ export const SERVICE_API = [
|
|
|
1862
1868
|
parameters: [{ name: 'path', description: 'the host path about to be opened or searched.' }, { name: 'request', description: 'optional session and approved mode override, as for {@link resolve}.' }],
|
|
1863
1869
|
returns: 'true when the read is allowed.',
|
|
1864
1870
|
},
|
|
1871
|
+
{
|
|
1872
|
+
signature: 'confinesReads(session: Session): boolean',
|
|
1873
|
+
description: 'Whether the mounted provider confines a session\'s host reads as well as its writes under `workspace-write`, as the Apple container backend does while the session runs on it. Commands of such a session cannot read or change host files outside the workspace, so a policy that would otherwise bypass the sandbox can keep it at the cost of workspace-bound work only. Providers that confine writes alone report false.',
|
|
1874
|
+
parameters: [{ name: 'session', description: 'the session whose backend applies.' }],
|
|
1875
|
+
returns: 'true when confined commands of `session` cannot read host files outside the read scope.',
|
|
1876
|
+
},
|
|
1865
1877
|
{
|
|
1866
1878
|
signature: 'overrideOf(session: Session): SandboxMode | undefined',
|
|
1867
1879
|
description: 'Read the session override without applying the deployment default.',
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
en: 192bbbb187278f91
|
|
19
19
|
zh: 1f7e5632c15bdcf7
|
|
20
20
|
/deepseek-ai-dsh-tui-app/use-this-package/starting-and-resuming:
|
|
21
|
-
en:
|
|
22
|
-
zh:
|
|
21
|
+
en: 19374746e69c8ca0
|
|
22
|
+
zh: 211dac2851029319
|
|
23
23
|
/deepseek-ai-dsh-tui-app/use-this-package/the-screen:
|
|
24
24
|
en: c0def609539d52c1
|
|
25
25
|
zh: 3f39ecad30f5162c
|
|
26
26
|
/deepseek-ai-dsh-tui-app/use-this-package/keys-and-commands:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
27
|
+
en: 248e4478a29c7837
|
|
28
|
+
zh: 5830a4bfdf9128e4
|
|
29
29
|
/deepseek-ai-dsh-tui-app/use-this-package/background-tool-calls:
|
|
30
30
|
en: 322ae3c6d76383ec
|
|
31
31
|
zh: 8c38eee4b57ed8dd
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
en: f124d406565fef39
|
|
46
46
|
zh: 90344b5eec319cad
|
|
47
47
|
/deepseek-ai-dsh-tui-app/understand-the-implementation/run-flow:
|
|
48
|
-
en:
|
|
49
|
-
zh:
|
|
48
|
+
en: 843f7f46161ca8d3
|
|
49
|
+
zh: ddff3216005e2b57
|
|
50
50
|
/deepseek-ai-dsh-tui-app/understand-the-implementation/rendering-model:
|
|
51
51
|
en: fb43018b679482fb
|
|
52
52
|
zh: e60cc1d0cbaa40a0
|
|
@@ -36,7 +36,7 @@ dsh tui --resume <session-id> # continue an earlier session
|
|
|
36
36
|
dsh tui --no-open # print sign-in URLs without opening a browser
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>` on stderr for the session bound at that moment. A resumed session redraws its persisted history before accepting input and continues with that session's last model, or the launch default when the log has no request header; inside the terminal, `/resume` and `/sessions` open the same picker over every persisted root session and resume the selected previous session, `/new`
|
|
39
|
+
On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>` on stderr for the session bound at that moment. A resumed session redraws its persisted history before accepting input and continues with that session's last model, or the launch default when the log has no request header; inside the terminal, `/resume` and `/sessions` open the same picker over every persisted root session and resume the selected previous session, `/new` starts a fresh empty session with the launch default model, while `/clear` starts a fresh empty session that retains the current model and reasoning effort; the previous session stays on disk for `/resume`, and `/fork` copies the current session up to its last completed turn into a new one, the same cut the browser's fork takes. Switching releases the previous Agent and redraws the transcript of the next.
|
|
40
40
|
|
|
41
41
|
### The screen
|
|
42
42
|
|
|
@@ -174,8 +174,8 @@ Typing `/` at the start of the editor completes the terminal's own commands and
|
|
|
174
174
|
| `/help` | List the commands, and the keys each focus state answers; `?` on an empty input does the same |
|
|
175
175
|
| `/model` | Pick the model (type to filter the rows), then its reasoning effort when the model declares more than one, for the next request; `/model <provider>/<model>` selects directly, `/model save` stores the current selection as the default, and `Ctrl+S` in the model list stores the highlighted model as the default for the next launch without closing the list |
|
|
176
176
|
| `/effort [id]` | With no argument, open the current model's reasoning-effort picker for the next request, the same picker as editor `Shift+Tab`; an id selects directly and `/effort default` restores the provider default |
|
|
177
|
-
| `/permission [preset]` | With no argument, open the permission-preset picker; a preset selects directly. The shipped profile includes experimental Auto review; `/permission auto` selects it for the current session |
|
|
178
|
-
| `/sandbox [container\|local]` | With the Apple container provider composed, open a backend picker with a live access preview; an argument switches directly through the shared command. The picker marks the current backend, omits unavailable containers with an explanation, and shows the workspace, read/write restrictions, and a warning when `danger-full-access` bypasses either backend. `Enter` applies; `Esc` keeps the current backend. File policy and approvals stay unchanged; `/permission` controls those |
|
|
177
|
+
| `/permission [preset]` | With no argument, open the permission-preset picker; a preset selects directly. The shipped profile includes experimental Auto review; `/permission auto` selects it for the current session, and on the Apple container backend it keeps the container (`workspace-write`) instead of switching to full access |
|
|
178
|
+
| `/sandbox [container\|local]` | With the Apple container provider composed, open a backend picker with a live access preview; an argument switches directly through the shared command. The picker marks the current backend, omits unavailable containers with an explanation, and shows the workspace, read/write restrictions, and a warning when `danger-full-access` bypasses either backend. `Enter` applies; `Esc` keeps the current backend. File policy and approvals stay unchanged; `/permission` controls those, except that an Auto session still at full access previews the container as confined, because Auto confines itself there from its next call |
|
|
179
179
|
| `/search [deepseek\|openrouter [model]]` | With no argument, open the web-search route picker; `deepseek` restores the default route and `openrouter` routes `web_search` through OpenRouter with `OPENROUTER_API_KEY` and the typed model (default: the model `/model` selected when it is an OpenRouter model, otherwise `deepseek/deepseek-v4-flash-0731`). It writes the `web-search-deepseek` settings namespace, which the next search reads |
|
|
180
180
|
| `/resume` | Open the same persisted-session picker as `/sessions` and resume the selected previous session |
|
|
181
181
|
| `/sessions` | Open the persisted-session picker and switch to the selected session |
|
|
@@ -264,7 +264,7 @@ The runner is a direct driver over the core API carrier, like `dsh-headless`, th
|
|
|
264
264
|
|
|
265
265
|
### Run flow
|
|
266
266
|
|
|
267
|
-
The runner awaits the complete application (`ctx.get('loader')?.await()`) and builds a session host over the core registry with five operations: `create` makes one fresh persisted Agent with the shared [`agentDefaultModel`](../../core/agent-default-model/README.md) selection, `resume` takes the Agent write handle first and then observes the live Session through `ctx.sessionQuery` so bind draws every persisted event including resume closers, and `fork` observes the source through `ctx.sessionQuery`, cuts after the chosen (by default the last) `turn/end` up to the next `turn/start`, and creates a seeded Agent with `parentSession` and `isSeeded` metadata, and `observe` opens a subagent session without releasing the bound one — a resident subagent Agent is read live and its release does nothing, and any other session is resumed, and `aside` creates a `/btw` side agent seeded through `buildForkSeed` with the bound session's whole log as `ctx.sessionQuery` observes it, recording `parentSession`, `isSeeded`, and `origin: 'subagent'` but passing no parent Agent and appending no catalog event to the parent, then in its setup appends the `read-only` sandbox mode and the `never` approval policy and restricts its global tools to the configured names. Every operation except a resident `observe` installs a `ModelSelectionRef` in the Agent's scoped setup so `/model` changes the next request; `resume` passes the launch default as AgentOptions so assemble has a `{{model}}` value, then overlays the log's last request header onto the selection when one exists, else keeps that default. The terminal application starts on the session `--resume` or a fresh `create` yields, subscribes to `session/event`, `agent/assistant-stream`, and `agent/status`, answers the `approval/request` and `user-questions/request` waterfalls for the bound Agent and for every session a view is held open over, and switches sessions by binding the next one and disposing the previous handle; while the host opens the next session the editor refuses input, and a quit during that wait releases the session that arrives afterwards. Quitting cancels any running turn, waits for quiescence, flushes the bound Session, disposes its handle, and requests exit 0; a driver failure writes `dsh: <message>` to stderr and requests exit 1. `/resume` and `/sessions` share the persisted-session chooser. Editor `Shift+Tab` dispatches empty `/effort` to open its current-model picker, and editor `Shift+Left` / `Shift+Right` use pi-tui's word navigation. `/login` starts `authorization.begin` with only subscription methods (every method except a key-collecting `api-key` login). A notice the flow marks with `openInBrowser` is handed to the default browser through `dsh-native-command`'s credential-scrubbed helper while the URL stays printed; the handoff is suppressed when `openBrowser` is false, the launch came through SSH, or the host has no desktop, and an opener failure becomes a notice beside the URL rather than a sign-in failure. A nonempty `!` or `!!` line submitted in the editor runs through `ctx.shell` in this process; `!` injects a next-step notice and `!!` stays local.
|
|
267
|
+
The runner awaits the complete application (`ctx.get('loader')?.await()`) and builds a session host over the core registry with five operations: `create` makes one fresh persisted Agent with its requested selection or the shared [`agentDefaultModel`](../../core/agent-default-model/README.md) selection, `resume` takes the Agent write handle first and then observes the live Session through `ctx.sessionQuery` so bind draws every persisted event including resume closers, and `fork` observes the source through `ctx.sessionQuery`, cuts after the chosen (by default the last) `turn/end` up to the next `turn/start`, and creates a seeded Agent with `parentSession` and `isSeeded` metadata, and `observe` opens a subagent session without releasing the bound one — a resident subagent Agent is read live and its release does nothing, and any other session is resumed, and `aside` creates a `/btw` side agent seeded through `buildForkSeed` with the bound session's whole log as `ctx.sessionQuery` observes it, recording `parentSession`, `isSeeded`, and `origin: 'subagent'` but passing no parent Agent and appending no catalog event to the parent, then in its setup appends the `read-only` sandbox mode and the `never` approval policy and restricts its global tools to the configured names. Every operation except a resident `observe` installs a `ModelSelectionRef` in the Agent's scoped setup so `/model` changes the next request; `resume` passes the launch default as AgentOptions so assemble has a `{{model}}` value, then overlays the log's last request header onto the selection when one exists, else keeps that default. The terminal application starts on the session `--resume` or a fresh `create` yields, subscribes to `session/event`, `agent/assistant-stream`, and `agent/status`, answers the `approval/request` and `user-questions/request` waterfalls for the bound Agent and for every session a view is held open over, and switches sessions by binding the next one and disposing the previous handle; while the host opens the next session the editor refuses input, and a quit during that wait releases the session that arrives afterwards. Quitting cancels any running turn, waits for quiescence, flushes the bound Session, disposes its handle, and requests exit 0; a driver failure writes `dsh: <message>` to stderr and requests exit 1. `/resume` and `/sessions` share the persisted-session chooser. Editor `Shift+Tab` dispatches empty `/effort` to open its current-model picker, and editor `Shift+Left` / `Shift+Right` use pi-tui's word navigation. `/login` starts `authorization.begin` with only subscription methods (every method except a key-collecting `api-key` login). A notice the flow marks with `openInBrowser` is handed to the default browser through `dsh-native-command`'s credential-scrubbed helper while the URL stays printed; the handoff is suppressed when `openBrowser` is false, the launch came through SSH, or the host has no desktop, and an opener failure becomes a notice beside the URL rather than a sign-in failure. A nonempty `!` or `!!` line submitted in the editor runs through `ctx.shell` in this process; `!` injects a next-step notice and `!!` stays local.
|
|
268
268
|
|
|
269
269
|
### Rendering model
|
|
270
270
|
|
|
@@ -36,7 +36,7 @@ dsh tui --resume <session-id> # continue an earlier session
|
|
|
36
36
|
dsh tui --no-open # print sign-in URLs without opening a browser
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
退出时应用在 stderr 为当时绑定的会话打印 `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>`。恢复的会话会在接受输入前先重绘其持久化历史,并沿用该会话上次使用的模型;日志里还没有请求头时则使用启动默认模型。在终端内,`/resume` 与 `/sessions` 打开覆盖所有持久化根会话的同一个选择器,并恢复选中的先前会话,`/new`
|
|
39
|
+
退出时应用在 stderr 为当时绑定的会话打印 `dsh: session <id> saved; resume with: dsh --profile tui --resume <id>`。恢复的会话会在接受输入前先重绘其持久化历史,并沿用该会话上次使用的模型;日志里还没有请求头时则使用启动默认模型。在终端内,`/resume` 与 `/sessions` 打开覆盖所有持久化根会话的同一个选择器,并恢复选中的先前会话,`/new` 使用启动默认模型开始新的空会话,而 `/clear` 开始新的空会话并保留当前模型和推理强度;先前会话仍留在磁盘上可用 `/resume` 恢复,`/fork` 把当前会话复制到其最后一个完成轮次并作为新会话,切割点与浏览器的 fork 相同。切换会释放先前的 Agent 并重绘下一个会话的对话记录。
|
|
40
40
|
|
|
41
41
|
### 屏幕布局
|
|
42
42
|
|
|
@@ -174,8 +174,8 @@ follow-ups 面板持有键盘时:
|
|
|
174
174
|
| `/help` | 列出命令,以及每个焦点状态所应答的按键;输入为空时按 `?` 效果相同 |
|
|
175
175
|
| `/model` | 为下一次请求选择模型(输入即可过滤行),若模型声明多于一种推理强度则接着选择强度;`/model <provider>/<model>` 直接选择,`/model save` 把当前选择存为默认,在模型列表中按 `Ctrl+S` 则把高亮的模型存为下次启动的默认而不关闭列表 |
|
|
176
176
|
| `/effort [id]` | 不带参数时为下一次请求打开当前模型的推理强度选择器,与编辑器中的 `Shift+Tab` 打开的是同一个;id 直接选择,`/effort default` 恢复提供方默认值 |
|
|
177
|
-
| `/permission [preset]` | 不带参数时打开权限预设选择器;preset 直接选择。随附 profile 包含实验性 Auto review;`/permission auto`
|
|
178
|
-
| `/sandbox [container\|local]` | 已组合 Apple container 提供方时,打开带有实时访问预览的后端选择器;带参数时通过共享命令直接切换。选择器标记当前后端,隐藏不可用的容器选项并说明原因,显示 workspace、读写限制,以及 `danger-full-access` 绕过任一后端时的警告。`Enter` 应用,`Esc` 保留当前后端。文件策略与审批设置不变;使用 `/permission`
|
|
177
|
+
| `/permission [preset]` | 不带参数时打开权限预设选择器;preset 直接选择。随附 profile 包含实验性 Auto review;`/permission auto` 为当前会话选中它,在 Apple container 后端上它保留容器(`workspace-write`),而不是切换到完全访问 |
|
|
178
|
+
| `/sandbox [container\|local]` | 已组合 Apple container 提供方时,打开带有实时访问预览的后端选择器;带参数时通过共享命令直接切换。选择器标记当前后端,隐藏不可用的容器选项并说明原因,显示 workspace、读写限制,以及 `danger-full-access` 绕过任一后端时的警告。`Enter` 应用,`Esc` 保留当前后端。文件策略与审批设置不变;使用 `/permission` 控制它们,但仍处于完全访问的 Auto 会话除外:选择器把容器预览为受限,因为 Auto 会从下一次调用起把自己限制在容器内 |
|
|
179
179
|
| `/search [deepseek\|openrouter [model]]` | 不带参数时打开网页搜索路由选择器;`deepseek` 恢复默认路由,`openrouter` 通过 OpenRouter 路由 `web_search`,使用 `OPENROUTER_API_KEY` 与所输入的模型(默认:`/model` 所选模型属于 OpenRouter 时使用该模型,否则为 `deepseek/deepseek-v4-flash-0731`)。它写入 `web-search-deepseek` 设置命名空间,下一次搜索即读取 |
|
|
180
180
|
| `/resume` | 打开与 `/sessions` 相同的持久化会话选择器,并恢复选中的先前会话 |
|
|
181
181
|
| `/sessions` | 打开持久化会话选择器,并切换到选中的会话 |
|
|
@@ -264,7 +264,7 @@ runner 与 `dsh-headless` 一样是核心 API 载体之上的直接驱动器,
|
|
|
264
264
|
|
|
265
265
|
### 运行流程
|
|
266
266
|
|
|
267
|
-
runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心注册表之上构建含五个操作的会话宿主:`create`
|
|
267
|
+
runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心注册表之上构建含五个操作的会话宿主:`create` 用传入的选择或共享的 [`agentDefaultModel`](../../core/agent-default-model/README.zh.md) 选择创建一个全新的持久化 Agent,`resume` 先拿到 Agent 写句柄,再经 `ctx.sessionQuery` 观察实时 Session,使 bind 画出每条持久化事件(包括恢复时的闭合事件),`fork` 通过 `ctx.sessionQuery` 观察源会话、在所选(默认最后一个)`turn/end` 之后直到下一个 `turn/start` 处切割,并创建带 `parentSession` 与 `isSeeded` 元数据的种子 Agent,`observe` 打开子 agent 会话而不释放已绑定的会话——常驻的子 agent Agent 被实时读取、释放它什么也不做,其他会话则被恢复,`aside` 创建 `/btw` 旁路 agent:它以 `buildForkSeed` 用 `ctx.sessionQuery` 观察到的已绑定会话完整日志作种子,记录 `parentSession`、`isSeeded` 与 `origin: 'subagent'`,但不传入父 Agent,也不向父会话追加目录事件,随后在其 setup 中追加 `read-only` 沙箱模式与 `never` 审批策略,并把它的全局工具限制为配置的名称。除常驻会话的 `observe` 外,每个操作都在 Agent 的作用域 setup 中安装 `ModelSelectionRef`,因此 `/model` 会改变下一次请求;`resume` 把启动默认作为 AgentOptions 传入,使组装时 `{{model}}` 有值,再在有请求头时把它覆盖到该选择上,否则保留该默认。终端应用从 `--resume` 或一次新的 `create` 产生的会话开始,订阅 `session/event`、`agent/assistant-stream` 与 `agent/status`,为绑定的 Agent 以及每个被视图挡在后面的会话应答 `approval/request` 与 `user-questions/request` waterfall,并通过绑定下一个会话、dispose 先前句柄来切换会话;宿主打开下一个会话期间编辑器拒绝输入,等待期间退出会释放随后到达的会话。退出时取消任何进行中的轮次、等待完全停稳、flush 绑定的会话、dispose 其句柄并请求以 0 退出;驱动器失败会向 stderr 写入 `dsh: <message>` 并请求以 1 退出。`/resume` 与 `/sessions` 共用持久化会话选择器。编辑器中的 `Shift+Tab` 会派发空参数 `/effort` 以打开当前模型的推理强度选择器,而编辑器中的 `Shift+Left` / `Shift+Right` 使用 pi-tui 的词导航。`/login` 只带着订阅方法(除收集密钥的 `api-key` 登录外的每一种方法)启动 `authorization.begin`。flow 用 `openInBrowser` 标记的 notice 会经 `dsh-native-command` 的凭据擦除辅助进程交给默认浏览器,URL 同时保持打印;当 `openBrowser` 为 false、启动经过 SSH 或宿主没有桌面时抑制该交接,打开器失败则成为 URL 旁的一条通知,而非登录失败。编辑器里提交的非空 `!` 或 `!!` 行经本进程的 `ctx.shell` 运行;`!` 注入一条下一步通知,`!!` 只留在本地。
|
|
268
268
|
|
|
269
269
|
### 渲染模型
|
|
270
270
|
|
|
@@ -7136,7 +7136,16 @@ var ModalQueue = class {
|
|
|
7136
7136
|
*/
|
|
7137
7137
|
var SandboxPrompt = class extends PickPrompt {
|
|
7138
7138
|
policy;
|
|
7139
|
-
|
|
7139
|
+
autoConfines;
|
|
7140
|
+
/**
|
|
7141
|
+
* @param palette - the terminal palette.
|
|
7142
|
+
* @param provider - the sandbox provider whose backends the picker offers.
|
|
7143
|
+
* @param session - the session whose current backend is marked.
|
|
7144
|
+
* @param policy - the session's resolved file policy.
|
|
7145
|
+
* @param autoConfines - whether the session's Auto selection narrows a full-access
|
|
7146
|
+
* session to the container on its next call once the container is its backend.
|
|
7147
|
+
*/
|
|
7148
|
+
constructor(palette, provider, session, policy, autoConfines = false) {
|
|
7140
7149
|
const current = provider.backendFor(session);
|
|
7141
7150
|
super(palette, "Sandbox backend", [...provider.containerSupported ? [{
|
|
7142
7151
|
value: "container",
|
|
@@ -7151,25 +7160,28 @@ var SandboxPrompt = class extends PickPrompt {
|
|
|
7151
7160
|
body: [`current: ${current} · file policy: ${policy.mode} · Esc keeps it`, ...provider.containerSupported ? [] : ["Container unavailable: requires macOS on Apple silicon and the container CLI."]]
|
|
7152
7161
|
});
|
|
7153
7162
|
this.policy = policy;
|
|
7163
|
+
this.autoConfines = autoConfines;
|
|
7154
7164
|
}
|
|
7155
7165
|
listLines(width) {
|
|
7156
7166
|
const lines = super.listLines(width).flatMap((line) => wrapTextWithAnsi(line, Math.max(1, width)));
|
|
7157
7167
|
const selected = this.selected();
|
|
7158
7168
|
if (selected === null) return lines;
|
|
7159
7169
|
const container = selected.value === "container";
|
|
7160
|
-
const
|
|
7161
|
-
const
|
|
7170
|
+
const narrowed = this.autoConfines && container && this.policy.mode === "danger-full-access";
|
|
7171
|
+
const mode = narrowed ? "workspace-write" : this.policy.mode;
|
|
7172
|
+
const unrestricted = mode === "danger-full-access";
|
|
7173
|
+
const writes = mode === "read-only" ? "BLOCKED · file modifications" : mode === "workspace-write" ? "ALLOWED · workspace writes except provider-protected paths; temporary areas may be writable" : "UNRESTRICTED · host file modifications";
|
|
7162
7174
|
const preview = [
|
|
7163
7175
|
this.palette.bold(`Access preview · ${selected.label.replace(" ✓", "")}`),
|
|
7164
7176
|
`Workspace: ${this.policy.workspaceRoot}`,
|
|
7165
7177
|
unrestricted ? this.palette.warning("! Sandbox bypassed: commands run on the host, regardless of backend choice.") : `Commands → ${container ? "Linux container → shared workspace" : "host → native file sandbox"}`,
|
|
7166
|
-
`${
|
|
7178
|
+
`${mode === "read-only" ? "−" : "+"} ${writes}`,
|
|
7167
7179
|
...container && !unrestricted ? [
|
|
7168
7180
|
"+ READ · workspace and configured read-only mounts",
|
|
7169
7181
|
"− HOST ACCESS · other host paths and configured secret-file patterns hidden",
|
|
7170
7182
|
" Guest files outside shared mounts are not visible to host file tools."
|
|
7171
7183
|
] : ["+ READ · host paths (subject to OS permissions)", ...unrestricted ? [] : ["− WRITE · outside permitted paths; provider-protected paths remain blocked"]],
|
|
7172
|
-
"Backend changes do not change file policy or approval settings: use /permission.",
|
|
7184
|
+
narrowed ? "Auto confines itself to the container from its next call; approval settings do not change." : "Backend changes do not change file policy or approval settings: use /permission.",
|
|
7173
7185
|
"Wider access requires approved one-shot escalation when approvals are enabled."
|
|
7174
7186
|
];
|
|
7175
7187
|
const inner = Math.max(1, width - 2);
|
|
@@ -12555,6 +12567,11 @@ const SHELL_MISSING = "! needs a shell executor in this composition";
|
|
|
12555
12567
|
/** Shown when a second `!` is submitted while one is still running. */
|
|
12556
12568
|
const SHELL_BUSY = "A shell command is already running. Press Esc to cancel it first.";
|
|
12557
12569
|
/**
|
|
12570
|
+
* The Auto preset id. Its type comes from the permission owner's constant, so a
|
|
12571
|
+
* rename fails to compile, while the optional service stays a type-only import.
|
|
12572
|
+
*/
|
|
12573
|
+
const AUTO = "auto";
|
|
12574
|
+
/**
|
|
12558
12575
|
* Source for a prompt the person typed in this terminal.
|
|
12559
12576
|
* A string `rpcId` is the admission mark Auto review treats as a human instruction.
|
|
12560
12577
|
* An edited draft keeps a non-user source; a user draft is admitted again.
|
|
@@ -15194,9 +15211,11 @@ var TuiApp = class {
|
|
|
15194
15211
|
await this.openSessionPicker();
|
|
15195
15212
|
return;
|
|
15196
15213
|
case "new":
|
|
15197
|
-
case "clear":
|
|
15198
15214
|
await this.switchSession(() => this.deps.host.create(), "new session");
|
|
15199
15215
|
return;
|
|
15216
|
+
case "clear":
|
|
15217
|
+
await this.switchSession(() => this.deps.host.create(this.currentSelection()), "new session");
|
|
15218
|
+
return;
|
|
15200
15219
|
case "fork": {
|
|
15201
15220
|
const turn = argument === "" ? void 0 : Number(argument);
|
|
15202
15221
|
if (turn !== void 0 && !(Number.isSafeInteger(turn) && turn > 0)) {
|
|
@@ -15636,7 +15655,7 @@ var TuiApp = class {
|
|
|
15636
15655
|
await this.runSharedCommand(argument === "" ? "/sandbox" : `/sandbox ${argument}`, "sandbox");
|
|
15637
15656
|
return;
|
|
15638
15657
|
}
|
|
15639
|
-
const picked = await this.showModal(new SandboxPrompt(this.deps.palette, provider, this.agent.session, policy.resolve({ session: this.agent.session })));
|
|
15658
|
+
const picked = await this.showModal(new SandboxPrompt(this.deps.palette, provider, this.agent.session, policy.resolve({ session: this.agent.session }), this.deps.ctx.get("permissionPresets")?.current(this.agent.session) === AUTO));
|
|
15640
15659
|
if (picked !== void 0) await this.runSharedCommand(`/sandbox ${picked.value}`, "sandbox");
|
|
15641
15660
|
}
|
|
15642
15661
|
/**
|
|
@@ -17037,8 +17056,8 @@ function sessionHost(ctx, core, cwd, btw) {
|
|
|
17037
17056
|
dispose: () => handle.dispose()
|
|
17038
17057
|
};
|
|
17039
17058
|
};
|
|
17040
|
-
const create = (seed, parent) => bind((selection, setup) => {
|
|
17041
|
-
const model = defaultModel.currentSelection();
|
|
17059
|
+
const create = (seed, parent, initialSelection) => bind((selection, setup) => {
|
|
17060
|
+
const model = initialSelection ?? defaultModel.currentSelection();
|
|
17042
17061
|
selection.current = model;
|
|
17043
17062
|
return agents.create({
|
|
17044
17063
|
sessionId: brandString(`session-${randomUUID()}`),
|
|
@@ -17055,7 +17074,8 @@ function sessionHost(ctx, core, cwd, btw) {
|
|
|
17055
17074
|
},
|
|
17056
17075
|
agentOptions: {
|
|
17057
17076
|
provider: model.provider,
|
|
17058
|
-
model: model.model
|
|
17077
|
+
model: model.model,
|
|
17078
|
+
...model.reasoningEffort === void 0 ? {} : { reasoningEffort: model.reasoningEffort }
|
|
17059
17079
|
},
|
|
17060
17080
|
setup
|
|
17061
17081
|
});
|
|
@@ -17086,7 +17106,7 @@ function sessionHost(ctx, core, cwd, btw) {
|
|
|
17086
17106
|
};
|
|
17087
17107
|
};
|
|
17088
17108
|
return {
|
|
17089
|
-
create: () => create(void 0, void 0),
|
|
17109
|
+
create: (selection) => create(void 0, void 0, selection),
|
|
17090
17110
|
resume,
|
|
17091
17111
|
fork: async (id, turn) => create(await forkSeed(ctx, id, turn), id),
|
|
17092
17112
|
aside: async (parent) => {
|
package/package.json
CHANGED