dsh-subagent-library 0.3.4 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@
4
4
 
5
5
  This file documents user-facing changes. Format loosely follows [Keep a Changelog]; versions follow [SemVer].
6
6
 
7
+ ## [0.3.6] — 2026-11-06
8
+
9
+ ### 修复 / Fixed
10
+
11
+ - 通过 DSH 0.2.2 的原生设置图标插槽显示子代理库机器人图标,修复新版设置侧栏中的图标回退;尺寸与颜色随宿主显示。
12
+ - Use the native DSH 0.2.2 settings icon slot to restore the library's robot icon in the updated sidebar, with host-controlled sizing and theme colors.
13
+
14
+ ## [0.3.5] — 2026-10-17
15
+
16
+ ### 修复 / Fixed
17
+
18
+ - **适配 DSH `0.2.1-rc.2`**:修复可续聊与前台一次性委派的启动失败,以及后台一次性任务报 `has no live agent` 的问题。旧宿主启动分支仍保留,名册与 profile 路由无需迁移。
19
+ - Adapts to DSH `0.2.1-rc.2`: fixes startup failures for continuable and foreground one-shot delegation, and `has no live agent` errors for background one-shot jobs. Legacy start paths remain; no roster or profile-route migration is needed.
20
+ - **取消会停止子代理**:修复后台任务已经启动后取消未生效的问题,并处理取消与启动同时发生的情况;前台调用中止时也会释放子代理。
21
+ - Cancellation now stops the child after a background job has started, including cancellation during startup. Aborting a foreground call also disposes its child.
22
+ - **工具过滤限制会明确提示**:DSH 0.2.1 系列不支持逐条目 `toolFilter`。含该字段的条目会拒绝委派,不会无视限制直接启动;名册列表会标注原因,设置页保存时也会提示。仅删除该字段不能保证只读,请在宿主中配置所需权限。
23
+ - Tool-filter limitations are now explicit: the DSH 0.2.1 series cannot enforce per-entry `toolFilter`. Entries containing it are refused, not started without their restrictions. The roster marks them and saving shows a warning. Removing the field does not guarantee read-only access; configure the required host permissions.
24
+ - **角色提示词的行为有变化**:DSH 0.2.1 系列通过首条任务消息传递角色,不再作为系统 persona,也不插值 `{{…}}` 模板;续聊或上下文压缩后不保证仍保留。README 已同步说明。
25
+ - Role prompts on the DSH 0.2.1 series are sent in the first task message, rather than as a system persona. `{{…}}` templates are not interpolated, and the role is not guaranteed to persist across follow-up turns or compaction. The README documents these limits.
26
+
7
27
  ## [0.3.4] — 2026-10-14
8
28
 
9
29
  ### 修复 / Fixed
@@ -117,7 +137,12 @@ This file documents user-facing changes. Format loosely follows [Keep a Changelo
117
137
 
118
138
  - 修复设置页保存 400(移除保存期工具名预检,委派期 `tools.restrict` 为准);新条目卡补齐缺失字段。
119
139
 
120
- [Unreleased]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.0...HEAD
140
+ [Unreleased]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.5...HEAD
141
+ [0.3.5]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.4...v0.3.5
142
+ [0.3.4]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.3...v0.3.4
143
+ [0.3.3]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.2...v0.3.3
144
+ [0.3.2]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.1...v0.3.2
145
+ [0.3.1]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.0...v0.3.1
121
146
  [0.3.0]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.2.8...v0.3.0
122
147
  [0.2.8]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.2.7...v0.2.8
123
148
  [0.2.7]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.2.6...v0.2.7
package/README.en.md CHANGED
@@ -9,12 +9,12 @@
9
9
  <p align="center">
10
10
  <img src="https://img.shields.io/github/actions/workflow/status/MaRi23333/dsh-subagent-library/ci.yml?style=flat-square&label=CI" alt="CI" />
11
11
  <img src="https://img.shields.io/github/license/MaRi23333/dsh-subagent-library?style=flat-square" alt="License: MIT" />
12
- <img src="https://img.shields.io/badge/DeepSeek%20Harness-0.2.0--rc.2-4d6bfe?style=flat-square" alt="DeepSeek Harness 0.2.0-rc.2" />
12
+ <img src="https://img.shields.io/badge/DeepSeek%20Harness-0.2.1--rc.2-4d6bfe?style=flat-square" alt="DeepSeek Harness 0.2.1-rc.2" />
13
13
  </p>
14
14
 
15
15
  ## Overview
16
16
 
17
- A named subagent roster plugin for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) Web GUI: turn your recurring roles (code review, red team, multimodal understanding…) into a persistent named roster (model + persona + tool filter). Then **just tell the main agent "do this with xxx"** — the model picks and dispatches through two tools by itself:
17
+ A named subagent roster plugin for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) desktop and Web interfaces: turn your recurring roles (code review, red team, multimodal understanding…) into a persistent named roster with model, role prompt, depth and background-mode settings. Then **just tell the main agent "do this with xxx"** — the model picks and dispatches through two tools by itself:
18
18
 
19
19
  - `list_subagents` — lists roster entries (id / role description / model) so the model can pick a suitable one;
20
20
  - `delegate` — dispatches work by `library_id`: foreground wait, background one-shot, or a continuable (resumable) subagent, per the entry's configuration.
@@ -27,6 +27,117 @@ Adding entries needs no hand-written config either: ask the main agent to do it,
27
27
 
28
28
  > **Upgrading from 0.2.x?** Since 0.3 the roster is directory-backed (one YAML file per subagent). Your legacy config **migrates automatically**; after verifying it, clear the old `entries` section for your host generation. [MIGRATION.md](./MIGRATION.md) documents the config locations, failure/retry behavior, and rollback limits; [CHANGELOG.md](./CHANGELOG.md) lists all changes.
29
29
 
30
+ [Install](#install) · [Your first delegation](#your-first-delegation) · [Configuration reference](#configuration)
31
+
32
+ ## Host and desktop compatibility
33
+
34
+ **0.3.5 targets DSH `0.2.1-rc.2`:** fixes startup failures for continuable and one-shot subagents, and cancellation that failed to stop background children. Foreground one-shot, continuable, background startup and cancellation of running jobs have been checked on that desktop host. See [Configuration](#configuration) for role-prompt and tool-filter limitations, and [CHANGELOG.md](./CHANGELOG.md) for the full update.
35
+
36
+ The desktop client uses the Web plugin UI, so no separate desktop-specific package is needed. The legacy start paths remain, but this release's live checks target `0.2.1-rc.2`; model calls still depend on each provider's configuration and service. Roster directories, profile routes and migration rules are unchanged, so no new migration is needed.
37
+
38
+ ## Install
39
+
40
+ ### Desktop client (recommended)
41
+
42
+ Desktop and Web have separate plugin installations and activation states; installing for Web does not enable the desktop plugin. The desktop GUI route needs no PATH setup.
43
+
44
+ 1. In the desktop sidebar, open **Plugins** → **Add plugin**.
45
+ 2. Enter the npm package name `dsh-subagent-library@latest` and install it.
46
+ 3. Click **Enable now** when installation finishes. Closing the completed-install dialog leaves the plugin disabled.
47
+ 4. Restart only if the UI asks you to: fully exit with **Quit** in the application menu, then reopen the app. Closing a window may only hide it.
48
+
49
+ Once enabled, find **子代理库 (Subagent Library)** in Settings; the top of the page shows entry counts and the roster directory.
50
+
51
+ <details>
52
+ <summary>Alternative: use the desktop-bundled CLI (Windows / macOS)</summary>
53
+
54
+ Start the desktop client once to initialize it. In the application menu, open **Manage dsh Command…** → **Install** to register its bundled `dsh` command, then open a new terminal. If the UI reports a PATH conflict, follow its instructions first.
55
+
56
+ Fully exit the desktop client with **Quit**, then use the newly registered desktop-bundled CLI:
57
+
58
+ ```sh
59
+ dsh plugin --profile desktop add dsh-subagent-library@latest
60
+ dsh plugin --profile desktop list
61
+ ```
62
+
63
+ Reopen the desktop client afterwards. An npm-installed `dsh` or `npx` cannot manage the `desktop` profile. See the [official desktop command documentation](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-rc.2/apps/desktop/README.md#bundled-command-runtime).
64
+
65
+ </details>
66
+
67
+ ### Web
68
+
69
+ These commands manage Web plugins only. Use the same `dsh` CLI that starts your Web instance, matching that host's version, to install the stable release from npm:
70
+
71
+ ```sh
72
+ dsh plugin --profile web add dsh-subagent-library@latest
73
+ ```
74
+
75
+ After installation, stop the running `dsh web` process, start `dsh web` again with the same CLI, and refresh the page.
76
+
77
+ Other install sources:
78
+
79
+ ```sh
80
+ # From GitHub (lib/ build artifacts are committed; no local build needed)
81
+ dsh plugin --profile web add github:MaRi23333/dsh-subagent-library
82
+
83
+ # From a local checkout
84
+ git clone https://github.com/MaRi23333/dsh-subagent-library.git
85
+ cd dsh-subagent-library
86
+ pnpm install && pnpm run build
87
+ dsh plugin --profile web add /absolute/path/to/dsh-subagent-library
88
+ ```
89
+
90
+ > The repo commits `lib/` build artifacts, so git installs need no local build; after
91
+ > changing sources run `pnpm run build` and restart Web.
92
+ > Roster edits (files under `~/.dsh/subagents/`) are **hot-reloaded** — no restart.
93
+ >
94
+ > **Switching channels** — if you previously installed from GitHub or a local checkout and want npm-release upgrades, re-add with `dsh plugin --profile web add dsh-subagent-library@latest` to force the latest npm version.
95
+
96
+ ## Your first delegation
97
+
98
+ Start with a main conversation whose model already replies normally. This example uses that session's model to reorganize supplied text; it needs no separate provider setup or file/web tools. The settings UI currently uses Chinese labels; their English meanings are given below.
99
+
100
+ ### 1. Create a minimal role
101
+
102
+ Without existing roster files or legacy configuration, the roster starts empty. The plugin does not add sample roles automatically.
103
+
104
+ 1. Open **Settings → 子代理库 (Subagent Library)**. An empty roster shows the creation form immediately; otherwise click **+ 新增子代理 (Add subagent)**.
105
+ 2. Set **ID** to `text-helper` and **描述(模型可见) (Description, visible to the model)** to `Organize short text supplied by the main conversation.` If that ID already exists, choose an unused one and replace it in the example below too.
106
+ 3. Leave **模型 (Model), Provider, 角色提示词 (Role prompt), 禁用工具 (Denied tools), and the other optional fields blank**. Keep **后台模式 (Background mode)** at `one-shot`, then click **创建子代理 (Create subagent)**. This button saves immediately and enables the new entry; no second save is needed.
107
+
108
+ ### 2. Ask the main agent to list and delegate
109
+
110
+ Back in the main conversation, send:
111
+
112
+ ```text
113
+ Call list_subagents first and confirm that text-helper is available. Then use delegate to give it this task in the foreground:
114
+ Turn "apple, banana, pear" into a numbered list, keeping that order. Use only this text and do not call other tools.
115
+ Pass the subagent's result back to me.
116
+ ```
117
+
118
+ Look for `text-helper` in the `list_subagents` result, followed by a `delegate` call returning the child's numbered list. A direct answer from the main agent without a delegation call does not confirm that this flow worked. `/subagent` can display the roster, but does not perform the delegation.
119
+
120
+ Delegation still calls the model service. "Do not call other tools" is a task instruction; the host controls tool permissions. Per-entry `toolFilter` is unavailable on DSH 0.2.1, and a role name or prompt does not guarantee read-only access. See the [configuration limitations](#configuration).
121
+
122
+ ### 3. If it does not work
123
+
124
+ - **Entry missing:** confirm you clicked **创建子代理 (Create subagent)**, then use **刷新 (Refresh)** in Settings and check diagnostics. If the entry is disabled, switch it to **已启用 (Enabled)** and save.
125
+ - **Tools missing:** confirm the plugin is enabled in the desktop or Web instance you are using, then check tool availability for the current conversation.
126
+ - **Model startup fails:** first check that the main conversation can reply; leave both Provider and Model blank on the entry. Gray placeholder examples are not your configured routes. Follow the actual error for service authentication or quota issues.
127
+
128
+ <details>
129
+ <summary>Optional: create the same minimal role with YAML</summary>
130
+
131
+ Use either this file method or the UI steps above. Create `text-helper.yaml` in the roster directory shown in Settings (create the directory if needed; do not overwrite an existing entry):
132
+
133
+ ```yaml
134
+ description: Organize short text supplied by the main conversation.
135
+ ```
136
+
137
+ The filename supplies the ID. Omitting the other fields keeps the entry enabled and uses the session's model. Changes take effect without a restart. See [Configuration](#configuration) for more fields.
138
+
139
+ </details>
140
+
30
141
  ## Screenshots
31
142
 
32
143
  <p align="center">
@@ -44,6 +155,36 @@ Adding entries needs no hand-written config either: ask the main agent to do it,
44
155
  <em>Roster output example: one-line role description + model route + continuable marker per entry</em>
45
156
  </p>
46
157
 
158
+ ## Settings page
159
+
160
+ A **子代理库 (Subagent Library)** page appears under Settings. **Each entry is a card, closed by
161
+ default**; click its name to open the editor.
162
+
163
+ - **Layered cards** separate the name and enable switch, a description of up to two lines,
164
+ the model and provider, and a wrapping group of execution settings. Long names and model
165
+ routes wrap without squeezing the description or hiding the switch.
166
+ - A **summary band** stays at the top of the page: entry / enabled / disabled / unsaved counts
167
+ plus the roster directory.
168
+ - A **filter box** matches id, description, model and more; Expand/collapse all helps in a long
169
+ roster.
170
+ - **Expanded**, fields are grouped as Overview (description) / Routing & execution (provider,
171
+ model, transport, background mode, reasoning effort, depth, output cap) / Tools & prompt
172
+ (denied tools, persona), with Revert / Delete / Save at the bottom. Fields use two columns
173
+ in wider panels and one in narrow panels, with host light/dark themes and keyboard support.
174
+ - Toggling enable state creates a draft. The collapsed card exposes an unsaved badge and
175
+ Revert / Save changes; the setting takes effect only after saving. Saving one entry does
176
+ not submit other drafts, and Revert restores the entire saved entry.
177
+ - Disabled entries appear last; entries marked as legacy are promoted to files on save.
178
+ Storage and backup details are available in a disclosure at the bottom of the page.
179
+
180
+ Saved changes are written back to `<id>.yaml` in the roster directory and hot-reloaded.
181
+
182
+ > **Security note:** the roster settings endpoint (`/subagent-library/api`) follows the
183
+ > DSH Web Host's local trust boundary — the plugin itself adds no separate authentication
184
+ > layer. If you bind DSH Web to a LAN, the public internet, or a reverse proxy, put proper
185
+ > authentication and access control in front of it; do not expose this endpoint to
186
+ > untrusted clients — subagent personas and configuration may contain internal working rules.
187
+
47
188
  ## Configuration
48
189
 
49
190
  Since 0.3 the roster is a directory with **one file per named subagent** (hot-reloaded, no restart needed):
@@ -85,17 +226,17 @@ subagent-library:
85
226
  One entry file (`k3-reviewer.yaml`):
86
227
 
87
228
  ```yaml
88
- description: Independent read-only review on Kimi K3-256K, with image walkthroughs
229
+ description: Code review on Kimi K3-256K, with image walkthroughs
89
230
  provider: kimi-coding
90
231
  model: k3-256k
91
232
  persona: |
92
233
  You are an independent review agent running on Kimi K3-256K…
93
- toolFilter:
94
- deny: [write, edit, todo_write, create_goal, update_goal, subagent, subagent_fork, send_message, interrupt_agent, workflow, ralph, list_subagents, delegate]
95
234
  maxDepth: 1
96
235
  backgroundMode: continuable
97
236
  ```
98
237
 
238
+ > **DSH 0.2.1-series limitations:** the role prompt is sent in the first task message, not enforced as a system-level permission boundary. Per-entry `toolFilter` is unavailable, and entries containing it are refused. The example above therefore omits tool filtering and **does not guarantee read-only access**. Configure the required permissions in the host for read-only or tool-isolated work; a role name or prompt alone is not enough. The field table below also covers older hosts.
239
+
99
240
  Entry fields:
100
241
 
101
242
  | Field | Required | Notes |
@@ -107,8 +248,8 @@ Entry fields:
107
248
  | `reasoningEffort` | no | Thinking effort: adapter-owned id (e.g. `max` / `high` / `medium` / `low`); empty follows the parent session default. Rides the official `agentOptions.reasoningEffort` override; when the child model route differs, the harness auto-drops the inherited effort, so unset values never leak across models. Only id-shaped values (alphanumerics and `._-`) are accepted; anything else is rejected on save |
108
249
  | `subagentProvider` | no | **Subagent transport** (a `ctx.subagents` provider such as `spawn`); defaults to the plugin-level default `spawn` |
109
250
  | `maxTokens` | no | Subagent output cap |
110
- | `persona` | no | Subagent system prompt. Personas go through strict `{{…}}` template interpolation (same semantics as deployment personas) — an unregistered variable (e.g. `{{user}}`) fails child activation |
111
- | `toolFilter` | no | `allow`/`deny` tool-name lists (deny write-class tools for read-only roles). **Read-only/restricted roles should also deny `list_subagents`/`delegate`** so children are not taught by the global prompt to re-delegate in a chain. Names are resolved against the **calling session's restrictable set** at delegation (not "visibility"): names that session cannot apply are ignored and annotated with the reason (`本会话不存在` / `本会话专属工具`) in the delegate result and the `list_subagents` catalog — one shared entry never fails a whole delegation because a session lacks a tool. **An `allow` list that no name applies to refuses the delegation** (otherwise "keep only these" would silently become "keep nothing"). Registries without `view()` fall back to visibility, where scope-local names still make delegation fail loudly. Saves are not pre-validated |
251
+ | `persona` | no | Subagent role prompt. **DSH ≤0.2.0 hosts**: deployed as a system persona with strict `{{…}}` template interpolation (same semantics as deployment personas) — an unregistered variable (e.g. `{{user}}`) fails child activation. **DSH ≥0.2.1 hosts**: the start request has no persona field; the role is folded into the first task message under a `Role persona:` prefix — effective for the first turn, does NOT shadow a deployment persona, is not guaranteed to survive continuation turns or context compaction, and `{{…}}` is no longer interpolated (raw concatenation). A standalone `agentPreset` is deliberately not used to carry the role: an independent preset replaces the parent preset composition and drops the parent session's tools |
252
+ | `toolFilter` | no | `allow`/`deny` tool-name lists (deny write-class tools for read-only roles). **Read-only/restricted roles should also deny `list_subagents`/`delegate`** so children are not taught by the global prompt to re-delegate in a chain. Names are resolved against the **calling session's restrictable set** at delegation (not "visibility"): names that session cannot apply are ignored and annotated with the reason (`本会话不存在` / `本会话专属工具`) in the delegate result and the `list_subagents` catalog — one shared entry never fails a whole delegation because a session lacks a tool. **An `allow` list that no name applies to refuses the delegation** (otherwise "keep only these" would silently become "keep nothing"). Registries without `view()` fall back to visibility, where scope-local names still make delegation fail loudly. Saves are not pre-validated. **DSH ≥0.2.1 hosts cannot enforce per-entry tool filters**: entries carrying `toolFilter` are refused at delegate time (marked undelegable in the catalog, warned at save time); such entries only work on ≤0.2.0 hosts |
112
253
  | `maxDepth` | no | Delegation depth cap; **when unset, defaults to 3 when the transport supports depthLimit** (aligned with the official subagent tool to prevent chained recursive delegation; the harness itself has no global depth cap). Transports without depthLimit stay uncapped |
113
254
  | `backgroundMode` | no | `one-shot` (default, omitted in files) / `continuable` (resumable) |
114
255
  | `enabled` | no | Write `enabled: false` to disable an entry (it stays visible in the directory and the settings page; `delegate` refuses it); omit or set `true` to enable |
@@ -122,73 +263,6 @@ The 0.2.8 legacy `entries` fallback is for DSH ≤0.1.6 only; on DSH ≥0.1.7 th
122
263
  > Mind the two provider concepts: `provider` is the LLM route (`agentOptions.provider`),
123
264
  > while `subagentProvider` is the subagent transport (`ctx.subagents` registration name, e.g. `spawn`/`fork`/`acp`).
124
265
 
125
- ## Host and desktop compatibility
126
-
127
- `0.3.1` adapts to the SettingsForms mechanism introduced in DSH `0.1.7-rc.2`. On 2026-09-30, the development team additionally reported it working with DSH `0.2.0-rc.2` and the desktop client of the same version. The roster retains the 0.3 series directory-backed storage and migration rules; this documentation update does not migrate data again.
128
-
129
- **0.3.2** adds English and Chinese names and descriptions to the plugin manager, following the client language. Roster and delegation behavior are unchanged. See [CHANGELOG.md](./CHANGELOG.md) for update notes.
130
-
131
- The desktop client uses the Web plugin UI, so no separate desktop-specific package is needed. This compatibility statement reflects maintainer usage feedback. Online model calls still depend on each provider's configuration and service; a working settings page does not establish acceptance of every model or cross-platform scenario.
132
-
133
- ## Install
134
-
135
- One command, from npm (recommended):
136
-
137
- ```sh
138
- npx @deepseek-ai/dsh plugin --profile web add dsh-subagent-library
139
- ```
140
-
141
- Then **restart `dsh web`** (stop the process, run `dsh web` again) and refresh the page.
142
-
143
- Other install sources:
144
-
145
- ```sh
146
- # From GitHub (git-hosted plugin; lib/ build artifacts are committed, no local build needed)
147
- npx @deepseek-ai/dsh plugin --profile web add github:MaRi23333/dsh-subagent-library
148
-
149
- # From a local checkout
150
- git clone https://github.com/MaRi23333/dsh-subagent-library.git
151
- cd dsh-subagent-library
152
- pnpm install && pnpm run build
153
- npx @deepseek-ai/dsh plugin --profile web add /absolute/path/to/dsh-subagent-library
154
- ```
155
-
156
- > The repo commits `lib/` build artifacts, so git installs need no local build; after
157
- > changing sources run `pnpm run build` and restart.
158
- > Roster edits (files under `~/.dsh/subagents/`) are **hot-reloaded** — no restart.
159
- >
160
- > **Switching channels** — if you previously installed from GitHub or a local checkout and want npm-release upgrades, re-add with `npx @deepseek-ai/dsh plugin --profile web add dsh-subagent-library@latest` to force the latest npm version.
161
-
162
- ## Settings page
163
-
164
- A **Subagent Library** page appears under Settings. **Each entry is a card, closed by
165
- default**; click its name to open the editor.
166
-
167
- - **Layered cards** separate the name and enable switch, a description of up to two lines,
168
- the model and provider, and a wrapping group of execution settings. Long names and model
169
- routes wrap without squeezing the description or hiding the switch.
170
- - A **summary band** stays at the top of the page: entry / enabled / disabled / unsaved counts
171
- plus the roster directory.
172
- - A **filter box** matches id, description, model and more; Expand/collapse all helps in a long
173
- roster.
174
- - **Expanded**, fields are grouped as Overview (description) / Routing & execution (provider,
175
- model, transport, background mode, reasoning effort, depth, output cap) / Tools & prompt
176
- (denied tools, persona), with Revert / Delete / Save at the bottom. Fields use two columns
177
- in wider panels and one in narrow panels, with host light/dark themes and keyboard support.
178
- - Toggling enable state creates a draft. The collapsed card exposes an unsaved badge and
179
- Revert / Save changes; the setting takes effect only after saving. Saving one entry does
180
- not submit other drafts, and Revert restores the entire saved entry.
181
- - Disabled entries appear last; entries marked as legacy are promoted to files on save.
182
- Storage and backup details are available in a disclosure at the bottom of the page.
183
-
184
- Saved changes are written back to `<id>.yaml` in the roster directory and hot-reloaded.
185
-
186
- > **Security note:** the roster settings endpoint (`/subagent-library/api`) follows the
187
- > DSH Web Host's local trust boundary — the plugin itself adds no separate authentication
188
- > layer. If you bind DSH Web to a LAN, the public internet, or a reverse proxy, put proper
189
- > authentication and access control in front of it; do not expose this endpoint to
190
- > untrusted clients — subagent personas and configuration may contain internal working rules.
191
-
192
266
  ## Design notes
193
267
 
194
268
  - Tools register on the **host plane**: no dependency on any agent preset, and switching presets never loses them;
package/README.md CHANGED
@@ -9,19 +9,19 @@
9
9
  <p align="center">
10
10
  <img src="https://img.shields.io/github/actions/workflow/status/MaRi23333/dsh-subagent-library/ci.yml?style=flat-square&label=CI" alt="CI" />
11
11
  <img src="https://img.shields.io/github/license/MaRi23333/dsh-subagent-library?style=flat-square" alt="License: MIT" />
12
- <img src="https://img.shields.io/badge/DeepSeek%20Harness-0.2.0--rc.2-4d6bfe?style=flat-square" alt="DeepSeek Harness 0.2.0-rc.2" />
12
+ <img src="https://img.shields.io/badge/DeepSeek%20Harness-0.2.1--rc.2-4d6bfe?style=flat-square" alt="DeepSeek Harness 0.2.1-rc.2" />
13
13
  </p>
14
14
 
15
15
  > **English:** dsh-subagent-library is a named subagent roster plugin for the
16
- > [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Web GUI —
17
- > manage role entries (model / persona / tool filter / depth / background mode)
16
+ > [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) desktop and Web interfaces —
17
+ > manage role entries (model / role prompt / depth / background mode)
18
18
  > from a settings page, hot-reloaded, then let any conversation pick one with
19
19
  > `list_subagents` and dispatch work with `delegate`. See
20
20
  > [README.en.md](./README.en.md) for the full English version.
21
21
 
22
22
  ## 简介
23
23
 
24
- DeepSeek Harness 的具名子代理库插件:把常用角色(代码审查、红队、多模态理解……)配成一份持久化的具名子代理名册(模型 + persona + 工具过滤),之后**只需告诉主会话 agent「用 xxx 做这件事」**——模型自己通过两个工具完成选人和派活:
24
+ DeepSeek Harness 的具名子代理库插件:把常用角色(代码审查、红队、多模态理解……)配成一份持久化的具名子代理名册(模型、角色提示词、深度与后台模式),之后**只需告诉主会话 agent「用 xxx 做这件事」**——模型自己通过两个工具完成选人和派活:
25
25
 
26
26
  - `list_subagents` — 列出名册条目(id / 角色描述 / 模型),模型据此挑选;
27
27
  - `delegate` — 按 `library_id` 派活:前台等待、后台 one-shot 任务、或 continuable 可续聊子代理(按条目配置)。
@@ -34,6 +34,116 @@ DeepSeek Harness 的具名子代理库插件:把常用角色(代码审查、
34
34
 
35
35
  > **从 0.2.x 升级?** 0.3 起名册目录化(一个子代理一个 YAML 文件),旧配置**自动迁移**;确认无误后可按宿主版本清除旧 `entries` 段。配置位置、失败重试和回滚边界见 [MIGRATION.md](./MIGRATION.md),完整变更见 [CHANGELOG.md](./CHANGELOG.md)。
36
36
 
37
+ [安装](#安装) · [第一次委派](#第一次委派) · [配置参考](#配置)
38
+
39
+ ## 宿主与桌面端兼容
40
+
41
+ **0.3.5 对齐 DSH `0.2.1-rc.2`**:修复可续聊子代理与一次性委派无法启动,以及后台任务取消未能停止子代理的问题。前台一次性、可续聊、后台启动及运行中取消已在该版桌面宿主中复验。角色提示词与工具过滤的限制见[配置](#配置),完整变化见 [CHANGELOG.md](./CHANGELOG.md)。
42
+
43
+ 桌面客户端沿用 Web 插件界面,无需另装桌面专用包。旧宿主的启动分支仍保留,但本轮实际运行验证以 `0.2.1-rc.2` 为准;模型调用仍取决于各 Provider 的配置与服务。名册目录、profile 路由和迁移规则不变,无需重新迁移。
44
+
45
+ ## 安装
46
+
47
+ ### 桌面客户端(推荐)
48
+
49
+ 桌面客户端与 Web 的插件安装和启用状态各自独立;在 Web 安装不会自动在桌面端启用。桌面图形界面安装无需配置 PATH。
50
+
51
+ 1. 打开桌面客户端,进入侧栏 **插件(Plugins)** → **添加插件(Add plugin)**。
52
+ 2. 输入 npm 包名 `dsh-subagent-library@latest` 并安装。
53
+ 3. 安装完成后点击 **立即启用(Enable now)**;只关闭安装完成对话框会让插件保持停用。
54
+ 4. 仅在界面提示需要重启时,通过应用菜单 **退出(Quit)** 完整退出再重开。关闭窗口可能只是隐藏应用。
55
+
56
+ 启用后可在设置中找到 **子代理库** 页面;页面顶部显示条目计数和名册目录。
57
+
58
+ <details>
59
+ <summary>备用:使用桌面随附 CLI(Windows / macOS)</summary>
60
+
61
+ 先启动桌面客户端一次以完成初始化。在应用菜单打开 **Manage dsh Command…** → **Install**,注册桌面随附的 `dsh` 命令,再打开新终端;若界面报告 PATH 冲突,先按其提示处理。
62
+
63
+ 通过 **Quit** 完整退出桌面客户端后,使用刚注册的桌面随附 CLI:
64
+
65
+ ```sh
66
+ dsh plugin --profile desktop add dsh-subagent-library@latest
67
+ dsh plugin --profile desktop list
68
+ ```
69
+
70
+ 完成后重开桌面客户端。npm 安装的 `dsh` 和 `npx` 不能管理 `desktop` profile。命令注册说明见[官方桌面文档](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-rc.2/apps/desktop/README.md#bundled-command-runtime)。
71
+
72
+ </details>
73
+
74
+ ### Web
75
+
76
+ 以下命令只管理 Web 的插件。使用启动该 Web 实例的同一套、与宿主版本匹配的 `dsh` CLI,从 npm 安装稳定版本:
77
+
78
+ ```sh
79
+ dsh plugin --profile web add dsh-subagent-library@latest
80
+ ```
81
+
82
+ 安装后停止当前 `dsh web` 进程,用同一套 CLI 重新运行 `dsh web`,再刷新页面。
83
+
84
+ 其他安装来源:
85
+
86
+ ```sh
87
+ # 从 GitHub 安装(仓库已提交 lib/ 构建产物,安装无需本地构建)
88
+ dsh plugin --profile web add github:MaRi23333/dsh-subagent-library
89
+
90
+ # 从本地目录安装
91
+ git clone https://github.com/MaRi23333/dsh-subagent-library.git
92
+ cd dsh-subagent-library
93
+ pnpm install && pnpm run build
94
+ dsh plugin --profile web add /absolute/path/to/dsh-subagent-library
95
+ ```
96
+
97
+ > 仓库已提交 `lib/` 构建产物,git 安装无需本地构建;改源码后运行 `pnpm run build` 再重启 Web。
98
+ > 名册(`~/.dsh/subagents/` 下的条目文件)**热生效**,无需重启。
99
+ >
100
+ > **渠道切换**:之前从 GitHub / 本地目录安装、现在想跟随 npm 发布升级时,用 `dsh plugin --profile web add dsh-subagent-library@latest` 显式取 npm 最新版。
101
+
102
+ ## 第一次委派
103
+
104
+ 先确认当前主会话能正常与模型对话。本例沿用该会话的模型,只整理一段给定文字,无需另外配置 Provider 或文件、网页工具。
105
+
106
+ ### 1. 创建最小角色
107
+
108
+ 没有已有名册或旧配置时,列表为空,插件不会自动添加示例角色。
109
+
110
+ 1. 打开 **设置 → 子代理库**。空库会直接显示新增表单;已有条目时点击 **+ 新增子代理**。
111
+ 2. 填写 **ID** 为 `text-helper`,**描述(模型可见)** 为 `整理主会话提供的短文本。`。若该 ID 已存在,换一个未使用的 ID,并同步替换下文示例。
112
+ 3. **模型、Provider、角色提示词、禁用工具及其他选填项留空**,**后台模式**保持 `one-shot`,点击 **创建子代理**。这个按钮会直接保存,新条目默认启用,无需再点一次保存。
113
+
114
+ ### 2. 让主会话列出并委派
115
+
116
+ 回到主会话,发送:
117
+
118
+ ```text
119
+ 请先调用 list_subagents,确认有 text-helper;然后用 delegate 以前台方式将任务交给它:
120
+ 把“苹果、香蕉、梨”按原顺序改成编号列表。只处理这段文字,不调用其他工具。
121
+ 拿到子代理结果后转给我。
122
+ ```
123
+
124
+ 应看到 `list_subagents` 返回 `text-helper`,随后有一次 `delegate` 调用并返回子代理的编号列表。只有主会话直接回答、没有委派调用,还不能确认流程已经走通。`/subagent` 可以查看名册,但不会代替这次委派。
125
+
126
+ 这次委派仍会调用模型服务;“不调用其他工具”是任务要求,工具权限由宿主控制。DSH 0.2.1 的逐条目 `toolFilter` 暂不可用,角色名或提示词也不是只读权限保证,详见[配置中的限制](#配置)。
127
+
128
+ ### 3. 没走通时先看这几处
129
+
130
+ - **找不到条目**:确认已点“创建子代理”,在设置页点击“刷新”并检查诊断。若条目已停用,切为“已启用”后保存。
131
+ - **没有这两个工具**:确认插件在当前桌面或 Web 实例中启用,再检查当前会话的工具可用设置。
132
+ - **模型启动失败**:先确认主会话能正常回复;角色的 Provider 与模型均留空。不要把输入框里的灰色示例当成自己的路由;服务端鉴权、额度等错误按实际报错处理。
133
+
134
+ <details>
135
+ <summary>可选:用 YAML 创建同一个最小角色</summary>
136
+
137
+ 文件方式和上面的界面方式二选一。在设置页显示的名册目录里新建 `text-helper.yaml`(目录不存在时先创建;不要覆盖已有同名条目):
138
+
139
+ ```yaml
140
+ description: 整理主会话提供的短文本。
141
+ ```
142
+
143
+ ID 来自文件名;其他字段省略即可继承会话模型并默认启用。保存后热生效,无需重启。更多字段见[配置](#配置)。
144
+
145
+ </details>
146
+
37
147
  ## 界面
38
148
 
39
149
  <p align="center">
@@ -51,6 +161,21 @@ DeepSeek Harness 的具名子代理库插件:把常用角色(代码审查、
51
161
  <em>名册输出示例:每个条目一句话角色描述 + 模型路由 + 可续聊标记</em>
52
162
  </p>
53
163
 
164
+ ## 设置页
165
+
166
+ 打开 **设置 → 子代理库**:**每个条目是一张默认收起的卡片**,点击名称展开编辑。
167
+
168
+ - **分层卡片**:名称与启用开关位于首行,角色描述独占一段(最多两行),模型与 Provider 单独展示;可续聊、思考强度、深度、输出上限、角色提示词与工具限制统一排在下方。长名称和模型路由自动换行,标签不再挤占描述空间。
169
+ - **摘要带**常驻页面顶部:条目 / 启用 / 已停用 / 未保存计数 + 名册目录。
170
+ - **筛选框**匹配 id、描述、模型等,配合 全部展开 / 收起 在长名册里定位。
171
+ - **展开后**字段分组为「概述 / 路由与执行 / 工具与提示词」,宽面板两列、窄面板单列;底部是 还原 / 删除 / 保存。界面随宿主切换明暗主题,并支持键盘操作。
172
+ - 开关修改先保留为草稿:折叠卡片上会出现「未保存」提示和「还原 / 保存修改」,保存后才生效。保存一个条目不会提交其他条目的草稿;还原会完整恢复该条目的已保存配置。
173
+ - 停用条目在列表末尾显示;带「旧版条目」徽标的条目保存时自动晋升为文件。页面底部可展开存储与备份说明。
174
+
175
+ 保存后的改动写回名册目录下的 `<id>.yaml`,热生效。
176
+
177
+ > **安全提示**:子代理库的设置接口(`/subagent-library/api`)遵循 DSH Web Host 的本地可信边界,插件自身不含独立身份验证层。若将 DSH Web 绑定到局域网 / 公网 / 反向代理,请在外层配置认证与访问控制,不要把该接口暴露给不可信客户端——子代理 persona 与配置可能包含内部工作规则。
178
+
54
179
  ## 配置
55
180
 
56
181
  0.3 起,名册是一个目录,**一个具名子代理一个文件**(热生效,无需重启):
@@ -90,17 +215,17 @@ subagent-library:
90
215
  单个条目文件(`k3-reviewer.yaml`):
91
216
 
92
217
  ```yaml
93
- description: Kimi K3-256K 独立只读审核,支持图片视觉走查
218
+ description: Kimi K3-256K 代码审查,支持图片视觉走查
94
219
  provider: kimi-coding
95
220
  model: k3-256k
96
221
  persona: |
97
222
  你是运行在 Kimi K3-256K 上的独立审核 agent……
98
- toolFilter:
99
- deny: [write, edit, todo_write, create_goal, update_goal, subagent, subagent_fork, send_message, interrupt_agent, workflow, ralph, list_subagents, delegate]
100
223
  maxDepth: 1
101
224
  backgroundMode: continuable
102
225
  ```
103
226
 
227
+ > **DSH 0.2.1 系列的限制**:角色提示词随首条任务消息发送,不是系统级权限约束;逐条目 `toolFilter` 暂不可用,含该字段的条目会拒绝委派。上面的示例因此不含工具过滤,**不保证只读**。有只读或工具隔离需求时,应先在宿主中配置相应权限,不能只靠角色名称或提示词。旧宿主的字段行为见下表。
228
+
104
229
  条目字段:
105
230
 
106
231
  | 字段 | 必填 | 说明 |
@@ -112,8 +237,8 @@ backgroundMode: continuable
112
237
  | `reasoningEffort` | 否 | 思考强度:适配器自有值(如 `max` / `high` / `medium` / `low`),留空随父会话默认。走官方 `agentOptions.reasoningEffort` 覆盖通道;子代理换了模型路由时官方会自动丢弃继承值,未显式设置不会跨模型泄漏。只接受 id 形态(字母数字与 `._-`),其他值保存时被拒绝 |
113
238
  | `subagentProvider` | 否 | **子代理传输层**(`spawn` 等 `ctx.subagents` provider);默认取插件级默认 `spawn` |
114
239
  | `maxTokens` | 否 | 子代理输出上限 |
115
- | `persona` | 否 | 子代理角色提示词。注意 persona 走严格的 `{{…}}` 模板插值(与部署 persona 同语义)——出现未注册的变量(如 `{{user}}`)会让子代理激活失败 |
116
- | `toolFilter` | 否 | `allow`/`deny` 工具名单(只读角色用 deny 禁写类工具)。**只读/受限角色建议把 `list_subagents`/`delegate` 也列入 deny**,防止子代理被全局提示词教去链式再派活。名单在**委派时按调用方会话的可限制集合**解析(不是"可见"):不可应用的名字被忽略,并在派活结果与 `list_subagents` 目录里标注原因(`本会话不存在` / `本会话专属工具`)——共享条目不会因为某个会话缺该工具而整次派活失败。**`allow` 名单若在本会话全部不可应用则拒绝委派**(否则"只留这些"会变成"什么都不留")。旧注册表无 `view()` 时退回可见性判定,此时 scope-local 名仍会让委派明确报错。保存阶段不做校验 |
240
+ | `persona` | 否 | 子代理角色提示词。**DSH ≤0.2.0 宿主**:作为系统 persona 部署,走严格的 `{{…}}` 模板插值(与部署 persona 同语义)——出现未注册的变量(如 `{{user}}`)会让子代理激活失败。**DSH ≥0.2.1 宿主**:启动请求已无 persona 字段,角色以 `Role persona:` 前缀折叠进首条任务消息——首轮生效,但不遮蔽部署 persona;续聊回合与上下文压缩后不保证角色仍在;`{{…}}` 不再插值(原文拼接)。不采用独立 `agentPreset` 承载角色:独立 preset 会替换父 preset 组合、丢掉父会话工具 |
241
+ | `toolFilter` | 否 | `allow`/`deny` 工具名单(只读角色用 deny 禁写类工具)。**只读/受限角色建议把 `list_subagents`/`delegate` 也列入 deny**,防止子代理被全局提示词教去链式再派活。名单在**委派时按调用方会话的可限制集合**解析(不是"可见"):不可应用的名字被忽略,并在派活结果与 `list_subagents` 目录里标注原因(`本会话不存在` / `本会话专属工具`)——共享条目不会因为某个会话缺该工具而整次派活失败。**`allow` 名单若在本会话全部不可应用则拒绝委派**(否则"只留这些"会变成"什么都不留")。旧注册表无 `view()` 时退回可见性判定,此时 scope-local 名仍会让委派明确报错。保存阶段不做校验。**DSH ≥0.2.1 宿主无法强制执行逐条目工具过滤**:带 `toolFilter` 的条目会被委派直接拒绝(目录标注「无法强制执行」,保存时附警告);这类条目只适用于 ≤0.2.0 宿主 |
117
242
  | `maxDepth` | 否 | 委派深度上限;**缺省 = 传输层支持 depthLimit 时默认 3**(与官方 subagent 工具对齐,防链式递归派活;harness 自身无全局深度上限),不支持 depthLimit 的传输层则不设上限 |
118
243
  | `backgroundMode` | 否 | `one-shot`(默认,文件中省略)/ `continuable`(可续聊) |
119
244
  | `enabled` | 否 | 文件内写 `enabled: false` 停用该条目(目录与设置页仍可见,`delegate` 拒绝派活);省略或 `true` 为启用 |
@@ -127,57 +252,6 @@ backgroundMode: continuable
127
252
  > 注意区分两个 provider 概念:`provider` 指 LLM 路由(`agentOptions.provider`),
128
253
  > `subagentProvider` 指子代理传输层(`ctx.subagents` 注册名,如 `spawn`/`fork`/`acp`)。
129
254
 
130
- ## 宿主与桌面端兼容
131
-
132
- `0.3.1` 已适配 DSH `0.1.7-rc.2` 引入的 SettingsForms 设置机制;开发侧于 2026-09-30 进一步报告,它在 DSH `0.2.0-rc.2` 与同版本桌面客户端中可用。名册仍采用 0.3 系列的目录化存储与原有迁移规则,没有因本次说明更新再次迁移数据。
133
-
134
- **0.3.2** 为插件管理页增加随客户端语言切换的中英文名称与简介,名册和委派行为不变。更新说明见 [CHANGELOG.md](./CHANGELOG.md)。
135
-
136
- 桌面客户端沿用 Web 插件界面,无需另装桌面专用包。该兼容说明依据维护者使用反馈;模型在线调用仍取决于各 Provider 的配置与服务,不能由设置页可用推断全部模型或跨平台场景已验收。
137
-
138
- ## 安装
139
-
140
- 一条命令,从 npm 安装(推荐):
141
-
142
- ```sh
143
- npx @deepseek-ai/dsh plugin --profile web add dsh-subagent-library
144
- ```
145
-
146
- 然后**重启 dsh web**(关掉终端重新运行 `dsh web`)并刷新页面。
147
-
148
- 其他安装方式:
149
-
150
- ```sh
151
- # 从 GitHub 安装(git-hosted 插件;仓库已提交 lib/ 构建产物,安装无需本地构建)
152
- npx @deepseek-ai/dsh plugin --profile web add github:MaRi23333/dsh-subagent-library
153
-
154
- # 从本地目录安装
155
- git clone https://github.com/MaRi23333/dsh-subagent-library.git
156
- cd dsh-subagent-library
157
- pnpm install && pnpm run build
158
- npx @deepseek-ai/dsh plugin --profile web add /absolute/path/to/dsh-subagent-library
159
- ```
160
-
161
- > 仓库已提交 `lib/` 构建产物,git 安装无需本地构建;改源码后运行 `pnpm run build` 再重启即可。
162
- > 名册(`~/.dsh/subagents/` 下的条目文件)**热生效**,无需重启。
163
- >
164
- > **渠道切换**:之前从 GitHub / 本地目录安装、现在想跟随 npm 发布升级时,用 `npx @deepseek-ai/dsh plugin --profile web add dsh-subagent-library@latest` 显式取 npm 最新版。
165
-
166
- ## 设置页
167
-
168
- Settings → 设置 里新增「子代理库」页面:**每个条目是一张默认收起的卡片**,点击名称展开编辑。
169
-
170
- - **分层卡片**:名称与启用开关位于首行,角色描述独占一段(最多两行),模型与 Provider 单独展示;可续聊、思考强度、深度、输出上限、角色提示词与工具限制统一排在下方。长名称和模型路由自动换行,标签不再挤占描述空间。
171
- - **摘要带**常驻页面顶部:条目 / 启用 / 已停用 / 未保存计数 + 名册目录。
172
- - **筛选框**匹配 id、描述、模型等,配合 全部展开 / 收起 在长名册里定位。
173
- - **展开后**字段分组为「概述 / 路由与执行 / 工具与提示词」,宽面板两列、窄面板单列;底部是 还原 / 删除 / 保存。界面随宿主切换明暗主题,并支持键盘操作。
174
- - 开关修改先保留为草稿:折叠卡片上会出现「未保存」提示和「还原 / 保存修改」,保存后才生效。保存一个条目不会提交其他条目的草稿;还原会完整恢复该条目的已保存配置。
175
- - 停用条目在列表末尾显示;带「旧版条目」徽标的条目保存时自动晋升为文件。页面底部可展开存储与备份说明。
176
-
177
- 保存后的改动写回名册目录下的 `<id>.yaml`,热生效。
178
-
179
- > **安全提示**:子代理库的设置接口(`/subagent-library/api`)遵循 DSH Web Host 的本地可信边界,插件自身不含独立身份验证层。若将 DSH Web 绑定到局域网 / 公网 / 反向代理,请在外层配置认证与访问控制,不要把该接口暴露给不可信客户端——子代理 persona 与配置可能包含内部工作规则。
180
-
181
255
  ## 设计说明
182
256
 
183
257
  - 工具注册在 **host 平面**:不依赖任何 agent preset,切 preset 不会丢;
@@ -27,7 +27,7 @@
27
27
  <text x="248" y="192" font-family="'Segoe UI', 'Microsoft YaHei', system-ui, sans-serif"
28
28
  font-size="23" fill="#3d4468">DeepSeek Harness 具名子代理库 · 设置页可视化管理</text>
29
29
  <text x="248" y="228" font-family="'Segoe UI', 'Microsoft YaHei', system-ui, sans-serif"
30
- font-size="16" fill="#7c84a8">list_subagents 选人 · delegate 派活 · 模型 / persona / 工具过滤 / 深度可配</text>
30
+ font-size="16" fill="#7c84a8">list_subagents 选人 · delegate 派活 · 模型 / 角色提示词 / 深度可配</text>
31
31
  <text x="248" y="254" font-family="'Segoe UI', 'Microsoft YaHei', system-ui, sans-serif"
32
32
  font-size="16" fill="#7c84a8">named subagent roster for the DSH Web GUI</text>
33
33
 
package/lib/client.js CHANGED
@@ -1824,44 +1824,49 @@ function LibrarySettings(props) {
1824
1824
  });
1825
1825
  }
1826
1826
 
1827
+ //#endregion
1828
+ //#region src/client/icon.tsx
1829
+ /** Robot-head glyph for the library's settings row. */
1830
+ function LibraryNavIcon({ size = 16 }) {
1831
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1832
+ viewBox: "0 0 16 16",
1833
+ width: size,
1834
+ height: size,
1835
+ fill: "none",
1836
+ stroke: "currentColor",
1837
+ strokeWidth: 1.2,
1838
+ strokeLinecap: "round",
1839
+ strokeLinejoin: "round",
1840
+ "aria-hidden": "true",
1841
+ children: [
1842
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M8 6.5V3.9" }),
1843
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
1844
+ cx: "8",
1845
+ cy: "2.6",
1846
+ r: "0.85"
1847
+ }),
1848
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
1849
+ x: "3.25",
1850
+ y: "6.5",
1851
+ width: "9.5",
1852
+ height: "6.5",
1853
+ rx: "1.5"
1854
+ }),
1855
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5.75 9.25v1.25" }),
1856
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M10.25 9.25v1.25" }),
1857
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M1.75 9.25h1.5" }),
1858
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12.75 9.25h1.5" })
1859
+ ]
1860
+ });
1861
+ }
1862
+
1827
1863
  //#endregion
1828
1864
  //#region src/client/nav-icon.ts
1829
- /**
1830
- * Settings-nav icon decoration for this plugin's own row (子代理库).
1831
- *
1832
- * The official settings shell's navIcon(id) table is closed — official ids
1833
- * get drawn icons and everything else falls back to a generic gear. This
1834
- * replaces that fallback <svg> inside OUR nav button (matched by our own
1835
- * registered label text) with the drawn robot-head icon. A MutationObserver
1836
- * re-applies the icon when the panel re-renders; gated on the settings
1837
- * dialog being present so idle chat streams never pay the query cost.
1838
- */
1839
- const NAV_ICON_INNER = "<path d=\"M8 6.5V3.9\"/><circle cx=\"8\" cy=\"2.6\" r=\"0.85\"/><rect x=\"3.25\" y=\"6.5\" width=\"9.5\" height=\"6.5\" rx=\"1.5\"/><path d=\"M5.75 9.25v1.25\"/><path d=\"M10.25 9.25v1.25\"/><path d=\"M1.75 9.25h1.5\"/><path d=\"M12.75 9.25h1.5\"/>";
1840
- const NAV_LABELS = new Set(["子代理库"]);
1841
- function decorateSettingsNavIcon(ctx) {
1842
- ctx.effect(() => {
1843
- const decorate = () => {
1844
- if (document.querySelector("[role=\"dialog\"]") === null) return;
1845
- for (const button$1 of Array.from(document.querySelectorAll("button"))) {
1846
- const label = button$1.querySelector(":scope > span");
1847
- if (label === null || !NAV_LABELS.has(label.textContent ?? "")) continue;
1848
- const existing = button$1.firstElementChild;
1849
- if (existing instanceof SVGElement) {
1850
- if (existing.dataset.navIcon === "1") continue;
1851
- const template = document.createElement("template");
1852
- template.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-nav-icon="1">${NAV_ICON_INNER}</svg>`;
1853
- existing.replaceWith(template.content.firstElementChild);
1854
- }
1855
- }
1856
- };
1857
- const observer = new MutationObserver(() => decorate());
1858
- observer.observe(document.body, {
1859
- childList: true,
1860
- subtree: true
1861
- });
1862
- decorate();
1863
- return () => observer.disconnect();
1864
- }, "subagent-library: nav icon decoration");
1865
+ function registerSettingsNavIcon(ctx) {
1866
+ ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
1867
+ name: "settings.section.icon",
1868
+ id: "subagent-library"
1869
+ }, LibraryNavIcon));
1865
1870
  }
1866
1871
 
1867
1872
  //#endregion
@@ -2017,7 +2022,7 @@ function apply(ctx) {
2017
2022
  subscribeRefresh
2018
2023
  })
2019
2024
  }, LibrarySettings));
2020
- decorateSettingsNavIcon(ctx);
2025
+ registerSettingsNavIcon(ctx);
2021
2026
  }
2022
2027
 
2023
2028
  //#endregion
package/lib/index.js CHANGED
@@ -9221,12 +9221,48 @@ async function settleStart(start, signal) {
9221
9221
  };
9222
9222
  }
9223
9223
  }
9224
+ /** DSH ≥0.2.1 replaced the subagent start seam with startActivation. Places
9225
+ * that must branch on host generation (delegate, catalog, settings API) probe
9226
+ * the same property so every branch flips together on one host. */
9227
+ function isModernSubagentHost(subagents) {
9228
+ return typeof subagents?.startActivation === "function";
9229
+ }
9230
+ /** Pass `promise` through unless `signal` aborts first. The losing side is
9231
+ * silenced: a rejection that arrives after the race was decided resolves an
9232
+ * already-detached derived promise, and the abort listener is always removed. */
9233
+ function raceAbort(promise, signal, message) {
9234
+ if (signal.aborted) return Promise.reject(new Error(message));
9235
+ return new Promise((resolve, reject) => {
9236
+ let settled = false;
9237
+ const onAbort = () => {
9238
+ if (settled) return;
9239
+ settled = true;
9240
+ signal.removeEventListener("abort", onAbort);
9241
+ reject(new Error(message));
9242
+ };
9243
+ signal.addEventListener("abort", onAbort);
9244
+ promise.then((value) => {
9245
+ if (settled) return;
9246
+ settled = true;
9247
+ signal.removeEventListener("abort", onAbort);
9248
+ resolve(value);
9249
+ }, (error) => {
9250
+ if (settled) return;
9251
+ settled = true;
9252
+ signal.removeEventListener("abort", onAbort);
9253
+ reject(error);
9254
+ });
9255
+ });
9256
+ }
9224
9257
  /** Foreground collection: await the child, dispose the run, map stop reasons.
9225
- * `run.result` rejection must still release the run (mirrors settleRun). */
9226
- async function settleForegroundRun(run) {
9258
+ * `run.result` rejection must still release the run (mirrors settleRun).
9259
+ * A ≥0.2.1 activation signal stops covering the child once the host accepts
9260
+ * it, so an abort during collection has to dispose here; hosts without
9261
+ * startActivation keep cancelling through the signal alone. */
9262
+ async function settleForegroundRun(run, signal) {
9227
9263
  let result;
9228
9264
  try {
9229
- result = await run.result;
9265
+ result = await (signal === void 0 ? run.result : raceAbort(run.result, signal, "delegate: foreground collection aborted"));
9230
9266
  } finally {
9231
9267
  await run.dispose().catch(() => {});
9232
9268
  }
@@ -9868,6 +9904,9 @@ function apply(ctx, config$1) {
9868
9904
  }
9869
9905
  }
9870
9906
  const sweepWarnings = [];
9907
+ if (isModernSubagentHost(ctx.subagents)) {
9908
+ for (const [id, doc] of validated) if (doc.entry.toolFilter !== void 0) sweepWarnings.push(`条目 "${id}" 带 toolFilter:本宿主(DSH ≥0.2.1)无法强制执行逐条目工具过滤,委派该条目会被拒绝。`);
9909
+ }
9871
9910
  const profileState = currentProfile();
9872
9911
  if (profileState.kind === "unsafe") for (const [id, doc] of validated) {
9873
9912
  const shown = opened.view.entries[id]?.entry ?? { description: doc.entry.description };
@@ -9937,7 +9976,7 @@ function apply(ctx, config$1) {
9937
9976
  });
9938
9977
  ctx.tools.register(defineTool({
9939
9978
  name: "list_subagents",
9940
- description: "List the named subagents available in the subagent library: each entry shows its id, role description, provider, model, background mode and tool filter (allow/deny scoping — e.g. deny:[write, edit] marks a read-only role). Call this before delegating so you can pick a matching library_id.",
9979
+ description: "List the named subagents available in the subagent library: each entry shows its id, role description, provider, model, background mode and tool filter (allow/deny scoping — e.g. deny:[write, edit] marks a read-only role)" + (isModernSubagentHost(ctx.subagents) ? ". On this host (DSH ≥0.2.1) per-entry tool filters cannot be enforced: entries carrying toolFilter are refused at delegate time and marked as undelegable in the listing." : "") + " Call this before delegating so you can pick a matching library_id.",
9941
9980
  parameters: {},
9942
9981
  output: {
9943
9982
  schema: {
@@ -9966,13 +10005,17 @@ function apply(ctx, config$1) {
9966
10005
  const lib = await loadEffective();
9967
10006
  const { view } = lib;
9968
10007
  const agent = exec.agent;
10008
+ const modernCatalog = isModernSubagentHost(ctx.subagents);
9969
10009
  /** The catalog must not advertise a filter this session cannot apply:
9970
10010
  * summarize the SANITIZED filter and list what was ignored, so the model
9971
- * sees the same tool scope delegation will actually produce. */
10011
+ * sees the same tool scope delegation will actually produce. On a host
10012
+ * without filter enforcement the filter is undelegable outright, so the
10013
+ * row says so instead of advertising a scope delegation would refuse. */
9972
10014
  const filterSummary = (row) => {
9973
10015
  const entry = row.entry;
9974
10016
  if (entry.toolFilter === void 0) return void 0;
9975
10017
  const declared = [entry.toolFilter.allow !== void 0 ? `allow:[${entry.toolFilter.allow.join(", ")}]` : "", entry.toolFilter.deny !== void 0 ? `deny:[${entry.toolFilter.deny.join(", ")}]` : ""].filter(Boolean).join(" ");
10018
+ if (modernCatalog) return `${declared}(本宿主无法强制执行 toolFilter,委派该条目会被拒绝)`;
9976
10019
  if (agent === void 0) return declared;
9977
10020
  const { filter, dropped } = sanitizeToolFilter(ctx, entry.toolFilter, agent);
9978
10021
  const effective = filter === void 0 ? "(本会话无可应用的名单项)" : [filter.allow !== void 0 ? `allow:[${filter.allow.join(", ")}]` : "", filter.deny !== void 0 ? `deny:[${filter.deny.join(", ")}]` : ""].filter(Boolean).join(" ");
@@ -10074,13 +10117,17 @@ function apply(ctx, config$1) {
10074
10117
  if (maxDepth !== void 0) assertSubagentMaxDepth(maxDepth);
10075
10118
  const { filter: toolFilter, dropped, allowEmptied } = sanitizeToolFilter(ctx, entry.toolFilter, parent);
10076
10119
  const droppedTools = dropped.map((item) => item.reason === "session-local" ? `${item.name}(本会话专属工具,子代本就继承不到)` : `${item.name}(本会话不存在)`);
10120
+ const subagentHost = ctx.subagents;
10121
+ const modernHost = isModernSubagentHost(subagentHost);
10122
+ if (modernHost && entry.toolFilter !== void 0) throw new Error(`delegate: this host cannot enforce a per-child toolFilter (entry "${args.library_id}"). Remove toolFilter from the roster file, or run on a host that still accepts it.`);
10077
10123
  if (allowEmptied) throw new Error(`delegate: entry "${args.library_id}" allow list names no tool this session can apply (${droppedTools.join("; ")}) — refusing to start a child with no tools at all`);
10078
- if (!continuable) {
10079
- if (maxDepth !== void 0 && !transport.capabilities.depthLimit) throw new Error(`delegate: transport "${subagentProviderName}" cannot enforce maxDepth (no depthLimit capability)`);
10124
+ if (!continuable && maxDepth !== void 0 && !transport.capabilities.depthLimit) throw new Error(`delegate: transport "${subagentProviderName}" cannot enforce maxDepth (no depthLimit capability)`);
10125
+ if (!modernHost && !continuable) {
10080
10126
  if (entry.persona !== void 0 && !transport.capabilities.persona) throw new Error(`delegate: transport "${subagentProviderName}" cannot apply a persona (no persona capability)`);
10081
10127
  if (entry.toolFilter !== void 0 && entry.toolFilter.allow === void 0 && entry.toolFilter.deny === void 0) throw new Error(`delegate: entry "${args.library_id}" names a toolFilter with neither allow nor deny`);
10082
10128
  if (entry.toolFilter !== void 0 && !transport.capabilities.toolFilter) throw new Error(`delegate: transport "${subagentProviderName}" cannot apply a tool filter (no toolFilter capability)`);
10083
10129
  }
10130
+ const promptText = modernHost && entry.persona !== void 0 ? `Role persona:\n${entry.persona}\n\nTask:\n${args.prompt}` : args.prompt;
10084
10131
  const agentOptions = entry.provider !== void 0 || entry.model !== void 0 || entry.maxTokens !== void 0 || entry.reasoningEffort !== void 0 ? {
10085
10132
  ...entry.provider !== void 0 ? { provider: entry.provider } : {},
10086
10133
  ...entry.model !== void 0 ? { model: entry.model } : {},
@@ -10091,14 +10138,53 @@ function apply(ctx, config$1) {
10091
10138
  label: args.description ?? args.library_id,
10092
10139
  prompt: [{
10093
10140
  type: "text",
10094
- text: args.prompt
10141
+ text: promptText
10095
10142
  }],
10096
10143
  parent,
10097
10144
  ...agentOptions !== void 0 ? { agentOptions } : {},
10098
- ...entry.persona !== void 0 ? { persona: entry.persona } : {},
10099
- ...toolFilter !== void 0 ? { toolFilter } : {},
10145
+ ...!modernHost && entry.persona !== void 0 ? { persona: entry.persona } : {},
10146
+ ...!modernHost && toolFilter !== void 0 ? { toolFilter } : {},
10100
10147
  ...maxDepth !== void 0 ? { maxDepth } : {}
10101
10148
  };
10149
+ const begin = async (signal, delivery) => {
10150
+ if (subagentHost.startActivation !== void 0) {
10151
+ const { label,...task } = request;
10152
+ const started$1 = await subagentHost.startActivation({
10153
+ provider: subagentProviderName,
10154
+ label: label ?? args.library_id,
10155
+ request: task,
10156
+ signal,
10157
+ delivery
10158
+ });
10159
+ return {
10160
+ childId: started$1.childId,
10161
+ run: {
10162
+ id: started$1.childId,
10163
+ result: started$1.result,
10164
+ localAgent: void 0,
10165
+ dispose: () => started$1.dispose()
10166
+ }
10167
+ };
10168
+ }
10169
+ if (continuable) {
10170
+ if (subagentHost.startContinuable === void 0) throw new Error("delegate: this host has no startContinuable or startActivation");
10171
+ return { childId: (await subagentHost.startContinuable({
10172
+ provider: subagentProviderName,
10173
+ label: request.label ?? args.library_id,
10174
+ request,
10175
+ signal
10176
+ })).childId };
10177
+ }
10178
+ if (subagentHost.start === void 0) throw new Error("delegate: this host has no subagent start or startActivation");
10179
+ const run = await subagentHost.start(subagentProviderName, {
10180
+ ...request,
10181
+ signal
10182
+ });
10183
+ return {
10184
+ childId: run.id,
10185
+ run
10186
+ };
10187
+ };
10102
10188
  const droppedNote = {
10103
10189
  ...droppedTools.length > 0 ? { droppedTools } : {},
10104
10190
  ...routeNote !== void 0 && lib.notes[args.library_id] !== "profile" ? { routeNote } : {}
@@ -10106,12 +10192,7 @@ function apply(ctx, config$1) {
10106
10192
  if (args.run_in_background === true || continuable) {
10107
10193
  if (continuable) return {
10108
10194
  kind: "continuable",
10109
- subagentId: (await ctx.subagents.startContinuable({
10110
- provider: subagentProviderName,
10111
- label: args.description ?? args.library_id,
10112
- request,
10113
- signal: exec.signal
10114
- })).childId,
10195
+ subagentId: (await begin(exec.signal, "parent")).childId,
10115
10196
  ...droppedNote
10116
10197
  };
10117
10198
  const jobs = ctx.get("jobs");
@@ -10121,16 +10202,23 @@ function apply(ctx, config$1) {
10121
10202
  jobId: jobs.start({
10122
10203
  kind: "subagent",
10123
10204
  label: args.description ?? args.library_id,
10124
- owner: parent,
10205
+ owner: modernHost ? parent.session.id : parent,
10125
10206
  run: () => {
10126
10207
  const controller = new AbortController();
10208
+ let accepted;
10127
10209
  return {
10128
10210
  cancel: (reason) => {
10129
10211
  controller.abort(reason ?? "background subagent task killed");
10212
+ accepted?.dispose().catch(() => {});
10130
10213
  },
10131
- done: settleStart(ctx.subagents.start(subagentProviderName, {
10132
- ...request,
10133
- signal: controller.signal
10214
+ done: settleStart(begin(controller.signal, "caller").then((started$1) => {
10215
+ if (started$1.run === void 0) throw new Error("delegate: background start returned no run");
10216
+ accepted = started$1.run;
10217
+ if (controller.signal.aborted) {
10218
+ accepted.dispose().catch(() => {});
10219
+ throw new Error("background subagent task killed");
10220
+ }
10221
+ return accepted;
10134
10222
  }), controller.signal)
10135
10223
  };
10136
10224
  }
@@ -10138,11 +10226,10 @@ function apply(ctx, config$1) {
10138
10226
  ...droppedNote
10139
10227
  };
10140
10228
  }
10229
+ const started = await begin(exec.signal, "caller");
10230
+ if (started.run === void 0) throw new Error("delegate: foreground start returned no run");
10141
10231
  return {
10142
- ...await settleForegroundRun(await ctx.subagents.start(subagentProviderName, {
10143
- ...request,
10144
- signal: exec.signal
10145
- })),
10232
+ ...await settleForegroundRun(started.run, exec.signal),
10146
10233
  ...droppedNote
10147
10234
  };
10148
10235
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-subagent-library",
3
- "version": "0.3.4",
4
- "description": "Named subagent library for DeepSeek Harness: a directory-backed roster of role subagents (one YAML file per agent: model + persona + tool filter), exposed to every session through the list_subagents and delegate tools, a /subagent command, and a Settings page.",
3
+ "version": "0.3.6",
4
+ "description": "Named subagent library for DeepSeek Harness: a directory-backed roster with model, role prompt, depth and background-mode settings, exposed through list_subagents, delegate, a /subagent command and a Settings page.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",