@qlzt/dsh-tool-subagent 0.2.1-alpha.3 → 0.2.1-rc.2
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.i18n.yaml +36 -18
- package/README.md +39 -9
- package/README.zh.md +39 -9
- package/lib/index.js +96 -14
- package/lib/types/index.d.ts +4 -18
- package/lib/types/preset-selection.d.ts +43 -0
- package/locale/en.json +5 -0
- package/locale/model-selection-settings/en.json +5 -0
- package/locale/model-selection-settings/zh.json +5 -0
- package/locale/zh.json +6 -0
- package/package.json +37 -26
package/README.i18n.yaml
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
en: 686fb5136bef0a3b
|
|
10
10
|
zh: d25d6569174a01b5
|
|
11
11
|
/deepseek-ai-dsh-tool-subagent/summary:
|
|
12
|
-
en:
|
|
13
|
-
zh:
|
|
12
|
+
en: c09d40329253a9d8
|
|
13
|
+
zh: 91c1bbe5557bdda9
|
|
14
14
|
/deepseek-ai-dsh-tool-subagent/table-of-contents:
|
|
15
15
|
en: d152484eb41ac6b4
|
|
16
16
|
zh: 09388d293f9be9cb
|
|
@@ -18,11 +18,14 @@
|
|
|
18
18
|
en: 93f1701f5209ecb5
|
|
19
19
|
zh: 6310fd012400aead
|
|
20
20
|
/deepseek-ai-dsh-tool-subagent/use-this-package/minimal-configuration:
|
|
21
|
-
en:
|
|
22
|
-
zh:
|
|
21
|
+
en: 6a82283a51912841
|
|
22
|
+
zh: 35728acc16931bb4
|
|
23
23
|
/deepseek-ai-dsh-tool-subagent/use-this-package/managed-delegation:
|
|
24
|
-
en:
|
|
25
|
-
zh:
|
|
24
|
+
en: bb715d037cde14bd
|
|
25
|
+
zh: a88e98c07115fbd1
|
|
26
|
+
/deepseek-ai-dsh-tool-subagent/use-this-package/selecting-a-child-preset:
|
|
27
|
+
en: 1950ef92bab0f46e
|
|
28
|
+
zh: 593f5f64ed9b5631
|
|
26
29
|
/deepseek-ai-dsh-tool-subagent/use-this-package/selecting-a-child-llm:
|
|
27
30
|
en: 0d37e3b3957515e4
|
|
28
31
|
zh: ea1a94b2f29e7d9a
|
|
@@ -30,8 +33,8 @@
|
|
|
30
33
|
en: 6ce5f749256a7e6c
|
|
31
34
|
zh: a4f2adb04a70d9cf
|
|
32
35
|
/deepseek-ai-dsh-tool-subagent/understand-the-implementation/design-concept:
|
|
33
|
-
en:
|
|
34
|
-
zh:
|
|
36
|
+
en: e9df1e3d504a3625
|
|
37
|
+
zh: 4eca7bb1bc6def62
|
|
35
38
|
/deepseek-ai-dsh-tool-subagent/understand-the-implementation/activation-ownership:
|
|
36
39
|
en: ef692c4d17290920
|
|
37
40
|
zh: b1d0d3dab011e2cd
|
|
@@ -42,8 +45,8 @@
|
|
|
42
45
|
en: 1733728ac5aa6bb0
|
|
43
46
|
zh: 341ffc6e21a289af
|
|
44
47
|
/deepseek-ai-dsh-tool-subagent/understand-the-implementation/source-map:
|
|
45
|
-
en:
|
|
46
|
-
zh:
|
|
48
|
+
en: ce5147d9e1b2849c
|
|
49
|
+
zh: 67a707f05b2b7dc5
|
|
47
50
|
/deepseek-ai-dsh-tool-subagent/further-exploration:
|
|
48
51
|
en: fa3c9a967b636afb
|
|
49
52
|
zh: a9ce930a9766d5cb
|
|
@@ -54,11 +57,11 @@
|
|
|
54
57
|
en: e4c7376d4f29dbd5
|
|
55
58
|
zh: 6b7a9eaf69c9ea53
|
|
56
59
|
/deepseek-ai-dsh-tool-subagent/model-experience/tool-schema/what-the-model-sees:
|
|
57
|
-
en:
|
|
58
|
-
zh:
|
|
60
|
+
en: cdaa88b47ba03e23
|
|
61
|
+
zh: 2b7429db53e0aea7
|
|
59
62
|
/deepseek-ai-dsh-tool-subagent/model-experience/tool-schema/token-effect:
|
|
60
|
-
en:
|
|
61
|
-
zh:
|
|
63
|
+
en: 0c6cf11d65ba83dc
|
|
64
|
+
zh: 6e2b2e64bf1f18f2
|
|
62
65
|
/deepseek-ai-dsh-tool-subagent/model-experience/tool-schema/kv-cache-effect:
|
|
63
66
|
en: 46f736c6c389052a
|
|
64
67
|
zh: a7765541030e9104
|
|
@@ -78,8 +81,8 @@
|
|
|
78
81
|
en: cf78b9dd5596495f
|
|
79
82
|
zh: bd44560f8c2435e8
|
|
80
83
|
/deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/what-the-model-sees:
|
|
81
|
-
en:
|
|
82
|
-
zh:
|
|
84
|
+
en: 64a1c2edb455950c
|
|
85
|
+
zh: 15d280ff2c918672
|
|
83
86
|
/deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/what-the-model-sees/tool-guidance-section:
|
|
84
87
|
en: 82b3cd08b3961c98
|
|
85
88
|
zh: bdc2a34bcea16cac
|
|
@@ -89,6 +92,21 @@
|
|
|
89
92
|
/deepseek-ai-dsh-tool-subagent/model-experience/system-prompt/kv-cache-effect:
|
|
90
93
|
en: eaee0378bf87c980
|
|
91
94
|
zh: 2783a481ee349f1e
|
|
95
|
+
/deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context:
|
|
96
|
+
en: 1e58e87365d88e45
|
|
97
|
+
zh: 7648aa3b3865057f
|
|
98
|
+
/deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context/what-the-model-sees:
|
|
99
|
+
en: fde048c427103086
|
|
100
|
+
zh: 6614730cc00f02e4
|
|
101
|
+
/deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context/what-the-model-sees/depth-limit-notice:
|
|
102
|
+
en: 0ae8dbcee66d0cd6
|
|
103
|
+
zh: 5a69283739ae59e0
|
|
104
|
+
/deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context/token-effect:
|
|
105
|
+
en: dae9cd59b9649b5a
|
|
106
|
+
zh: 8bb35289ebaeaf7b
|
|
107
|
+
/deepseek-ai-dsh-tool-subagent/model-experience/runtime-depth-context/kv-cache-effect:
|
|
108
|
+
en: 9e6e8bc993992908
|
|
109
|
+
zh: 4de1e9d85ab3bfca
|
|
92
110
|
/deepseek-ai-dsh-tool-subagent/model-experience/start-result:
|
|
93
111
|
en: 45854c8f4da73af7
|
|
94
112
|
zh: 7a9803ca8c03c40f
|
|
@@ -114,8 +132,8 @@
|
|
|
114
132
|
en: f5d5f97a153f7c70
|
|
115
133
|
zh: 3d6bc05b9eadfbc2
|
|
116
134
|
/deepseek-ai-dsh-tool-subagent/known-limitations-and-deferred-work:
|
|
117
|
-
en:
|
|
118
|
-
zh:
|
|
135
|
+
en: c17c91a188bb0d8c
|
|
136
|
+
zh: d77c1ffcf1eca737
|
|
119
137
|
/deepseek-ai-dsh-tool-subagent/known-limitations-and-deferred-work/dev-note:
|
|
120
138
|
en: e67f633dc6fe7773
|
|
121
139
|
zh: 3bb0c20c93f16f98
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
|
|
9
9
|
|
|
10
10
|
## Summary
|
|
11
11
|
|
|
12
|
-
Use this package to give an agent a named tool that delegates work to a configured backend. Every call starts a managed activation and returns a child id; the runtime owns completion notices and cleanup. Local children support messages and restoration, while external backends execute one task and return their final answer through the completion notice. Supported backends can expose approved child LLM routes. Each instance can
|
|
12
|
+
Use this package to give an agent a named tool that delegates work to a configured backend. Every call starts a managed activation and returns a child id; the runtime owns completion notices and cleanup. Local children support messages and restoration, while external backends execute one task and return their final answer through the completion notice. Supported backends can expose approved child LLM routes. Each instance can select a child preset and depth limit.
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
@@ -48,8 +48,8 @@ Load the subagent service, an in-process or remote backend, and this tool; then
|
|
|
48
48
|
| `toolName` | `subagent` | Model-facing tool name; distinct for every loaded instance |
|
|
49
49
|
| `modelSelectionSettings` | `false` | Sample the Host's exact-route authorization preference for each top-level Session; a standing preset observes matching Sessions, while direct Agent setup passes its Session explicitly; requires provider `agentOptions` support |
|
|
50
50
|
| `agentOptions` | — | Configured child `provider`, `model`, adapter-owned `reasoningEffort`, and positive `maxTokens` defaults; requires provider `agentOptions` support and overlays any provider-owned route defaults |
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
51
|
+
| `agentPreset` | — | Default independent child preset id; requires in-process spawn |
|
|
52
|
+
| `allowedAgentPresets` | — | Non-empty preset-id allowlist exposed as the model's optional `agent_preset` enum; must include `agentPreset` when both are set |
|
|
53
53
|
| `maxDepth` | Host setting (`1`) | Absolute delegation-depth cap (`0` forbids delegation); `'provider-managed'` sends no cap to an out-of-process provider |
|
|
54
54
|
|
|
55
55
|
The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-tool-subagent) is the exhaustive source for every accepted field and its JSDoc.
|
|
@@ -60,7 +60,16 @@ Every call returns `started subagent <childId>` after the runtime accepts the ch
|
|
|
60
60
|
|
|
61
61
|
Every backend’s completion notice carries its final answer. Local Spawn and Fork children can also send messages, accept more work through `send_message` while active, or resume after settling. Codex, Claude Code, ACP, and DSH SDK backends do not accept follow-up messages.
|
|
62
62
|
|
|
63
|
-
`maxDepth` caps recursion (`0` forbids delegation); omission reads the current Host `subagent.maxDepth` setting, initially `1`, at each delegation. A numeric depth requires a provider with the `depthLimit` capability; `'provider-managed'` leaves the budget to an out-of-process provider.
|
|
63
|
+
`maxDepth` caps recursion (`0` forbids delegation); omission reads the current Host `subagent.maxDepth` setting, initially `1`, at each delegation. A numeric depth requires a provider with the `depthLimit` capability; `'provider-managed'` leaves the budget to an out-of-process provider. The tool stays visible at the cap; each attempted start checks the calling agent's current depth and rejects with an errored result.
|
|
64
|
+
|
|
65
|
+
<a id="selecting-a-child-preset"></a>
|
|
66
|
+
### Selecting a child preset
|
|
67
|
+
|
|
68
|
+
Set `agentPreset` to give every child an independent preset by default. Set `allowedAgentPresets` to let the model choose an id through `agent_preset`; without this allowlist, the model cannot override the configured choice. Only in-process spawn supports these options; fork and external backends reject them.
|
|
69
|
+
|
|
70
|
+
The configured default and allowlist must name declared presets. A tool inside a preset checks these ids and reads their descriptions during Agent initialization; a Host-mounted tool performs this check when it loads. This check does not activate candidate presets. Activation failures reject the selected preset when the child is composed. Without either selection field, the tool does not require the preset service. An omitted model choice uses the configured `agentPreset`, or joins the parent's current preset revision when no default is configured. Any explicit id mounts the currently available revision, even when it matches the parent's id.
|
|
71
|
+
|
|
72
|
+
Compose persona and tools in the [preset plugin list](../../preset/agent-preset-registry/README.md). Tool configuration containing `persona` or `toolFilter` fails at load with a migration error. Local children use the shared [preset restoration rules](../subagent/README.md#restoring-child-composition).
|
|
64
73
|
|
|
65
74
|
### Selecting a child LLM
|
|
66
75
|
|
|
@@ -80,7 +89,7 @@ This section explains how the tool mirrors provider lifecycle and settles runs;
|
|
|
80
89
|
|
|
81
90
|
### Design concept
|
|
82
91
|
|
|
83
|
-
One instance is one provider plus one tool name. The plugin mirrors provider lifecycle: it registers the tool when the named provider appears and disposes it when the provider leaves, so sibling load order and HMR replacement cannot strand a dangling tool. Direct Agent setup passes its unpublished Session explicitly and awaits installation before publication. A
|
|
92
|
+
One instance is one provider plus one tool name. The plugin mirrors provider lifecycle: it registers the tool when the named provider appears and disposes it when the provider leaves, so sibling load order and HMR replacement cannot strand a dangling tool. Direct Agent setup passes its unpublished Session explicitly and awaits installation before publication. A standing preset with model or preset selection receives each matching Agent through `agent/created`, validates preset references, selects any model policy from its Session, and awaits installation through its Context; installation failure rejects creation. A numeric `maxDepth` or configured LLM selection the provider cannot enforce fails the mount instead of the first delegation. At most one instance in a tool scope may own model selection because `list_subagent_models` has a global name.
|
|
84
93
|
|
|
85
94
|
### Activation ownership
|
|
86
95
|
|
|
@@ -99,6 +108,7 @@ The tool's description derives from `provider.inheritsParentContext`: a fresh ch
|
|
|
99
108
|
| File | Role |
|
|
100
109
|
|---|---|
|
|
101
110
|
| [`src/index.ts`](src/index.ts) | Tool registration, provider lifecycle mirroring, activation requests |
|
|
111
|
+
| [`src/preset-selection.ts`](src/preset-selection.ts) | Configured preset validation, model allowlist, and description guidance |
|
|
102
112
|
| [`src/model-selection.ts`](src/model-selection.ts) | Request/config merge and live LLM route preflight |
|
|
103
113
|
| [`src/model-selection-settings.ts`](src/model-selection-settings.ts) | Host-owned opt-in setting sampled for new Sessions |
|
|
104
114
|
| [`src/model-selection-state.ts`](src/model-selection-state.ts) | Session event that records and inherits the sampled decision |
|
|
@@ -128,11 +138,11 @@ Read these pages when the package-level contract is not enough; they move from t
|
|
|
128
138
|
|
|
129
139
|
#### What the model sees
|
|
130
140
|
|
|
131
|
-
The generated default [`subagent` schema](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent) appears under the configured tool name while its provider exists. An enabled Session policy adds `provider`, `model`, and `reasoning_effort` plus route guidance; the backend must support `agentOptions`. Context inheritance and continuation support determine the task and follow-up descriptions. A tool restriction removes both the schema and its `tool:<toolName>` guidance section.
|
|
141
|
+
The generated default [`subagent` schema](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent) appears under the configured tool name while its provider exists. An enabled Session policy adds `provider`, `model`, and `reasoning_effort` plus route guidance; the backend must support `agentOptions`. `allowedAgentPresets` adds the `agent_preset` enum and guidance from the presets' display descriptions. Context inheritance and continuation support determine the task and follow-up descriptions. A tool restriction removes both the schema and its `tool:<toolName>` guidance section.
|
|
132
142
|
|
|
133
143
|
#### Token effect
|
|
134
144
|
|
|
135
|
-
Fixed schema cost per parent request;
|
|
145
|
+
Fixed schema cost per parent request; LLM selection adds three parameters, while preset selection adds one enum parameter and preset descriptions. Each tool instance adds one schema and one short system-prompt section.
|
|
136
146
|
|
|
137
147
|
#### KV Cache effect
|
|
138
148
|
|
|
@@ -156,7 +166,7 @@ The schema is prefix-stable across adapter registration and catalog changes. Eac
|
|
|
156
166
|
|
|
157
167
|
#### What the model sees
|
|
158
168
|
|
|
159
|
-
Visible delegation tools share one guidance paragraph, listing tools in name order and instructing the model to start independent delegations together and keep working while they run. Hidden or unavailable tools are omitted; no guidance appears when none are visible. With both `subagent` and `subagent_fork` visible, the text is:
|
|
169
|
+
Visible delegation tools share one guidance paragraph, listing tools in name order and instructing the model to start independent delegations together and keep working while they run, and to end its turn instead of sleeping or polling when only waiting for their results remains. Hidden or unavailable tools are omitted; no guidance appears when none are visible. With both `subagent` and `subagent_fork` visible, the text is:
|
|
160
170
|
|
|
161
171
|
##### Tool-guidance section
|
|
162
172
|
|
|
@@ -172,6 +182,26 @@ At most one short delegation paragraph per parent request, listing the tool name
|
|
|
172
182
|
|
|
173
183
|
Prefix-stable while the visible tool names are unchanged; adding or removing a visible tool changes the paragraph.
|
|
174
184
|
|
|
185
|
+
### Runtime depth context
|
|
186
|
+
|
|
187
|
+
#### What the model sees
|
|
188
|
+
|
|
189
|
+
When the calling agent reaches or exceeds a visible tool's effective numeric depth cap, an optional runtime-context snapshot tells it to do the work directly. The cap is resolved again at each request, including after settings changes or session resume. Hidden tools and `provider-managed` limits contribute no depth text. For a child at depth one with a cap of one:
|
|
190
|
+
|
|
191
|
+
##### Depth-limit notice
|
|
192
|
+
|
|
193
|
+
```markdown
|
|
194
|
+
Delegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly.
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
#### Token effect
|
|
198
|
+
|
|
199
|
+
One short contribution per capped tool joins the user-role runtime-context snapshot. Unchanged snapshots are not appended again; agents below the cap receive no additional text. `includeRuntimeContext: false` suppresses this notice without changing runtime depth enforcement.
|
|
200
|
+
|
|
201
|
+
#### KV Cache effect
|
|
202
|
+
|
|
203
|
+
Depth changes do not alter the system prompt or tool schemas. Updated runtime context appends after existing history; the provider still enforces the cap if the model attempts delegation.
|
|
204
|
+
|
|
175
205
|
### Start result
|
|
176
206
|
|
|
177
207
|
#### What the model sees
|
|
@@ -209,7 +239,7 @@ These limits define what this tool does not return or enforce; they are current
|
|
|
209
239
|
|
|
210
240
|
- **This tool does not wait for results** — use the completion notice or child messages. Programmatic result waiting belongs to the subagent service.
|
|
211
241
|
- **Shipped fork tools cannot select a child LLM route** — they inherit the parent's provider and model to keep the copied conversation prefix eligible for KV Cache reuse. Re-enable selection only when route changes preserve reuse or expose a bounded recomputation cost.
|
|
212
|
-
- **
|
|
242
|
+
- **Depth limits are fixed per instance** — independently named tools can set different caps. LLM selection requires an enabled per-Session preference and a provider that advertises `agentOptions`; both in-process providers and DSH SDK advertise it, while ACP, Codex, and Claude Code reject it rather than ignore it.
|
|
213
243
|
|
|
214
244
|
<a id="dev-note"></a>
|
|
215
245
|
### Dev Note
|
package/README.zh.md
CHANGED
|
@@ -9,7 +9,7 @@ kind: "package-reference"
|
|
|
9
9
|
|
|
10
10
|
## 概述
|
|
11
11
|
|
|
12
|
-
使用本包可为 agent 提供具名工具,把工作委派给配置的后端。每次调用都会启动受管理的 activation 并返回子任务 id;运行时负责完成通知与清理。本地子任务支持消息和恢复,外部后端执行一次任务,并通过完成通知返回最终回答。受支持的后端可以公开获准的子级 LLM
|
|
12
|
+
使用本包可为 agent 提供具名工具,把工作委派给配置的后端。每次调用都会启动受管理的 activation 并返回子任务 id;运行时负责完成通知与清理。本地子任务支持消息和恢复,外部后端执行一次任务,并通过完成通知返回最终回答。受支持的后端可以公开获准的子级 LLM 路由。每个实例可选择子级 preset 和深度限制。
|
|
13
13
|
|
|
14
14
|
## 目录
|
|
15
15
|
|
|
@@ -48,8 +48,8 @@ kind: "package-reference"
|
|
|
48
48
|
| `toolName` | `subagent` | 面向模型的工具名称;每个已加载实例必须不同 |
|
|
49
49
|
| `modelSelectionSettings` | `false` | 为每个顶层 Session 读取宿主的精确路由授权偏好;常驻 preset 观察匹配 Session,直接 Agent setup 则显式传入其 Session;要求提供方支持 `agentOptions` |
|
|
50
50
|
| `agentOptions` | — | 配置的子级 `provider`、`model`、适配器所有的 `reasoningEffort` 与正整数 `maxTokens` 默认值;要求提供方支持 `agentOptions`,并会覆盖提供方持有的路由默认值 |
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
51
|
+
| `agentPreset` | — | 独立子级 preset 的默认 id;要求进程内 spawn |
|
|
52
|
+
| `allowedAgentPresets` | — | 非空 preset-id 白名单,作为模型可选的 `agent_preset` 枚举;与 `agentPreset` 同时配置时必须包含后者 |
|
|
53
53
|
| `maxDepth` | Host 设置(`1`) | 绝对委派深度上限(`0` 禁止委派);`'provider-managed'` 不向进程外提供方发送上限 |
|
|
54
54
|
|
|
55
55
|
生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-tool-subagent)是每个受支持字段及其 JSDoc 的穷尽式真源。
|
|
@@ -60,7 +60,16 @@ kind: "package-reference"
|
|
|
60
60
|
|
|
61
61
|
所有后端的完成通知都会附带最终回答。本地 Spawn 和 Fork 子任务还可以发送消息,在活跃期间通过 `send_message` 接受更多工作,或在结束后恢复。Codex、Claude Code、ACP 与 DSH SDK 后端不接受后续消息。
|
|
62
62
|
|
|
63
|
-
`maxDepth` 限制递归深度(`0` 禁止委派);省略时,每次委派读取 Host 当前的 `subagent.maxDepth` 设置,初始值为 `1`。数值深度要求提供方具备 `depthLimit` 能力;`'provider-managed'`
|
|
63
|
+
`maxDepth` 限制递归深度(`0` 禁止委派);省略时,每次委派读取 Host 当前的 `subagent.maxDepth` 设置,初始值为 `1`。数值深度要求提供方具备 `depthLimit` 能力;`'provider-managed'` 把预算留给进程外提供方。工具在达到上限时仍然可见;每次尝试启动都会检查调用 agent 的当前深度,被拒绝时返回出错的工具结果。
|
|
64
|
+
|
|
65
|
+
<a id="selecting-a-child-preset"></a>
|
|
66
|
+
### 选择子级 preset
|
|
67
|
+
|
|
68
|
+
设置 `agentPreset`,为每个子级指定默认的独立 preset。设置 `allowedAgentPresets`,允许模型通过 `agent_preset` 选择 id;没有此白名单时,模型不能覆盖配置中的选择。只有进程内 spawn 支持这些选项;fork 与外部后端会拒绝它们。
|
|
69
|
+
|
|
70
|
+
配置的默认值与白名单必须引用已声明 preset。preset 内的工具在 Agent 初始化期间检查这些 id 并读取描述;直接挂载在 Host 的工具在加载时检查。此检查不激活候选 preset。创建子级时,选中 preset 的激活失败会拒绝组装。两个选择字段都省略时,工具不要求 preset 服务。模型省略选择时使用配置的 `agentPreset`;若也没有默认值,则加入父方当前 preset 代际。任何显式 id 都挂载当前可用代际,即使与父方 id 相同。
|
|
71
|
+
|
|
72
|
+
在 [preset 插件列表](../../preset/agent-preset-registry/README.zh.md)中配置 persona 与工具。包含 `persona` 或 `toolFilter` 的工具配置在加载时会报迁移错误。本地子级采用共享的 [preset 恢复规则](../subagent/README.zh.md#restoring-child-composition)。
|
|
64
73
|
|
|
65
74
|
### 选择子级 LLM
|
|
66
75
|
|
|
@@ -80,7 +89,7 @@ kind: "package-reference"
|
|
|
80
89
|
|
|
81
90
|
### 设计理念
|
|
82
91
|
|
|
83
|
-
一个实例就是一个提供方加一个工具名称。插件镜像提供方生命周期:具名提供方出现时注册工具,提供方离开时释放工具,因此同级加载顺序与 HMR 替换不会让工具悬空。直接 Agent setup 显式传入尚未发布的 Session
|
|
92
|
+
一个实例就是一个提供方加一个工具名称。插件镜像提供方生命周期:具名提供方出现时注册工具,提供方离开时释放工具,因此同级加载顺序与 HMR 替换不会让工具悬空。直接 Agent setup 显式传入尚未发布的 Session,并在发布前等待安装完成。启用模型选择或 preset 选择的常驻 preset 通过 `agent/created` 接收每个匹配 Agent,校验 preset 引用,从其 Session 选择适用的模型策略,并等待通过其 Context 发起的安装;安装失败会拒绝创建。提供方无法执行的数值型 `maxDepth` 或已配置 LLM 选择会在挂载时失败,而不是在首次委派时失败。每个工具作用域内最多一个实例可以拥有模型选择,因为 `list_subagent_models` 使用全局名称。
|
|
84
93
|
|
|
85
94
|
### Activation 所有权
|
|
86
95
|
|
|
@@ -99,6 +108,7 @@ kind: "package-reference"
|
|
|
99
108
|
| 文件 | 职责 |
|
|
100
109
|
|---|---|
|
|
101
110
|
| [`src/index.ts`](src/index.ts) | 工具注册、提供方生命周期镜像、activation 请求 |
|
|
111
|
+
| [`src/preset-selection.ts`](src/preset-selection.ts) | 配置的 preset 校验、模型白名单与描述引导 |
|
|
102
112
|
| [`src/model-selection.ts`](src/model-selection.ts) | 请求/配置合并与实时 LLM 路由预检 |
|
|
103
113
|
| [`src/model-selection-settings.ts`](src/model-selection-settings.ts) | 为新 Session 读取的宿主所有 opt-in 设置 |
|
|
104
114
|
| [`src/model-selection-state.ts`](src/model-selection-state.ts) | 记录并继承已读取决定的 Session 事件 |
|
|
@@ -128,11 +138,11 @@ kind: "package-reference"
|
|
|
128
138
|
|
|
129
139
|
#### 模型看到什么
|
|
130
140
|
|
|
131
|
-
提供方存在时,以配置的工具名称公开生成的默认 [`subagent` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-subagent)。启用的 Session 策略会添加 `provider`、`model`、`reasoning_effort` 和路由指引;后端必须支持 `agentOptions
|
|
141
|
+
提供方存在时,以配置的工具名称公开生成的默认 [`subagent` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-subagent)。启用的 Session 策略会添加 `provider`、`model`、`reasoning_effort` 和路由指引;后端必须支持 `agentOptions`。`allowedAgentPresets` 增加 `agent_preset` 枚举和来自 preset 显示描述的引导。上下文继承和继续执行能力决定任务与后续消息的描述。工具限制会同时移除 schema 及其 `tool:<toolName>` 指引 section。
|
|
132
142
|
|
|
133
143
|
#### Token 影响
|
|
134
144
|
|
|
135
|
-
每个父级请求支付固定的 schema
|
|
145
|
+
每个父级请求支付固定的 schema 成本;LLM 选择增加三个参数,preset 选择增加一个枚举参数和 preset 描述。每个工具实例增加一个 schema 和一个简短的系统提示词 section。
|
|
136
146
|
|
|
137
147
|
#### KV Cache 影响
|
|
138
148
|
|
|
@@ -156,7 +166,7 @@ Session 携带策略的 settings 控制实例会公开子级 LLM 选择字段与
|
|
|
156
166
|
|
|
157
167
|
#### 模型看到什么
|
|
158
168
|
|
|
159
|
-
|
|
169
|
+
可见的委派工具共享一段指导,列出按名称排序的工具,指示模型一起启动相互独立的委派,并在它们运行时继续工作;当只剩等待它们的结果时,结束本轮,而不是休眠或轮询。隐藏或不可用的工具不列入其中;没有可见工具时,不输出指导。`subagent` 和 `subagent_fork` 都可见时,文本为:
|
|
160
170
|
|
|
161
171
|
##### 工具指导 section
|
|
162
172
|
|
|
@@ -172,6 +182,26 @@ Start independent delegations with `subagent` or `subagent_fork` together in one
|
|
|
172
182
|
|
|
173
183
|
可见工具名不变时,前缀保持稳定;增加或移除可见工具会更改这段指导。
|
|
174
184
|
|
|
185
|
+
### 运行时深度上下文
|
|
186
|
+
|
|
187
|
+
#### 模型看到什么
|
|
188
|
+
|
|
189
|
+
当调用方 agent 达到或超过某个可见工具实际生效的数值深度上限时,可选的运行时上下文快照会提示它直接完成工作。每次请求都会重新解析上限,包括 settings 变更或会话恢复之后。隐藏的工具和 `provider-managed` 上限不贡献深度文本。深度和上限都为一时,子 agent 看到:
|
|
190
|
+
|
|
191
|
+
##### 深度上限提示
|
|
192
|
+
|
|
193
|
+
```markdown
|
|
194
|
+
Delegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly.
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
#### Token 影响
|
|
198
|
+
|
|
199
|
+
每个达到上限的工具向用户角色的运行时上下文快照贡献一小段文本。未变化的快照不会重复追加;未达到上限的 agent 不收到额外文本。`includeRuntimeContext: false` 会抑制这条提示,但不改变运行时对深度上限的强制执行。
|
|
200
|
+
|
|
201
|
+
#### KV Cache 影响
|
|
202
|
+
|
|
203
|
+
深度变化不改变系统提示词或工具 schema。更新的运行时上下文追加在已有历史之后;模型尝试委派时,提供方仍会强制执行上限。
|
|
204
|
+
|
|
175
205
|
### 启动结果
|
|
176
206
|
|
|
177
207
|
#### 模型看到什么
|
|
@@ -209,7 +239,7 @@ Start independent delegations with `subagent` or `subagent_fork` together in one
|
|
|
209
239
|
|
|
210
240
|
- **本工具不等待结果**——使用完成通知或子任务消息。程序化结果等待由 subagent 服务提供。
|
|
211
241
|
- **随附 fork 工具不能选择子级 LLM 路由**——它们继承父级提供方与模型,使复制的对话前缀仍有资格复用 KV Cache。仅当路由变更能保留复用或公开有界重算成本时,才重新启用选择。
|
|
212
|
-
-
|
|
242
|
+
- **深度上限按实例固定**——不同名称的工具可设置不同上限。LLM 选择要求启用逐 Session 偏好,且提供方必须声明 `agentOptions`;两个进程内提供方和 DSH SDK 会声明该能力,而 ACP、Codex 与 Claude Code 会拒绝它,而不是忽略它。
|
|
213
243
|
|
|
214
244
|
<a id="dev-note"></a>
|
|
215
245
|
### 开发备注
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import z from "@deepseek-ai/schemastery";
|
|
|
2
2
|
import { scopeChainOf, scopeOf } from "@qlzt/dsh-scope";
|
|
3
3
|
import { defineTool } from "@qlzt/dsh-tools";
|
|
4
4
|
import { SessionSeq } from "@qlzt/dsh-session";
|
|
5
|
-
import { assertSubagentMaxDepth, parentAgentOptionsForDelegation } from "@qlzt/dsh-subagent";
|
|
5
|
+
import { assertSubagentMaxDepth, delegationDepthOf, parentAgentOptionsForDelegation } from "@qlzt/dsh-subagent";
|
|
6
6
|
import { ReasoningEffortId } from "@qlzt/dsh-llm";
|
|
7
7
|
import { z as z$1 } from "zod";
|
|
8
8
|
z.object({
|
|
@@ -195,6 +195,66 @@ function registerListSubagentModels(ctx, policy) {
|
|
|
195
195
|
}
|
|
196
196
|
}));
|
|
197
197
|
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region lib/types/preset-selection.js
|
|
200
|
+
/** Validates configured references and resolves model input against the allowlist. */
|
|
201
|
+
var SubagentPresetSelection = class {
|
|
202
|
+
config;
|
|
203
|
+
descriptions = [];
|
|
204
|
+
constructor(config) {
|
|
205
|
+
this.config = config;
|
|
206
|
+
const { agentPreset, allowedAgentPresets } = config;
|
|
207
|
+
if (allowedAgentPresets === void 0) return;
|
|
208
|
+
if (new Set(allowedAgentPresets).size !== allowedAgentPresets.length) throw new Error("tool-subagent: allowedAgentPresets contains duplicate preset ids");
|
|
209
|
+
if (agentPreset !== void 0 && !allowedAgentPresets.includes(agentPreset)) throw new Error("tool-subagent: agentPreset must be included in allowedAgentPresets");
|
|
210
|
+
}
|
|
211
|
+
/** Whether this tool requires the preset service and an independently composing provider. */
|
|
212
|
+
get configured() {
|
|
213
|
+
return this.config.agentPreset !== void 0 || this.config.allowedAgentPresets !== void 0;
|
|
214
|
+
}
|
|
215
|
+
/** Preset ids advertised in the model parameter. */
|
|
216
|
+
get choices() {
|
|
217
|
+
return this.config.allowedAgentPresets;
|
|
218
|
+
}
|
|
219
|
+
/** Model-visible selection guidance and configured preset descriptions. */
|
|
220
|
+
get description() {
|
|
221
|
+
return `Agent preset for this child. ${this.config.agentPreset === void 0 ? "Omit to inherit the parent agent's current preset." : `Omit to use ${this.config.agentPreset}.`}` + (this.descriptions.length === 0 ? "" : ` Available presets: ${this.descriptions.join("; ")}`);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Read configured preset declarations before publishing the tool; mounting validates their activation.
|
|
225
|
+
* @param ctx - Tool composition containing the preset service.
|
|
226
|
+
*/
|
|
227
|
+
async validate(ctx) {
|
|
228
|
+
const presets = ctx.get("agentPresets");
|
|
229
|
+
if (presets === void 0) throw new Error("tool-subagent: agent preset selection requires the agent-presets service");
|
|
230
|
+
const ids = new Set([...this.config.agentPreset === void 0 ? [] : [this.config.agentPreset], ...this.config.allowedAgentPresets ?? []]);
|
|
231
|
+
const descriptions = [];
|
|
232
|
+
for (const id of ids) {
|
|
233
|
+
const preset = await presets.readDocument(id);
|
|
234
|
+
if (this.choices?.includes(id) && preset.description !== void 0) descriptions.push(`${id}: ${preset.description}`);
|
|
235
|
+
}
|
|
236
|
+
this.descriptions = descriptions;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Reject independent selection for providers that inherit conversation history or lack support.
|
|
240
|
+
* @param provider - Currently registered delegation provider.
|
|
241
|
+
*/
|
|
242
|
+
assertProvider(provider) {
|
|
243
|
+
if (this.configured && (!provider.capabilities.agentPreset || provider.inheritsParentContext)) throw new Error(`tool-subagent: provider "${provider.name}" does not support independent agent preset selection`);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Validate model input and apply the deployment default.
|
|
247
|
+
* @param request - Model-supplied tool arguments.
|
|
248
|
+
* @returns Selected preset id, or omission to inherit the parent.
|
|
249
|
+
*/
|
|
250
|
+
resolve(request) {
|
|
251
|
+
const id = request.agent_preset;
|
|
252
|
+
if (id === void 0) return this.config.agentPreset;
|
|
253
|
+
if (this.choices === void 0) throw new Error("agent_preset selection is disabled for this tool instance");
|
|
254
|
+
if (typeof id !== "string" || !this.choices.includes(id)) throw new Error(`agent_preset must be one of: ${this.choices.join(", ")}`);
|
|
255
|
+
return id;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
198
258
|
/** Host-only projection of the durable model-selection policy. */
|
|
199
259
|
const subagentModelSelectionProjectionDefinition = {
|
|
200
260
|
key: "subagentModelSelectionPolicy",
|
|
@@ -258,11 +318,8 @@ const Config = z.object({
|
|
|
258
318
|
reasoningEffort: z.string().min(1),
|
|
259
319
|
maxTokens: z.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER)
|
|
260
320
|
}).default(void 0),
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
allow: z.array(z.string()).default(void 0),
|
|
264
|
-
deny: z.array(z.string()).default(void 0)
|
|
265
|
-
}).default(void 0),
|
|
321
|
+
agentPreset: z.string().min(1),
|
|
322
|
+
allowedAgentPresets: z.array(z.string().min(1)).min(1).default(void 0),
|
|
266
323
|
maxDepth: z.union([z.natural().max(Number.MAX_SAFE_INTEGER), z.const("provider-managed")])
|
|
267
324
|
});
|
|
268
325
|
/**
|
|
@@ -289,17 +346,21 @@ function providerWording(inheritsConversation) {
|
|
|
289
346
|
}
|
|
290
347
|
/**
|
|
291
348
|
* Install one delegation-tool composition.
|
|
349
|
+
* Standing preset choices are validated for each Agent before its tool is installed.
|
|
292
350
|
* @param ctx - Context that owns the registrations.
|
|
293
351
|
* @param config - delegation-tool configuration.
|
|
294
352
|
* @param session - unpublished Session supplied by a direct Agent setup; omit for a standing composition.
|
|
295
353
|
*/
|
|
296
|
-
function apply(ctx, config, session) {
|
|
354
|
+
async function apply(ctx, config, session) {
|
|
355
|
+
for (const field of ["persona", "toolFilter"]) if (Object.hasOwn(config, field)) throw new Error(`tool-subagent: ${field} is no longer supported; configure persona and tool plugins in an Agent Preset and select it with agentPreset (spawn only)`);
|
|
356
|
+
const presets = new SubagentPresetSelection(config);
|
|
357
|
+
if (presets.configured && ctx.get("agentPresets") === void 0) throw new Error("tool-subagent: agent preset selection requires the agent-presets service");
|
|
297
358
|
if (config.maxDepth !== "provider-managed") assertSubagentMaxDepth(config.maxDepth);
|
|
298
|
-
if (config.toolFilter !== void 0 && config.toolFilter.allow === void 0 && config.toolFilter.deny === void 0) throw new Error("tool-subagent: `toolFilter` is configured but names neither `allow` nor `deny` — remove the key or fill the filter");
|
|
299
359
|
const toolName = config.toolName ?? "subagent";
|
|
300
360
|
const modelSelectionCapable = config.modelSelectionSettings === true;
|
|
301
361
|
ctx.sessionProjections.register(subagentModelSelectionProjectionDefinition);
|
|
302
362
|
const assertSubagentProviderConfiguration = (subagentProvider) => {
|
|
363
|
+
presets.assertProvider(subagentProvider);
|
|
303
364
|
if (ctx.subagents.resolveMaxDepth(config.maxDepth) !== void 0 && !subagentProvider.capabilities.depthLimit) throw new Error(`tool-subagent: provider "${subagentProvider.name}" cannot enforce maxDepth (no depthLimit capability) — set maxDepth: 'provider-managed' to leave the recursion budget to the provider`);
|
|
304
365
|
if (config.agentOptions !== void 0 && !subagentProvider.capabilities.agentOptions) throw new Error(`tool-subagent: provider "${subagentProvider.name}" does not support child agentOptions`);
|
|
305
366
|
if (modelSelectionCapable && !subagentProvider.capabilities.agentOptions) throw new Error(`tool-subagent: provider "${subagentProvider.name}" does not support child model selection`);
|
|
@@ -336,6 +397,11 @@ function apply(ctx, config, session) {
|
|
|
336
397
|
required: true,
|
|
337
398
|
description: wording.promptDescription
|
|
338
399
|
},
|
|
400
|
+
...presets.choices === void 0 ? {} : { agent_preset: {
|
|
401
|
+
type: "string",
|
|
402
|
+
enum: [...presets.choices],
|
|
403
|
+
description: presets.description
|
|
404
|
+
} },
|
|
339
405
|
...modelSelectionEnabled ? {
|
|
340
406
|
provider: {
|
|
341
407
|
type: "string",
|
|
@@ -376,6 +442,7 @@ function apply(ctx, config, session) {
|
|
|
376
442
|
async execute(args, exec) {
|
|
377
443
|
const parent = exec.agent;
|
|
378
444
|
if (!parent) throw new Error("subagent tool requires a calling agent (exec.agent was undefined)");
|
|
445
|
+
const agentPreset = presets.resolve(args);
|
|
379
446
|
const modelRequest = args;
|
|
380
447
|
const parentOptions = parentAgentOptionsForDelegation(parent);
|
|
381
448
|
const requiresRoutePreflight = hasDelegationModelRequest(modelRequest) || hasConfiguredLlmSelection(config.agentOptions);
|
|
@@ -399,9 +466,8 @@ function apply(ctx, config, session) {
|
|
|
399
466
|
text: args.prompt
|
|
400
467
|
}],
|
|
401
468
|
parent,
|
|
469
|
+
...agentPreset === void 0 ? {} : { agentPreset },
|
|
402
470
|
...requestedChildAgentOptions !== void 0 ? { agentOptions: requestedChildAgentOptions } : {},
|
|
403
|
-
...config.persona !== void 0 ? { persona: config.persona } : {},
|
|
404
|
-
...config.toolFilter !== void 0 ? { toolFilter: config.toolFilter } : {},
|
|
405
471
|
...maxDepth !== void 0 ? { maxDepth } : {}
|
|
406
472
|
};
|
|
407
473
|
return {
|
|
@@ -418,6 +484,7 @@ function apply(ctx, config, session) {
|
|
|
418
484
|
});
|
|
419
485
|
mounted = {
|
|
420
486
|
subagentProvider,
|
|
487
|
+
definition,
|
|
421
488
|
disposeTool: runtimeCtx.effect(() => {
|
|
422
489
|
const unregister = runtimeCtx.tools.register(definition);
|
|
423
490
|
delegationTools.add(definition);
|
|
@@ -449,14 +516,29 @@ function apply(ctx, config, session) {
|
|
|
449
516
|
return `Start independent delegations with ${visible.map((name) => `\`${name}\``).join(" or ")} together in one assistant message and continue useful work while they run.`;
|
|
450
517
|
}
|
|
451
518
|
});
|
|
519
|
+
runtimeCtx.systemPrompt.context({
|
|
520
|
+
name: `tool:${toolName}:depth`,
|
|
521
|
+
order: runtimeCtx.systemPrompt.getContextOrder("SUBAGENT_DELEGATION"),
|
|
522
|
+
text: (context) => {
|
|
523
|
+
if (context.agent === void 0 || mounted === void 0 || runtimeCtx.tools.get(toolName, context.scope) !== mounted.definition) return "";
|
|
524
|
+
const maxDepth = runtimeCtx.subagents.resolveMaxDepth(config.maxDepth);
|
|
525
|
+
if (maxDepth === void 0) return "";
|
|
526
|
+
const depth = delegationDepthOf(context.agent);
|
|
527
|
+
if (depth < maxDepth) return "";
|
|
528
|
+
return `Delegation depth for \`${toolName}\`: current ${depth}, maximum ${maxDepth}, remaining levels 0. Do not call \`${toolName}\` at this depth; carry out the work directly.`;
|
|
529
|
+
}
|
|
530
|
+
});
|
|
452
531
|
};
|
|
453
|
-
|
|
532
|
+
const compositionScope = scopeOf(ctx);
|
|
533
|
+
if (presets.configured && (session !== void 0 || compositionScope === void 0)) await presets.validate(ctx);
|
|
534
|
+
if (!modelSelectionCapable && (!presets.configured || session !== void 0 || compositionScope === void 0)) {
|
|
454
535
|
install(ctx, void 0);
|
|
455
536
|
return;
|
|
456
537
|
}
|
|
457
538
|
const settings = ctx.get("subagentModelSelection");
|
|
458
|
-
if (settings === void 0) throw new Error("tool-subagent: `modelSelectionSettings` requires @qlzt/dsh-tool-subagent/model-selection-settings in the Host scope");
|
|
539
|
+
if (modelSelectionCapable && settings === void 0) throw new Error("tool-subagent: `modelSelectionSettings` requires @qlzt/dsh-tool-subagent/model-selection-settings in the Host scope");
|
|
459
540
|
const selectForSession = (target) => {
|
|
541
|
+
if (!modelSelectionCapable || settings === void 0) return void 0;
|
|
460
542
|
const freshSession = target.firstLiveSeq === 0 && target.eventAt(SessionSeq(0))?.type !== "session/end-seed";
|
|
461
543
|
let allowedModels = subagentModelSelectionPolicy(ctx.sessionProjections, target);
|
|
462
544
|
if (allowedModels === void 0) {
|
|
@@ -478,7 +560,6 @@ function apply(ctx, config, session) {
|
|
|
478
560
|
install(ctx, selectForSession(session));
|
|
479
561
|
return;
|
|
480
562
|
}
|
|
481
|
-
const compositionScope = scopeOf(ctx);
|
|
482
563
|
if (compositionScope === void 0) throw new Error("tool-subagent: standing `modelSelectionSettings` requires a scoped preset Context");
|
|
483
564
|
const agents = ctx.get("agents");
|
|
484
565
|
/* v8 ignore next -- shipped preset compositions always include the Agent registry. */
|
|
@@ -498,7 +579,8 @@ function apply(ctx, config, session) {
|
|
|
498
579
|
"tools",
|
|
499
580
|
"subagents",
|
|
500
581
|
"systemPrompt"
|
|
501
|
-
], (runtimeCtx) => {
|
|
582
|
+
], async (runtimeCtx) => {
|
|
583
|
+
if (presets.configured) await presets.validate(ctx);
|
|
502
584
|
install(runtimeCtx, policy);
|
|
503
585
|
});
|
|
504
586
|
} finally {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -9,10 +9,11 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
9
9
|
import z from '@deepseek-ai/schemastery';
|
|
10
10
|
import type { AgentOptions } from '@qlzt/dsh-agent';
|
|
11
11
|
import type { Session } from '@qlzt/dsh-session';
|
|
12
|
+
import { type PresetSelectionConfig } from './preset-selection.ts';
|
|
12
13
|
export declare const name = "tool-subagent";
|
|
13
14
|
export declare const inject: string[];
|
|
14
15
|
/** Config: which registered provider this tool delegates to, plus child defaults. */
|
|
15
|
-
export interface Config {
|
|
16
|
+
export interface Config extends PresetSelectionConfig {
|
|
16
17
|
/** The `ctx.subagents` provider name to start runs on (e.g. `spawn`, `acp`). */
|
|
17
18
|
provider: string;
|
|
18
19
|
/**
|
|
@@ -29,22 +30,6 @@ export interface Config {
|
|
|
29
30
|
* Agent options applied to every child; omitted fields use child-loop defaults.
|
|
30
31
|
*/
|
|
31
32
|
agentOptions?: AgentOptions;
|
|
32
|
-
/**
|
|
33
|
-
* Per-child persona that shadows `deployment:persona-prefix`. Requires the
|
|
34
|
-
* provider's `persona` capability; omission preserves the deployment persona.
|
|
35
|
-
*/
|
|
36
|
-
persona?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Tool filter applied to every child. Filtered tools disappear from its
|
|
39
|
-
* prompt and reject execution. Requires the provider's `toolFilter`
|
|
40
|
-
* capability; unknown names fail startup.
|
|
41
|
-
*/
|
|
42
|
-
toolFilter?: {
|
|
43
|
-
/** Global tool names the child keeps; everything else is removed. */
|
|
44
|
-
allow?: string[];
|
|
45
|
-
/** Global tool names removed from the child. */
|
|
46
|
-
deny?: string[];
|
|
47
|
-
};
|
|
48
33
|
/**
|
|
49
34
|
* Maximum child depth: a non-negative safe integer (`0` forbids delegation),
|
|
50
35
|
* or `'provider-managed'` to send no cap. A numeric cap
|
|
@@ -60,9 +45,10 @@ export interface Config {
|
|
|
60
45
|
export declare const Config: z<Config>;
|
|
61
46
|
/**
|
|
62
47
|
* Install one delegation-tool composition.
|
|
48
|
+
* Standing preset choices are validated for each Agent before its tool is installed.
|
|
63
49
|
* @param ctx - Context that owns the registrations.
|
|
64
50
|
* @param config - delegation-tool configuration.
|
|
65
51
|
* @param session - unpublished Session supplied by a direct Agent setup; omit for a standing composition.
|
|
66
52
|
*/
|
|
67
|
-
export declare function apply(ctx: Context, config: Config, session?: Session): void
|
|
53
|
+
export declare function apply(ctx: Context, config: Config, session?: Session): Promise<void>;
|
|
68
54
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Deployment-owned preset choices for one delegation tool. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { SubagentProvider } from '@qlzt/dsh-subagent';
|
|
4
|
+
/** Optional default and model-selectable preset ids for a spawn tool. */
|
|
5
|
+
export interface PresetSelectionConfig {
|
|
6
|
+
/** Default independent preset; omission inherits the parent when the model makes no selection. */
|
|
7
|
+
agentPreset?: string;
|
|
8
|
+
/** Non-empty allowlist exposing agent_preset to the model; omission disables model selection. */
|
|
9
|
+
allowedAgentPresets?: string[] | undefined;
|
|
10
|
+
}
|
|
11
|
+
/** Untrusted preset selection from model/tool JSON. */
|
|
12
|
+
export interface PresetSelectionRequest {
|
|
13
|
+
readonly agent_preset?: unknown;
|
|
14
|
+
}
|
|
15
|
+
/** Validates configured references and resolves model input against the allowlist. */
|
|
16
|
+
export declare class SubagentPresetSelection {
|
|
17
|
+
private readonly config;
|
|
18
|
+
private descriptions;
|
|
19
|
+
constructor(config: PresetSelectionConfig);
|
|
20
|
+
/** Whether this tool requires the preset service and an independently composing provider. */
|
|
21
|
+
get configured(): boolean;
|
|
22
|
+
/** Preset ids advertised in the model parameter. */
|
|
23
|
+
get choices(): readonly string[] | undefined;
|
|
24
|
+
/** Model-visible selection guidance and configured preset descriptions. */
|
|
25
|
+
get description(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Read configured preset declarations before publishing the tool; mounting validates their activation.
|
|
28
|
+
* @param ctx - Tool composition containing the preset service.
|
|
29
|
+
*/
|
|
30
|
+
validate(ctx: Context): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Reject independent selection for providers that inherit conversation history or lack support.
|
|
33
|
+
* @param provider - Currently registered delegation provider.
|
|
34
|
+
*/
|
|
35
|
+
assertProvider(provider: SubagentProvider): void;
|
|
36
|
+
/**
|
|
37
|
+
* Validate model input and apply the deployment default.
|
|
38
|
+
* @param request - Model-supplied tool arguments.
|
|
39
|
+
* @returns Selected preset id, or omission to inherit the parent.
|
|
40
|
+
*/
|
|
41
|
+
resolve(request: PresetSelectionRequest): string | undefined;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=preset-selection.d.ts.map
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlzt/dsh-tool-subagent",
|
|
3
3
|
"description": "Model-facing subagent delegation tool over the ctx.subagents seam",
|
|
4
|
-
"version": "0.2.1-
|
|
4
|
+
"version": "0.2.1-rc.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -23,43 +23,54 @@
|
|
|
23
23
|
"default": "./lib/model-selection-settings.js"
|
|
24
24
|
},
|
|
25
25
|
"./src/*": "./src/*",
|
|
26
|
-
"./package.json": "./package.json"
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
"./locale/*.json": "./locale/*.json",
|
|
28
|
+
"./model-selection-settings/locale/*.json": "./locale/model-selection-settings/*.json"
|
|
27
29
|
},
|
|
28
30
|
"files": [
|
|
31
|
+
"locale/*.json",
|
|
32
|
+
"locale/model-selection-settings/*.json",
|
|
29
33
|
"lib/index.js",
|
|
30
34
|
"lib/model-selection-settings.js",
|
|
31
35
|
"lib/types/**/*.d.ts"
|
|
32
36
|
],
|
|
33
37
|
"license": "MIT",
|
|
34
38
|
"peerDependencies": {
|
|
35
|
-
"@qlzt/dsh-agent": "0.2.1-
|
|
36
|
-
"@qlzt/dsh-
|
|
37
|
-
"@qlzt/dsh-
|
|
38
|
-
"@qlzt/dsh-session
|
|
39
|
-
"@qlzt/dsh-
|
|
40
|
-
"@qlzt/dsh-
|
|
41
|
-
"@qlzt/dsh-
|
|
42
|
-
"@qlzt/dsh-
|
|
43
|
-
"@
|
|
39
|
+
"@qlzt/dsh-agent": "0.2.1-rc.2",
|
|
40
|
+
"@qlzt/dsh-agent-preset-registry": "0.2.1-rc.2",
|
|
41
|
+
"@qlzt/dsh-llm": "0.2.1-rc.2",
|
|
42
|
+
"@qlzt/dsh-session": "0.2.1-rc.2",
|
|
43
|
+
"@qlzt/dsh-session-projection": "0.2.1-rc.2",
|
|
44
|
+
"@qlzt/dsh-scope": "0.2.1-rc.2",
|
|
45
|
+
"@qlzt/dsh-subagent": "0.2.1-rc.2",
|
|
46
|
+
"@qlzt/dsh-system-prompt": "0.2.1-rc.2",
|
|
47
|
+
"@qlzt/dsh-tools": "0.2.1-rc.2",
|
|
48
|
+
"@deepseek-ai/cordis": "~4.0.5"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@deepseek-ai/dsh-agent-preset-registry": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
44
54
|
},
|
|
45
55
|
"dependencies": {
|
|
46
|
-
"@deepseek-ai/schemastery": "~3.18.5
|
|
47
|
-
"zod": "
|
|
56
|
+
"@deepseek-ai/schemastery": "~3.18.5",
|
|
57
|
+
"zod": "4.4.3"
|
|
48
58
|
},
|
|
49
59
|
"devDependencies": {
|
|
50
|
-
"@deepseek-ai/cordis-plugin-loader": "~1.0.6
|
|
51
|
-
"@deepseek-ai/dsh-agent": "0.2.1-
|
|
52
|
-
"@deepseek-ai/dsh-
|
|
53
|
-
"@deepseek-ai/dsh-
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
56
|
-
"@deepseek-ai/dsh-session-persistence
|
|
57
|
-
"@deepseek-ai/dsh-
|
|
58
|
-
"@deepseek-ai/dsh-subagent
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
"@deepseek-ai/
|
|
62
|
-
"@deepseek-ai/
|
|
60
|
+
"@deepseek-ai/cordis-plugin-loader": "~1.0.6",
|
|
61
|
+
"@deepseek-ai/dsh-agent": "0.2.1-rc.2",
|
|
62
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.1-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-llm": "0.2.1-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-session": "0.2.1-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-scope": "0.2.1-rc.2",
|
|
66
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2",
|
|
67
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-rc.2",
|
|
68
|
+
"@deepseek-ai/dsh-subagent": "0.2.1-rc.2",
|
|
69
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.1-rc.2",
|
|
70
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
|
|
71
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.2",
|
|
72
|
+
"@deepseek-ai/cordis": "~4.0.5",
|
|
73
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-rc.2"
|
|
63
74
|
},
|
|
64
75
|
"dsh": {}
|
|
65
76
|
}
|