@songtonyli/dsh-cli 0.1.63 → 0.1.65
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 +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- 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/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js +13 -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 +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.zh.md +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/index.js +14 -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-bash/lib/index.js +3 -1
- 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/node_modules/http-cache-semantics/index.js +32 -9
- package/node_modules/http-cache-semantics/package.json +3 -3
- package/package.json +2 -2
|
@@ -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: ab093e9042b86b99
|
|
28
28
|
zh: d173df7cb3649446
|
|
29
29
|
/deepseek-ai-dsh-sandbox/use-this-package/denied-calls-and-escalation:
|
|
30
|
-
en:
|
|
31
|
-
zh:
|
|
30
|
+
en: 70c53dd52c94ab56
|
|
31
|
+
zh: 6b836c8078469cba
|
|
32
32
|
/deepseek-ai-dsh-sandbox/use-this-package/fail-closed-behavior:
|
|
33
33
|
en: 6bf240632a7a6bf5
|
|
34
34
|
zh: ebf414f5cf435875
|
|
@@ -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 approval service obtains consent for the operation. The request retains its audit reason and supplies English and Chinese presentation copy with the model's justification unchanged. Missing translations follow the locale service's fallback chain, ultimately English; requesters own their translated presentation text. 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.
|
|
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 approval service obtains consent for the operation. The request retains its audit reason and supplies English and Chinese presentation copy with the model's justification unchanged. Missing translations follow the locale service's fallback chain, ultimately English; requesters own their translated presentation text. A provider can append a sentence to the prompt through `SandboxProvider.escalationNote`, for example to say that the call will leave its container. 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
|
|
|
@@ -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` 重试一次完全相同的调用;审批服务为操作取得同意。请求保留审计原因,同时提供英文和中文展示文案,模型给出的理由保持原样。缺失的译文遵循语言服务的回退链,最终回退到英文;请求方负责自己的展示译文。提供方可以通过 `SandboxProvider.escalationNote` 向审批提示追加一句话,例如说明该调用将离开其容器。更宽的模式需要审批,且只作用于该次调用。重复指定调用的生效模式无需审批即可成功;更窄的目标仍然无效。
|
|
67
67
|
|
|
68
68
|
### 故障关闭行为
|
|
69
69
|
|
|
@@ -98,7 +98,7 @@ function sandboxPermissionsDescription(subject) {
|
|
|
98
98
|
* @returns the granted mode, consumed by the one call that asked.
|
|
99
99
|
*/
|
|
100
100
|
async function approveEscalation(request, approval) {
|
|
101
|
-
const { requestedMode: mode, effectiveMode, justification, subject } = request;
|
|
101
|
+
const { requestedMode: mode, effectiveMode, justification, subject, note } = request;
|
|
102
102
|
if (mode === effectiveMode) return effectiveMode;
|
|
103
103
|
if (!(WIDER_MODES[effectiveMode] ?? []).includes(mode)) throw new Error(`sandbox escalation to "${mode}" is not strictly wider than this call's current "${effectiveMode}" mode`);
|
|
104
104
|
if (approval.approver === void 0) throw new Error(`sandbox escalation to "${mode}" requires approval, but no approval service is composed`);
|
|
@@ -107,10 +107,10 @@ async function approveEscalation(request, approval) {
|
|
|
107
107
|
agent: approval.agent,
|
|
108
108
|
toolName: approval.toolName,
|
|
109
109
|
callId: approval.callId,
|
|
110
|
-
reason: `escalate sandbox to ${mode}: ${justification}`,
|
|
110
|
+
reason: `escalate sandbox to ${mode}: ${justification}${note === void 0 ? "" : ` (${note.en})`}`,
|
|
111
111
|
displayReason: {
|
|
112
|
-
en: `Allow this operation with ${mode} permissions: ${justification}`,
|
|
113
|
-
zh: `允许本次操作使用 ${mode} 权限:${justification}`
|
|
112
|
+
en: `Allow this operation with ${mode} permissions: ${justification}${note === void 0 ? "" : ` ${note.en}`}`,
|
|
113
|
+
zh: `允许本次操作使用 ${mode} 权限:${justification}${note === void 0 ? "" : ` ${note.zh ?? note.en}`}`
|
|
114
114
|
},
|
|
115
115
|
...approval.signal ? { signal: approval.signal } : {}
|
|
116
116
|
});
|
|
@@ -350,6 +350,15 @@ var SandboxProvider = class extends Service {
|
|
|
350
350
|
* @returns the read scope, or `undefined` for unconfined reads.
|
|
351
351
|
*/
|
|
352
352
|
readScope(_policy) {}
|
|
353
|
+
/**
|
|
354
|
+
* A user-facing sentence to add to the approval prompt for escalating one
|
|
355
|
+
* call to `target`, for backends where the wider mode changes where the
|
|
356
|
+
* command runs. The base implementation adds nothing.
|
|
357
|
+
* @param _policy - the file-effect policy the call currently runs under.
|
|
358
|
+
* @param _target - the wider mode the call asks for.
|
|
359
|
+
* @returns the localized sentence, or `undefined` when the prompt needs no addition.
|
|
360
|
+
*/
|
|
361
|
+
escalationNote(_policy, _target) {}
|
|
353
362
|
};
|
|
354
363
|
//#endregion
|
|
355
364
|
export { ESCALATION_TARGETS, SANDBOX_UNAVAILABLE, SandboxProvider, SandboxProvider as default, SandboxUnavailableError, WIDER_MODES, approveEscalation, canonicalPath, classifyRunnerFailure, escalationHintMarker, isHiddenIn, isReadableIn, isRunnerSpawnFailure, matchesNameGlob, matchesSignature, sandboxDenialMarker, sandboxPermissionsDescription, validateEscalationArgs, writableRoots };
|
|
@@ -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: b88b6a821a2504eb
|
|
31
|
+
zh: 891ed523b2419020
|
|
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 approval prompt for an escalation to `danger-full-access` from a container session adds that the command runs directly on the Mac, outside the container. 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
|
|
|
@@ -132,7 +132,7 @@ One `sandbox:backend` contribution in the runtime-context snapshot when the sess
|
|
|
132
132
|
##### Container backend
|
|
133
133
|
|
|
134
134
|
```markdown
|
|
135
|
-
Commands confined by the DSH file sandbox run inside a Linux container from image <image>. Only the session workspace <workspace root> is shared with the host; files written elsewhere stay inside the container and are not visible to file tools. File tools ask the user before reading a host path outside the workspace; secret files such as `.env` and private keys stay hidden from commands and file tools.
|
|
135
|
+
Commands confined by the DSH file sandbox run inside a Linux container from image <image>. Only the session workspace <workspace root> is shared with the host; files written elsewhere stay inside the container and are not visible to file tools. Host-installed programs (macOS apps, Homebrew tools, browsers) and the host home directory are absent, and HOME is /root; when a skill or command needs them, rerun it with `sandbox_permissions` escalation to run on the host, or ask the user to run `/sandbox local`. File tools ask the user before reading a host path outside the workspace; secret files such as `.env` and private keys stay hidden from commands and file tools.
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
#### Token effect
|
|
@@ -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`,因此在任一后端下都在宿主机上运行。从容器会话升权到 `danger-full-access` 时,审批提示会补充说明该命令将直接在 Mac 上运行,而不是在容器内。会话运行在此后端时,Auto 权限不会写入它:而是写入 `workspace-write`,并由 reviewer 而不是提示批准离开容器的一次性提权([Auto review](../../experimental/auto-review/README.zh.md))。在 `local` 后端上,Auto 仍写入 `danger-full-access`。
|
|
77
77
|
|
|
78
78
|
### 失败与恢复
|
|
79
79
|
|
|
@@ -132,7 +132,7 @@ CLI 缺失、已停止且无法启动的 API 服务器,或 `container run` 失
|
|
|
132
132
|
##### container 后端
|
|
133
133
|
|
|
134
134
|
```markdown
|
|
135
|
-
Commands confined by the DSH file sandbox run inside a Linux container from image <image>. Only the session workspace <workspace root> is shared with the host; files written elsewhere stay inside the container and are not visible to file tools. File tools ask the user before reading a host path outside the workspace; secret files such as `.env` and private keys stay hidden from commands and file tools.
|
|
135
|
+
Commands confined by the DSH file sandbox run inside a Linux container from image <image>. Only the session workspace <workspace root> is shared with the host; files written elsewhere stay inside the container and are not visible to file tools. Host-installed programs (macOS apps, Homebrew tools, browsers) and the host home directory are absent, and HOME is /root; when a skill or command needs them, rerun it with `sandbox_permissions` escalation to run on the host, or ask the user to run `/sandbox local`. File tools ask the user before reading a host path outside the workspace; secret files such as `.env` and private keys stay hidden from commands and file tools.
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
#### Token 影响
|
|
@@ -594,7 +594,7 @@ var AppleContainerSandboxProvider = class extends LocalSandboxProvider {
|
|
|
594
594
|
if (session === void 0 || this.backendFor(session) !== "container") return "";
|
|
595
595
|
const policy = scope.sandboxPolicy.resolve({ session });
|
|
596
596
|
if (policy.mode === "danger-full-access") return "";
|
|
597
|
-
return `Commands confined by the DSH file sandbox run inside a Linux container from image ${JSON.stringify(this.image)}. Only the session workspace ${JSON.stringify(policy.workspaceRoot)} is shared with the host; files written elsewhere stay inside the container and are not visible to file tools. File tools ask the user before reading a host path outside the workspace; secret files such as \`.env\` and private keys stay hidden from commands and file tools.`;
|
|
597
|
+
return `Commands confined by the DSH file sandbox run inside a Linux container from image ${JSON.stringify(this.image)}. Only the session workspace ${JSON.stringify(policy.workspaceRoot)} is shared with the host; files written elsewhere stay inside the container and are not visible to file tools. Host-installed programs (macOS apps, Homebrew tools, browsers) and the host home directory are absent, and HOME is /root; when a skill or command needs them, rerun it with \`sandbox_permissions\` escalation to run on the host, or ask the user to run \`/sandbox local\`. File tools ask the user before reading a host path outside the workspace; secret files such as \`.env\` and private keys stay hidden from commands and file tools.`;
|
|
598
598
|
}
|
|
599
599
|
});
|
|
600
600
|
});
|
|
@@ -661,6 +661,19 @@ var AppleContainerSandboxProvider = class extends LocalSandboxProvider {
|
|
|
661
661
|
};
|
|
662
662
|
}
|
|
663
663
|
/**
|
|
664
|
+
* Tells the user that `danger-full-access` leaves the container.
|
|
665
|
+
* @param policy - the calling session's resolved policy.
|
|
666
|
+
* @param target - the wider mode the call asks for.
|
|
667
|
+
* @returns the localized sentence for a container-backed call escalating to `danger-full-access`, otherwise `undefined`.
|
|
668
|
+
*/
|
|
669
|
+
escalationNote(policy, target) {
|
|
670
|
+
if (target !== "danger-full-access" || this.policyBackend(policy) !== "container") return void 0;
|
|
671
|
+
return {
|
|
672
|
+
en: "It will run directly on your Mac, outside the Linux container.",
|
|
673
|
+
zh: "它将直接在你的 Mac 上运行,而不是在 Linux 容器内。"
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
664
677
|
* The host read scope of a container-backed confined policy: the workspace
|
|
665
678
|
* (canonical and as spelled) and the extra read-only mounts, minus the
|
|
666
679
|
* hidden files. The local backend and `danger-full-access` confine no reads.
|
|
@@ -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.
|
|
@@ -361,11 +361,13 @@ function apply(ctx, config = {}) {
|
|
|
361
361
|
const approveBashEscalation = (mode, justification, exec, standingPolicy) => {
|
|
362
362
|
if (escalationModes.length === 0) throw new Error("sandbox_permissions is not available in this composition (no sandboxing executor to escalate)");
|
|
363
363
|
const effectiveMode = standingPolicy.mode;
|
|
364
|
+
const note = ctx.get("sandbox")?.escalationNote(standingPolicy, mode);
|
|
364
365
|
return approveEscalation({
|
|
365
366
|
requestedMode: mode,
|
|
366
367
|
justification,
|
|
367
368
|
effectiveMode,
|
|
368
|
-
subject: "command"
|
|
369
|
+
subject: "command",
|
|
370
|
+
...note === void 0 ? {} : { note }
|
|
369
371
|
}, {
|
|
370
372
|
approver: ctx.get("approval"),
|
|
371
373
|
agent: exec.agent,
|
|
@@ -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) => {
|