relay-dsh-plugin-claude 0.1.3 → 0.1.5

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 CHANGED
@@ -6,23 +6,36 @@
6
6
  [![GitHub stars](https://img.shields.io/github/stars/yangbobo2021/relay-dsh-plugin-claude?style=flat)](https://github.com/yangbobo2021/relay-dsh-plugin-claude/stargazers)
7
7
  [![MIT license](https://img.shields.io/github/license/yangbobo2021/relay-dsh-plugin-claude)](LICENSE)
8
8
  [![DSH compatibility](https://img.shields.io/badge/DSH-0.1.1--rc.2-2f7d68)](https://github.com/deepseek-ai/deepseek-harness)
9
- [![npm provenance](https://img.shields.io/badge/npm_provenance-verified-2f9e44)](https://www.npmjs.com/package/relay-dsh-plugin-claude/v/0.1.1-rc.2)
9
+ [![npm provenance](https://img.shields.io/badge/npm_provenance-verified-2f9e44)](https://www.npmjs.com/package/relay-dsh-plugin-claude/v/0.1.5)
10
10
 
11
11
  English | [中文](README.zh.md)
12
12
 
13
13
  **npm package:** [`relay-dsh-plugin-claude`](https://www.npmjs.com/package/relay-dsh-plugin-claude)
14
14
  · [All Relay DSH plugins](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/dsh-plugins.md)
15
15
 
16
- [![Live npm-installed Relay plugins in official DSH](https://raw.githubusercontent.com/yangbobo2021/Relay/codex/relay-foundation/docs/media/dsh-plugin-suite-demo.gif)](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/dsh-plugins.md)
16
+ **Run Claude Code inside official DeepSeek Harness without switching interfaces
17
+ or maintaining a DSH fork.**
17
18
 
18
- *Real npm-installed demo on official DSH: live Codex and Claude replies, a
19
- workspace file preview, and an executed terminal command. [Watch the H.264
20
- MP4](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/media/dsh-plugin-suite-demo.mp4?raw=1).*
19
+ `relay-dsh-plugin-claude` adds **Claude Code as a native conversation backend**
20
+ to the official [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)
21
+ (DSH) Web UI. You keep DSH's workspace, conversation history, composer,
22
+ approvals, questions, and tool display while each DSH Session continues one
23
+ Claude Agent SDK session. The plugin installs independently; no Relay checkout
24
+ is required.
21
25
 
22
- `relay-dsh-plugin-claude` adds **Claude Code as a conversation backend** to the
23
- official [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)
24
- (DSH) Web UI. After installation, **Claude Code** appears in DSH's New Session
25
- mode menu. One DSH Session is bound to one Claude Agent SDK session.
26
+ ## Try It on Official DSH
27
+
28
+ Complete normal Claude Code authentication with `claude` before the first
29
+ Session. The install requires Node.js 22.13 or newer and `pnpm` on `PATH`. Then
30
+ stop DSH Web, install the tested release candidate, and restart DSH:
31
+
32
+ ```bash
33
+ npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add relay-dsh-plugin-claude@next
34
+ npx @deepseek-ai/dsh@0.1.1-rc.2 web
35
+ ```
36
+
37
+ Open **New Session**, select a workspace, choose **Claude Code** from the mode
38
+ menu, and send a message.
26
39
 
27
40
  ![Codex and Claude Code in the DSH New Session mode menu](docs/images/dsh-new-session-backends.jpg)
28
41
 
@@ -30,6 +43,13 @@ The screenshot was captured from official DSH `0.1.1-rc.2` with the Codex and
30
43
  Claude plugins installed. If you install only this plugin, only **Claude Code**
31
44
  is added.
32
45
 
46
+ [Review all Relay DSH plugins](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/dsh-plugins.md)
47
+ · [report an install result](https://github.com/yangbobo2021/relay-dsh-plugin-claude/issues)
48
+
49
+ If this removes an interface switch from your DSH workflow,
50
+ [star this plugin](https://github.com/yangbobo2021/relay-dsh-plugin-claude).
51
+ That signal helps other DSH users find a tested Claude Code backend.
52
+
33
53
  ## Do I Need This Plugin?
34
54
 
35
55
  Install it when you want to:
@@ -45,7 +65,7 @@ Install it when you want to:
45
65
  You do not need it to use DSH's standard agents. It also does not add Relay
46
66
  Events, file browsing, or a terminal panel. Those are separate optional plugins.
47
67
 
48
- ## Quick Start With Official DSH
68
+ ## Complete Setup and Compatibility
49
69
 
50
70
  The steps below were validated with:
51
71
 
@@ -89,7 +109,7 @@ Use `@latest` to install the current stable release:
89
109
  npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add relay-dsh-plugin-claude@latest
90
110
  ```
91
111
 
92
- At the time of writing, `latest` resolves to stable version `0.1.0`. The linked
112
+ At the time of writing, `latest` resolves to stable version `0.1.5`. The linked
93
113
  npm page is the source of truth for the current version.
94
114
 
95
115
  #### npm prerelease (recommended during DSH preview)
@@ -102,7 +122,7 @@ contains the latest model-selection synchronization fix:
102
122
  npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add relay-dsh-plugin-claude@next
103
123
  ```
104
124
 
105
- At the time of writing, `next` resolves to `0.1.1-rc.2`.
125
+ At the time of writing, `next` resolves to `0.1.5`.
106
126
 
107
127
  #### GitHub development build
108
128
 
@@ -116,7 +136,7 @@ npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add github:yangbobo2021/rel
116
136
  full Commit SHA instead. For example:
117
137
 
118
138
  ```bash
119
- npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add github:yangbobo2021/relay-dsh-plugin-claude#v0.1.1-rc.2
139
+ npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add github:yangbobo2021/relay-dsh-plugin-claude#v0.1.5
120
140
  ```
121
141
 
122
142
  The official DSH CLI initializes the `web` Profile if it does not exist, asks
@@ -151,6 +171,34 @@ at startup, so restarting after installation, update, or removal is required.
151
171
  There is no separate activation command. A successful install plus a DSH restart
152
172
  activates the bundle and registers the managed **Claude Code** mode automatically.
153
173
 
174
+ ### 5. Import an existing Claude terminal Session
175
+
176
+ 1. Select **Import sessions...** below the Workspace list, then choose **Import
177
+ from Claude**.
178
+ 2. In the dialog, confirm or change the visible **Target Workspace**, then select
179
+ **Scan Sessions**. The current Session owner or recent Workspace is only the
180
+ initial selection; scanning never starts before this confirmation.
181
+ 3. Review the full Session IDs, titles, source paths, activity times, and import
182
+ status. Select one, several, or all Sessions.
183
+ 4. Select **Import selected**, then open the imported DSH Session.
184
+ 5. Send the next message and confirm that it continues the same native Claude
185
+ Session.
186
+
187
+ The selector uses the Claude Agent SDK's public Session APIs and matches the
188
+ terminal `/resume` scope. It excludes worktrees, SDK/headless Sessions,
189
+ already-bound Sessions, and Sessions outside the explicitly selected Workspace.
190
+ The imported history is a one-time presentation snapshot of user text, visible
191
+ assistant text and thinking, and completed textual tool activity. Unknown or
192
+ private blocks are skipped; Claude's source transcript is never modified.
193
+
194
+ The SDK inventory does not expose a durable running/idle status. Avoid writing
195
+ the same Session from another Claude client while continuing it in DSH. If
196
+ resume fails, DSH keeps the exact imported binding for retry and never silently
197
+ creates a replacement Session. Import is unavailable with the CLI fallback.
198
+ See
199
+ [`docs/spec/claude-native-session-import.md`](docs/spec/claude-native-session-import.md)
200
+ for the complete contract and delivery cases.
201
+
154
202
  ## What Works
155
203
 
156
204
  - One persistent Claude Agent SDK session per DSH Session
@@ -161,7 +209,47 @@ activates the bundle and registers the managed **Claude Code** mode automaticall
161
209
  final answer
162
210
  - DSH approval and user-question flows
163
211
  - Interruption and session continuation
212
+ - Selective import and exact-ID continuation of existing Claude terminal Sessions
164
213
  - Generic DSH tools exposed through an in-process Claude SDK MCP server
214
+ - Dedicated native Claude `Glob` and `Grep` search tools on every SDK query
215
+ - Pre-persistence redaction of sensitive environment values from tool output
216
+
217
+ ### Sensitive environment output
218
+
219
+ Before each new or resumed SDK turn, the plugin resolves Claude's effective
220
+ environment and classifies credential-bearing variable names such as `SECRET`,
221
+ `TOKEN`, `PASSWORD`, and `API_KEY`. Exact occurrences of those values in tool
222
+ results are replaced before the result reaches Claude, DSH activity, or the
223
+ native Claude JSONL transcript. Variables explicitly listed in Claude sandbox
224
+ credential settings are protected as well. Ordinary environment values and
225
+ successful tool outputs without a match are left unchanged.
226
+
227
+ This protection covers successful tool results; it does not rewrite user
228
+ prompts, tool inputs, arbitrary values that are not identifiable from host
229
+ configuration, or SDK execution failures without a replaceable tool output.
230
+ See
231
+ [`docs/spec/claude-tool-output-redaction.md`](docs/spec/claude-tool-output-redaction.md)
232
+ for the complete contract and acceptance cases.
233
+
234
+ ### Explicit local Claude plugins
235
+
236
+ Trusted Host configuration can load an uninstalled local Claude plugin into
237
+ business conversations by setting `claudePlugins` on this DSH plugin:
238
+
239
+ ```yaml
240
+ config:
241
+ claudePlugins:
242
+ - type: local
243
+ path: /absolute/path/to/plugin
244
+ ```
245
+
246
+ The order and optional `skipMcpDiscovery` Boolean are forwarded to every new and
247
+ resumed Claude Agent SDK query. Hidden title-generation Sessions use no local
248
+ plugins. A non-empty list is rejected when the CLI fallback is active because
249
+ the CLI backend cannot honor this SDK option. Local plugins execute as the DSH
250
+ user, so configure only reviewed paths. See
251
+ [`docs/spec/claude-local-plugins.md`](docs/spec/claude-local-plugins.md) for the
252
+ full contract and acceptance cases.
165
253
 
166
254
  Tools execute through the owning Agent's DSH tool runtime and remain subject to
167
255
  DSH permissions and Claude approval behavior. The tool bridge requires the
@@ -186,12 +274,13 @@ This repository was designed and compatibility-tested in
186
274
  long-running agent work, external-event delivery, reusable DSH workbench views,
187
275
  and multiple conversation backends.
188
276
 
189
- The plugin is independently installable. It has no runtime dependency on the
190
- Relay application, Relay Events, or another Relay plugin. It does not replace the
191
- official DSH layout or install Files and Terminal views. This separation lets a
192
- user install only Claude while the broader Relay project can compose Codex,
193
- Claude, events, waits, monitors, and workbench extensions when those capabilities
194
- are needed.
277
+ The plugin is independently installable. Its only Relay package dependency is
278
+ the provider-neutral session import hub, which the package manager installs
279
+ automatically. It has no runtime dependency on the Relay application, Relay
280
+ Events, or another feature plugin. It does not replace the official DSH layout
281
+ or install Files and Terminal views. This separation lets a user install only
282
+ Claude while the broader Relay project can compose Codex, Claude, events, waits,
283
+ monitors, and workbench extensions when those capabilities are needed.
195
284
 
196
285
  Explore or star Relay to follow that broader work:
197
286
  <https://github.com/yangbobo2021/Relay>.
package/README.zh.md CHANGED
@@ -6,29 +6,48 @@
6
6
  [![GitHub Stars](https://img.shields.io/github/stars/yangbobo2021/relay-dsh-plugin-claude?style=flat)](https://github.com/yangbobo2021/relay-dsh-plugin-claude/stargazers)
7
7
  [![MIT 许可证](https://img.shields.io/github/license/yangbobo2021/relay-dsh-plugin-claude)](LICENSE)
8
8
  [![DSH 兼容版本](https://img.shields.io/badge/DSH-0.1.1--rc.2-2f7d68)](https://github.com/deepseek-ai/deepseek-harness)
9
- [![npm 来源证明](https://img.shields.io/badge/npm_provenance-verified-2f9e44)](https://www.npmjs.com/package/relay-dsh-plugin-claude/v/0.1.1-rc.2)
9
+ [![npm 来源证明](https://img.shields.io/badge/npm_provenance-verified-2f9e44)](https://www.npmjs.com/package/relay-dsh-plugin-claude/v/0.1.5)
10
10
 
11
11
  [English](README.md) | 中文
12
12
 
13
13
  **npm 包名:** [`relay-dsh-plugin-claude`](https://www.npmjs.com/package/relay-dsh-plugin-claude)
14
14
  · [全部 Relay DSH 插件](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/dsh-plugins.zh.md)
15
15
 
16
- [![在官方 DSH 中实装运行的 Relay 插件](https://raw.githubusercontent.com/yangbobo2021/Relay/codex/relay-foundation/docs/media/dsh-plugin-suite-demo.gif)](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/dsh-plugins.zh.md)
17
-
18
- *演示来自官方 DSH 上的真实 npm 安装:Codex 与 Claude 返回真实回复,Files
19
- 预览工作区文件,Terminal 实际执行命令。[观看 H.264
20
- MP4](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/media/dsh-plugin-suite-demo.mp4?raw=1)。*
16
+ **无需切换界面或维护 DSH Fork,直接在官方 DeepSeek Harness 中运行 Claude
17
+ Code。**
21
18
 
22
19
  `relay-dsh-plugin-claude` 为官方
23
20
  [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(DSH)Web
24
- 界面增加 **Claude Code 对话后端**。安装后,DSH 的新建会话模式菜单中会出现
25
- **Claude Code**。每个 DSH Session 会绑定一个 Claude Agent SDK Session。
21
+ 界面增加原生 **Claude Code 对话后端**。你可以继续使用 DSH 的工作区、对话
22
+ 历史、输入框、审批、提问和工具展示;每个 DSH Session 会持续绑定一个 Claude
23
+ Agent SDK Session。本插件可独立安装,不需要下载 Relay 仓库。
24
+
25
+ ## 在官方 DSH 中立即试用
26
+
27
+ 首次创建 Session 前,请先运行 `claude` 完成 Claude Code 的正常认证。安装
28
+ 要求 Node.js 22.13 或更高版本,并且 `pnpm` 已加入 `PATH`。然后停止 DSH Web,
29
+ 安装经过测试的候选版本并重新启动:
30
+
31
+ ```bash
32
+ npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add relay-dsh-plugin-claude@next
33
+ npx @deepseek-ai/dsh@0.1.1-rc.2 web
34
+ ```
35
+
36
+ 打开 **New Session**,选择工作区,再从模式菜单中选择 **Claude Code** 并发送
37
+ 消息。
26
38
 
27
39
  ![DSH 新建会话菜单中的 Codex 和 Claude Code](docs/images/dsh-new-session-backends.jpg)
28
40
 
29
41
  上图来自安装了 Codex 和 Claude 插件的官方 DSH `0.1.1-rc.2`。如果只安装
30
42
  本插件,菜单中只会新增 **Claude Code**。
31
43
 
44
+ [查看全部 Relay DSH 插件](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/dsh-plugins.zh.md)
45
+ · [反馈安装结果](https://github.com/yangbobo2021/relay-dsh-plugin-claude/issues)
46
+
47
+ 如果它能让你少切换一个界面,欢迎
48
+ [Star 本插件](https://github.com/yangbobo2021/relay-dsh-plugin-claude)。
49
+ 这些真实信号能帮助更多 DSH 用户找到经过验证的 Claude Code 后端。
50
+
32
51
  ## 什么情况下需要这个插件?
33
52
 
34
53
  以下情况适合安装:
@@ -44,7 +63,7 @@ MP4](https://github.com/yangbobo2021/Relay/blob/codex/relay-foundation/docs/medi
44
63
  使用 DSH 标准 Agent 不需要安装本插件。本插件也不提供 Relay Events、文件
45
64
  浏览和终端面板,这些能力由其他可选插件提供。
46
65
 
47
- ## 基于官方 DSH 的快速安装
66
+ ## 完整安装与兼容性说明
48
67
 
49
68
  以下步骤已经在这些版本上实际验证:
50
69
 
@@ -85,7 +104,7 @@ claude
85
104
  npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add relay-dsh-plugin-claude@latest
86
105
  ```
87
106
 
88
- 本文更新时,`latest` 指向稳定版 `0.1.0`。最新版本请以链接中的 npm 页面
107
+ 本文更新时,`latest` 指向稳定版 `0.1.5`。最新版本请以链接中的 npm 页面
89
108
  为准。
90
109
 
91
110
  #### npm 预发布版(DSH 预览阶段推荐)
@@ -97,7 +116,7 @@ npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add relay-dsh-plugin-claude
97
116
  npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add relay-dsh-plugin-claude@next
98
117
  ```
99
118
 
100
- 本文更新时,`next` 指向 `0.1.1-rc.2`。
119
+ 本文更新时,`next` 指向 `0.1.5`。
101
120
 
102
121
  #### GitHub 开发版
103
122
 
@@ -111,7 +130,7 @@ npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add github:yangbobo2021/rel
111
130
  SHA。例如:
112
131
 
113
132
  ```bash
114
- npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add github:yangbobo2021/relay-dsh-plugin-claude#v0.1.1-rc.2
133
+ npx @deepseek-ai/dsh@0.1.1-rc.2 plugin --profile web add github:yangbobo2021/relay-dsh-plugin-claude#v0.1.5
115
134
  ```
116
135
 
117
136
  官方 DSH CLI 会在需要时初始化 `web` Profile,通过 `pnpm` 安装所选软件包和
@@ -143,6 +162,28 @@ npx @deepseek-ai/dsh@0.1.1-rc.2 web
143
162
  插件不需要单独的激活命令。安装成功并重启 DSH 后,Bundle 会自动激活,
144
163
  并注册由插件管理的 **Claude Code** 模式。
145
164
 
165
+ ### 5. 导入已有的 Claude 终端会话
166
+
167
+ 1. 点击工作区列表下方的 **导入会话...**,然后选择 **从 Claude 导入**。
168
+ 2. 在弹窗中确认或切换可见的 **目标 Workspace**,然后点击 **扫描会话**。
169
+ 当前 Session 所属 Workspace 或最近 Workspace 只作为初始选项;确认前不会开始扫描。
170
+ 3. 检查完整 Session ID、标题、源路径、活动时间和导入状态,然后选择一个、
171
+ 多个或全部会话。
172
+ 4. 点击 **导入所选会话**,再打开导入后的 DSH Session。
173
+ 5. 发送下一条消息,确认它继续的是同一个原生 Claude Session。
174
+
175
+ 选择器只使用 Claude Agent SDK 的公开 Session API,其范围与终端 `/resume`
176
+ 一致。它会排除 worktree、SDK/headless、已经绑定以及不属于用户所选精确工作区
177
+ 的 Session。导入历史是一次性的展示快照,包含用户文本、可见的助手文本与
178
+ thinking,以及已有结果的文本工具活动。未知或私有块会被跳过,Claude 源转录
179
+ 不会被修改。
180
+
181
+ SDK 列表不提供持久的 running/idle 状态。通过 DSH 继续会话时,应避免另一个
182
+ Claude 客户端同时写入同一个 Session。如果恢复失败,DSH 会保留原始绑定供
183
+ 重试,绝不会静默创建替代 Session。CLI fallback 不支持导入。完整契约和交付
184
+ 用例见
185
+ [`docs/spec/claude-native-session-import.md`](docs/spec/claude-native-session-import.md)。
186
+
146
187
  ## 支持的能力
147
188
 
148
189
  - 每个 DSH Session 持续绑定一个 Claude Agent SDK Session
@@ -152,7 +193,40 @@ npx @deepseek-ai/dsh@0.1.1-rc.2 web
152
193
  - 在对话中持久展示 Claude 最终回答所引用的工作区图片
153
194
  - DSH 原生审批和用户提问流程
154
195
  - 中断和会话延续
196
+ - 选择性导入已有 Claude 终端会话,并通过原始 ID 继续
155
197
  - 通过进程内 Claude SDK MCP Server 提供通用 DSH 工具
198
+ - 在每次 SDK 查询中启用 Claude 原生 `Glob` 与 `Grep` 专用搜索工具
199
+ - 在工具结果持久化前脱敏其中的敏感环境变量值
200
+
201
+ ### 敏感环境变量输出脱敏
202
+
203
+ 每次新建或恢复 SDK turn 前,插件都会解析 Claude 的有效环境,并识别变量名中
204
+ 含有 `SECRET`、`TOKEN`、`PASSWORD`、`API_KEY` 等凭据特征的值。工具结果中
205
+ 与这些值完全相同的内容,会在进入 Claude、DSH activity 或 Claude 原生 JSONL
206
+ 转录之前替换。Claude sandbox 凭据设置中显式列出的环境变量也会受到保护。
207
+ 普通环境值及没有命中的成功工具输出保持不变。
208
+
209
+ 该保护仅覆盖成功工具结果,不会改写用户消息、工具输入、无法从 Host 配置
210
+ 识别的任意内容,或 SDK 未提供可替换输出的执行失败。完整契约与验收用例见
211
+ [`docs/spec/claude-tool-output-redaction.md`](docs/spec/claude-tool-output-redaction.md)。
212
+
213
+ ### 显式加载本地 Claude 插件
214
+
215
+ 可信的 Host 配置可以通过本 DSH 插件的 `claudePlugins` 字段,将未安装的
216
+ 本地 Claude 插件加载到业务对话中:
217
+
218
+ ```yaml
219
+ config:
220
+ claudePlugins:
221
+ - type: local
222
+ path: /absolute/path/to/plugin
223
+ ```
224
+
225
+ 插件顺序和可选的 Boolean 字段 `skipMcpDiscovery` 会传递给每次新建及恢复的
226
+ Claude Agent SDK 查询。标题生成等隐藏辅助 Session 不加载这些插件。CLI
227
+ fallback 无法实现该 SDK 能力,因此非空列表会被明确拒绝。因为本地插件以
228
+ DSH 用户身份运行,只应配置经过审查的路径。完整契约和验收用例见
229
+ [`docs/spec/claude-local-plugins.md`](docs/spec/claude-local-plugins.md)。
156
230
 
157
231
  工具通过当前 Agent 的 DSH 工具运行时执行,并继续受到 DSH 权限和 Claude
158
232
  审批机制约束。工具桥接依赖默认 SDK 后端。如果开发者明确选择 CLI fallback,
@@ -171,10 +245,11 @@ PNG;工作区中不会产生同名 PNG,也不会加载外部资源或执行
171
245
  兼容性验证。Relay 是面向长时间运行 Agent、外部事件投递、可复用 DSH
172
246
  工作台视图和多种对话后端的开源项目。
173
247
 
174
- 本插件可以独立安装。运行时不依赖 Relay 应用、Relay Events 或其他 Relay
175
- 插件,也不会替换 DSH 官方布局或安装 Files、Terminal 视图。用户可以只安装
176
- Claude;需要时,Relay 项目则可以进一步组合 Codex、Claude、事件、Wait、
177
- Monitor 和工作台扩展。
248
+ 本插件可以独立安装。唯一依赖的 Relay 包是由包管理器自动安装的中立“会话
249
+ 导入中心”;运行时不依赖 Relay 应用、Relay Events 或其他功能插件,也不会
250
+ 替换 DSH 官方布局或安装 FilesTerminal 视图。用户可以只安装 Claude;需要
251
+ 时,Relay 项目则可以进一步组合 Codex、Claude、事件、Wait、Monitor 和工作台
252
+ 扩展。
178
253
 
179
254
  可以访问或 Star Relay 仓库,关注这些更完整的工作:
180
255
  <https://github.com/yangbobo2021/Relay>。
@@ -236,8 +311,8 @@ DSH_ROOT=/path/to/deepseek-harness npm run verify
236
311
  npm pack
237
312
  ```
238
313
 
239
- `npm run verify` 会执行类型检查、测试和生产构建。边界测试会阻止插件意外
240
- 增加对 Relay 或其他功能插件的运行时依赖。
314
+ `npm run verify` 会执行类型检查、测试和生产构建。边界测试仅允许中立的会话
315
+ 导入中心依赖,并会阻止插件意外增加对 Relay 应用或其他功能插件的运行时依赖。
241
316
 
242
317
  ## 反馈
243
318
 
package/cordis.patch.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  - insert:
2
+ - id: relay-session-import-for-claude
3
+ name: 'relay-dsh-plugin-session-import'
2
4
  - id: relay-claude-host
3
5
  name: 'relay-dsh-plugin-claude'
@@ -0,0 +1,56 @@
1
+ # Claude Local Plugin Loading
2
+
3
+ ## Contract
4
+
5
+ The DSH host configuration may provide `claudePlugins`, an ordered array of
6
+ Claude Agent SDK local-plugin descriptors:
7
+
8
+ ```yaml
9
+ config:
10
+ claudePlugins:
11
+ - type: local
12
+ path: /absolute/path/to/plugin
13
+ skipMcpDiscovery: false
14
+ ```
15
+
16
+ Each descriptor must contain `type: local` and a non-empty `path`.
17
+ `skipMcpDiscovery`, when present, must be Boolean. Unknown fields are rejected.
18
+ Relative paths remain relative and are interpreted by the Claude Agent SDK.
19
+ Relay does not check path existence before the SDK starts, avoiding a separate
20
+ check/use result from the SDK's authoritative load.
21
+
22
+ The configuration is trusted startup configuration: a local Claude plugin can
23
+ load instructions, hooks, agents, commands, Skills, and MCP definitions with the
24
+ same operating-system access as the Claude process. It is not accepted from a
25
+ conversation message or model output.
26
+
27
+ ## Session behavior
28
+
29
+ - A configured list is cloned into every new business Claude SDK Session.
30
+ - A linked DSH Session resumed after a Host restart receives the current Host
31
+ list, including when its older link record predates this option.
32
+ - Every query for that Claude Session carries the same ordered list, including
33
+ resumed queries.
34
+ - Message-level plugin replacement is rejected before `query()`; conversation
35
+ input and model output cannot introduce a local plugin path.
36
+ - An explicit empty list disables configured plugins for that Session.
37
+ - Hidden auxiliary Sessions, including title generation, always use an explicit
38
+ empty list. They must not run user plugin hooks or discover user plugin Skills.
39
+ - With no configured list, Relay omits the SDK `plugins` option and preserves
40
+ existing behavior.
41
+ - The CLI backend cannot load SDK local-plugin paths. It rejects a non-empty list
42
+ with `CLAUDE_LOCAL_PLUGINS_REQUIRE_SDK` instead of silently dropping it.
43
+
44
+ ## Delivery acceptance
45
+
46
+ | ID | Scenario | Required result |
47
+ | --- | --- | --- |
48
+ | LP1 | New Session | Runtime creation and first SDK query receive the exact ordered descriptors. |
49
+ | LP2 | Continued Session | A later query uses `resume` and receives the same descriptors. |
50
+ | LP3 | Host restart | Runtime resume receives the current configured descriptors without relying on the persisted link record. |
51
+ | LP4 | No configuration | Runtime and SDK options do not gain a `plugins` property. |
52
+ | LP5 | Auxiliary Session | Runtime creation receives `plugins: []`. |
53
+ | LP6 | Invalid configuration | Relay fails before creating a Session or invoking `query()`. |
54
+ | LP7 | CLI backend | A non-empty descriptor list fails explicitly and spawns no process. |
55
+ | LP8 | Real SDK load | With no CLI installation or setting source, SDK init reports the target plugin and namespaced Skill exactly once. |
56
+ | LP9 | Message injection | A message-level `plugins` field fails before SDK `query()` and does not alter the Session list. |
@@ -0,0 +1,127 @@
1
+ # Native Claude Session Import
2
+
3
+ This specification defines how `relay-dsh-plugin-claude` discovers an existing
4
+ Claude terminal Session, creates its DSH presentation, and continues the exact
5
+ same native Session. It is the delivery contract for migration case
6
+ `CLD-SES-004`.
7
+
8
+ ## Supported backend and source boundary
9
+
10
+ Import is available only when the active Claude Agent SDK exposes the public
11
+ `listSessions`, `getSessionInfo`, and `getSessionMessages` functions. The Host
12
+ must call those APIs and must not parse Claude's private JSONL storage. The CLI
13
+ fallback reports `CLAUDE_SESSION_IMPORT_UNAVAILABLE`; it must not return an empty
14
+ or fabricated inventory.
15
+
16
+ The scan calls `listSessions` with the exact registered DSH Workspace path,
17
+ `includeWorktrees: false`, and `includeProgrammatic: false`. This matches the
18
+ Claude terminal `/resume` inventory: SDK/headless, daemon, worktree, sidechain,
19
+ and other-Workspace Sessions are not import candidates. Every returned `cwd` is
20
+ canonicalized and checked again by the plugin because SDK filtering alone is not
21
+ the authorization boundary.
22
+
23
+ The public SDK inventory is a point-in-time snapshot. It does not expose a
24
+ durable running/idle field, so DSH must not label a candidate as completed or
25
+ promise that another Claude client is no longer writing it.
26
+
27
+ ## Inventory and selection
28
+
29
+ The provider-neutral session import hub owns one sidebar footer action. Claude
30
+ registers one renderless provider descriptor with the localized label **Import
31
+ from Claude**, the Claude mark, order `20`, and an `open` callback. Selecting
32
+ that menu row closes the hub menu and presents Claude's visible Workspace
33
+ selector. The current Session owner, then the recent Workspace, is only an
34
+ initial choice. The user may change it, and the plugin must not scan until the
35
+ user invokes **Scan Sessions**.
36
+
37
+ Each candidate exposes the full native Session ID, deterministic title, source
38
+ path, source `lastModified`, and either `ready` or `recoverable` status. The
39
+ ordering is descending source activity time with Session ID as a deterministic
40
+ tie-breaker. Already-bound Sessions remain in aggregate counts but are not
41
+ selectable or disclosed as candidates. Sessions outside the exact Workspace are
42
+ neither counted nor disclosed.
43
+
44
+ The UI defaults to every eligible candidate and supports selecting one, several,
45
+ all, or none. An empty selection cannot be submitted. The request carries the
46
+ exact selected `sessionIds`. Before creating or mutating a DSH Session, the Host
47
+ rescans and validates the entire selection. Empty, malformed, duplicate,
48
+ unknown, cross-Workspace, stale, or already-bound IDs reject the selection
49
+ without partial mutation. Omitting `sessionIds` retains the Host's import-all
50
+ API behavior; an explicit empty array is invalid.
51
+
52
+ After selection validation, an individual persistence or DSH composition
53
+ failure may produce a partial batch result. Its durable import state remains
54
+ recoverable and retrying the same source must continue that transaction instead
55
+ of creating a second DSH Session.
56
+
57
+ ## History projection
58
+
59
+ The Host reads the selected source again with `getSessionInfo` and
60
+ `getSessionMessages` immediately before reserving its binding. The source ID and
61
+ canonical `cwd` must still match. DSH receives a deterministic presentation seed
62
+ containing:
63
+
64
+ - top-level user text, whether the public SDK returns it as a string or text blocks;
65
+ - visible assistant text and SDK `thinking` blocks as DSH reasoning;
66
+ - a tool call only when its matching tool result exists;
67
+ - textual tool-result content and its error flag.
68
+
69
+ Malformed messages, pre-turn assistant content, system/private blocks, unmatched
70
+ tool calls or results, non-text tool-result blocks, and unknown future block
71
+ types are skipped and counted. They must never be converted into explanatory
72
+ model text. The source transcript is read-only and is never changed by import.
73
+
74
+ The initial DSH title comes from `customTitle`, `summary`, or `firstPrompt`, and
75
+ the DSH list recency comes from the source timestamps. History projection and
76
+ title persistence must complete before Workspace attachment is committed.
77
+
78
+ Import creates a one-time DSH presentation snapshot. It does not poll the source
79
+ or merge turns written later by a second Claude client. Turns sent through DSH
80
+ after import are persisted normally by DSH and the native Claude Session.
81
+
82
+ ## Binding and recovery
83
+
84
+ One DSH Session binds at most one native Claude Session, and one native Claude
85
+ Session binds at most one DSH Session. Imported DSH IDs are deterministic from
86
+ the complete source Session ID. The binding and the monotonic transaction states
87
+ `reserved`, `session-created`, `hydrated`, `attached`, and `committed` are
88
+ persisted before the next state is attempted.
89
+
90
+ Restart, duplicate request, concurrent request, and retry must converge on the
91
+ same DSH Session and native Session. Opening or sending the next DSH turn resumes
92
+ the exact imported native Session ID. If resume fails because the source is busy,
93
+ missing, or temporarily unavailable, the plugin reports
94
+ `CLAUDE_IMPORTED_SESSION_RESUME_FAILED`, keeps the binding, and creates no
95
+ replacement Session.
96
+
97
+ ## Web route
98
+
99
+ The Host exposes one exact POST route at `/api/relay/claude/import`. It accepts
100
+ JSON only, bounds request size, resolves the requested path through DSH's
101
+ registered Workspace service, and returns no-store responses. Loopback requests
102
+ are accepted. A non-loopback caller requires a constant-time checked Bearer token
103
+ configured by `claudeImportToken` or `RELAY_CLAUDE_IMPORT_TOKEN`.
104
+
105
+ ## Delivery acceptance
106
+
107
+ Delivery requires all of the following evidence:
108
+
109
+ 1. The historical plugin revision reproduces the absence of native Session
110
+ discovery/import for the same source fixture.
111
+ 2. Focused tests cover SDK capability failure, exact inventory options,
112
+ Workspace isolation, deterministic ordering, selection atomicity, source
113
+ revalidation, projection, one-to-one durability, concurrency, retry, and the
114
+ no-replacement resume rule.
115
+ 3. Client tests cover provider registration and disposal, explicit menu-driven
116
+ opening, visible Workspace choice, no automatic scan, exact selected path,
117
+ candidate selection, request payloads, chunked NDJSON progress, error
118
+ handling, disabled empty submission, and refresh order.
119
+ 4. A real installed SDK lists and reads a native terminal Session using only the
120
+ public APIs.
121
+ 5. Official DSH imports that Session, displays the projected history and title,
122
+ and sends the next turn to the same complete native Session ID.
123
+ 6. A combined Claude + Codex browser check and screenshots prove one hub action
124
+ presents both explicit provider rows in expanded and collapsed sidebars and
125
+ that the selector dialog is readable.
126
+ 7. Typecheck, the full repository test suite, build, package-content inspection,
127
+ and remote CI all pass.
@@ -0,0 +1,40 @@
1
+ # Claude Search Tool Contract
2
+
3
+ ## Scope
4
+
5
+ The Claude Agent SDK backend exposes Claude's dedicated `Glob` and `Grep`
6
+ tools on every business and auxiliary query. This contract does not apply to
7
+ the text-only CLI fallback.
8
+
9
+ ## Availability
10
+
11
+ Native Claude builds may otherwise provide filename and content search only
12
+ through Bash. The plugin must opt into `Glob` and `Grep` through the SDK's
13
+ `allowedTools` option so both dedicated tools are present without an approval
14
+ round trip. It must do so for new and resumed Sessions and whether or not the
15
+ owning DSH turn contributes tools.
16
+
17
+ The bare allow entries intentionally auto-approve only these two native,
18
+ read-only search tools, so the SDK does not call `canUseTool` for them. They do
19
+ not grant any mutation tool. The plugin still registers the permission callback
20
+ for every tool that is not otherwise allowed, and the SDK remains authoritative
21
+ for search path resolution and access enforcement.
22
+
23
+ The search entries augment the allowlist. They must never replace an
24
+ `mcp__dsh__*` entry created by the DSH tool bridge or alter the configured
25
+ permission mode, permission callback, working directory, plugins, or Session
26
+ continuation options.
27
+
28
+ ## Delivery Acceptance
29
+
30
+ 1. A query without DSH-contributed tools allows exactly the dedicated `Glob`
31
+ and `Grep` additions and does not create a DSH MCP server.
32
+ 2. A query with DSH-contributed tools preserves every generated
33
+ `mcp__dsh__*` allow entry after `Glob` and `Grep`.
34
+ 3. A fresh real SDK Session uses native `Glob` followed by native `Grep` to
35
+ find a precommitted unique path and marker, with no Bash fallback, approval,
36
+ or workspace mutation.
37
+ 4. The same run returns the exact expected path and marker, and the recorded
38
+ SDK initialization advertises both tool names.
39
+ 5. Existing SDK option, interaction, image, plugin, and DSH tool-bridge tests
40
+ remain green.