dsh-submodel 0.1.0 → 0.2.0

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.en.md ADDED
@@ -0,0 +1,249 @@
1
+ # dsh-submodel
2
+
3
+ **The default policy pack for the official subagent.** Install once and "who does what, when to delegate, and to whom" is configured for you.
4
+
5
+ ![dsh-submodel: the main model routes work to an executor route or expert routes](https://raw.githubusercontent.com/angel291592/dsh-submodel/main/assets/hero.svg)
6
+
7
+ [![npm version](https://img.shields.io/npm/v/dsh-submodel.svg)](https://www.npmjs.com/package/dsh-submodel)
8
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-submodel.svg)](https://www.npmjs.com/package/dsh-submodel)
9
+ [![license](https://img.shields.io/npm/l/dsh-submodel.svg)](https://github.com/angel291592/dsh-submodel/blob/main/LICENSE)
10
+ [![DSH](https://img.shields.io/badge/DeepSeek%20Harness-%E2%89%A50.2.2-4d6bfe.svg)](https://github.com/angel291592/dsh-submodel)
11
+ [![dshbase](https://img.shields.io/badge/dshbase-install--tested-2ea44f.svg)](https://github.com/ylwl1997/dshbase/issues/221)
12
+
13
+ [中文](README.md) | **English**
14
+
15
+ It does **not** ship its own provider system — it reads the channels and models already configured in your
16
+ profile, writes a delegation policy into the system prompt, and adds one unified entry point
17
+ (`delegate_task`) on top of the official `subagent`. Since 0.2.0 the mode is decided by **route** (no model
18
+ naming convention required), and there is a first-run setup wizard plus `economyRoutes`. Requires DSH
19
+ `0.2.2-rc.1` (`0.2.1` and older are not compatible).
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ dsh plugin --profile <your-profile> add dsh-submodel # 1. install
25
+ dsh --profile <your-profile> # 2. start (restart the profile after adding)
26
+ # 3. on the first session, follow "Configuration (two steps)" below; or call configure_submodel
27
+ ```
28
+
29
+ ## Configuration (two steps)
30
+
31
+ Configuration has **two layers**, and delegation only works when both are done:
32
+
33
+ | Layer | What it controls | If missing |
34
+ |---|---|---|
35
+ | ① Host authorization | DSH's own "subagent model selection" setting: which routes a subagent may switch to | Delegating to a non-inherited route fails with `child LLM route "…/…" is not allowed for this Session` |
36
+ | ② Plugin config | This package's `executor` (execution route) and `experts` (expert routes) | In boss mode there is no default delegation target: an `error` is logged and nothing is delegated |
37
+
38
+ ### ① Host authorization (required)
39
+
40
+ By default the native `subagent` only lets a child inherit the parent session's route. To let a child switch
41
+ to an execution/expert route, authorize it in the host first:
42
+
43
+ - **GUI**: open **subagent model selection** in Settings (config id `subagent-model-selection-settings`),
44
+ turn it on, and add the execution route and expert routes to the allow-list one by one.
45
+ - **Or write the profile patch YAML** (`~/.dsh/profiles/<your-profile>/cordis.patch.yml`; the file is an empty
46
+ array `[]` by default — append the entry to that array):
47
+
48
+ ```yaml
49
+ - id: subagent-model-selection-settings
50
+ config:
51
+ enabled: true
52
+ allowedModels:
53
+ - provider: your-provider
54
+ model: your-model
55
+ - provider: your-provider
56
+ model: your-strong-model
57
+ ```
58
+
59
+ Note: `allowedModels` must not be empty when `enabled: true`; host authorization only applies to **new
60
+ sessions**, so open a new session (or restart the profile) after writing it.
61
+
62
+ ### ② Plugin configuration (pick one)
63
+
64
+ **Option A (recommended): call `configure_submodel` on the first session — it writes both places**
65
+
66
+ No YAML by hand. As long as you are the top-level agent, `autoConfigure` keeps its default `true`, and
67
+ `executor` is not configured yet, the `configure_submodel` tool appears on the first session:
68
+
69
+ 1. Call it. It asks three questions — **execution route** (where verifiable execution blocks go; single
70
+ choice), **expert routes** (models you may name when escalating; multi-choice), and **whether to write the
71
+ host authorization row too** (recommended: yes);
72
+ 2. On confirmation it uses the official `configEditor` to write **host authorization first, then plugin
73
+ config** (the plugin config's `executor`, `experts` and `economyRoutes` all reflect your choices), so both
74
+ take effect together;
75
+ 3. It takes effect on the next session. Writing the plugin config reloads this plugin and the tool
76
+ disappears afterwards — that is expected, not an error.
77
+
78
+ On clients without a GUI (headless / plain CLI) or when a required service is missing, no question card is
79
+ shown: the tool returns copyable manual YAML instead and **writes nothing**.
80
+
81
+ **Option B: five-line YAML by hand**
82
+
83
+ In your profile patch layer (`~/.dsh/profiles/<your-profile>/cordis.patch.yml`), override this package by id.
84
+ The file is an empty array `[]` by default: **replace `[]` with the entry below**; if it already has entries,
85
+ append this one to the array.
86
+
87
+ ```yaml
88
+ - id: submodel
89
+ config:
90
+ executor:
91
+ provider: your-provider
92
+ model: your-model
93
+ ```
94
+
95
+ Note: a profile patch **replaces the whole `config` block** of an entry — fields you leave out fall back to
96
+ their defaults (see the table below); they are not merged field by field with the built-in defaults.
97
+
98
+ Full field reference:
99
+
100
+ | Field | Default | Description |
101
+ |---|---|---|
102
+ | `enabled` | `true` | Master switch; when `false`, only an empty prompt section is registered and no tools/guards are installed |
103
+ | `autoConfigure` | `true` | Whether to register the `configure_submodel` wizard for first-run setup (visible only for a top-level agent whose `executor` is not configured); turn it off to configure everything manually |
104
+ | `preset` | `standard` | Only applies to that composition |
105
+ | `executor.provider` / `executor.model` | empty | Execution route: the default delegation target in boss mode; **leaving it empty logs an `error`** (see Troubleshooting). Switching the main model to this route also means Flash mode |
106
+ | `executor.reasoningEffort` | `max` | Default effort only when the caller did not specify one |
107
+ | `economyRoutes` | `[]` | Extra "cheap routes", each `{provider?, model}`: the current request matching any of them counts as Flash (`economize`) mode. Omit `provider` to match on `model` alone; **when non-empty, the legacy flash-suffix rule no longer applies** |
108
+ | `experts` | `[]` | Expert routes you may name explicitly when escalating, each `{label, provider, model, reasoningEffort?}`; `reasoningEffort` is reserved for now and does not affect delegation |
109
+ | `texts.economize` / `texts.boss` / `texts.child` | empty | When non-empty, replaces the built-in prompt section verbatim (no interpolation afterwards) |
110
+ | `toolName` | `list_subagent_models` | Tool name used as the capability gate for the policy section |
111
+ | `order` | `2850` | Order of the policy section in the system prompt |
112
+ | `guardNativeSubagent` | `true` | Whether to reject a non-economy-route (non-Flash mode) top-level agent that calls the native `subagent` without a complete provider/model pair |
113
+
114
+ ## How it decides who does what (route-based since 0.2.0)
115
+
116
+ There are two modes, and the decision looks only at the **route of the current request** (`provider` +
117
+ `model`) — no model-name suffix is required:
118
+
119
+ 1. Current request route **== the configured `executor` route** → **Flash (`economize`) mode**;
120
+ 2. The request matches any route in **`economyRoutes`** → **Flash (`economize`) mode** (for multiple cheap routes);
121
+ 3. When `economyRoutes` is empty, the legacy rule still applies: a model name ending in `flash` → **Flash
122
+ (`economize`) mode**;
123
+ 4. Everything else → **boss mode**.
124
+
125
+ Built-in behaviour:
126
+
127
+ - **Flash mode**: do the work yourself by default; ordinary subtasks go through `delegate_task` (no
128
+ provider/model — the child inherits the current route); escalate only when "the problem itself is complex"
129
+ or "it exceeds your execution limits", naming a route from `experts`.
130
+ - **Boss mode**: understanding, judgement and writing stay with the main model; verifiable execution blocks
131
+ default to the configured `executor` route.
132
+ - **Children**: hard boundary — `delegate_task` / `subagent` / `subagent_fork` / `workflow` / `spawn_teammate`
133
+ are unavailable to a child, preventing recursive delegation.
134
+ - **`delegate_task`**: same parameters as the native `subagent` (`description`, `prompt`, and optional
135
+ `provider` / `model` / `reasoning_effort`; `provider` and `model` must be supplied **together** — one alone
136
+ fails immediately). It goes through `ctx.tools.execute` and raises a real native call, so the host's
137
+ allowlist / preflight / permissions still apply. Since 0.2.0 the semantics are "starts an independently
138
+ managed subagent and **immediately returns its id**; the runtime notifies you when it finishes": do not poll
139
+ repeatedly — use `list_agents` to look at live subagents, `send_message` to append, and `interrupt_agent` to
140
+ stop. Call `list_subagent_models` first if you are unsure which routes are authorized.
141
+
142
+ Two typical calls:
143
+
144
+ ```json
145
+ // 1) Boss → execution route: omit provider/model and the configured executor is filled in
146
+ { "description": "run the tests", "prompt": "<complete task: goal, constraints, what has been tried>" }
147
+ ```
148
+
149
+ ```json
150
+ // 2) Escalate → expert route: provider/model together, and the route must be in the host allow-list
151
+ { "description": "review the state machine", "prompt": "<complete task>", "provider": "your-provider", "model": "your-model" }
152
+ ```
153
+
154
+ ## Relationship to the official plugins
155
+
156
+ | Capability | Provided by |
157
+ |---|---|
158
+ | Status view `list_agents`, append `send_message`, stop `interrupt_agent` | Official `@deepseek-ai/dsh-tool-subagent-control` (this package does **not** register them) |
159
+ | Policy text, `delegate_task`, child guard, `configure_submodel` wizard | This package |
160
+ | Model selection itself (`provider` / `model` parameters of `subagent`) | Official subagent (this package only consumes it) |
161
+
162
+ ## Compatibility
163
+
164
+ | DSH version | Status |
165
+ |---|---|
166
+ | `0.2.2-rc.1` | ✅ Target version: fixture + isolated-profile **real-host load verified**; GUI end-to-end is for the user to accept (**not verified**) |
167
+ | `0.2.1-rc.5` and older | ❌ Incompatible: no batch `ctx.tools.execute`, and no 0.2.2 child-route semantics |
168
+ | Other `0.2.x` versions | Not tested per version; `engines.dsh` declares `>=0.2.2-rc.1 <0.3.0`, so out-of-range versions are rejected by the installer |
169
+
170
+ ## Troubleshooting
171
+
172
+ Fail-fast: startup warnings are logged only and never thrown; errors only surface when you call a tool.
173
+
174
+ | Symptom | Level | Meaning and fix |
175
+ |---|---|---|
176
+ | `config.executor.provider/model 未配置,自动委派不可用…` | `error` | No default delegation target: call `configure_submodel` or add `executor` manually as in "Configuration (two steps)" |
177
+ | `child LLM route "…/…" is not allowed for this Session` | error on delegation | **Host authorization missing** (or this route is not in the allow-list): open "subagent model selection", add the route (takes effect on new sessions), or re-run `configure_submodel` and accept the host-authorization write |
178
+ | `configure_submodel` is not visible | — | ① `executor` is already configured (the wizard intentionally appears only once); ② `autoConfigure` is `false`; ③ the native `subagent` in this session exposes no model-selection parameters (check that model selection is enabled in the profile/preset); ④ you are not the top-level agent |
179
+ | `configure_submodel` returns no question card | — | The client has no GUI (headless / plain CLI), so there is nobody to ask; the tool returns manual YAML and writes nothing — use Option B above |
180
+ | `当前 profile 无 agentPresets 服务,策略不生效` | `warn` | This profile has no agentPresets service; use a profile that supports compositions |
181
+ | `原生 subagent 未暴露 provider/model,delegate_task 不安装` | `warn` | The native `subagent` in this session exposes no model-selection parameters: the whole install (policy section / guard / tools) is skipped and retried automatically once the capability appears |
182
+ | `本会话未启用官方 subagent 模型选择,策略段不渲染` | `info` | Enable `subagent-model-selection-settings` in Settings (host authorization applies to new sessions only); tools are still installed subject to their own gate |
183
+
184
+ ## Known limitations
185
+
186
+ - The policy text is Chinese by default; override it with `texts.*` (tool descriptions and some guard
187
+ rejections stay in English).
188
+ - Applies only to the composition named by `preset` (default `standard`).
189
+ - No budget guard / nudging / failure re-routing (watchdog).
190
+ - `configure_submodel` writes exactly two places — this package's config row and the host authorization row
191
+ (`subagent-model-selection-settings`); it does not create channels or credentials and does not touch other
192
+ plugins.
193
+ - Model metadata has no price field, so which routes count as "cheap" is up to your configuration (the wizard
194
+ only pre-fills candidates; it does not decide for you).
195
+ - Non-GUI clients have no question card, so use Option B (manual YAML).
196
+
197
+ ## Rollback
198
+
199
+ ```bash
200
+ dsh plugin --profile <your-profile> remove dsh-submodel
201
+ ```
202
+
203
+ Removing the plugin leaves the host authorization row in the profile patch; to revert that too, delete the
204
+ `subagent-model-selection-settings` entry manually.
205
+
206
+ ## Development and verification
207
+
208
+ ```bash
209
+ npm install # development dependency (schemastery)
210
+ node tests/unit/flash-routing-fixture.mjs ./lib # pure functions + lifecycle regression
211
+ python -m unittest discover -s tests/unit # Python driver (run from the package root)
212
+ node tests/unit/public-profile-smoke.mjs # deterministic smoke test with a clean user config
213
+ ```
214
+
215
+ Current verification counts (CI runs the same commands on every push / PR, see `.github/workflows/ci.yml`):
216
+
217
+ <!-- verification counts: fixture / Python / smoke numbers live only in this table; update here if measurements differ. -->
218
+
219
+ | Check | Result |
220
+ |---|---|
221
+ | fixture | **104** assertions, `failed: 0` |
222
+ | Python driver | **7** test cases, `OK` |
223
+ | Public-profile smoke | **7** assertions, `failed: 0` |
224
+
225
+ GUI end-to-end (the `configure_submodel` card and both writes, `delegate_task` delegation, and switching the
226
+ main model to the execution route to enter economize mode) must be accepted by the user in a restarted real
227
+ GUI session and is **not verified yet**.
228
+
229
+ ## Contributing
230
+
231
+ - Read [CONTRIBUTING.en.md](CONTRIBUTING.en.md) ([简体中文](CONTRIBUTING.md)) before opening an issue or a
232
+ pull request: it lists the three test suites, the commit format, and what must not end up in the repo.
233
+ - Security problems go through the private channel in [SECURITY.en.md](SECURITY.en.md), not a public issue.
234
+ - By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.en.md).
235
+
236
+ ## Releasing (maintainers)
237
+
238
+ Releases go through GitHub Actions + npm **Trusted Publishing (OIDC)**; no npm token is stored on this
239
+ machine or in the repository:
240
+
241
+ 1. Add a `## <version> (YYYY-MM-DD)` section at the top of `CHANGELOG.md`;
242
+ 2. On `main`, run `pwsh scripts/release.ps1 <version>`: it runs the gates, bumps the `package.json`
243
+ version, commits, tags and pushes, then polls npm until the new version appears;
244
+ 3. The repository's `release` workflow (`.github/workflows/release.yml`) re-runs the tests after the tag
245
+ push and publishes with `npm publish`; the script tries to create the GitHub Release once npm confirms.
246
+
247
+ One-time setup: configure a Trusted Publisher in the npm package settings (repository
248
+ `angel291592/dsh-submodel`, workflow `release.yml`, allow Direct publish). After that, releasing needs no
249
+ npm password, one-time code, or token.
package/README.md CHANGED
@@ -1,27 +1,87 @@
1
1
  # dsh-submodel
2
2
 
3
- > **官方 subagent 的默认策略包**:装上一次配好「什么时候自己干、什么时候派出去、派给谁」。
3
+ **官方 subagent 的默认策略包**:装上一次配好「什么时候自己干、什么时候派出去、派给谁」。
4
+
5
+ ![dsh-submodel:主脑按意图把任务路由到执行路由或专家路由](https://raw.githubusercontent.com/angel291592/dsh-submodel/main/assets/hero.svg)
6
+
7
+ [![npm version](https://img.shields.io/npm/v/dsh-submodel.svg)](https://www.npmjs.com/package/dsh-submodel)
8
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-submodel.svg)](https://www.npmjs.com/package/dsh-submodel)
9
+ [![license](https://img.shields.io/npm/l/dsh-submodel.svg)](https://github.com/angel291592/dsh-submodel/blob/main/LICENSE)
10
+ [![DSH](https://img.shields.io/badge/DeepSeek%20Harness-%E2%89%A50.2.2-4d6bfe.svg)](https://github.com/angel291592/dsh-submodel)
11
+ [![dshbase](https://img.shields.io/badge/dshbase-install--tested-2ea44f.svg)](https://github.com/ylwl1997/dshbase/issues/221)
12
+
13
+ **中文** | [English](README.en.md)
4
14
 
5
15
  它**不新建 provider 体系**——只读你 profile 里已有的渠道与模型配置,把委派策略写进系统提示词,
6
- 并给官方 `subagent` 补一个统一的委派入口 `delegate_task`。本机实测于 DeepSeek Harness `0.2.1-rc.5`。
16
+ 并给官方 `subagent` 补一个统一的委派入口 `delegate_task`。0.2.0 起模式按**路由**判定(不再依赖
17
+ 模型命名约定),并提供首次配置向导与 `economyRoutes`;要求 DSH `0.2.2-rc.1`(`0.2.1` 及更早不兼容)。
7
18
 
8
19
  ## 安装
9
20
 
10
21
  ```bash
11
- dsh plugin --profile <你的 profile> add dsh-submodel
22
+ dsh plugin --profile <你的 profile> add dsh-submodel # 1. 安装
23
+ dsh --profile <你的 profile> # 2. 启动(装完插件需重启 profile)
24
+ # 3. 首次会话按下面「两步配置」完成授权与路由;或直接调用 configure_submodel
25
+ ```
26
+
27
+ ## 配置(两步)
28
+
29
+ 配置分**两层**,缺一层都派不出去:
30
+
31
+ | 层 | 管什么 | 缺失的后果 |
32
+ |---|---|---|
33
+ | ① 宿主授权 | DSH 自己的「子代理模型选择」设置:允许子代理切到哪些路由 | 子代理要切到非继承路由时,派工报 `child LLM route "…/…" is not allowed for this Session` |
34
+ | ② 插件配置 | 本包的 `executor`(执行路由)与 `experts`(专家路由) | 强主脑模式下没有默认派工目标,只记 error 日志、不派工 |
35
+
36
+ ### ① 宿主授权(必须)
37
+
38
+ DSH 原生 `subagent` 默认只允许子代理沿用父会话的路由;要让子代理切到执行/专家路由,先做宿主授权:
39
+
40
+ - **GUI**:打开「设置」里的 **子代理模型选择**(配置项 id 为 `subagent-model-selection-settings`),
41
+ 打开开关,并把执行路由、专家路由**逐条**加入允许列表。
42
+ - **或手写 profile 补丁 YAML**(`~/.dsh/profiles/<你的 profile>/cordis.patch.yml`;该文件默认是空数组
43
+ `[]`,把下面的条目追加进数组即可):
44
+
45
+ ```yaml
46
+ - id: subagent-model-selection-settings
47
+ config:
48
+ enabled: true
49
+ allowedModels:
50
+ - provider: your-provider
51
+ model: your-model
52
+ - provider: your-provider
53
+ model: your-strong-model
12
54
  ```
13
55
 
14
- ## 配置(5 行)
56
+ 注意:`enabled: true` 时 `allowedModels` 不能为空;宿主授权**只对新会话生效**,写完要新开会话(或重启 profile)。
57
+
58
+ ### ② 插件配置(二选一)
59
+
60
+ **方式 A(推荐):首次会话调用 `configure_submodel` 自动写两处**
61
+
62
+ 不用手写 YAML。只要满足:顶层主代理 + `autoConfigure` 保持默认 `true` + `executor` 还没配置,
63
+ 首次会话里就会出现 `configure_submodel` 工具:
64
+
65
+ 1. 调用它,会依次问 3 个问题——**执行路由**(日常可验证的执行块派给谁,单选)、
66
+ **专家路由**(需要升级时允许点名的模型,可多选)、**是否同时写宿主授权表**(推荐「是」);
67
+ 2. 确认后它用官方 `configEditor` **先写宿主授权、再写插件配置**(插件配置里的 `executor`、`experts`
68
+ 与 `economyRoutes` 都按你的选择落盘),两处一起生效;
69
+ 3. 新会话生效。写入成功后本插件会重载、该工具随之消失——这是预期的,不是出错。
70
+
71
+ 没有 GUI 客户端(headless / 纯 CLI)或相关服务不可用时,它不会弹卡,而是直接返回可复制的手动
72
+ YAML,并且**不会写任何配置**。
73
+
74
+ **方式 B:手动写 5 行 YAML**
15
75
 
16
- 在你的 profile 补丁层(`~/.dsh/profiles/<你的 profile>/cordis.patch.yml`)里按 id 覆盖配置。
76
+ 在 profile 补丁层(`~/.dsh/profiles/<你的 profile>/cordis.patch.yml`)里按 id 覆盖配置。
17
77
  该文件默认是空数组 `[]`:**把 `[]` 替换成下面的条目**;已有其他条目时,把它追加到数组里。
18
78
 
19
79
  ```yaml
20
80
  - id: submodel
21
81
  config:
22
82
  executor:
23
- provider: <执行渠道>
24
- model: <执行模型>
83
+ provider: your-provider
84
+ model: your-model
25
85
  ```
26
86
 
27
87
  注意:profile 补丁对某一条目的 `config` 是**整段替换**——没写的字段回落到默认值(见下表),
@@ -32,55 +92,91 @@ dsh plugin --profile <你的 profile> add dsh-submodel
32
92
  | 字段 | 默认值 | 说明 |
33
93
  |---|---|---|
34
94
  | `enabled` | `true` | 总开关;`false` 时只注册一个空段,不装任何工具/guard |
95
+ | `autoConfigure` | `true` | 是否在首次配置时注册 `configure_submodel` 向导(顶层主代理且 `executor` 未配置才可见);关掉后完全手动配置 |
35
96
  | `preset` | `standard` | 只对这个 composition 生效 |
36
- | `executor.provider` / `executor.model` | 空 | 非 Flash 主脑的默认派工目标;**留空会记 error 日志**(见故障排查) |
97
+ | `executor.provider` / `executor.model` | 空 | 执行路由:强主脑的默认派工目标;**留空会记 error 日志**(见故障排查)。主模型切到这条路由本身也等于进入 Flash 模式 |
37
98
  | `executor.reasoningEffort` | `max` | 只在调用方没显式指定档位时作缺省 |
99
+ | `economyRoutes` | `[]` | 额外声明「便宜路由」,每项 `{provider?, model}`:本次请求命中任一项即算 Flash(economize)模式。`provider` 省略时只按 `model` 匹配;**非空时旧的 flash 后缀规则不再生效** |
38
100
  | `experts` | `[]` | 允许升级时显式点名的专家路由列表,每项 `{label, provider, model, reasoningEffort?}`;`reasoningEffort` 目前为预留字段,不影响派工 |
39
101
  | `texts.economize` / `texts.boss` / `texts.child` | 空 | 非空时整段替换内置正文(替换后不再插值) |
40
102
  | `toolName` | `list_subagent_models` | 策略段的能力门控工具名 |
41
103
  | `order` | `2850` | 策略段在系统提示词里的顺序 |
42
- | `guardNativeSubagent` | `true` | 是否拦截"非 Flash 顶层用原生 `subagent` 却不给完整 provider/model" |
104
+ | `guardNativeSubagent` | `true` | 是否拦截"非经济路由(非 Flash 模式)顶层用原生 `subagent` 却不给完整 provider/model" |
43
105
 
44
- ## 它做什么
106
+ ## 它怎么判断该谁干(0.2.0 起按路由)
45
107
 
46
- - **Flash 主脑**:默认自己干;普通子任务用 `delegate_task`(不传 provider/model,子代继承当前路由);
108
+ 两种模式,判定只看**本次请求的路由**(`provider` + `model`),不再要求模型名带特定后缀:
109
+
110
+ 1. 本次请求路由 **== 配置的 `executor` 路由** → **Flash(`economize`)模式**;
111
+ 2. 命中配置的 **`economyRoutes`** 任一条 → **Flash(`economize`)模式**(有多条便宜路由时用);
112
+ 3. `economyRoutes` 为空时保留旧版兼容:模型名以 `flash` 结尾 → **Flash(`economize`)模式**;
113
+ 4. 其余 → **强主脑(`boss`)模式**。
114
+
115
+ 内置正文与行为:
116
+
117
+ - **Flash 模式**:默认自己干;普通子任务用 `delegate_task`(不传 provider/model,子代继承当前路由);
47
118
  只有"问题本身够复杂"或"超出执行上限"时才升级,升级时从 `experts` 里点名。
48
- - **非 Flash 主脑**:理解/判断/写作自己来;可验证的执行块默认派给 `executor` 配置的执行路由。
119
+ - **强主脑模式**:理解/判断/写作自己来;可验证的执行块默认派给 `executor` 配置的执行路由。
49
120
  - **子代**:硬边界——`delegate_task` / `subagent` / `subagent_fork` / `workflow` / `spawn_teammate`
50
121
  一律不可用,防止递归派活。
51
- - **`delegate_task`**:参数与原生 `subagent` 相同;`provider` 与 `model` 必须成对传;经
52
- `ctx.tools.execute` 发起真正的原生调用,宿主的 allowlist / 预检 / 权限照旧生效。
122
+ - **`delegate_task`**:参数与原生 `subagent` 相同(`description`、`prompt`,以及可选的
123
+ `provider` / `model` / `reasoning_effort`;`provider` 与 `model` 必须**成对**传,只给一个会立即失败)。
124
+ 经 `ctx.tools.execute` 发起真正的原生调用,宿主的 allowlist / 预检 / 权限照旧生效。
125
+ 0.2.0 起语义为「启动后**立即返回子会话 id**,完成时由运行时通知」:不要反复轮询,需要查看在线
126
+ 子代理用 `list_agents`、追加消息用 `send_message`、停止用 `interrupt_agent`。
127
+ 不确定有哪些已授权路由时先调 `list_subagent_models`。
128
+
129
+ 两个典型用法:
130
+
131
+ ```json
132
+ // 1) 强主脑 → 执行路由:不传 provider/model,自动补 executor
133
+ { "description": "跑通测试", "prompt": "<完整任务说明:目标、约束、已试过的方案>" }
134
+ ```
135
+
136
+ ```json
137
+ // 2) 升级 → 专家路由:provider/model 成对,且必须已在宿主授权列表里
138
+ { "description": "复核状态机", "prompt": "<完整任务说明>", "provider": "your-provider", "model": "your-model" }
139
+ ```
53
140
 
54
141
  ## 与官方插件的边界
55
142
 
56
143
  | 能力 | 提供方 |
57
144
  |---|---|
58
145
  | 状态查看 `list_agents`、追加消息 `send_message`、停止 `interrupt_agent` | 官方 `@deepseek-ai/dsh-tool-subagent-control`(本包**不重复注册**) |
59
- | 策略正文、`delegate_task`、子代 guard | 本包 |
146
+ | 策略正文、`delegate_task`、子代 guard、`configure_submodel` 向导 | 本包 |
60
147
  | 模型选择能力本身(`subagent` 的 `provider`/`model` 参数) | 官方 subagent(本包只消费) |
61
148
 
62
149
  ## 兼容性
63
150
 
64
151
  | DSH 版本 | 状态 |
65
152
  |---|---|
66
- | `0.2.1-rc.5` | ✅ 实测通过(安装、`--dump-config`、启动均实测) |
67
- | 其他 rc / 正式版 | 未逐一实测(`engines.dsh` 声明 `>=0.2.1-rc.3 <0.3.0`,不作宽承诺) |
153
+ | `0.2.2-rc.1` | ✅ 目标版本:fixture + 隔离 profile **真机装载已验**;GUI 端到端由用户验收(**未验证**) |
154
+ | `0.2.1-rc.5` 及更早 | ❌ 不兼容:没有批量 `ctx.tools.execute`,也没有 0.2.2 的子代理路由语义 |
155
+ | 其他 `0.2.x` 版本 | 未逐版实测;`engines.dsh` 声明 `>=0.2.2-rc.1 <0.3.0`,范围外的版本会被安装器拦住 |
156
+
157
+ ## 故障排查
68
158
 
69
- ## 故障排查(fail-fast:只记日志,绝不抛)
159
+ fail-fast:启动期的告警只记日志、绝不抛;只有你主动调用工具时才可能收到错误。
70
160
 
71
- | 现象(日志) | 级别 | 含义与处理 |
161
+ | 现象 | 级别 | 含义与处理 |
72
162
  |---|---|---|
73
- | `config.executor.provider/model 未配置,自动委派不可用` | `error` | 非 Flash 主脑没有默认派工目标;按上面的 5 行配置补上 |
163
+ | `config.executor.provider/model 未配置,自动委派不可用…` | `error` | 没有默认派工目标:调用 `configure_submodel` 自动配置,或按上面「两步配置」手动补 `executor` |
164
+ | `child LLM route "…/…" is not allowed for this Session` | 派工时报错 | **宿主授权缺失**(或没包含这条路由):打开「子代理模型选择」并把该路由加入允许列表(新会话生效);或重新运行 `configure_submodel` 并勾选写宿主授权 |
165
+ | 看不到 `configure_submodel` | — | ① `executor` 已配置(向导按设计只出现一次);② `autoConfigure` 被设为 `false`;③ 当前会话的原生 `subagent` 没有选模参数(先确认 profile/preset 开启了模型选择);④ 当前不是顶层主代理 |
166
+ | 调用 `configure_submodel` 后没有弹提问卡 | — | 当前客户端没有 GUI(headless / 纯 CLI),没人可问;工具会返回手动 YAML 且不写配置,按「方式 B」手写即可 |
74
167
  | `当前 profile 无 agentPresets 服务,策略不生效` | `warn` | 该 profile 没有 agentPresets 服务;换一个支持 composition 的 profile |
75
- | `原生 subagent 未暴露 provider/model,delegate_task 不安装` | `warn` | 本会话的原生 `subagent` 没有选模参数:该 agent 上**整套安装**(策略段 / guard / `delegate_task`)都会跳过,等能力出现后由 `tools/change` 或 `agent/pre-step` 自动补装 |
76
- | `本会话未启用官方 subagent 模型选择,策略段不渲染` | `info` | 去设置里启用 `subagent-model-selection`;工具本身仍按注册门控安装 |
168
+ | `原生 subagent 未暴露 provider/model,delegate_task 不安装` | `warn` | 本会话的原生 `subagent` 没有选模参数:该 agent 上**整套安装**(策略段 / guard / 工具)都会跳过,等能力出现后由 `tools/change` 或 `agent/pre-step` 自动补装 |
169
+ | `本会话未启用官方 subagent 模型选择,策略段不渲染` | `info` | 去设置里启用 `subagent-model-selection-settings`(宿主授权只对新会话生效);工具本身仍按注册门控安装 |
77
170
 
78
171
  ## 已知限制
79
172
 
173
+ - 策略正文默认中文;可用 `texts.*` 整段覆盖(工具描述与部分 guard 拒绝理由仍为英文)。
80
174
  - 只对 `preset` 指定的 composition 生效(默认 `standard`)。
81
- - 不提供预算护栏 / 催收 / 故障改派(watchdog)——v0.2 候选。
82
- - 不提供英文文案与 locale:默认中文,可用 `texts.*` 整段覆盖(工具描述与 guard 拒绝理由仍为英文)。
83
- - 正文里的执行路由与专家路由全部来自你的配置,本包内置模板**不含任何具体渠道/模型名**。
175
+ - 不提供预算护栏 / 催收 / 故障改派(watchdog)。
176
+ - `configure_submodel` 只写两处:本插件配置行 + 宿主授权行(`subagent-model-selection-settings`);
177
+ 不创建渠道/密钥,也不改其他插件。
178
+ - 模型元数据里没有价格字段,哪些路由算"便宜"由你的配置决定(向导只做候选预填,不替你拍板)。
179
+ - 非 GUI 客户端没有提问卡可用,只能用「方式 B」手动 YAML。
84
180
 
85
181
  ## 回滚
86
182
 
@@ -88,10 +184,46 @@ dsh plugin --profile <你的 profile> add dsh-submodel
88
184
  dsh plugin --profile <你的 profile> remove dsh-submodel
89
185
  ```
90
186
 
187
+ 插件移除后,宿主授权行仍在 profile 补丁里;如需一并撤销,手动删除 `subagent-model-selection-settings` 条目即可。
188
+
91
189
  ## 开发与验证
92
190
 
93
191
  ```bash
94
- node tests/unit/flash-routing-fixture.mjs ./lib # 纯函数 + 生命周期回归(71 条断言)
95
- python -m unittest discover -s tests/unit # 包根执行(7 个用例)
96
- node tests/unit/public-profile-smoke.mjs # 干净用户配置的确定性冒烟(5 条断言)
192
+ npm install # 安装开发依赖(schemastery)
193
+ node tests/unit/flash-routing-fixture.mjs ./lib # 纯函数 + 生命周期回归
194
+ python -m unittest discover -s tests/unit # Python 驱动(包根执行)
195
+ node tests/unit/public-profile-smoke.mjs # 干净用户配置的确定性冒烟
97
196
  ```
197
+
198
+ 当前验证计数(CI 在每次 push / PR 跑同一组命令,见 `.github/workflows/ci.yml`):
199
+
200
+ <!-- 验证计数:fixture / Python / smoke 三处数字集中在这里;实测有出入时只改本表。 -->
201
+
202
+ | 检查 | 结果 |
203
+ |---|---|
204
+ | fixture | **104** 条断言,`failed: 0` |
205
+ | Python 驱动 | **7** 个用例 `OK` |
206
+ | 公共 profile 冒烟 | **7** 条断言,`failed: 0` |
207
+
208
+ GUI 端到端(`configure_submodel` 弹卡与两处写入、`delegate_task` 派工、主模型切到执行路由后进入
209
+ economize 模式)需要在重启后的真实 GUI 会话里由用户验收,**尚未验证**。
210
+
211
+ ## 参与贡献
212
+
213
+ - 提 issue / PR 前先看[贡献指南](CONTRIBUTING.md)(English: [CONTRIBUTING.en.md](CONTRIBUTING.en.md)):
214
+ 要跑的三条测试、提交格式、以及不该带进仓库的东西都写在那里。
215
+ - 安全问题请走私密渠道([安全政策](SECURITY.md)),不要开公开 issue。
216
+ - 参与本项目即视为同意[行为准则](CODE_OF_CONDUCT.md)。
217
+
218
+ ## 发版(维护者)
219
+
220
+ 发布走 GitHub Actions + npm **Trusted Publishing(OIDC)**,本机与仓库都不保存 npm 令牌:
221
+
222
+ 1. 在 `CHANGELOG.md` 顶部补 `## <版本>(YYYY-MM-DD)` 段;
223
+ 2. 在 `main` 分支运行 `pwsh scripts/release.ps1 <版本>`:跑门禁 → 改 `package.json` 版本 →
224
+ 提交 → 打 tag → push,并轮询 npm 直到看到新版本;
225
+ 3. 仓库的 `release` 工作流(`.github/workflows/release.yml`)在 tag push 后再次跑测试并自动
226
+ `npm publish`;`scripts/release.ps1` 验证成功后会尽量创建 GitHub Release。
227
+
228
+ 首次接入需在 npm 包设置里一次性配置 Trusted Publisher(仓库 `angel291592/dsh-submodel`、
229
+ 工作流 `release.yml`,并允许 Direct publish),之后发版不再需要 npm 密码 / 动态码 / 令牌。