dsh-subagent-library 0.3.4 → 0.3.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/CHANGELOG.md +19 -1
- package/README.en.md +9 -11
- package/README.md +10 -12
- package/assets/readme/hero.svg +1 -1
- package/lib/index.js +111 -24
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
This file documents user-facing changes. Format loosely follows [Keep a Changelog]; versions follow [SemVer].
|
|
6
6
|
|
|
7
|
+
## [0.3.5] — 2026-10-17
|
|
8
|
+
|
|
9
|
+
### 修复 / Fixed
|
|
10
|
+
|
|
11
|
+
- **适配 DSH `0.2.1-rc.2`**:修复可续聊与前台一次性委派的启动失败,以及后台一次性任务报 `has no live agent` 的问题。旧宿主启动分支仍保留,名册与 profile 路由无需迁移。
|
|
12
|
+
- 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.
|
|
13
|
+
- **取消会停止子代理**:修复后台任务已经启动后取消未生效的问题,并处理取消与启动同时发生的情况;前台调用中止时也会释放子代理。
|
|
14
|
+
- Cancellation now stops the child after a background job has started, including cancellation during startup. Aborting a foreground call also disposes its child.
|
|
15
|
+
- **工具过滤限制会明确提示**:DSH 0.2.1 系列不支持逐条目 `toolFilter`。含该字段的条目会拒绝委派,不会无视限制直接启动;名册列表会标注原因,设置页保存时也会提示。仅删除该字段不能保证只读,请在宿主中配置所需权限。
|
|
16
|
+
- 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.
|
|
17
|
+
- **角色提示词的行为有变化**:DSH 0.2.1 系列通过首条任务消息传递角色,不再作为系统 persona,也不插值 `{{…}}` 模板;续聊或上下文压缩后不保证仍保留。README 已同步说明。
|
|
18
|
+
- 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.
|
|
19
|
+
|
|
7
20
|
## [0.3.4] — 2026-10-14
|
|
8
21
|
|
|
9
22
|
### 修复 / Fixed
|
|
@@ -117,7 +130,12 @@ This file documents user-facing changes. Format loosely follows [Keep a Changelo
|
|
|
117
130
|
|
|
118
131
|
- 修复设置页保存 400(移除保存期工具名预检,委派期 `tools.restrict` 为准);新条目卡补齐缺失字段。
|
|
119
132
|
|
|
120
|
-
[Unreleased]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.
|
|
133
|
+
[Unreleased]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.5...HEAD
|
|
134
|
+
[0.3.5]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.4...v0.3.5
|
|
135
|
+
[0.3.4]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.3...v0.3.4
|
|
136
|
+
[0.3.3]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.2...v0.3.3
|
|
137
|
+
[0.3.2]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.1...v0.3.2
|
|
138
|
+
[0.3.1]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.3.0...v0.3.1
|
|
121
139
|
[0.3.0]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.2.8...v0.3.0
|
|
122
140
|
[0.2.8]: https://github.com/MaRi23333/dsh-subagent-library/compare/v0.2.7...v0.2.8
|
|
123
141
|
[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.
|
|
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
|
|
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 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.
|
|
@@ -85,17 +85,17 @@ subagent-library:
|
|
|
85
85
|
One entry file (`k3-reviewer.yaml`):
|
|
86
86
|
|
|
87
87
|
```yaml
|
|
88
|
-
description:
|
|
88
|
+
description: Code review on Kimi K3-256K, with image walkthroughs
|
|
89
89
|
provider: kimi-coding
|
|
90
90
|
model: k3-256k
|
|
91
91
|
persona: |
|
|
92
92
|
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
93
|
maxDepth: 1
|
|
96
94
|
backgroundMode: continuable
|
|
97
95
|
```
|
|
98
96
|
|
|
97
|
+
> **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.
|
|
98
|
+
|
|
99
99
|
Entry fields:
|
|
100
100
|
|
|
101
101
|
| Field | Required | Notes |
|
|
@@ -107,8 +107,8 @@ Entry fields:
|
|
|
107
107
|
| `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
108
|
| `subagentProvider` | no | **Subagent transport** (a `ctx.subagents` provider such as `spawn`); defaults to the plugin-level default `spawn` |
|
|
109
109
|
| `maxTokens` | no | Subagent output cap |
|
|
110
|
-
| `persona` | no | Subagent
|
|
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 |
|
|
110
|
+
| `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 |
|
|
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. **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
112
|
| `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
113
|
| `backgroundMode` | no | `one-shot` (default, omitted in files) / `continuable` (resumable) |
|
|
114
114
|
| `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 |
|
|
@@ -124,11 +124,9 @@ The 0.2.8 legacy `entries` fallback is for DSH ≤0.1.6 only; on DSH ≥0.1.7 th
|
|
|
124
124
|
|
|
125
125
|
## Host and desktop compatibility
|
|
126
126
|
|
|
127
|
-
|
|
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.
|
|
127
|
+
**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 the notice and field table above for role-prompt and tool-filter limitations, and [CHANGELOG.md](./CHANGELOG.md) for the full update.
|
|
130
128
|
|
|
131
|
-
The desktop client uses the Web plugin UI, so no separate desktop-specific package is needed.
|
|
129
|
+
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.
|
|
132
130
|
|
|
133
131
|
## Install
|
|
134
132
|
|
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.
|
|
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
16
|
> [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Web GUI —
|
|
17
|
-
> manage role entries (model /
|
|
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
|
|
24
|
+
DeepSeek Harness 的具名子代理库插件:把常用角色(代码审查、红队、多模态理解……)配成一份持久化的具名子代理名册(模型、角色提示词、深度与后台模式),之后**只需告诉主会话 agent「用 xxx 做这件事」**——模型自己通过两个工具完成选人和派活:
|
|
25
25
|
|
|
26
26
|
- `list_subagents` — 列出名册条目(id / 角色描述 / 模型),模型据此挑选;
|
|
27
27
|
- `delegate` — 按 `library_id` 派活:前台等待、后台 one-shot 任务、或 continuable 可续聊子代理(按条目配置)。
|
|
@@ -90,17 +90,17 @@ subagent-library:
|
|
|
90
90
|
单个条目文件(`k3-reviewer.yaml`):
|
|
91
91
|
|
|
92
92
|
```yaml
|
|
93
|
-
description: Kimi K3-256K
|
|
93
|
+
description: Kimi K3-256K 代码审查,支持图片视觉走查
|
|
94
94
|
provider: kimi-coding
|
|
95
95
|
model: k3-256k
|
|
96
96
|
persona: |
|
|
97
97
|
你是运行在 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
98
|
maxDepth: 1
|
|
101
99
|
backgroundMode: continuable
|
|
102
100
|
```
|
|
103
101
|
|
|
102
|
+
> **DSH 0.2.1 系列的限制**:角色提示词随首条任务消息发送,不是系统级权限约束;逐条目 `toolFilter` 暂不可用,含该字段的条目会拒绝委派。上面的示例因此不含工具过滤,**不保证只读**。有只读或工具隔离需求时,应先在宿主中配置相应权限,不能只靠角色名称或提示词。旧宿主的字段行为见下表。
|
|
103
|
+
|
|
104
104
|
条目字段:
|
|
105
105
|
|
|
106
106
|
| 字段 | 必填 | 说明 |
|
|
@@ -112,8 +112,8 @@ backgroundMode: continuable
|
|
|
112
112
|
| `reasoningEffort` | 否 | 思考强度:适配器自有值(如 `max` / `high` / `medium` / `low`),留空随父会话默认。走官方 `agentOptions.reasoningEffort` 覆盖通道;子代理换了模型路由时官方会自动丢弃继承值,未显式设置不会跨模型泄漏。只接受 id 形态(字母数字与 `._-`),其他值保存时被拒绝 |
|
|
113
113
|
| `subagentProvider` | 否 | **子代理传输层**(`spawn` 等 `ctx.subagents` provider);默认取插件级默认 `spawn` |
|
|
114
114
|
| `maxTokens` | 否 | 子代理输出上限 |
|
|
115
|
-
| `persona` | 否 |
|
|
116
|
-
| `toolFilter` | 否 | `allow`/`deny` 工具名单(只读角色用 deny 禁写类工具)。**只读/受限角色建议把 `list_subagents`/`delegate` 也列入 deny**,防止子代理被全局提示词教去链式再派活。名单在**委派时按调用方会话的可限制集合**解析(不是"可见"):不可应用的名字被忽略,并在派活结果与 `list_subagents` 目录里标注原因(`本会话不存在` / `本会话专属工具`)——共享条目不会因为某个会话缺该工具而整次派活失败。**`allow` 名单若在本会话全部不可应用则拒绝委派**(否则"只留这些"会变成"什么都不留")。旧注册表无 `view()` 时退回可见性判定,此时 scope-local
|
|
115
|
+
| `persona` | 否 | 子代理角色提示词。**DSH ≤0.2.0 宿主**:作为系统 persona 部署,走严格的 `{{…}}` 模板插值(与部署 persona 同语义)——出现未注册的变量(如 `{{user}}`)会让子代理激活失败。**DSH ≥0.2.1 宿主**:启动请求已无 persona 字段,角色以 `Role persona:` 前缀折叠进首条任务消息——首轮生效,但不遮蔽部署 persona;续聊回合与上下文压缩后不保证角色仍在;`{{…}}` 不再插值(原文拼接)。不采用独立 `agentPreset` 承载角色:独立 preset 会替换父 preset 组合、丢掉父会话工具 |
|
|
116
|
+
| `toolFilter` | 否 | `allow`/`deny` 工具名单(只读角色用 deny 禁写类工具)。**只读/受限角色建议把 `list_subagents`/`delegate` 也列入 deny**,防止子代理被全局提示词教去链式再派活。名单在**委派时按调用方会话的可限制集合**解析(不是"可见"):不可应用的名字被忽略,并在派活结果与 `list_subagents` 目录里标注原因(`本会话不存在` / `本会话专属工具`)——共享条目不会因为某个会话缺该工具而整次派活失败。**`allow` 名单若在本会话全部不可应用则拒绝委派**(否则"只留这些"会变成"什么都不留")。旧注册表无 `view()` 时退回可见性判定,此时 scope-local 名仍会让委派明确报错。保存阶段不做校验。**DSH ≥0.2.1 宿主无法强制执行逐条目工具过滤**:带 `toolFilter` 的条目会被委派直接拒绝(目录标注「无法强制执行」,保存时附警告);这类条目只适用于 ≤0.2.0 宿主 |
|
|
117
117
|
| `maxDepth` | 否 | 委派深度上限;**缺省 = 传输层支持 depthLimit 时默认 3**(与官方 subagent 工具对齐,防链式递归派活;harness 自身无全局深度上限),不支持 depthLimit 的传输层则不设上限 |
|
|
118
118
|
| `backgroundMode` | 否 | `one-shot`(默认,文件中省略)/ `continuable`(可续聊) |
|
|
119
119
|
| `enabled` | 否 | 文件内写 `enabled: false` 停用该条目(目录与设置页仍可见,`delegate` 拒绝派活);省略或 `true` 为启用 |
|
|
@@ -129,11 +129,9 @@ backgroundMode: continuable
|
|
|
129
129
|
|
|
130
130
|
## 宿主与桌面端兼容
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
**0.3.2** 为插件管理页增加随客户端语言切换的中英文名称与简介,名册和委派行为不变。更新说明见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
132
|
+
**0.3.5 对齐 DSH `0.2.1-rc.2`**:修复可续聊子代理与一次性委派无法启动,以及后台任务取消未能停止子代理的问题。前台一次性、可续聊、后台启动及运行中取消已在该版桌面宿主中复验。角色提示词与工具过滤的限制见上方提示和字段表,完整变化见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
135
133
|
|
|
136
|
-
桌面客户端沿用 Web
|
|
134
|
+
桌面客户端沿用 Web 插件界面,无需另装桌面专用包。旧宿主的启动分支仍保留,但本轮实际运行验证以 `0.2.1-rc.2` 为准;模型调用仍取决于各 Provider 的配置与服务。名册目录、profile 路由和迁移规则不变,无需重新迁移。
|
|
137
135
|
|
|
138
136
|
## 安装
|
|
139
137
|
|
package/assets/readme/hero.svg
CHANGED
|
@@ -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 派活 · 模型 /
|
|
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/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
|
-
|
|
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
|
-
|
|
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:
|
|
10141
|
+
text: promptText
|
|
10095
10142
|
}],
|
|
10096
10143
|
parent,
|
|
10097
10144
|
...agentOptions !== void 0 ? { agentOptions } : {},
|
|
10098
|
-
|
|
10099
|
-
|
|
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
|
|
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(
|
|
10132
|
-
|
|
10133
|
-
|
|
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(
|
|
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
|
-
"description": "Named subagent library for DeepSeek Harness: a directory-backed roster
|
|
3
|
+
"version": "0.3.5",
|
|
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",
|