refactor(working-directory): single root accessor, extras helper, and review follow-ups
workingDirectory.recordedRootOf returns the recorded root without the deployment fallback, so sandbox-policy and workspace-files share one "root, else header, else own fallback" rule instead of comparing anchor counts. dsh-sandbox exports additionalWritableRoots, the canonical extra roots beside the workspace, which sandbox-local uses for ACEs and runner arguments instead of slicing workspaceWritableRoots. sandbox-policy keeps a local within and reads working-directory as a type-only dependency; its derivation filter dedupes before dropping nested candidates. tool-skill validates the directory before reading the root, as the other root consumers do. The capability graph names api-workspace-files and api-terminal-controller so their nodes link, the workspace-changes README states the per-turn repository and root, the workspace-files solution tsconfig keeps only its face references, and the terminal spawn comment states that the root is read after validation. Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796752 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796760 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796781 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796818 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796826 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796841 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796849 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796855 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796861 Review: https://github.com/deepseek-harness/deepseek-harness/pull/7820#discussion_r4463796879
This commit is contained in:
1 parent
bb078f4e2b
commit
dac3cfc231
34 files changed
+143
-73
No files matched your search
@@ -6,5 +6,5 @@
|
||||
en: 41d772192075e133
|
||||
zh: 5ef3da69b4de1d8a
|
||||
/capability-seams-and-core-services:
|
||||
en: 2a8998fb919f4e2e
|
||||
zh: eb7d61cb7c66d38c
|
||||
en: 0b60c2496f5c1f91
|
||||
zh: de827062a248d9b2
|
||||
@@ -55,8 +55,8 @@ flowchart LR
|
||||
pkg_subagent["subagent"]
|
||||
pkg_sdk_jsonrpc_server["sdk-jsonrpc-server"]
|
||||
pkg_sandbox_policy["sandbox-policy"]
|
||||
pkg_workspace_files["workspace-files"]
|
||||
pkg_terminal_controller["terminal-controller"]
|
||||
pkg_api_workspace_files["api-workspace-files"]
|
||||
pkg_api_terminal_controller["api-terminal-controller"]
|
||||
pkg_workspace_changes["workspace-changes"]
|
||||
pkg_file_reference_local["file-reference-local"]
|
||||
pkg_tool_skill["tool-skill"]
|
||||
@@ -118,10 +118,8 @@ flowchart LR
|
||||
pkg_api_settings_controller["api-settings-controller"]
|
||||
svc_credentialsController["ctx.credentialsController<br/>Host credential-surface Remote controller"]
|
||||
svc_settingsController["ctx.settingsController<br/>Host settings-surface Remote controller"]
|
||||
pkg_api_workspace_files["api-workspace-files"]
|
||||
svc_workspaceFiles["ctx.workspaceFiles<br/>Host workspace file Remote service"]
|
||||
svc_workspaceChanges["ctx.workspaceChanges<br/>Host per-turn changed-file summaries"]
|
||||
pkg_api_terminal_controller["api-terminal-controller"]
|
||||
svc_terminalController["ctx.terminalController<br/>Session interactive terminal Remote controller"]
|
||||
pkg_api_workspace_controller["api-workspace-controller"]
|
||||
svc_workspaceController["ctx.workspaceController<br/>Host Workspace Remote controller"]
|
||||
@@ -639,11 +637,12 @@ flowchart LR
|
||||
svc_workflowEngine --> pkg_tool_ralph
|
||||
svc_workflowEngine --> pkg_tool_workflow
|
||||
svc_workingDirectory --> pkg_agent_instructions
|
||||
svc_workingDirectory --> pkg_api_terminal_controller
|
||||
svc_workingDirectory --> pkg_api_workspace_files
|
||||
svc_workingDirectory --> pkg_file_reference_local
|
||||
svc_workingDirectory --> pkg_sandbox_policy
|
||||
svc_workingDirectory --> pkg_sdk_jsonrpc_server
|
||||
svc_workingDirectory --> pkg_subagent
|
||||
svc_workingDirectory --> pkg_terminal_controller
|
||||
svc_workingDirectory --> pkg_tool_bash
|
||||
svc_workingDirectory --> pkg_tool_fs
|
||||
svc_workingDirectory --> pkg_tool_lsp
|
||||
@@ -651,7 +650,6 @@ flowchart LR
|
||||
svc_workingDirectory --> pkg_tool_skill
|
||||
svc_workingDirectory --> pkg_tool_working_directory
|
||||
svc_workingDirectory --> pkg_workspace_changes
|
||||
svc_workingDirectory --> pkg_workspace_files
|
||||
svc_workspaceRegistry --> pkg_api_session_controller
|
||||
svc_workspaceRegistry --> pkg_api_workspace_controller
|
||||
svc_worktrees --> pkg_experimental_tool_worktree
|
||||
@@ -675,7 +673,7 @@ flowchart LR
|
||||
| `ctx.forgeSession` | `service` | [`experimental-forge-session`](../packages/experimental/forge-session) | - | [`experimental-client-ui-forge`](../packages/experimental/client-ui-forge) | - | A Session projection derives bindings from shell results and binding records and publishes their URLs without status to clients; push results trigger head-branch discovery, and Session watchers poll bound change requests through the forge registry. |
|
||||
| `ctx.forgePanel` | `service` | [`experimental-client-ui-forge`](../packages/experimental/client-ui-forge) | - | - | - | Streams one panel state per followed Session: Git inspection using Session permissions, the recognized code host and its sign-in, and the bound change requests with polled status. |
|
||||
| `ctx.worktrees` | `seam` | [`experimental-worktree`](../packages/experimental/worktree) | [`experimental-worktree`](../packages/experimental/worktree) | [`experimental-tool-worktree`](../packages/experimental/tool-worktree) | - | Explicit experimental creation from a pinned local commit. Existing write permissions govern checkout and shared Git metadata; the working-directory service owns the resulting Session directory. |
|
||||
| `ctx.workingDirectory` | `seam` | [`working-directory`](../packages/session/working-directory) | [`working-directory`](../packages/session/working-directory) | [`tool-working-directory`](../packages/session/tool-working-directory), [`tool-fs`](../packages/fs/tool-fs), [`tool-bash`](../packages/shell/tool-bash), [`tool-pwsh`](../packages/shell/tool-pwsh), [`subagent`](../packages/subagent/subagent), [`sdk-jsonrpc-server`](../packages/sdk/server), [`sandbox-policy`](../packages/sandbox/sandbox-policy), `workspace-files`, `terminal-controller`, [`workspace-changes`](../packages/deliverables/workspace-changes), [`file-reference-local`](../packages/context/file-reference-local), [`tool-skill`](../packages/skill/tool-skill), [`agent-instructions`](../packages/context/agent-instructions), [`tool-lsp`](../packages/lsp/tool-lsp) | - | Two Session projections own the effective execution directory and the workspace root it is in. The filesystem validates changes and user context reports them; model tools follow the directory while the sandbox boundary, file views, and discovery follow the root, and original metadata stays fixed. |
|
||||
| `ctx.workingDirectory` | `seam` | [`working-directory`](../packages/session/working-directory) | [`working-directory`](../packages/session/working-directory) | [`tool-working-directory`](../packages/session/tool-working-directory), [`tool-fs`](../packages/fs/tool-fs), [`tool-bash`](../packages/shell/tool-bash), [`tool-pwsh`](../packages/shell/tool-pwsh), [`subagent`](../packages/subagent/subagent), [`sdk-jsonrpc-server`](../packages/sdk/server), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`api-workspace-files`](../packages/api/workspace-files), [`api-terminal-controller`](../packages/api/terminal-controller), [`workspace-changes`](../packages/deliverables/workspace-changes), [`file-reference-local`](../packages/context/file-reference-local), [`tool-skill`](../packages/skill/tool-skill), [`agent-instructions`](../packages/context/agent-instructions), [`tool-lsp`](../packages/lsp/tool-lsp) | - | Two Session projections own the effective execution directory and the workspace root it is in. The filesystem validates changes and user context reports them; model tools follow the directory while the sandbox boundary, file views, and discovery follow the root, and original metadata stays fixed. |
|
||||
| `ctx.mcpResources` | `seam` | [`mcp-resources`](../packages/mcp/mcp-resources) | [`mcp-client`](../packages/mcp/mcp-client) | [`mcp-resources`](../packages/mcp/mcp-resources) | - | Connection-owned providers serve shared resource tools in the calling agent scope. |
|
||||
| `ctx.browserUse` | `seam` | [`browser-use`](../packages/browser-use/browser-use) | [`experimental-browser-use-playwright-mcp`](../packages/experimental/browser-use-playwright-mcp), [`experimental-browser-use-chrome-devtools-mcp`](../packages/experimental/browser-use-chrome-devtools-mcp), [`experimental-browser-use-stagehand-native`](../packages/experimental/browser-use-stagehand-native) | [`experimental-browser-use-playwright-mcp`](../packages/experimental/browser-use-playwright-mcp), [`experimental-browser-use-chrome-devtools-mcp`](../packages/experimental/browser-use-chrome-devtools-mcp), [`experimental-browser-use-stagehand-native`](../packages/experimental/browser-use-stagehand-native) | - | One provider-owned name per service instance. Providers own their tools and browser resources per live Session; the shared service has no browser operation API. |
|
||||
| `ctx.computerUse` | `seam` | [`computer-use`](../packages/computer-use/computer-use) | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp), [`experimental-computer-use-cua-driver-native`](../packages/experimental/computer-use-cua-driver-native) | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp), [`experimental-computer-use-cua-driver-native`](../packages/experimental/computer-use-cua-driver-native) | - | One provider-owned name per service instance. Each provider also owns its model tools; the service has no common action API, runtime selection, or Session workflow lock. |
|
||||
|
||||
@@ -57,8 +57,8 @@ flowchart LR
|
||||
pkg_subagent["subagent"]
|
||||
pkg_sdk_jsonrpc_server["sdk-jsonrpc-server"]
|
||||
pkg_sandbox_policy["sandbox-policy"]
|
||||
pkg_workspace_files["workspace-files"]
|
||||
pkg_terminal_controller["terminal-controller"]
|
||||
pkg_api_workspace_files["api-workspace-files"]
|
||||
pkg_api_terminal_controller["api-terminal-controller"]
|
||||
pkg_workspace_changes["workspace-changes"]
|
||||
pkg_file_reference_local["file-reference-local"]
|
||||
pkg_tool_skill["tool-skill"]
|
||||
@@ -120,10 +120,8 @@ flowchart LR
|
||||
pkg_api_settings_controller["api-settings-controller"]
|
||||
svc_credentialsController["ctx.credentialsController<br/>Host credential-surface Remote controller"]
|
||||
svc_settingsController["ctx.settingsController<br/>Host settings-surface Remote controller"]
|
||||
pkg_api_workspace_files["api-workspace-files"]
|
||||
svc_workspaceFiles["ctx.workspaceFiles<br/>Host workspace file Remote service"]
|
||||
svc_workspaceChanges["ctx.workspaceChanges<br/>Host per-turn changed-file summaries"]
|
||||
pkg_api_terminal_controller["api-terminal-controller"]
|
||||
svc_terminalController["ctx.terminalController<br/>Session interactive terminal Remote controller"]
|
||||
pkg_api_workspace_controller["api-workspace-controller"]
|
||||
svc_workspaceController["ctx.workspaceController<br/>Host Workspace Remote controller"]
|
||||
@@ -641,11 +639,12 @@ flowchart LR
|
||||
svc_workflowEngine --> pkg_tool_ralph
|
||||
svc_workflowEngine --> pkg_tool_workflow
|
||||
svc_workingDirectory --> pkg_agent_instructions
|
||||
svc_workingDirectory --> pkg_api_terminal_controller
|
||||
svc_workingDirectory --> pkg_api_workspace_files
|
||||
svc_workingDirectory --> pkg_file_reference_local
|
||||
svc_workingDirectory --> pkg_sandbox_policy
|
||||
svc_workingDirectory --> pkg_sdk_jsonrpc_server
|
||||
svc_workingDirectory --> pkg_subagent
|
||||
svc_workingDirectory --> pkg_terminal_controller
|
||||
svc_workingDirectory --> pkg_tool_bash
|
||||
svc_workingDirectory --> pkg_tool_fs
|
||||
svc_workingDirectory --> pkg_tool_lsp
|
||||
@@ -653,7 +652,6 @@ flowchart LR
|
||||
svc_workingDirectory --> pkg_tool_skill
|
||||
svc_workingDirectory --> pkg_tool_working_directory
|
||||
svc_workingDirectory --> pkg_workspace_changes
|
||||
svc_workingDirectory --> pkg_workspace_files
|
||||
svc_workspaceRegistry --> pkg_api_session_controller
|
||||
svc_workspaceRegistry --> pkg_api_workspace_controller
|
||||
svc_worktrees --> pkg_experimental_tool_worktree
|
||||
@@ -677,7 +675,7 @@ flowchart LR
|
||||
| `ctx.forgeSession` | `service` | [`experimental-forge-session`](../packages/experimental/forge-session) | - | [`experimental-client-ui-forge`](../packages/experimental/client-ui-forge) | - | Session 投影从 shell 结果与绑定记录派生绑定,并把不含状态的 URL 发布给客户端;推送结果触发按 head 分支的发现,Session 监听方通过 forge 注册表轮询已绑定的变更请求。 |
|
||||
| `ctx.forgePanel` | `service` | [`experimental-client-ui-forge`](../packages/experimental/client-ui-forge) | - | - | - | 为每个被跟随的 Session 推送一份面板状态:使用 Session 权限进行的 Git 检查、识别出的代码托管平台及其登录状态,以及带轮询状态的已绑定变更请求。 |
|
||||
| `ctx.worktrees` | `seam` | [`experimental-worktree`](../packages/experimental/worktree) | [`experimental-worktree`](../packages/experimental/worktree) | [`experimental-tool-worktree`](../packages/experimental/tool-worktree) | - | 显式实验组合从固定的本地提交创建工作树。检出目录与共享 Git 元数据受现有写权限约束;工作目录服务拥有创建后的 Session 目录。 |
|
||||
| `ctx.workingDirectory` | `seam` | [`working-directory`](../packages/session/working-directory) | [`working-directory`](../packages/session/working-directory) | [`tool-working-directory`](../packages/session/tool-working-directory), [`tool-fs`](../packages/fs/tool-fs), [`tool-bash`](../packages/shell/tool-bash), [`tool-pwsh`](../packages/shell/tool-pwsh), [`subagent`](../packages/subagent/subagent), [`sdk-jsonrpc-server`](../packages/sdk/server), [`sandbox-policy`](../packages/sandbox/sandbox-policy), `workspace-files`, `terminal-controller`, [`workspace-changes`](../packages/deliverables/workspace-changes), [`file-reference-local`](../packages/context/file-reference-local), [`tool-skill`](../packages/skill/tool-skill), [`agent-instructions`](../packages/context/agent-instructions), [`tool-lsp`](../packages/lsp/tool-lsp) | - | 两个 Session 投影拥有有效执行目录及其所在的工作区根。文件系统验证变更并由用户上下文报告;模型工具跟随当前目录,而沙箱边界、文件视图与发现跟随根,原始元数据保持不变。 |
|
||||
| `ctx.workingDirectory` | `seam` | [`working-directory`](../packages/session/working-directory) | [`working-directory`](../packages/session/working-directory) | [`tool-working-directory`](../packages/session/tool-working-directory), [`tool-fs`](../packages/fs/tool-fs), [`tool-bash`](../packages/shell/tool-bash), [`tool-pwsh`](../packages/shell/tool-pwsh), [`subagent`](../packages/subagent/subagent), [`sdk-jsonrpc-server`](../packages/sdk/server), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`api-workspace-files`](../packages/api/workspace-files), [`api-terminal-controller`](../packages/api/terminal-controller), [`workspace-changes`](../packages/deliverables/workspace-changes), [`file-reference-local`](../packages/context/file-reference-local), [`tool-skill`](../packages/skill/tool-skill), [`agent-instructions`](../packages/context/agent-instructions), [`tool-lsp`](../packages/lsp/tool-lsp) | - | 两个 Session 投影拥有有效执行目录及其所在的工作区根。文件系统验证变更并由用户上下文报告;模型工具跟随当前目录,而沙箱边界、文件视图与发现跟随根,原始元数据保持不变。 |
|
||||
| `ctx.mcpResources` | `seam` | [`mcp-resources`](../packages/mcp/mcp-resources) | [`mcp-client`](../packages/mcp/mcp-client) | [`mcp-resources`](../packages/mcp/mcp-resources) | - | 连接所有者提供的操作在调用 agent 的作用域内服务于共享资源工具。 |
|
||||
| `ctx.browserUse` | `seam` | [`browser-use`](../packages/browser-use/browser-use) | [`experimental-browser-use-playwright-mcp`](../packages/experimental/browser-use-playwright-mcp), [`experimental-browser-use-chrome-devtools-mcp`](../packages/experimental/browser-use-chrome-devtools-mcp), [`experimental-browser-use-stagehand-native`](../packages/experimental/browser-use-stagehand-native) | [`experimental-browser-use-playwright-mcp`](../packages/experimental/browser-use-playwright-mcp), [`experimental-browser-use-chrome-devtools-mcp`](../packages/experimental/browser-use-chrome-devtools-mcp), [`experimental-browser-use-stagehand-native`](../packages/experimental/browser-use-stagehand-native) | - | 每个服务实例注册一个提供方拥有的名称。提供方按实时 Session 拥有自己的工具与浏览器资源;共享服务不提供浏览器操作 API。 |
|
||||
| `ctx.computerUse` | `seam` | [`computer-use`](../packages/computer-use/computer-use) | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp), [`experimental-computer-use-cua-driver-native`](../packages/experimental/computer-use-cua-driver-native) | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp), [`experimental-computer-use-cua-driver-native`](../packages/experimental/computer-use-cua-driver-native) | - | 每个服务实例只注册一个提供方自定的名称。各提供方也拥有自己的模型工具;服务不提供通用操作 API、运行时选择或 Session 流程锁。 |
|
||||
|
||||
@@ -362,7 +362,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-api-workspace-files`
|
||||
|
||||
- `inject`: `fs` · `sandboxPolicy` · `sessions` · `typert`
|
||||
- `source`: [`packages/api/workspace-files/src/index.ts:101`](../packages/api/workspace-files/src/index.ts)
|
||||
- `source`: [`packages/api/workspace-files/src/index.ts:100`](../packages/api/workspace-files/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Deployment caps on one page or one listing. */
|
||||
@@ -2960,7 +2960,7 @@ export interface Config {
|
||||
|
||||
- `inject`: `sessionProjections`
|
||||
- `refs`: [`SandboxMode`](subsystems/sandbox.md)
|
||||
- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:119`](../packages/sandbox/sandbox-policy/src/index.ts)
|
||||
- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:128`](../packages/sandbox/sandbox-policy/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/**
|
||||
@@ -4353,7 +4353,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-tool-skill`
|
||||
|
||||
- `inject`: `agents` · `tools` · `skills` · `workingDirectory`
|
||||
- `source`: [`packages/skill/tool-skill/src/index.ts:64`](../packages/skill/tool-skill/src/index.ts)
|
||||
- `source`: [`packages/skill/tool-skill/src/index.ts:74`](../packages/skill/tool-skill/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Model-facing skill catalog configuration. */
|
||||
|
||||
@@ -364,7 +364,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-api-workspace-files`
|
||||
|
||||
- `inject`: `fs` · `sandboxPolicy` · `sessions` · `typert`
|
||||
- `source`: [`packages/api/workspace-files/src/index.ts:101`](../packages/api/workspace-files/src/index.ts)
|
||||
- `source`: [`packages/api/workspace-files/src/index.ts:100`](../packages/api/workspace-files/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Deployment caps on one page or one listing. */
|
||||
@@ -2962,7 +2962,7 @@ export interface Config {
|
||||
|
||||
- `inject`: `sessionProjections`
|
||||
- `refs`: [`SandboxMode`](subsystems/sandbox.zh.md)
|
||||
- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:119`](../packages/sandbox/sandbox-policy/src/index.ts)
|
||||
- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:128`](../packages/sandbox/sandbox-policy/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/**
|
||||
@@ -4355,7 +4355,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-tool-skill`
|
||||
|
||||
- `inject`: `agents` · `tools` · `skills` · `workingDirectory`
|
||||
- `source`: [`packages/skill/tool-skill/src/index.ts:64`](../packages/skill/tool-skill/src/index.ts)
|
||||
- `source`: [`packages/skill/tool-skill/src/index.ts:74`](../packages/skill/tool-skill/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Model-facing skill catalog configuration. */
|
||||
|
||||
@@ -1233,8 +1233,8 @@
|
||||
en: a7b8c3f842059eec
|
||||
zh: 4b345faa13cc39f6
|
||||
/session-persistence-event-catalog/resolved-persistence-types/skillcatalogsource:
|
||||
en: 2c3148e4a9f0c8f9
|
||||
zh: dab42cb485067bcd
|
||||
en: 960723f932f13bda
|
||||
zh: 853a662a7e2255be
|
||||
/session-persistence-event-catalog/resolved-persistence-types/skillinvocationsource:
|
||||
en: ecc15ebadb77afdf
|
||||
zh: 97ac27d6a4175f6f
|
||||
@@ -1494,8 +1494,8 @@
|
||||
en: 10a2d594b106f6fe
|
||||
zh: 8408379e744ad987
|
||||
/session-persistence-event-catalog/resolved-persistence-types/description-name:
|
||||
en: 26072d80c066a334
|
||||
zh: 48deed5b57fecba4
|
||||
en: 04dfb35081271008
|
||||
zh: a5ad49936214775c
|
||||
/session-persistence-event-catalog/resolved-persistence-types/description-name~2:
|
||||
en: a07969828eed2e6f
|
||||
zh: e06893743af544b5
|
||||
|
||||
@@ -4828,7 +4828,7 @@ Sources: [`packages/experimental/liveshare/src/host/viewer-principal.ts:24`](../
|
||||
|
||||
SHA-256: `65d583e66518c5236015e0846470fb32efcf92375ed306aef14e50a9d2cd2099`
|
||||
|
||||
Sources: [`packages/skill/tool-skill/src/index.ts:35`](../packages/skill/tool-skill/src/index.ts)
|
||||
Sources: [`packages/skill/tool-skill/src/index.ts:45`](../packages/skill/tool-skill/src/index.ts)
|
||||
|
||||
| Property | Presence | Type |
|
||||
|---|---|---|
|
||||
@@ -6236,7 +6236,7 @@ Sources: [`packages/llm/llm-retry/src/types.ts:30`](../packages/llm/llm-retry/sr
|
||||
|
||||
SHA-256: `83079c8a3f733ac3fa603eefa0fbb4737ca4d8b69e7e2e7298b60f9ac4098693`
|
||||
|
||||
Sources: [`packages/skill/tool-skill/src/index.ts:43`](../packages/skill/tool-skill/src/index.ts)
|
||||
Sources: [`packages/skill/tool-skill/src/index.ts:53`](../packages/skill/tool-skill/src/index.ts)
|
||||
|
||||
| Property | Presence | Type |
|
||||
|---|---|---|
|
||||
|
||||
@@ -4830,7 +4830,7 @@ SHA-256: `4d60dddaa65d3da8d4cd014d85ce3d2c2875664dd0433e331d8e9d395289686b`
|
||||
|
||||
SHA-256: `65d583e66518c5236015e0846470fb32efcf92375ed306aef14e50a9d2cd2099`
|
||||
|
||||
来源:[`packages/skill/tool-skill/src/index.ts:35`](../packages/skill/tool-skill/src/index.ts)
|
||||
来源:[`packages/skill/tool-skill/src/index.ts:45`](../packages/skill/tool-skill/src/index.ts)
|
||||
|
||||
| 属性 | 存在性 | 类型 |
|
||||
|---|---|---|
|
||||
@@ -6238,7 +6238,7 @@ SHA-256: `374fdd68aee5ff844e378c0cbdd961d247a0f22e4ade0bb03d800cd2a46a2b8b`
|
||||
|
||||
SHA-256: `83079c8a3f733ac3fa603eefa0fbb4737ca4d8b69e7e2e7298b60f9ac4098693`
|
||||
|
||||
来源:[`packages/skill/tool-skill/src/index.ts:43`](../packages/skill/tool-skill/src/index.ts)
|
||||
来源:[`packages/skill/tool-skill/src/index.ts:53`](../packages/skill/tool-skill/src/index.ts)
|
||||
|
||||
| 属性 | 存在性 | 类型 |
|
||||
|---|---|---|
|
||||
|
||||
Generated
+2
-2
@@ -319,7 +319,7 @@
|
||||
{"digest":"65377a76c6a58f785d95b89f89f2e13d289cb88a70ea74939d0ec08f429f0a6e","names":[],"sources":["packages/core/session/src/types.ts:321"]},
|
||||
{"digest":"6598cd6da253948d6b207c6374a45335804c79b576866d6215649c2d1bc85e25","names":["packages/team/agent-team/src/types.ts#TeamMemberSnapshot"],"sources":["packages/team/agent-team/src/types.ts:50"]},
|
||||
{"digest":"65a8400e451e667e5b6e34df72ceb81fca8c12330330fa72083ad40279b189ad","names":["packages/llm/llm/src/message.ts#SystemPromptMessageSource"],"sources":["packages/llm/llm/src/message.ts:35"]},
|
||||
{"digest":"65d583e66518c5236015e0846470fb32efcf92375ed306aef14e50a9d2cd2099","names":["packages/skill/tool-skill/src/index.ts#SkillCatalogSource"],"sources":["packages/skill/tool-skill/src/index.ts:35"]},
|
||||
{"digest":"65d583e66518c5236015e0846470fb32efcf92375ed306aef14e50a9d2cd2099","names":["packages/skill/tool-skill/src/index.ts#SkillCatalogSource"],"sources":["packages/skill/tool-skill/src/index.ts:45"]},
|
||||
{"digest":"66ba70f6f068da443f969a0b947a013c3addd776b9b60a0a393759c19825e9a2","names":["packages/llm/llm/src/types.ts#ToolSchema"],"sources":["packages/llm/llm/src/types.ts:517"]},
|
||||
{"digest":"672c4aa2a9b736e3d6e5da6346d2e2ed5e3573f2d0baafa18e7407c9f3fee3db","names":["packages/skill/skill/src/index.ts#SkillInvocationSource"],"sources":["packages/skill/skill/src/index.ts:146"]},
|
||||
{"digest":"67d5f73ceae82f5265258142ad6cf172de2c1fef93ba551b7f0454e0a93bffe0","names":["packages/llm/llm/src/call-config.ts#LlmCallConfig"],"sources":["packages/llm/llm/src/call-config.ts:31"]},
|
||||
@@ -389,7 +389,7 @@
|
||||
{"digest":"824a4aad44a54e245c67196817d67946734a2dc0eee0b0b6834a5b2a6ef352ce","names":[],"sources":[]},
|
||||
{"digest":"825ca23416b1ea9d81442afead5cf9229a6fa05842f042135cc3aa9710a6a2d8","names":[],"sources":[]},
|
||||
{"digest":"829a2fb3be6efd4ba36aef8ed2d381a4c6fb2a0aaf50c823a6f3f8290786b809","names":[],"sources":[]},
|
||||
{"digest":"83079c8a3f733ac3fa603eefa0fbb4737ca4d8b69e7e2e7298b60f9ac4098693","names":[],"sources":["packages/skill/tool-skill/src/index.ts:43"]},
|
||||
{"digest":"83079c8a3f733ac3fa603eefa0fbb4737ca4d8b69e7e2e7298b60f9ac4098693","names":[],"sources":["packages/skill/tool-skill/src/index.ts:53"]},
|
||||
{"digest":"8338ee303e2bd448e9e6144069942f63e3cfd5868962bddc9347d7009e8919d6","names":[],"sources":[]},
|
||||
{"digest":"83d6916021eede8f2d83a1872716caa1efdec39a3681890996c55147187fdd12","names":[],"sources":[]},
|
||||
{"digest":"83da72c6857601c75da11212ef847f57d457b9c99f0a82246dcdff3e26700239","names":["packages/context/agent-instructions/src/render.ts#AgentInstructionChange"],"sources":["packages/context/agent-instructions/src/render.ts:62"]},
|
||||
|
||||
@@ -75,6 +75,14 @@ get(session: Session): string
|
||||
*/
|
||||
rootOf(session: Session): string
|
||||
|
||||
/**
|
||||
* Read the recorded workspace root without the deployment fallback and without filesystem I/O.
|
||||
* @param session - Session whose root is requested.
|
||||
* @returns the longest registered anchor containing the current directory, or undefined while the
|
||||
* log registers no anchor; consumers apply their own fallback.
|
||||
*/
|
||||
recordedRootOf(session: Session): string | undefined
|
||||
|
||||
/**
|
||||
* Read the registered workspace anchors without filesystem I/O.
|
||||
* @param session - Session whose anchors are requested.
|
||||
|
||||
@@ -75,6 +75,14 @@ get(session: Session): string
|
||||
*/
|
||||
rootOf(session: Session): string
|
||||
|
||||
/**
|
||||
* Read the recorded workspace root without the deployment fallback and without filesystem I/O.
|
||||
* @param session - Session whose root is requested.
|
||||
* @returns the longest registered anchor containing the current directory, or undefined while the
|
||||
* log registers no anchor; consumers apply their own fallback.
|
||||
*/
|
||||
recordedRootOf(session: Session): string | undefined
|
||||
|
||||
/**
|
||||
* Read the registered workspace anchors without filesystem I/O.
|
||||
* @param session - Session whose anchors are requested.
|
||||
|
||||
@@ -312,7 +312,9 @@ export class TerminalController extends TypertRemoteService {
|
||||
|
||||
private async spawn(agent: Agent, owner: OwnedSession, request: TerminalCreateRequest, signal: AbortSignal): Promise<BrowserTerminal> {
|
||||
const { subprocess, workingDirectory } = this.execution(agent)
|
||||
// A user terminal starts in the checkout the Session works in, not at the model's cursor.
|
||||
// A user terminal starts in the checkout the Session works in, not at the model's cursor. The root is
|
||||
// read after validation, not from ensure's return value: a directory change landing in between is the
|
||||
// Session's later state, and the process keeps whichever root it was spawned in.
|
||||
await workingDirectory.ensure(agent, signal)
|
||||
const cwd = workingDirectory.rootOf(agent.session)
|
||||
const shell = request.shellPath === undefined
|
||||
|
||||
@@ -80,8 +80,7 @@ async function workspaceFileScopeOf(
|
||||
): Promise<WorkspaceFileScope | undefined> {
|
||||
const live = ctx.get('sessions')?.get(sessionId)
|
||||
if (live !== undefined) {
|
||||
const directories = ctx.get('workingDirectory')
|
||||
const root = directories !== undefined && directories.anchorsOf(live).length > 0 ? directories.rootOf(live) : live.header.cwd
|
||||
const root = ctx.get('workingDirectory')?.recordedRootOf(live) ?? live.header.cwd
|
||||
return { sessionId, workspaceRoot: root ?? ctx.sandboxPolicy.workspaceRoot }
|
||||
}
|
||||
const stored = await ctx.get('sessionPersistence')?.stat(sessionId, signal === undefined ? undefined : { signal })
|
||||
|
||||
@@ -44,10 +44,7 @@ describe('Workspace Files Session scope lookup', () => {
|
||||
ctx.provide('sandboxPolicy', { workspaceRoot: resolve('fallback-workspace') } as never)
|
||||
ctx.provide('sessionPersistence', { stat } as never)
|
||||
ctx.provide('sessionProjectionCache', { cachedSnapshot } as never)
|
||||
ctx.provide('workingDirectory', {
|
||||
anchorsOf: () => [liveRoot, liveWorktree],
|
||||
rootOf: () => liveWorktree,
|
||||
} as never)
|
||||
ctx.provide('workingDirectory', { recordedRootOf: () => liveWorktree } as never)
|
||||
const sessions = await ctx.plugin(SessionStore)
|
||||
const typert = await ctx.plugin(TypertRegistry)
|
||||
const workspaceFiles = await ctx.plugin(WorkspaceFiles, CAPS)
|
||||
|
||||
@@ -6,12 +6,6 @@
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.client.json"
|
||||
},
|
||||
{
|
||||
"path": "../../session/session-projection-cache"
|
||||
},
|
||||
{
|
||||
"path": "../../session/working-directory"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -15,8 +15,8 @@
|
||||
en: d152484eb41ac6b4
|
||||
zh: 09388d293f9be9cb
|
||||
/deepseek-ai-dsh-workspace-changes/use-this-package:
|
||||
en: 0d13b6aa2a5f604e
|
||||
zh: 18349da659029d2c
|
||||
en: 8e7b9071ced0f59b
|
||||
zh: e0244b4975fda0fc
|
||||
/deepseek-ai-dsh-workspace-changes/understand-the-implementation:
|
||||
en: 9bfc66bea548bda2
|
||||
zh: 7023c42cdb44569b
|
||||
|
||||
@@ -43,7 +43,7 @@ The shipped Web bundle mounts this plugin. Mount it in any composition with the
|
||||
|
||||
This plugin requires the `subprocess` and `fs` services. Every Session with a working directory and no subagent origin is recorded; subagent Sessions are not. Snapshots are written through a private index into a temporary object directory owned by the Session, with the repository's own object store attached as a read-only alternate; the repository's index, objects, work tree, and refs stay untouched, and the user's earlier uncommitted changes never enter a summary. Session disposal removes the directory. Nested repositories and submodules inside the working directory are recorded as gitlinks, so their internal changes do not appear. A working directory outside any git repository takes no snapshots. Without git — or, on macOS, with only the developer-tools stub at `/usr/bin/git` — no repository is located either, and the plugin logs that once. Either way the summary lists the file-tool edits alone, as described next, with the working directory as the workspace; shell edits are absent.
|
||||
|
||||
After a `write`, `edit`, or mutating `str_replace_editor` call resolves its target and obtains its mutation guard, the recorder copies that exact file before the mutation into the Session's temporary directory, once per path per turn, and copies it again at turn end; the copies are named by the SHA-1 of their bytes, so identical content is stored once. This needs no git. Repository discovery and display paths retain the original project; file captures follow the operation's resolved target even after the Session changes directories. Paths the snapshots cover keep their git counts; the copies serve the other paths — files matching an ignore pattern, files outside the repository, and every file-tool edit when there is no snapshot — with counts from a line comparison of the two copies, so repeated edits to one file count once and a shell edit after a file-tool edit is included. A path whose content is unchanged at turn end is not listed. A copy larger than `maxFileBytes` is not stored: the file is listed with `oversized` and no counts, and a path whose both sides are that large is listed too, since unread content is never known to be unchanged. A path whose only difference is a missing final newline compares as unchanged, while git still counts that line. Files under `/tmp` or the platform temporary directory are excluded unless they lie inside the repository. Changes made only through shell commands outside the snapshot coverage are not recorded.
|
||||
After a `write`, `edit`, or mutating `str_replace_editor` call resolves its target and obtains its mutation guard, the recorder copies that exact file before the mutation into the Session's temporary directory, once per path per turn, and copies it again at turn end; the copies are named by the SHA-1 of their bytes, so identical content is stored once. This needs no git. Repository discovery follows the current directory the turn started in and display paths the workspace root it started in; file captures follow the operation's resolved target even after the Session changes directories. Paths the snapshots cover keep their git counts; the copies serve the other paths — files matching an ignore pattern, files outside the repository, and every file-tool edit when there is no snapshot — with counts from a line comparison of the two copies, so repeated edits to one file count once and a shell edit after a file-tool edit is included. A path whose content is unchanged at turn end is not listed. A copy larger than `maxFileBytes` is not stored: the file is listed with `oversized` and no counts, and a path whose both sides are that large is listed too, since unread content is never known to be unchanged. A path whose only difference is a missing final newline compares as unchanged, while git still counts that line. Files under `/tmp` or the platform temporary directory are excluded unless they lie inside the repository. Changes made only through shell commands outside the snapshot coverage are not recorded.
|
||||
|
||||
Each turn reads the Session's current directory and workspace root when it starts, so a Session that entered a worktree is snapshotted in that checkout and lists paths relative to that root. Each file carries a durable `path` — relative to the workspace root inside it, absolute elsewhere — and a `display` path used for ordering and labels: the relative path, a `../` path for repository files above the workspace root, a `~` path under the home directory, otherwise the absolute path. Files sort by `display` in code-unit order, which lists parent and absolute paths before the workspace root's own files. The `workspace/changes` event carries only the turn number; `ctx.workspaceChanges.summary(sessionId, seq)` returns the summary the event with that sequence announced, or undefined once the Session is disposed or when this Host process never recorded it. `ctx.workspaceChanges.diff(sessionId, seq, index, signal)` compares the listed file at that index: hunks with three context lines from the two snapshot trees or the two copies, `binary` for a side git reported as binary or that holds a NUL byte, `oversized` for a side larger than `maxFileBytes`. A line comparison that runs longer than `diffTimeoutMs` degrades to one hunk replacing every line, marked `coarse`. A conversation reopened after a Host restart therefore has no card, and no comparison, for its earlier turns.
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ kind: "package-reference"
|
||||
|
||||
本插件需要 `subprocess` 与 `fs` 服务。有工作目录且不是子代理来源的 Session 都会被记录;子代理 Session 不记录。快照通过私有 index 写入 Session 自己拥有的临时对象目录,仓库自己的对象库以只读 alternate 的方式挂接;仓库的 index、对象、工作树和 ref 保持不变,用户此前未提交的改动也不会进入摘要。Session 释放时删除该目录。工作目录内的嵌套仓库和 submodule 记录为 gitlink,其内部改动不会出现。不在任何 git 仓库内的工作目录不做快照。没有 git 时——或者 macOS 上只有 `/usr/bin/git` 的开发者工具桩程序时——同样定位不到仓库,插件记录一次日志。两种情况下摘要都只列下文所述的文件工具编辑,并以工作目录作为工作区;shell 的改动不会出现。
|
||||
|
||||
在 `write`、`edit`、`apply_patch` 或有修改作用的 `str_replace_editor` 调用解析目标并取得修改防护之后,记录器在实际修改前把该文件复制到 Session 的临时目录,每轮每个路径只复制第一次,轮次结束时再复制一次;副本按其字节的 SHA-1 命名,相同内容只存一份。这一步不需要 git。仓库定位与显示路径保留原始项目;即使 Session 切换目录,文件捕获仍跟随该操作已解析的目标。快照覆盖到的路径保留 git 的行数;其余路径由副本提供,也就是匹配忽略模式的文件、仓库之外的文件,以及没有快照时的每一次文件工具编辑,行数来自两份副本的逐行对比,因此同一文件的重复编辑只计一次,文件工具编辑之后的 shell 改动也包含在内。轮次结束时内容没有变化的路径不会列出。超过 `maxFileBytes` 的副本不会保存:该文件列出时带 `oversized`,没有行数;两侧都这么大的路径同样列出,因为没读过的内容永远不能认定为没有改动。只差一个末尾换行的路径对比为两侧相同,而 git 仍会把那一行计入行数。`/tmp` 与平台临时目录下的文件被排除,除非它们位于仓库内。快照覆盖范围之外只通过 shell 命令做出的改动不会被记录。
|
||||
在 `write`、`edit`、`apply_patch` 或有修改作用的 `str_replace_editor` 调用解析目标并取得修改防护之后,记录器在实际修改前把该文件复制到 Session 的临时目录,每轮每个路径只复制第一次,轮次结束时再复制一次;副本按其字节的 SHA-1 命名,相同内容只存一份。这一步不需要 git。仓库按该轮开始时的当前目录定位,显示路径以该轮开始时的工作区根为基准;即使 Session 切换目录,文件捕获仍跟随该操作已解析的目标。快照覆盖到的路径保留 git 的行数;其余路径由副本提供,也就是匹配忽略模式的文件、仓库之外的文件,以及没有快照时的每一次文件工具编辑,行数来自两份副本的逐行对比,因此同一文件的重复编辑只计一次,文件工具编辑之后的 shell 改动也包含在内。轮次结束时内容没有变化的路径不会列出。超过 `maxFileBytes` 的副本不会保存:该文件列出时带 `oversized`,没有行数;两侧都这么大的路径同样列出,因为没读过的内容永远不能认定为没有改动。只差一个末尾换行的路径对比为两侧相同,而 git 仍会把那一行计入行数。`/tmp` 与平台临时目录下的文件被排除,除非它们位于仓库内。快照覆盖范围之外只通过 shell 命令做出的改动不会被记录。
|
||||
|
||||
每个 turn 开始时读取 Session 的当前目录和工作区根,因此进入 worktree 的 Session 在该检出目录中拍快照,并以该根为基准列出相对路径。每个文件携带持久的 `path`——位于工作区根内时为相对路径,否则为绝对路径——以及用于排序和标签的 `display` 路径:相对路径,仓库内位于工作区根之上的文件为 `../` 路径,家目录下的文件为 `~` 路径,其余为绝对路径。文件按 `display` 的码元顺序排序,因此上级路径和绝对路径排在工作区根自身文件之前。`workspace/changes` 事件只携带轮号;`ctx.workspaceChanges.summary(sessionId, seq)` 返回该序号的事件宣告的摘要,Session 已释放或本 Host 进程从未记录时返回 undefined。`ctx.workspaceChanges.diff(sessionId, seq, index, signal)` 对比该下标所列的文件:从两棵快照树或两份副本得出带三行上下文的 hunk;git 报告为二进制或某一侧含 NUL 字节时返回 `binary`;某一侧超过 `maxFileBytes` 时返回 `oversized`。逐行对比运行超过 `diffTimeoutMs` 时退化为一个替换全部行的 hunk,并标记 `coarse`。因此 Host 重启后重新打开的对话,先前轮次既没有卡片也没有对比。
|
||||
|
||||
|
||||
@@ -4459,6 +4459,12 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [
|
||||
parameters: [{ name: 'session', description: 'Session whose root is requested.' }],
|
||||
returns: 'the registered anchor containing the current directory, or the deployment default when none is recorded.',
|
||||
},
|
||||
{
|
||||
signature: 'recordedRootOf(session: Session): string | undefined',
|
||||
description: 'Read the recorded workspace root without the deployment fallback and without filesystem I/O.',
|
||||
parameters: [{ name: 'session', description: 'Session whose root is requested.' }],
|
||||
returns: 'the longest registered anchor containing the current directory, or undefined while the log registers no anchor; consumers apply their own fallback.',
|
||||
},
|
||||
{
|
||||
signature: 'anchorsOf(session: Session): readonly string[]',
|
||||
description: 'Read the registered workspace anchors without filesystem I/O.',
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
} from '@deepseek-ai/node-addon-system/landlock-run'
|
||||
import { Context } from '@deepseek-ai/cordis'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import { SandboxProvider, SandboxUnavailableError, canonicalPath, workspaceWritableRoots } from '@deepseek-ai/dsh-sandbox'
|
||||
import { SandboxProvider, SandboxUnavailableError, additionalWritableRoots, canonicalPath } from '@deepseek-ai/dsh-sandbox'
|
||||
import type { ConfinedArgv, ConfinedSandboxMode, RunnerFailureRule, SandboxEnforcement, SandboxPolicy } from '@deepseek-ai/dsh-sandbox'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session'
|
||||
import { AclWriteGrant, assertTempRootOutsideWorkspace, registerAclDiagnosisSkill, tempWriteSid, workspaceWriteSid } from '@deepseek-ai/dsh-sandbox-windows-acl'
|
||||
@@ -371,8 +371,8 @@ export class LocalSandboxProvider extends SandboxProvider {
|
||||
* @returns the runner invocation.
|
||||
*/
|
||||
private windowsAclRunnerArgv(policy: SandboxPolicy): string[] {
|
||||
// Canonical, validated extra roots; the workspace root itself leads that list.
|
||||
const extras = policy.mode === 'workspace-write' ? workspaceWritableRoots(policy).slice(1) : []
|
||||
// Canonical, validated extra roots beside the workspace root.
|
||||
const extras = additionalWritableRoots(policy)
|
||||
const writable = extras.flatMap(directory => ['--writable', directory])
|
||||
const sessionId = policy.sessionId
|
||||
if (sessionId === undefined || policy.mode === 'read-only') {
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
"@deepseek-ai/dsh-session": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-projection": "workspace:*",
|
||||
"@deepseek-ai/dsh-system-prompt": "workspace:*",
|
||||
"@deepseek-ai/dsh-tools": "workspace:*",
|
||||
"@deepseek-ai/dsh-working-directory": "workspace:*"
|
||||
"@deepseek-ai/dsh-tools": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@deepseek-ai/schemastery": "workspace:~",
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @module @deepseek-ai/dsh-sandbox-policy
|
||||
*/
|
||||
|
||||
import { isAbsolute } from 'node:path'
|
||||
import { isAbsolute, relative, sep } from 'node:path'
|
||||
import { Context, Service } from '@deepseek-ai/cordis'
|
||||
import { z as zod } from 'zod'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
@@ -34,7 +34,7 @@ import type { Session } from '@deepseek-ai/dsh-session'
|
||||
import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection'
|
||||
import type {} from '@deepseek-ai/dsh-system-prompt'
|
||||
import type {} from '@deepseek-ai/dsh-tools'
|
||||
import { within } from '@deepseek-ai/dsh-working-directory'
|
||||
import type {} from '@deepseek-ai/dsh-working-directory'
|
||||
|
||||
export { SANDBOX_MODES, setSandboxMode } from './session-mode.ts'
|
||||
|
||||
@@ -83,6 +83,15 @@ function renderPolicyContext(policy: SandboxExecutionPolicy): string {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether `path` is `root` or lies below it. Both are canonical absolute paths of one execution
|
||||
* world; the test is lexical and never touches the filesystem.
|
||||
*/
|
||||
function within(root: string, path: string): boolean {
|
||||
const rest = relative(root, path)
|
||||
return rest === '' || (rest !== '..' && !rest.startsWith(`..${sep}`) && !isAbsolute(rest))
|
||||
}
|
||||
|
||||
/** The `gitdir:` pointer line of a linked checkout's `.git` file. */
|
||||
const GITDIR_POINTER = /^gitdir:[ \t]*(.+?)[ \t\r]*$/m
|
||||
|
||||
@@ -324,9 +333,10 @@ export class SandboxPolicyService extends Service {
|
||||
}
|
||||
}
|
||||
signal.throwIfAborted()
|
||||
const derived = Object.freeze(outside.filter((directory, index) => !within(root, directory)
|
||||
&& !outside.some((other, otherIndex) => otherIndex !== index && other !== directory && within(other, directory))
|
||||
&& outside.indexOf(directory) === index))
|
||||
// Distinct directories outside the root, keeping only those no other candidate already contains.
|
||||
const candidates = [...new Set(outside)].filter(directory => !within(root, directory))
|
||||
const derived = Object.freeze(candidates.filter(directory =>
|
||||
!candidates.some(other => other !== directory && within(other, directory))))
|
||||
this.gitAdministration.set(root, derived)
|
||||
return derived
|
||||
} catch (error) {
|
||||
@@ -337,14 +347,12 @@ export class SandboxPolicyService extends Service {
|
||||
}
|
||||
|
||||
/**
|
||||
* The session's workspace root: the working-directory root when one is recorded, else the header directory,
|
||||
* The session's workspace root: the root the working-directory service recorded, else the header directory,
|
||||
* else the deployment fallback.
|
||||
*/
|
||||
private rootOf(session: Session | undefined): string {
|
||||
if (session === undefined) return this.workspaceRoot
|
||||
const directories = this.ctx.get('workingDirectory')
|
||||
if (directories !== undefined && directories.anchorsOf(session).length > 0) return directories.rootOf(session)
|
||||
return session.header.cwd ?? this.workspaceRoot
|
||||
return this.ctx.get('workingDirectory')?.recordedRootOf(session) ?? session.header.cwd ?? this.workspaceRoot
|
||||
}
|
||||
|
||||
private additionalRootsWith(derived: readonly string[] | undefined): readonly string[] | undefined {
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
en: 1b418d41f571ab3d
|
||||
zh: 62b289cdd6f4d272
|
||||
/deepseek-ai-dsh-sandbox/understand-the-implementation/writable-roots:
|
||||
en: 00dcc13597416429
|
||||
zh: eaff9233d0611ad0
|
||||
en: 6f96a2279c524831
|
||||
zh: b85ca02a4c9a7491
|
||||
/deepseek-ai-dsh-sandbox/further-exploration:
|
||||
en: 33d09277fb15d59f
|
||||
zh: 920ffe66671b56f3
|
||||
|
||||
@@ -100,7 +100,7 @@ The ladder is a closed table — `read-only` may escalate to `workspace-write` o
|
||||
|
||||
### Writable roots
|
||||
|
||||
`workspaceWritableRoots` derives the workspace and explicit extra directories for bwrap and Landlock. `writableRoots` adds the host temporary areas for Seatbelt and the in-process filesystem fence. Both deduplicate roots and reject extra paths that are missing, are not directories, or resolve through symlinks. See the [mode definitions](../../../docs/subsystems/sandbox.md).
|
||||
`workspaceWritableRoots` derives the workspace and explicit extra directories for bwrap and Landlock; `additionalWritableRoots` yields only the extra directories, for a backend that grants them separately from the root. `writableRoots` adds the host temporary areas for Seatbelt and the in-process filesystem fence. Both deduplicate roots and reject extra paths that are missing, are not directories, or resolve through symlinks. See the [mode definitions](../../../docs/subsystems/sandbox.md).
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ kind: "package-reference"
|
||||
|
||||
### 可写根目录
|
||||
|
||||
`workspaceWritableRoots` 为 bwrap 和 Landlock 推导工作区与显式额外目录。`writableRoots` 为 Seatbelt 和进程内文件系统围栏加入主机临时区域。两者都对根目录去重,并拒绝不存在、不是目录或经过符号链接解析的额外路径。参见[模式定义](../../../docs/subsystems/sandbox.zh.md)。
|
||||
`workspaceWritableRoots` 为 bwrap 和 Landlock 推导工作区与显式额外目录;`additionalWritableRoots` 只给出额外目录,供单独授权它们的后端使用。`writableRoots` 为 Seatbelt 和进程内文件系统围栏加入主机临时区域。两者都对根目录去重,并拒绝不存在、不是目录或经过符号链接解析的额外路径。参见[模式定义](../../../docs/subsystems/sandbox.zh.md)。
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export {
|
||||
validateEscalationArgs,
|
||||
} from './escalation.ts'
|
||||
export type { EscalationApproval, EscalationApprover, EscalationOutcome, EscalationRequest } from './escalation.ts'
|
||||
export { canonicalPath, workspaceWritableRoots, writableRoots, SandboxInvalidRootError } from './roots.ts'
|
||||
export { additionalWritableRoots, canonicalPath, workspaceWritableRoots, writableRoots, SandboxInvalidRootError } from './roots.ts'
|
||||
|
||||
/**
|
||||
* File-effect policy for confined processes. `read-only` permits only required
|
||||
|
||||
@@ -84,6 +84,19 @@ export function workspaceWritableRoots(policy: SandboxExecutionPolicy): string[]
|
||||
return [...new Set([canonicalPath(policy.workspaceRoot), ...(policy.additionalWritableRoots ?? []).map(additionalRoot)])]
|
||||
}
|
||||
|
||||
/**
|
||||
* The explicit extra writable roots of a policy as canonical, validated, deduplicated paths with the
|
||||
* workspace root itself removed: the directories an enforcement layer grants beside the root.
|
||||
* @param policy - the file-effect policy to derive the extras from.
|
||||
* @returns the canonical extra roots; empty under `read-only` or without extras.
|
||||
* @throws {SandboxInvalidRootError} An extra root is missing, is not a directory, or uses a symlink.
|
||||
*/
|
||||
export function additionalWritableRoots(policy: SandboxExecutionPolicy): string[] {
|
||||
if (policy.mode !== 'workspace-write') return []
|
||||
const root = canonicalPath(policy.workspaceRoot)
|
||||
return [...new Set((policy.additionalWritableRoots ?? []).map(additionalRoot))].filter(directory => directory !== root)
|
||||
}
|
||||
|
||||
/**
|
||||
* The roots one confined execution may WRITE under — the mode's meaning as a
|
||||
* canonical, deduplicated allow-list. `read-only` allows nothing;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'n
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { canonicalPath, workspaceWritableRoots, writableRoots } from '@deepseek-ai/dsh-sandbox'
|
||||
import { additionalWritableRoots, canonicalPath, workspaceWritableRoots, writableRoots } from '@deepseek-ai/dsh-sandbox'
|
||||
|
||||
/** Every temp root created by this file, removed after each test. */
|
||||
const roots: string[] = []
|
||||
@@ -29,6 +29,18 @@ describe('canonicalPath', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('additionalWritableRoots', () => {
|
||||
it('lists the canonical extra roots beside the workspace, deduplicated and without the workspace itself', () => {
|
||||
const ws = mkdtempSync(join(tmpdir(), 'dsh-ws-'))
|
||||
const extra = realpathSync.native(mkdtempSync(join(tmpdir(), 'dsh-extra-')))
|
||||
roots.push(ws, extra)
|
||||
expect(additionalWritableRoots({ mode: 'workspace-write', workspaceRoot: ws })).toEqual([])
|
||||
expect(additionalWritableRoots({ mode: 'workspace-write', workspaceRoot: ws, additionalWritableRoots: [extra, extra, realpathSync.native(ws)] }))
|
||||
.toEqual([extra])
|
||||
expect(additionalWritableRoots({ mode: 'read-only', workspaceRoot: ws, additionalWritableRoots: [extra] })).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('workspaceWritableRoots', () => {
|
||||
it('workspace-write grants only the workspace when no extra root is configured', () => {
|
||||
const ws = mkdtempSync(join(tmpdir(), 'dsh-ws-'))
|
||||
|
||||
@@ -213,6 +213,16 @@ export class WorkingDirectoryService extends Service {
|
||||
return this.workspaceRootProjectionHandle.stateOf(session).root ?? this.defaultDirectory
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the recorded workspace root without the deployment fallback and without filesystem I/O.
|
||||
* @param session - Session whose root is requested.
|
||||
* @returns the longest registered anchor containing the current directory, or undefined while the
|
||||
* log registers no anchor; consumers apply their own fallback.
|
||||
*/
|
||||
recordedRootOf(session: Session): string | undefined {
|
||||
return this.workspaceRootProjectionHandle.stateOf(session).root ?? undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the registered workspace anchors without filesystem I/O.
|
||||
* @param session - Session whose anchors are requested.
|
||||
|
||||
@@ -46,6 +46,7 @@ describe('Session workspace roots', () => {
|
||||
it('starts with the original project as the only anchor and root', async () => {
|
||||
await using f = await fixture()
|
||||
expect(f.ctx.workingDirectory.rootOf(f.agent.session)).toBe(f.root)
|
||||
expect(f.ctx.workingDirectory.recordedRootOf(f.agent.session)).toBe(f.root)
|
||||
expect(f.ctx.workingDirectory.anchorsOf(f.agent.session)).toEqual([f.root])
|
||||
expect(f.ctx.sessionProjections.snapshot(f.agent.session).values.workspaceRoot).toBe(f.root)
|
||||
expect(await f.context()).toContain(`Current working directory: ${JSON.stringify(f.root)}.`)
|
||||
@@ -184,12 +185,14 @@ describe('Session workspace roots', () => {
|
||||
await using f = await fixture()
|
||||
const agent = await f.harness.create(SessionId('without-origin'))
|
||||
expect(f.ctx.workingDirectory.rootOf(agent.session)).toBe(f.ctx.workingDirectory.defaultDirectory)
|
||||
expect(f.ctx.workingDirectory.recordedRootOf(agent.session)).toBeUndefined()
|
||||
expect(f.ctx.workingDirectory.anchorsOf(agent.session)).toEqual([])
|
||||
expect(f.ctx.sessionProjections.snapshot(agent.session).values.workspaceRoot).toBeNull()
|
||||
// Relocation registers the deployment fallback first, so leaving the checkout later selects it.
|
||||
const fallback = await realpath(f.ctx.workingDirectory.defaultDirectory)
|
||||
await f.ctx.workingDirectory.relocate(agent, f.worktree)
|
||||
expect(f.ctx.workingDirectory.rootOf(agent.session)).toBe(f.worktree)
|
||||
expect(f.ctx.workingDirectory.recordedRootOf(agent.session)).toBe(f.worktree)
|
||||
expect(f.ctx.workingDirectory.anchorsOf(agent.session)).toEqual([fallback, f.worktree])
|
||||
})
|
||||
|
||||
|
||||
@@ -22,6 +22,16 @@ import {
|
||||
type SkillSummary,
|
||||
} from '@deepseek-ai/dsh-skill'
|
||||
|
||||
|
||||
/**
|
||||
* The workspace root after the directory service validated the Session's current directory, so a
|
||||
* vanished checkout is recovered before skills are looked up, as the other root consumers do.
|
||||
*/
|
||||
async function validatedRoot(ctx: Context, agent: Agent, signal?: AbortSignal): Promise<string> {
|
||||
await ctx.workingDirectory.ensure(agent, signal)
|
||||
return ctx.workingDirectory.rootOf(agent.session)
|
||||
}
|
||||
|
||||
export const name = 'tool-skill'
|
||||
export const inject = ['agents', 'tools', 'skills', 'workingDirectory']
|
||||
|
||||
@@ -133,7 +143,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
||||
}
|
||||
// The agent is its own scope key, so the lookup resolves the layered
|
||||
// registry exactly as this agent's composition sees it.
|
||||
const cwd = exec.agent === undefined ? undefined : ctx.workingDirectory.rootOf(exec.agent.session)
|
||||
const cwd = exec.agent === undefined ? undefined : await validatedRoot(ctx, exec.agent, exec.signal)
|
||||
const lookup = { cwd, signal: exec.signal, scope: exec.agent }
|
||||
const summary = (await ctx.skills.list(lookup)).find(skill => skill.name === args.name)
|
||||
if (!summary) {
|
||||
@@ -187,7 +197,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
||||
const names = invokedSkillNames(messages)
|
||||
if (names.length === 0) return decision
|
||||
signal.throwIfAborted()
|
||||
const lookup = { cwd: ctx.workingDirectory.rootOf(agent.session), signal, scope: agent }
|
||||
const lookup = { cwd: await validatedRoot(ctx, agent, signal), signal, scope: agent }
|
||||
const injections: UserMessage[] = []
|
||||
for (const name of names) {
|
||||
const skill = await ctx.skills.get(name, lookup)
|
||||
@@ -223,7 +233,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
||||
signal.throwIfAborted()
|
||||
const toolVisible = ctx.tools.get(skillTool.name, agent) === skillTool
|
||||
const snapshot = toolVisible
|
||||
? await ctx.skills.snapshot({ cwd: ctx.workingDirectory.rootOf(agent.session), signal, scope: agent })
|
||||
? await ctx.skills.snapshot({ cwd: await validatedRoot(ctx, agent, signal), signal, scope: agent })
|
||||
: { skills: [], complete: true }
|
||||
signal.throwIfAborted()
|
||||
const skills = snapshot.skills.filter(isModelInvocable)
|
||||
|
||||
@@ -24,6 +24,10 @@ class FixtureWorkingDirectory extends Service {
|
||||
?? session?.header.cwd ?? process.cwd()
|
||||
}
|
||||
|
||||
recordedRootOf(session: Session): string | undefined {
|
||||
return this.anchors.get(session) === undefined ? session?.header.cwd : this.rootOf(session)
|
||||
}
|
||||
|
||||
anchorsOf(session: Session): readonly string[] {
|
||||
return this.anchors.get(session) ?? [session?.header.cwd ?? process.cwd()]
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ export function provideWorkingDirectoryFixture(ctx: Context, defaultDirectory =
|
||||
defaultDirectory,
|
||||
get,
|
||||
rootOf: get,
|
||||
recordedRootOf: (session: Session): string | undefined => session.header.cwd,
|
||||
anchorsOf: (session: Session): readonly string[] => session.header.cwd === undefined ? [] : [get(session)],
|
||||
ensure: (agent: Agent): Promise<string> => Promise.resolve(get(agent.session)),
|
||||
})
|
||||
|
||||
@@ -233,7 +233,7 @@ const SERVICE_ROLES: ServiceRole[] = [
|
||||
title: 'Session working directory',
|
||||
mode: 'seam',
|
||||
implementations: ['working-directory'],
|
||||
consumers: ['tool-working-directory', 'tool-fs', 'tool-bash', 'tool-pwsh', 'subagent', 'sdk-jsonrpc-server', 'sandbox-policy', 'workspace-files', 'terminal-controller', 'workspace-changes', 'file-reference-local', 'tool-skill', 'agent-instructions', 'tool-lsp'],
|
||||
consumers: ['tool-working-directory', 'tool-fs', 'tool-bash', 'tool-pwsh', 'subagent', 'sdk-jsonrpc-server', 'sandbox-policy', 'api-workspace-files', 'api-terminal-controller', 'workspace-changes', 'file-reference-local', 'tool-skill', 'agent-instructions', 'tool-lsp'],
|
||||
note: 'Two Session projections own the effective execution directory and the workspace root it is in. The filesystem validates changes and user context reports them; model tools follow the directory while the sandbox boundary, file views, and discovery follow the root, and original metadata stays fixed.',
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user