Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers

Adapt the consumers to the Host-only workspace model of the base branch:

- sandbox-policy: a marked working-directory change, not an anchor, is the
  point that reads the entered root's Git layout again.
- working-directory: keep recordedRootOf on the reworked service and its
  test doubles.
- Tests that entered a checkout through relocate use set; tests that relied
  on a directory change inside the root append a change without the marker.
- SDK documents and the upgrade guide state that the workspace-write boundary
  follows setWorkingDirectory and a Host-chosen child start directory, and
  that exit_worktree leaves a worktree.
This commit is contained in:
LegGasai committed 2026-11-11 22:08:19 +08:00
commit 434ef15931
325 files changed
+1121 -4431

No files matched your search

-1
View File
@@ -146,7 +146,6 @@
"@deepseek-ai/dsh-tool-todo": "workspace:*",
"@deepseek-ai/dsh-tool-web": "workspace:*",
"@deepseek-ai/dsh-tool-workflow": "workspace:*",
"@deepseek-ai/dsh-tool-working-directory": "workspace:*",
"@deepseek-ai/dsh-tool-workspace-dependencies": "workspace:*",
"@deepseek-ai/dsh-tools": "workspace:*",
"@deepseek-ai/dsh-typert-protocol": "workspace:*",
+4 -4
View File
@@ -18,11 +18,11 @@
en: 1d18c09832dd4a42
zh: 6e7260b650a1f987
/deepseek-harness-python-sdk/customize-plugins:
en: 0cfa22d329a704db
zh: ff04b5e01e2c5936
en: 5d91d1905add265f
zh: ecec2471aba1d2ad
/deepseek-harness-python-sdk/native-user-questions:
en: 979ad00fe498b2be
zh: 4b656bd268292a13
/deepseek-harness-python-sdk/results-and-notifications:
en: 5ffe82e8d28abdbf
zh: 94de9eeee9acb32f
en: 26dcdc193e82adb5
zh: 5d4075ff9859b0ce
+2 -2
View File
@@ -129,7 +129,7 @@ with DeepSeekHarness(
`provider` selects a provider route registered by the chosen Cordis composition; `model` is the model id resolved by that adapter. `reasoning_effort` is an optional non-empty adapter-owned identifier for that exact route; omission preserves the model's own default. `max_tokens` is an optional positive per-request output-token cap for the root agent and its in-process descendants; omission leaves the provider default in control. Initialization rejects a missing adapter, unavailable model, or unsupported effort before a prompt runs. Compaction summaries keep the separate limit configured by their compaction plugin. The bundled default composition registers `deepseek-official`. A custom composition can mount `llm-pi-ai`, configure provider-specific credentials/endpoints there, and select any provider/model present in pi-ai's installed catalog.
The shipped `sdk-minimal` profile is a standalone explicit tree rather than an overlay on `dsh-base`. Select it with `profile="sdk-minimal"`; the ordinary `model` argument is the sole runtime model selection, including for model ids outside the adapter's advisory catalog. It provides a platform-selected persistent shell, `read_image`, `working_directory`, local execution, JSONL sessions, and automatic compaction. Text file tools, settings, managed credentials, telemetry, Web tools, and the full default tool roster remain available through the separate full `sdk` and `web` profiles. The `sdk-minimal` profile leaves unsupported slash input on the ordinary prompt path.
The shipped `sdk-minimal` profile is a standalone explicit tree rather than an overlay on `dsh-base`. Select it with `profile="sdk-minimal"`; the ordinary `model` argument is the sole runtime model selection, including for model ids outside the adapter's advisory catalog. It provides a platform-selected persistent shell, `read_image`, local execution, JSONL sessions, and automatic compaction. Text file tools, settings, managed credentials, telemetry, Web tools, and the full default tool roster remain available through the separate full `sdk` and `web` profiles. The `sdk-minimal` profile leaves unsupported slash input on the ordinary prompt path.
## Native user questions
@@ -149,4 +149,4 @@ The selected home stores profiles, plugins, and every profile-owned durable reso
See the [Python tutorial](../../docs/user/guide/python-sdk.md), [runnable example](examples/README.md), and [runtime wheel reference](../sdk-runtime/README.md).
`Session.get_working_directory()` reads the effective working directory; `get_workspace_root()` reads the workspace root that directory is in; `set_working_directory(path)` changes the directory and returns the validated absolute path. Each creates an unknown Session without running a model turn. Relative paths use that Session's current directory. Origin metadata, permissions, and existing processes remain unchanged. The low-level client provides the same methods with a leading `session_id` argument.
`Session.get_working_directory()` reads the effective working directory; `set_working_directory(path)` changes it and returns the validated absolute path. Both create an unknown Session without running a model turn. Relative paths use that Session's current directory. Origin metadata and existing processes remain unchanged; the `workspace-write` boundary moves to the new directory. The low-level client provides the same methods with a leading `session_id` argument.
+2 -2
View File
@@ -129,7 +129,7 @@ with DeepSeekHarness(
`provider` 选择指定 Cordis 组合所注册的提供方路由;`model` 是该适配器解析出的模型 ID。`reasoning_effort` 是该确切路由可选的非空适配器自有标识符;省略时保留模型自身的默认值。`max_tokens` 是一个可选的正整数,用于限制根 agent 及其进程内后代在每次请求中输出的 token 数量;省略该参数时,由提供方的默认行为决定输出上限。缺少适配器、模型不可用或推理强度不受支持时,初始化会在提示词运行前拒绝。压缩(compaction)摘要继续使用压缩插件单独配置的上限。内置默认组合注册 `deepseek-official`。自定义组合可以挂载 `llm-pi-ai`,在其中配置各提供方专属的凭据和端点,并选择 pi-ai 已安装 catalog 中存在的任意提供方/模型组合。
随附的 `sdk-minimal` profile 是独立显式配置树,而不是 `dsh-base` 上的 overlay。使用 `profile="sdk-minimal"` 选择它;普通 `model` 参数是唯一运行时模型选择,也适用于不在适配器建议目录中的模型 ID。它提供按平台选择的持久 shell、`read_image`、`working_directory`、本地执行、JSONL 会话和自动压缩。文本文件工具、设置、托管凭据、遥测、Web 工具与完整默认工具清单仍由独立的完整 `sdk` 与 `web` profile 提供。`sdk-minimal` profile 将不支持的斜杠输入保留在普通提示词路径上。
随附的 `sdk-minimal` profile 是独立显式配置树,而不是 `dsh-base` 上的 overlay。使用 `profile="sdk-minimal"` 选择它;普通 `model` 参数是唯一运行时模型选择,也适用于不在适配器建议目录中的模型 ID。它提供按平台选择的持久 shell、`read_image`、本地执行、JSONL 会话和自动压缩。文本文件工具、设置、托管凭据、遥测、Web 工具与完整默认工具清单仍由独立的完整 `sdk` 与 `web` profile 提供。`sdk-minimal` profile 将不支持的斜杠输入保留在普通提示词路径上。
## 原生用户问答
@@ -149,4 +149,4 @@ with DeepSeekHarness(
另见 [Python 教程](../../docs/user/guide/python-sdk.zh.md)、[可运行示例](examples/README.zh.md) 和 [运行时 wheel 包参考](../sdk-runtime/README.zh.md)。
`Session.get_working_directory()` 读取有效工作目录;`get_workspace_root()` 读取该目录所在的工作区根;`set_working_directory(path)` 修改目录并返回校验后的绝对路径。每个方法都可创建未知 Session,而不运行模型轮次。相对路径以该 Session 当前目录解析。起始目录元数据、权限与已有进程保持不变。底层客户端提供同名方法,并以 `session_id` 作为首个参数。
`Session.get_working_directory()` 读取有效工作目录;`set_working_directory(path)` 修改目录并返回校验后的绝对路径。两者都可创建未知 Session,而不运行模型轮次。相对路径以该 Session 当前目录解析。起始目录元数据与已有进程保持不变;`workspace-write` 边界移到新目录。底层客户端提供同名方法,并以 `session_id` 作为首个参数。
+2 -2
View File
@@ -6,8 +6,8 @@
en: c97ffc5ce0f7db05
zh: bdd91202075498a3
/python-sdk-example/run-the-minimal-agent:
en: ac09bb6bc3ab76a0
zh: e69d1e2bd796f3bf
en: 9807fc909be30878
zh: 9cef470f85212250
/python-sdk-example/compact-a-full-sdk-session:
en: 6325ac9aaf9b9b67
zh: 004a0ba5c2ff341b
-1
View File
@@ -23,7 +23,6 @@ The shipped [`@deepseek-ai/dsh-sdk-minimal` bundle](../../../packages/bundle/sdk
- owner-scoped persistent `bash` on Linux/macOS or `pwsh` on Windows
- `read_image` for PNG/JPEG/WebP/GIF files, with an image-capable model
- `working_directory` to inspect or change the Session directory
The bundle does not include `dsh-base`, so every additional row is an explicit profile change. Runtime context, text file tools, local instruction discovery, settings, managed credentials, telemetry, Web tools, subagents, and the full default tool roster are absent. The tree retains SDK startup and JSON-RPC serving, one environment-configured DeepSeek adapter, local execution, and JSONL persistence. [Automatic context compaction](../../../packages/bundle/sdk-minimal/README.md#model-experience) summarizes older history through an additional model request while preserving the complete log. This minimal composition leaves unsupported slash input on the ordinary prompt path.
-1
View File
@@ -23,7 +23,6 @@ python python/sdk/examples/minimal.py \
- Linux/macOS 上所有者作用域内的持久 `bash`,或 Windows 上的 `pwsh`
- 配合支持图片输入的模型读取 PNG/JPEG/WebP/GIF 文件的 `read_image`
- 查询或修改 Session 目录的 `working_directory`
该组合包不包含 `dsh-base`,因此每一个新增配置项都是显式 profile 变更。运行时上下文、文本文件工具、本地指令发现、设置、托管凭据、遥测、Web 工具、subagent 与完整默认工具清单均不存在。配置树保留 SDK 启动与 JSON-RPC 服务、一个由环境配置的 DeepSeek 适配器、本地执行和 JSONL 持久化。[自动上下文压缩](../../../packages/bundle/sdk-minimal/README.zh.md#model-experience)通过额外模型请求生成较早历史的摘要,同时保留完整日志。这个最小组合将不支持的斜杠输入保留在普通提示词路径上。
-5
View File
@@ -206,11 +206,6 @@ class Session:
self.harness.start()
return self.harness.client.get_working_directory(self.id)
def get_workspace_root(self) -> str:
"""Read the workspace root the effective directory is in, recovering a missing directory first."""
self.harness.start()
return self.harness.client.get_workspace_root(self.id)
def set_working_directory(self, path: str) -> str:
"""Change the effective directory while existing processes retain their own directories."""
self.harness.start()
+1 -11
View File
@@ -249,17 +249,8 @@ class HarnessClient:
)
return response.cwd
def get_workspace_root(self, session_id: str) -> str:
"""Read the workspace root the effective directory is in, recovering a missing directory first."""
response = self.request(
"session/working-directory/get",
{"sessionId": session_id},
response_model=_WorkingDirectoryResponse,
)
return response.root
def set_working_directory(self, session_id: str, path: str) -> str:
"""Enter an absolute or Session-relative directory without changing origin or permissions."""
"""Enter an absolute or Session-relative directory; the origin is unchanged and the write boundary follows."""
response = self.request(
"session/working-directory/set",
{"sessionId": session_id, "path": path},
@@ -726,7 +717,6 @@ class _SessionPromptResponse(BaseModel):
class _WorkingDirectoryResponse(BaseModel):
cwd: str
root: str
class _EmptyResponse(BaseModel):
+2 -3
View File
@@ -31,13 +31,13 @@ for line in sys.stdin:
print(json.dumps({'jsonrpc': '2.0', 'id': frame['id'], 'result': {}}), flush=True)
break
elif method == 'session/working-directory/get':
result = {'cwd': directories.get(params['sessionId'], origin), 'root': origin}
result = {'cwd': directories.get(params['sessionId'], origin)}
elif method == 'session/working-directory/set':
assert not os.path.isabs(params['path']), 'client must preserve relative paths'
previous = directories.get(params['sessionId'], origin)
current = os.path.normpath(os.path.join(previous, params['path']))
directories[params['sessionId']] = current
result = {'cwd': 7 if params['path'] == 'malformed' else current, 'root': origin}
result = {'cwd': 7 if params['path'] == 'malformed' else current}
else:
raise AssertionError(method)
print(json.dumps({'jsonrpc': '2.0', 'id': frame['id'], 'result': result}), flush=True)
@@ -49,7 +49,6 @@ for line in sys.stdin:
assert first.get_working_directory() == str(tmp_path)
assert first.set_working_directory("child") == str(tmp_path / "child")
assert first.get_working_directory() == str(tmp_path / "child")
assert first.get_workspace_root() == str(tmp_path)
assert second.get_working_directory() == str(tmp_path)
with pytest.raises(ValidationError):
second.set_working_directory("malformed")