@songtonyli/dsh-cli 0.1.58 → 0.1.59
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-agent-preset/skills/cordis-composition-reference/references/packages.md +1 -0
- package/node_modules/@deepseek-ai/dsh-api-session-controller/lib/client.js +1 -0
- 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-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js +59 -4
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.i18n.yaml +73 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.md +166 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.zh.md +166 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/exec-shim.js +227 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/index.js +704 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/package.json +62 -0
- 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 +23 -0
- package/node_modules/@deepseek-ai/dsh-session/lib/index.js +1 -0
- package/node_modules/@deepseek-ai/dsh-session/lib/types/known-event-types.js +1 -0
- package/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/worker.cjs +1 -0
- package/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js +1 -0
- package/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +22 -0
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +24 -0
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.md +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.zh.md +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/lib/index.js +28 -3
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/package.json +7 -2
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/lib/index.js +14 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/cordis.patch.yml +20 -0
- package/node_modules/@deepseek-ai/dsh-tui-app/package.json +1 -0
- package/node_modules/@deepseek-ai/libreoffice-kit/README.md +20 -5
- package/node_modules/@deepseek-ai/libreoffice-kit/README.zh.md +21 -6
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/cli.js +499 -253
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/font-snapshot-worker.js +37 -26
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/index.js +498 -252
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/worker.js +39 -13
- package/node_modules/@deepseek-ai/libreoffice-kit/package.json +5 -3
- package/node_modules/@earendil-works/pi-ai/README.md +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +117 -18
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +19 -8
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +24 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +3 -2
- package/node_modules/@earendil-works/pi-ai/package.json +6 -2
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@shikijs/core/dist/index.mjs +15 -12
- package/node_modules/@shikijs/core/package.json +4 -4
- package/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs +2 -4
- package/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs +2 -4
- package/node_modules/@shikijs/engine-javascript/dist/index.mjs +1 -1
- package/node_modules/@shikijs/engine-javascript/dist/string-TLTPtCPs.mjs +115 -0
- package/node_modules/@shikijs/engine-javascript/package.json +3 -3
- package/node_modules/@shikijs/engine-oniguruma/package.json +3 -3
- package/node_modules/@shikijs/langs/dist/ada.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/ahk.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/beancount.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/coq.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/csharp.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/css.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/dart.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/dotenv.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/emacs-lisp.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/gn.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/handlebars.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/julia.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/latex.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/luau.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/marko.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/moonbit.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nextflow-groovy.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nextflow.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nushell.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/php.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/powershell.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/ruby.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/rust.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/sql.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/svelte.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/twig.mjs +3 -3
- package/node_modules/@shikijs/langs/dist/typespec.mjs +1 -1
- package/node_modules/@shikijs/langs/package.json +3 -3
- package/node_modules/@shikijs/primitive/dist/index.mjs +2 -1
- package/node_modules/@shikijs/primitive/package.json +3 -3
- package/node_modules/@shikijs/themes/dist/monokai.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/one-dark-pro.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/red.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/solarized-dark.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/solarized-light.mjs +1 -1
- package/node_modules/@shikijs/themes/package.json +3 -3
- package/node_modules/@shikijs/types/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +33 -11
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/exceptions.js +33 -11
- package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +3 -0
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/node-addon-native-custom-loader/lib/index.js +23 -10
- package/node_modules/node-addon-native-custom-loader/package.json +6 -1
- package/node_modules/node-addon-require-builtin/package.json +7 -2
- package/node_modules/powershell-utils/index.js +40 -19
- package/node_modules/powershell-utils/package.json +1 -1
- package/node_modules/powershell-utils/readme.md +69 -13
- package/node_modules/shiki/package.json +10 -10
- package/node_modules/wsl-utils/index.js +18 -37
- package/node_modules/wsl-utils/package.json +2 -2
- package/package.json +33 -29
- package/node_modules/@shikijs/engine-javascript/dist/scanner-DX8LRFGE.mjs +0 -77
- package/node_modules/open/node_modules/powershell-utils/index.js +0 -79
- package/node_modules/open/node_modules/powershell-utils/license +0 -9
- package/node_modules/open/node_modules/powershell-utils/package.json +0 -47
- package/node_modules/open/node_modules/powershell-utils/readme.md +0 -209
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deepseek-ai/dsh-sandbox-apple-container",
|
|
3
|
+
"description": "Apple container sandbox backend for the DeepSeek Harness sandbox seam: confined commands run in a per-workspace Linux VM with the workspace bind-mounted, switchable per session to the local backend",
|
|
4
|
+
"version": "0.2.0-rc.2",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/sandbox/sandbox-apple-container"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./src/*": "./src/*",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib/index.js",
|
|
26
|
+
"lib/exec-shim.js",
|
|
27
|
+
"lib/types/**/*.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
32
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
33
|
+
"@deepseek-ai/dsh-commands": "0.2.0-rc.2",
|
|
34
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
35
|
+
"@deepseek-ai/dsh-sandbox": "0.2.0-rc.2",
|
|
36
|
+
"@deepseek-ai/dsh-sandbox-local": "0.2.0-rc.2",
|
|
37
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.0-rc.2",
|
|
38
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
39
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
|
|
40
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@deepseek-ai/schemastery": "3.18.4",
|
|
44
|
+
"zod": "^4.4.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
48
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
49
|
+
"@deepseek-ai/dsh-bash-sandbox": "0.2.0-rc.2",
|
|
50
|
+
"@deepseek-ai/dsh-commands": "0.2.0-rc.2",
|
|
51
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
52
|
+
"@deepseek-ai/dsh-sandbox": "0.2.0-rc.2",
|
|
53
|
+
"@deepseek-ai/dsh-sandbox-local": "0.2.0-rc.2",
|
|
54
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.0-rc.2",
|
|
55
|
+
"@deepseek-ai/dsh-scope": "0.2.0-rc.2",
|
|
56
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
|
|
58
|
+
"@deepseek-ai/dsh-shell": "0.2.0-rc.2",
|
|
59
|
+
"@deepseek-ai/dsh-subprocess-local": "0.2.0-rc.2",
|
|
60
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -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: 707b80e05a9d7366
|
|
37
|
+
zh: 867f03478bf3bf41
|
|
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
|
-
`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. `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
|
-
`resolve({ session, mode })` 返回一份完整的逐调用策略:已批准的显式模式优先于会话最后一条 `sandbox/mode` 事件,后者又优先于部署默认值。会话的不可变 `cwd` 提供工作区根目录;否则使用配置的回退值。执行环境中的绝对路径写法保持不变。执行限制的提供方在自己的文件系统上规范化根目录,因此远端 `symlink/..` 路径绝不会在 Harness 主机上解析。
|
|
72
|
+
`readScope(request)` 询问已挂载的 `ctx.sandbox` 提供方在解析出的策略下受限进程能读取什么,`canRead(path, request)` 用规范化后的路径对照该范围检查;面向模型的文件工具在读取前调用 `canRead`。`resolve({ session, mode })` 返回一份完整的逐调用策略:已批准的显式模式优先于会话最后一条 `sandbox/mode` 事件,后者又优先于部署默认值。会话的不可变 `cwd` 提供工作区根目录;否则使用配置的回退值。执行环境中的绝对路径写法保持不变。执行限制的提供方在自己的文件系统上规范化根目录,因此远端 `symlink/..` 路径绝不会在 Harness 主机上解析。
|
|
73
73
|
|
|
74
74
|
### 逐会话存储
|
|
75
75
|
|
|
@@ -2,6 +2,7 @@ import { isAbsolute } from "node:path";
|
|
|
2
2
|
import { Service } from "@deepseek-ai/cordis";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import z$1 from "@deepseek-ai/schemastery";
|
|
5
|
+
import { isReadableIn } from "@deepseek-ai/dsh-sandbox";
|
|
5
6
|
//#region lib/types/session-mode.js
|
|
6
7
|
/**
|
|
7
8
|
* Per-session sandbox-mode override: the session log as the store. A runtime
|
|
@@ -147,6 +148,28 @@ var SandboxPolicyService = class extends Service {
|
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
150
|
/**
|
|
151
|
+
* The host read scope of confined processes under the resolved policy,
|
|
152
|
+
* from the mounted `ctx.sandbox` provider.
|
|
153
|
+
* @param request - optional session and approved mode override, as for {@link resolve}.
|
|
154
|
+
* @returns the scope, or `undefined` when no provider confines reads.
|
|
155
|
+
*/
|
|
156
|
+
readScope(request = {}) {
|
|
157
|
+
return this.ctx.get("sandbox")?.readScope(this.resolve(request));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Whether a model-facing tool may read `path` on the host: true when reads
|
|
161
|
+
* are unconfined, otherwise only inside the {@link readScope}. Tools that
|
|
162
|
+
* read file contents or search them call this before reading, so their view
|
|
163
|
+
* never exceeds the confined processes'.
|
|
164
|
+
* @param path - the host path about to be opened or searched.
|
|
165
|
+
* @param request - optional session and approved mode override, as for {@link resolve}.
|
|
166
|
+
* @returns true when the read is allowed.
|
|
167
|
+
*/
|
|
168
|
+
canRead(path, request = {}) {
|
|
169
|
+
const scope = this.readScope(request);
|
|
170
|
+
return scope === void 0 || isReadableIn(path, scope);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
150
173
|
* Read the session override without applying the deployment default.
|
|
151
174
|
* @param session - session whose log supplies the override.
|
|
152
175
|
* @returns the last logged mode, or `undefined` without one.
|
|
@@ -1802,6 +1802,12 @@ export const SERVICE_API = [
|
|
|
1802
1802
|
parameters: [{ name: 'argv', description: 'the exact argv the caller is about to spawn (program plus arguments), NOT a shell string — a shell-shaped consumer passes `[\'bash\', \'-c\', command]`.' }, { name: 'policy', description: 'the file-effect policy this execution runs under, carried per call (see {@link SandboxPolicy}).' }, { name: 'signal', description: 'cancellation while the provider resolves the policy and runner.' }],
|
|
1803
1803
|
returns: 'the argv to spawn instead, plus the enforcement completeness the selected backend achieves for it.',
|
|
1804
1804
|
},
|
|
1805
|
+
{
|
|
1806
|
+
signature: 'readScope(_policy: SandboxExecutionPolicy): SandboxReadScope | undefined',
|
|
1807
|
+
description: 'What a process confined under `policy` can read on the host, or `undefined` when this backend does not confine reads. Model-facing tools that read the host for the same session must refuse paths outside the scope, so their view never exceeds the confined processes\'. The base implementation confines no reads.',
|
|
1808
|
+
parameters: [{ name: '_policy', description: 'the file-effect policy of the calling session.' }],
|
|
1809
|
+
returns: 'the read scope, or `undefined` for unconfined reads.',
|
|
1810
|
+
},
|
|
1805
1811
|
],
|
|
1806
1812
|
},
|
|
1807
1813
|
{
|
|
@@ -1825,6 +1831,18 @@ export const SERVICE_API = [
|
|
|
1825
1831
|
parameters: [{ name: 'request', description: 'optional session and approved mode override.' }],
|
|
1826
1832
|
returns: 'the fully resolved per-call mode and absolute workspace root.',
|
|
1827
1833
|
},
|
|
1834
|
+
{
|
|
1835
|
+
signature: 'readScope(request: SandboxPolicyRequest = {}): SandboxReadScope | undefined',
|
|
1836
|
+
description: 'The host read scope of confined processes under the resolved policy, from the mounted `ctx.sandbox` provider.',
|
|
1837
|
+
parameters: [{ name: 'request', description: 'optional session and approved mode override, as for {@link resolve}.' }],
|
|
1838
|
+
returns: 'the scope, or `undefined` when no provider confines reads.',
|
|
1839
|
+
},
|
|
1840
|
+
{
|
|
1841
|
+
signature: 'canRead(path: string, request: SandboxPolicyRequest = {}): boolean',
|
|
1842
|
+
description: 'Whether a model-facing tool may read `path` on the host: true when reads are unconfined, otherwise only inside the readScope. Tools that read file contents or search them call this before reading, so their view never exceeds the confined processes\'.',
|
|
1843
|
+
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}.' }],
|
|
1844
|
+
returns: 'true when the read is allowed.',
|
|
1845
|
+
},
|
|
1828
1846
|
{
|
|
1829
1847
|
signature: 'overrideOf(session: Session): SandboxMode | undefined',
|
|
1830
1848
|
description: 'Read the session override without applying the deployment default.',
|
|
@@ -6274,6 +6292,10 @@ export const TYPE_API = [
|
|
|
6274
6292
|
name: 'SandboxPolicyRequest',
|
|
6275
6293
|
declaration: 'export interface SandboxPolicyRequest {\n session?: Session;\n mode?: SandboxMode;\n}',
|
|
6276
6294
|
},
|
|
6295
|
+
{
|
|
6296
|
+
name: 'SandboxReadScope',
|
|
6297
|
+
declaration: 'export interface SandboxReadScope {\n roots: readonly string[];\n hiddenNames: readonly string[];\n}',
|
|
6298
|
+
},
|
|
6277
6299
|
{
|
|
6278
6300
|
name: 'SaveFileAttachment',
|
|
6279
6301
|
declaration: 'export interface SaveFileAttachment {\n data: Uint8Array;\n name?: string;\n}',
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
en: 7eb705e3b132fcba
|
|
28
28
|
zh: 883207b13d381f9e
|
|
29
29
|
/deepseek-ai-dsh-tool-fs/use-this-package/policy-and-sandbox-behavior:
|
|
30
|
-
en:
|
|
31
|
-
zh:
|
|
30
|
+
en: 97152a766158d6c1
|
|
31
|
+
zh: 0bd315b51de3a8f8
|
|
32
32
|
/deepseek-ai-dsh-tool-fs/use-this-package/failures-and-recovery:
|
|
33
33
|
en: 962b09e21305a04b
|
|
34
34
|
zh: 382d2b8cce217569
|
|
@@ -65,7 +65,7 @@ The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-a
|
|
|
65
65
|
|
|
66
66
|
### Policy and sandbox behavior
|
|
67
67
|
|
|
68
|
-
Path authorization for `read` and `read_image` belongs
|
|
68
|
+
Path authorization for `read` and `read_image` belongs to `ctx.fs`, narrowed by the sandbox read scope: when the mounted `ctx.sandbox` provider confines reads (the Apple container backend does), `read`, `read_image`, `edit`, and `write` refuse a path outside the scope or a hidden secret file with `FS_SANDBOX_DENIED` before observing it. Media-type declarations and file signatures only decide whether `read_image` accepts the bytes returned by that backend.
|
|
69
69
|
|
|
70
70
|
With the policy plugin mounted, `write` and `edit` obtain their guard from the `fs/*` intent slots, so an unread target or a stale observation fails with `FS_NOT_OBSERVED` or `FS_STALE_VERSION` and a recovery instruction. Under a confining backend (`fs-sandbox`), `write`/`edit` additionally advertise `sandbox_permissions` and `justification`; a denied mutation returns the `[sandbox: file access denied under <mode> mode]` marker with the same-turn escalation hint, and an approved retry may stamp a strictly wider mode for that one call. The justification asks the model to use the language of the current user request.
|
|
71
71
|
|
|
@@ -65,7 +65,7 @@ kind: "package-reference"
|
|
|
65
65
|
|
|
66
66
|
### 策略与沙箱行为
|
|
67
67
|
|
|
68
|
-
`read` 与 `read_image`
|
|
68
|
+
`read` 与 `read_image` 的路径授权由 `ctx.fs` 负责,并受沙箱读取范围收窄:当挂载的 `ctx.sandbox` 提供方限制读取时(Apple container 后端即如此),`read`、`read_image`、`edit` 与 `write` 会在观察路径之前,以 `FS_SANDBOX_DENIED` 拒绝范围之外的路径或被隐藏的密钥文件。媒体类型声明和文件签名只决定 `read_image` 是否接受该后端返回的字节。
|
|
69
69
|
|
|
70
70
|
挂载策略插件后,`write` 与 `edit` 从 `fs/*` 意图槽位取得防护,因此未读目标或陈旧观察会以 `FS_NOT_OBSERVED` 或 `FS_STALE_VERSION` 及恢复指令失败。使用施加沙箱限制的后端(`fs-sandbox`)时,`write`/`edit` 还会公开 `sandbox_permissions` 与 `justification`;被拒绝的变更返回 `[sandbox: file access denied under <mode> mode]` 标记与同轮次升级提示,获批的重试可以在该次调用中加盖严格更宽的模式。理由字段提示模型使用用户当前提问的语言。
|
|
71
71
|
|
|
@@ -193,6 +193,27 @@ function sessionResolveOptions(exec, policyWorkspaceRoot) {
|
|
|
193
193
|
* @module @deepseek-ai/dsh-tool-fs/src/read-target
|
|
194
194
|
*/
|
|
195
195
|
/**
|
|
196
|
+
* Refuse a target the calling session's sandbox hides from reads: a path
|
|
197
|
+
* outside the read scope of `ctx.sandbox`, or a hidden secret file. Tools
|
|
198
|
+
* that read, edit, or overwrite (and so present) existing content call it
|
|
199
|
+
* after resolution and before any stat, so a refusal reveals nothing about
|
|
200
|
+
* the file.
|
|
201
|
+
* @param ctx - the plugin context; reads are unconfined without `ctx.sandboxPolicy`.
|
|
202
|
+
* @param exec - the current tool execution, supplying the session.
|
|
203
|
+
* @param target - the resolved target.
|
|
204
|
+
* @param mode - the call's approved escalation mode, when one applies.
|
|
205
|
+
* @throws {FsError} `FS_SANDBOX_DENIED` when the target is outside the read scope.
|
|
206
|
+
*/
|
|
207
|
+
function assertSandboxReadable(ctx, exec, target, mode) {
|
|
208
|
+
const policy = ctx.get("sandboxPolicy");
|
|
209
|
+
const session = exec.agent?.session;
|
|
210
|
+
if (policy === void 0 || policy.canRead(ctx.fs.processPath(target), {
|
|
211
|
+
...session === void 0 ? {} : { session },
|
|
212
|
+
...mode === void 0 ? {} : { mode }
|
|
213
|
+
})) return;
|
|
214
|
+
throw new FsError(`cannot read "${target.displayPath}": the sandbox hides this path from this session`, "FS_SANDBOX_DENIED");
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
196
217
|
* Resolve a model-supplied path, observe absence, and require a regular file.
|
|
197
218
|
* @param ctx - the plugin context providing filesystem resolution and observation events.
|
|
198
219
|
* @param exec - the current tool execution, including session cwd and cancellation.
|
|
@@ -201,6 +222,7 @@ function sessionResolveOptions(exec, policyWorkspaceRoot) {
|
|
|
201
222
|
*/
|
|
202
223
|
async function resolveRegularReadTarget(ctx, exec, requestedPath) {
|
|
203
224
|
const target = await ctx.fs.resolve(requestedPath, sessionResolveOptions(exec));
|
|
225
|
+
assertSandboxReadable(ctx, exec, target);
|
|
204
226
|
const info = await ctx.fs.stat(target, exec.signal);
|
|
205
227
|
if (info === void 0) {
|
|
206
228
|
ctx.emit("fs/observed", target, { kind: "absent" }, exec);
|
|
@@ -599,6 +621,7 @@ function applyWriteTool(ctx, sandbox) {
|
|
|
599
621
|
const input = parseWriteArgs(args);
|
|
600
622
|
const sandboxPolicy = await sandbox.resolvePolicy("write", args, exec);
|
|
601
623
|
const target = await ctx.fs.resolve(input.filePath, sessionResolveOptions(exec, sandboxPolicy?.workspaceRoot));
|
|
624
|
+
assertSandboxReadable(ctx, exec, target, sandboxPolicy?.mode);
|
|
602
625
|
const intent = await ctx.waterfall("fs/write-intent", target, exec, () => void 0);
|
|
603
626
|
let outcome;
|
|
604
627
|
try {
|
|
@@ -744,6 +767,7 @@ function applyEditTool(ctx, sandbox) {
|
|
|
744
767
|
const input = parseEditArgs(args);
|
|
745
768
|
const sandboxPolicy = await sandbox.resolvePolicy("edit", args, exec);
|
|
746
769
|
const target = await ctx.fs.resolve(input.filePath, sessionResolveOptions(exec, sandboxPolicy?.workspaceRoot));
|
|
770
|
+
assertSandboxReadable(ctx, exec, target, sandboxPolicy?.mode);
|
|
747
771
|
let outcome;
|
|
748
772
|
try {
|
|
749
773
|
const intent = await ctx.waterfall("fs/edit-intent", target, exec, () => void 0);
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
en: 4aa9b74deef586bc
|
|
31
31
|
zh: f855f815829d4e1e
|
|
32
32
|
/deepseek-ai-dsh-tool-fs-search/use-this-package/failures-and-recovery:
|
|
33
|
-
en:
|
|
34
|
-
zh:
|
|
33
|
+
en: bc9f98d7c20ac27b
|
|
34
|
+
zh: 44b0f43623cdd1fd
|
|
35
35
|
/deepseek-ai-dsh-tool-fs-search/understand-the-implementation:
|
|
36
36
|
en: 7546db09c46181e0
|
|
37
37
|
zh: 3aae6dc6a773511c
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
en: 2d4f2c8605eccab3
|
|
100
100
|
zh: 67f1f0218f73c6bf
|
|
101
101
|
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-errors/what-the-model-sees:
|
|
102
|
-
en:
|
|
103
|
-
zh:
|
|
102
|
+
en: 59ab1c2d63f63651
|
|
103
|
+
zh: 9086a3a508087938
|
|
104
104
|
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-errors/token-effect:
|
|
105
105
|
en: 681cadd5be7b8ac1
|
|
106
106
|
zh: 1f0102977ea02785
|
|
@@ -74,7 +74,7 @@ Node deployments receive the `@vscode/ripgrep` platform package on supported mac
|
|
|
74
74
|
|
|
75
75
|
### Failures and recovery
|
|
76
76
|
|
|
77
|
-
Search failures carry the package-owned codes `SEARCH_INVALID_PATTERN` (ripgrep rejected the regex or glob), `SEARCH_FAILED` (a failed launch, inaccessible target, signal kill, or malformed `--json` output), `SEARCH_RAW_OUTPUT_OVERFLOW` (raw output over the cap),
|
|
77
|
+
Search failures carry the package-owned codes `SEARCH_INVALID_PATTERN` (ripgrep rejected the regex or glob), `SEARCH_FAILED` (a failed launch, inaccessible target, signal kill, or malformed `--json` output), `SEARCH_RAW_OUTPUT_OVERFLOW` (raw output over the cap), `SEARCH_ABORTED` (cooperative timeout or caller cancellation), and `SEARCH_SANDBOX_DENIED` (the search path is outside the sandbox read scope). When the mounted `ctx.sandbox` provider confines reads, `grep` also excludes the scope's hidden file names from content searches. Exit 0 is success with results and exit 1 is a successful empty search; model argument mistakes stay ordinary tool argument errors.
|
|
78
78
|
|
|
79
79
|
-----
|
|
80
80
|
|
|
@@ -188,7 +188,7 @@ Append-only; newly visible content follows the reusable request prefix and does
|
|
|
188
188
|
|
|
189
189
|
#### What the model sees
|
|
190
190
|
|
|
191
|
-
Failures are normalized as `Error: <message>` with structured `SEARCH_INVALID_PATTERN`, `SEARCH_FAILED`, `SEARCH_RAW_OUTPUT_OVERFLOW`, or `
|
|
191
|
+
Failures are normalized as `Error: <message>` with structured `SEARCH_INVALID_PATTERN`, `SEARCH_FAILED`, `SEARCH_RAW_OUTPUT_OVERFLOW`, `SEARCH_ABORTED`, or `SEARCH_SANDBOX_DENIED` metadata for callers.
|
|
192
192
|
|
|
193
193
|
#### Token effect
|
|
194
194
|
|
|
@@ -74,7 +74,7 @@ Node 部署在受支持的 macOS、Linux 与 Windows 目标上获得 `@vscode/ri
|
|
|
74
74
|
|
|
75
75
|
### 失败与恢复
|
|
76
76
|
|
|
77
|
-
搜索失败携带本包定义的错误码:`SEARCH_INVALID_PATTERN`(ripgrep 拒绝正则或 glob)、`SEARCH_FAILED`(启动失败、目标不可访问、信号终止或 `--json` 输出格式错误)、`SEARCH_RAW_OUTPUT_OVERFLOW
|
|
77
|
+
搜索失败携带本包定义的错误码:`SEARCH_INVALID_PATTERN`(ripgrep 拒绝正则或 glob)、`SEARCH_FAILED`(启动失败、目标不可访问、信号终止或 `--json` 输出格式错误)、`SEARCH_RAW_OUTPUT_OVERFLOW`(原始输出超过上限)、`SEARCH_ABORTED`(协作式超时或调用方取消)与 `SEARCH_SANDBOX_DENIED`(搜索路径位于沙箱读取范围之外)。当挂载的 `ctx.sandbox` 提供方限制读取时,`grep` 还会在内容搜索中排除该范围的隐藏文件名。退出 0 表示成功且有结果,退出 1 表示成功的空搜索;模型参数错误仍是普通工具参数错误。
|
|
78
78
|
|
|
79
79
|
-----
|
|
80
80
|
|
|
@@ -188,7 +188,7 @@ glob 描述声明了配置的超过上限排序方式。生成的 [`glob` 和 `g
|
|
|
188
188
|
|
|
189
189
|
#### 模型看到的内容
|
|
190
190
|
|
|
191
|
-
失败被规范化为 `Error: <message>`,并携带结构化 `SEARCH_INVALID_PATTERN`、`SEARCH_FAILED`、`SEARCH_RAW_OUTPUT_OVERFLOW` 或 `
|
|
191
|
+
失败被规范化为 `Error: <message>`,并携带结构化 `SEARCH_INVALID_PATTERN`、`SEARCH_FAILED`、`SEARCH_RAW_OUTPUT_OVERFLOW`、`SEARCH_ABORTED` 或 `SEARCH_SANDBOX_DENIED` 元数据供调用方使用。
|
|
192
192
|
|
|
193
193
|
#### Token 影响
|
|
194
194
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { MAX_TIMER_DELAY_MS } from "@deepseek-ai/dsh-timeout";
|
|
3
|
-
import { isAbsolute, join, parse, relative, sep } from "node:path";
|
|
3
|
+
import { isAbsolute, join, parse, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
7
7
|
import { ItemRetainer, TextRetainer } from "@deepseek-ai/dsh-output-retention";
|
|
8
|
+
import { isReadableIn } from "@deepseek-ai/dsh-sandbox";
|
|
8
9
|
//#region lib/types/search-core.js
|
|
9
10
|
/**
|
|
10
11
|
* Shared execution plumbing for the `glob` / `grep` search tools: the
|
|
@@ -128,6 +129,23 @@ function resolveRgPath() {
|
|
|
128
129
|
return rgPathPromise;
|
|
129
130
|
}
|
|
130
131
|
/**
|
|
132
|
+
* The calling session's host read scope, after refusing a search path the
|
|
133
|
+
* sandbox hides. A search inside the scope must still exclude the scope's
|
|
134
|
+
* hidden file names from content reads.
|
|
135
|
+
* @param ctx - the plugin context; reads are unconfined without `ctx.sandboxPolicy`.
|
|
136
|
+
* @param exec - the tool execution, supplying the session and its cwd.
|
|
137
|
+
* @param toolName - `glob` or `grep`, used in the refusal.
|
|
138
|
+
* @param path - the model-supplied search path, relative to the session cwd; absent searches the cwd.
|
|
139
|
+
* @returns the read scope, or `undefined` when reads are unconfined.
|
|
140
|
+
* @throws {SearchError} `SEARCH_SANDBOX_DENIED` when the path is outside the scope.
|
|
141
|
+
*/
|
|
142
|
+
function searchReadScope(ctx, exec, toolName, path) {
|
|
143
|
+
const scope = ctx.get("sandboxPolicy")?.readScope(exec.agent === void 0 ? {} : { session: exec.agent.session });
|
|
144
|
+
if (scope === void 0) return void 0;
|
|
145
|
+
if (!isReadableIn(resolve(exec.agent?.session.header.cwd ?? process.cwd(), path ?? "."), scope)) throw new SearchError(`${toolName} cannot search "${path ?? "."}": the sandbox hides this path from this session`, "SEARCH_SANDBOX_DENIED");
|
|
146
|
+
return scope;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
131
149
|
* Run the packaged ripgrep binary with a plain argv vector and return its
|
|
132
150
|
* complete raw stdout. The working directory is the calling agent's session
|
|
133
151
|
* cwd (`exec.agent.session.header.cwd`) when available, else
|
|
@@ -824,6 +842,7 @@ function applyGlobTool(ctx, caps) {
|
|
|
824
842
|
},
|
|
825
843
|
async execute(args, exec) {
|
|
826
844
|
const input = parseGlobArgs(args);
|
|
845
|
+
searchReadScope(ctx, exec, "glob", input.path);
|
|
827
846
|
const run = await runRipgrep(ctx, exec, "glob", buildGlobCommand(input), caps.rawOutputMaxBytes, caps.graceMs, caps.stderrMaxBytes);
|
|
828
847
|
const root = input.path === void 0 ? "." : toWorkdirRelative(input.path, run.workdir);
|
|
829
848
|
if (run.noMatches) return {
|
|
@@ -927,12 +946,17 @@ function parseGrepArgs(args) {
|
|
|
927
946
|
* and the target behind `--`, so a leading-dash value can never be parsed as
|
|
928
947
|
* a flag.
|
|
929
948
|
*
|
|
949
|
+
* File names the sandbox hides ride as trailing negated globs, which take
|
|
950
|
+
* precedence over the include glob.
|
|
951
|
+
*
|
|
930
952
|
* @param input - the validated arguments.
|
|
953
|
+
* @param hiddenNames - file-name globs whose contents must not be searched.
|
|
931
954
|
* @returns the complete ripgrep argument vector (excluding the binary itself).
|
|
932
955
|
*/
|
|
933
|
-
function buildGrepCommand(input) {
|
|
956
|
+
function buildGrepCommand(input, hiddenNames = []) {
|
|
934
957
|
const parts = ["--json", `--regexp=${input.pattern}`];
|
|
935
958
|
if (input.include !== void 0) parts.push(`--glob=${input.include}`);
|
|
959
|
+
for (const name of hiddenNames) parts.push(`--iglob=!${name}`);
|
|
936
960
|
if (input.path !== void 0) parts.push("--", input.path);
|
|
937
961
|
return parts;
|
|
938
962
|
}
|
|
@@ -1139,7 +1163,8 @@ function applyGrepTool(ctx, caps) {
|
|
|
1139
1163
|
presentationMeta: (_args, value) => grepSearchMeta(retainGrepMatches(value.matches, caps.maxMatches, caps.maxLineBytes), caps.maxMetaBytes)
|
|
1140
1164
|
},
|
|
1141
1165
|
async execute(args, exec) {
|
|
1142
|
-
const
|
|
1166
|
+
const input = parseGrepArgs(args);
|
|
1167
|
+
const run = await runRipgrep(ctx, exec, "grep", buildGrepCommand(input, searchReadScope(ctx, exec, "grep", input.path)?.hiddenNames ?? []), caps.rawOutputMaxBytes, caps.graceMs, caps.stderrMaxBytes);
|
|
1143
1168
|
if (run.noMatches) return { matches: [] };
|
|
1144
1169
|
const all = [];
|
|
1145
1170
|
for (const raw of parseGrepMatches(run.stdout)) {
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
40
40
|
"@deepseek-ai/dsh-timeout": "0.2.0-rc.2",
|
|
41
41
|
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
42
|
-
"@deepseek-ai/cordis": "4.0.4"
|
|
42
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
43
|
+
"@deepseek-ai/dsh-sandbox": "0.2.0-rc.2",
|
|
44
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.0-rc.2"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
47
|
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
@@ -53,6 +55,9 @@
|
|
|
53
55
|
"@deepseek-ai/dsh-timeout": "0.2.0-rc.2",
|
|
54
56
|
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
55
57
|
"@deepseek-ai/cordis": "4.0.4",
|
|
56
|
-
"@deepseek-ai/dsh-scope": "0.2.0-rc.2"
|
|
58
|
+
"@deepseek-ai/dsh-scope": "0.2.0-rc.2",
|
|
59
|
+
"@deepseek-ai/dsh-sandbox": "0.2.0-rc.2",
|
|
60
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.0-rc.2",
|
|
61
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2"
|
|
57
62
|
}
|
|
58
63
|
}
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
en: 554e8446946fbd96
|
|
28
28
|
zh: 3af12627c19a0111
|
|
29
29
|
/deepseek-ai-dsh-tool-str-replace-editor/use-this-package/failures-and-recovery:
|
|
30
|
-
en:
|
|
31
|
-
zh:
|
|
30
|
+
en: f116c32b0a508833
|
|
31
|
+
zh: 22905d226e9a0609
|
|
32
32
|
/deepseek-ai-dsh-tool-str-replace-editor/understand-the-implementation:
|
|
33
33
|
en: b0b36a22cd4421eb
|
|
34
34
|
zh: db47ef5b71dd51df
|
|
@@ -50,7 +50,7 @@ A backend, optionally the policy plugin, then the tool; the editor composes with
|
|
|
50
50
|
|
|
51
51
|
### Failures and recovery
|
|
52
52
|
|
|
53
|
-
A metadata miss from `view`, `str_replace`, or `insert` records confirmed absence before returning `FS_NOT_FOUND`, so a later `create` can recover an externally deleted path through the mounted policy's guarded-create flow; absence never authorizes `str_replace` or `insert`. Guarded mutations inherit the policy plugin's codes and remedies — `FS_NOT_OBSERVED` (read the file, then retry), `FS_STALE_VERSION` (re-read, then retry) — and sandbox denials surface as the `[sandbox: file access denied under <mode> mode]` marker. Paths must be absolute; a relative path is refused with a hint.
|
|
53
|
+
A metadata miss from `view`, `str_replace`, or `insert` records confirmed absence before returning `FS_NOT_FOUND`, so a later `create` can recover an externally deleted path through the mounted policy's guarded-create flow; absence never authorizes `str_replace` or `insert`. Guarded mutations inherit the policy plugin's codes and remedies — `FS_NOT_OBSERVED` (read the file, then retry), `FS_STALE_VERSION` (re-read, then retry) — and sandbox denials surface as the `[sandbox: file access denied under <mode> mode]` marker. When the mounted `ctx.sandbox` provider confines reads, every command refuses a path outside its read scope or a hidden secret file with `FS_SANDBOX_DENIED` before observing it. Paths must be absolute; a relative path is refused with a hint.
|
|
54
54
|
|
|
55
55
|
-----
|
|
56
56
|
|
|
@@ -50,7 +50,7 @@ kind: "package-reference"
|
|
|
50
50
|
|
|
51
51
|
### 失败与恢复
|
|
52
52
|
|
|
53
|
-
`view`、`str_replace` 或 `insert` 发生元数据未命中时,工具会在返回 `FS_NOT_FOUND` 前记录确认缺失,因此后续 `create` 可以通过已挂载策略的防护创建流程恢复外部删除的路径;缺失状态绝不会授权 `str_replace` 或 `insert`。防护变更继承策略插件的错误码与恢复指令——`FS_NOT_OBSERVED`(先读取文件再重试)、`FS_STALE_VERSION`(先重新读取再重试)——沙箱拒绝则表现为 `[sandbox: file access denied under <mode> mode]`
|
|
53
|
+
`view`、`str_replace` 或 `insert` 发生元数据未命中时,工具会在返回 `FS_NOT_FOUND` 前记录确认缺失,因此后续 `create` 可以通过已挂载策略的防护创建流程恢复外部删除的路径;缺失状态绝不会授权 `str_replace` 或 `insert`。防护变更继承策略插件的错误码与恢复指令——`FS_NOT_OBSERVED`(先读取文件再重试)、`FS_STALE_VERSION`(先重新读取再重试)——沙箱拒绝则表现为 `[sandbox: file access denied under <mode> mode]` 标记。当挂载的 `ctx.sandbox` 提供方限制读取时,每个命令都会在观察路径之前,以 `FS_SANDBOX_DENIED` 拒绝读取范围之外的路径或被隐藏的密钥文件。路径必须是绝对路径;相对路径会被拒绝并给出提示。
|
|
54
54
|
|
|
55
55
|
-----
|
|
56
56
|
|
|
@@ -65,10 +65,18 @@ var MutationPolicy = class {
|
|
|
65
65
|
return new FsError(sandboxDenialMarker(mode), "FS_SANDBOX_DENIED", { cause: error });
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Resolve an absolute model path, refusing one the calling session's sandbox
|
|
70
|
+
* hides from reads before anything observes it.
|
|
71
|
+
*/
|
|
72
|
+
async function resolveTarget(ctx, path, exec) {
|
|
69
73
|
if (path.trim().length === 0) throw new Error("path must be a non-empty string");
|
|
70
74
|
if (!isAbsolute(path)) throw new Error(`The path ${path} is not an absolute path, it should start with \`/\`. Maybe you meant /${path}?`);
|
|
71
|
-
|
|
75
|
+
const target = await ctx.fs.resolve(path, { signal: exec.signal });
|
|
76
|
+
const policy = ctx.get("sandboxPolicy");
|
|
77
|
+
const request = exec.agent === void 0 ? {} : { session: exec.agent.session };
|
|
78
|
+
if (policy !== void 0 && !policy.canRead(ctx.fs.processPath(target), request)) throw new FsError(`cannot read "${target.displayPath}": the sandbox hides this path from this session`, "FS_SANDBOX_DENIED");
|
|
79
|
+
return target;
|
|
72
80
|
}
|
|
73
81
|
async function statExisting(ctx, target, command, exec) {
|
|
74
82
|
const info = await ctx.fs.stat(target, exec.signal);
|
|
@@ -123,7 +131,7 @@ async function listDirectory(ctx, target, maxOutputChars, exec) {
|
|
|
123
131
|
return `Here're the files and directories up to 2 levels deep in ${target.displayPath}, excluding hidden items, node_modules, and Python cache directories:\n${listing}\n`;
|
|
124
132
|
}
|
|
125
133
|
async function viewPath(ctx, path, viewRange, maxOutputChars, exec) {
|
|
126
|
-
const target = await resolveTarget(ctx, path, exec
|
|
134
|
+
const target = await resolveTarget(ctx, path, exec);
|
|
127
135
|
const info = await statExisting(ctx, target, "view", exec);
|
|
128
136
|
if (info.type === "directory") {
|
|
129
137
|
if (viewRange !== void 0) throw new Error("The `view_range` parameter is not allowed when `path` points to a directory.");
|
|
@@ -140,7 +148,7 @@ async function viewPath(ctx, path, viewRange, maxOutputChars, exec) {
|
|
|
140
148
|
async function createFile(ctx, policy, path, fileText, exec) {
|
|
141
149
|
const content = requiredForCommand(fileText, "file_text", "create");
|
|
142
150
|
const sandboxPolicy = policy.resolve(exec);
|
|
143
|
-
const target = await resolveTarget(ctx, path, exec
|
|
151
|
+
const target = await resolveTarget(ctx, path, exec);
|
|
144
152
|
if (await ctx.fs.stat(target, exec.signal) !== void 0) throw new Error(`File already exists at: ${target.displayPath}. Cannot overwrite files using command \`create\`.`);
|
|
145
153
|
const intent = await ctx.waterfall("fs/write-intent", target, exec, () => ({ kind: "createIfAbsent" }));
|
|
146
154
|
let outcome;
|
|
@@ -158,7 +166,7 @@ async function createFile(ctx, policy, path, fileText, exec) {
|
|
|
158
166
|
async function replaceInFile(ctx, policy, path, oldStr, newStr, exec) {
|
|
159
167
|
if (newStr === null) throw new Error("Parameter `new_str` must be omitted or contain a string for command: str_replace");
|
|
160
168
|
const sandboxPolicy = policy.resolve(exec);
|
|
161
|
-
const target = await resolveTarget(ctx, path, exec
|
|
169
|
+
const target = await resolveTarget(ctx, path, exec);
|
|
162
170
|
const intent = await ctx.waterfall("fs/edit-intent", target, exec, () => void 0);
|
|
163
171
|
const oldValue = requiredForCommand(oldStr, "old_str", "str_replace", false);
|
|
164
172
|
const newValue = newStr ?? "";
|
|
@@ -191,7 +199,7 @@ async function insertInFile(ctx, policy, path, insertLine, newStr, exec) {
|
|
|
191
199
|
if (insertLine === void 0) throw new Error("Parameter `insert_line` is required for command: insert");
|
|
192
200
|
const value = requiredForCommand(newStr, "new_str", "insert");
|
|
193
201
|
const sandboxPolicy = policy.resolve(exec);
|
|
194
|
-
const target = await resolveTarget(ctx, path, exec
|
|
202
|
+
const target = await resolveTarget(ctx, path, exec);
|
|
195
203
|
const intent = await ctx.waterfall("fs/edit-intent", target, exec, () => void 0);
|
|
196
204
|
const info = await statExisting(ctx, target, "insert", exec);
|
|
197
205
|
if (info.type !== "file") throw new FsError(`cannot insert into "${target.displayPath}": not a regular file`, "FS_NOT_REGULAR_FILE");
|
|
@@ -16,7 +16,27 @@
|
|
|
16
16
|
# Keep the same temporary process-wide PTC mode opt-in as the Web surface.
|
|
17
17
|
mode: !!js process.env.DSH_TOOLS_MODE
|
|
18
18
|
|
|
19
|
+
# The terminal confines commands with the Apple container backend below
|
|
20
|
+
# instead of the base local sandbox row.
|
|
21
|
+
- id: sandbox
|
|
22
|
+
disabled: true
|
|
23
|
+
|
|
19
24
|
- insert:
|
|
25
|
+
# `auto` runs confined commands in an Apple container VM on macOS on Apple
|
|
26
|
+
# silicon when the `container` CLI is installed, and through the inherited
|
|
27
|
+
# local sandbox chain elsewhere; `/sandbox` switches one session. Skill
|
|
28
|
+
# roots are mounted read-only so loaded skills can read their resources.
|
|
29
|
+
- id: sandbox-apple-container
|
|
30
|
+
name: '@deepseek-ai/dsh-sandbox-apple-container'
|
|
31
|
+
config:
|
|
32
|
+
backend: auto
|
|
33
|
+
readOnlyMounts: !!js >-
|
|
34
|
+
process.platform !== 'darwin' ? [] : [
|
|
35
|
+
`${process.env.DSH_HOME ?? `${process.env.HOME}/.dsh`}/skills`,
|
|
36
|
+
`${process.env.DSH_AGENTS_HOME ?? `${process.env.HOME}/.agents`}/skills`,
|
|
37
|
+
...(process.env.DSH_BUNDLED_SKILL_DIR ? [process.env.DSH_BUNDLED_SKILL_DIR] : []),
|
|
38
|
+
]
|
|
39
|
+
|
|
20
40
|
# The model-facing question tool; the terminal runner answers its
|
|
21
41
|
# `user-questions/request` waterfall in the same process.
|
|
22
42
|
- id: tool-ask-user
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
50
50
|
"@deepseek-ai/dsh-native-command": "0.2.0-rc.2",
|
|
51
51
|
"@deepseek-ai/dsh-plugin-manager": "0.2.0-rc.2",
|
|
52
|
+
"@deepseek-ai/dsh-sandbox-apple-container": "0.2.0-rc.2",
|
|
52
53
|
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
53
54
|
"@deepseek-ai/dsh-session-log-export": "0.2.0-rc.2",
|
|
54
55
|
"@deepseek-ai/dsh-session-reference": "0.2.0-rc.2",
|