dsh-subagent-default-model 2.2.1 → 2.2.4
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 +180 -0
- package/README.en.md +25 -6
- package/README.md +30 -6
- package/lib/client.js +19 -151
- package/lib/index.js +721 -53
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,185 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.4 (2026-11-13)
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
**上下文注入改成真正的「宿主看得见」的注入行;主代理也开始收到一条。**
|
|
8
|
+
|
|
9
|
+
用户指出的问题很具体:注入行此前只是本插件**自绘的修饰**,宿主并不知道它的存在。
|
|
10
|
+
|
|
11
|
+
- **`form` 从 `"route-context"` 改为 `"notice"`。** 这是根因。宿主 `dsh-client-ui-chat` 只认识
|
|
12
|
+
`instructions / catalog / snapshot / notice / relay / recall` 六个 form
|
|
13
|
+
(`KNOWN_FORMS`),别的值一律 `contextForm() === null` 并被丢给 `OpaqueBody`
|
|
14
|
+
——于是那一行既没有摘要、展开也只有一坨原始 JSON。改用它认识的 `notice`
|
|
15
|
+
并补上 `source.summary`(`provider/model`),宿主自己的
|
|
16
|
+
`ContextInjectionRow` 才会画出「上下文注入 · dsh-subagent-default-model · minmax/MiniMax-M3.1-Flash」。
|
|
17
|
+
- **删掉自绘的对话行。** `chat-subagent-model-notice` 节点 kind、`SubagentModelNoticeRow`
|
|
18
|
+
渲染器、`conversation.chat.node` 注册与整套样式全部移除。它存在的理由是
|
|
19
|
+
DSH 0.1.7 的 `isVisibleChatNode()` 会硬排除 `node.kind === "context"`;当前宿主
|
|
20
|
+
(0.2.2)只排除 `system-prompt`。而只要注入是真注入(落进 session 的
|
|
21
|
+
`user/message`),宿主**必然**自己画一行——再自绘一条就是两行「上下文注入」。
|
|
22
|
+
- **主代理现在也收到一行。** 内容是设置里的默认派发模型(多模型时带策略),
|
|
23
|
+
因为这份设置在主代理的上下文里读不到,「你的子代理跑在哪个模型上」原本无从回答。
|
|
24
|
+
它报的是**派发目标**,不是主代理自己的 provider/model。这一行不推进轮换游标:
|
|
25
|
+
它只是报告,看一眼不该改变下一次派发拿到哪条路由。
|
|
26
|
+
|
|
27
|
+
- **跨重启去重。** 内存里的「本行已注入」记录随进程消失,而主对话能活过很多次重启,
|
|
28
|
+
每次重启追加一行就会像 `dsh-ldvh` 那样在一个会话里堆出三四条相同通知
|
|
29
|
+
(实测该插件会话中 `ldvh=3` / `ldvh=4`)。现在除内存记录外,还会读
|
|
30
|
+
`session.deriveMessages()`——会话自己的派生历史折叠(即发给模型的那份)——判断同一行
|
|
31
|
+
是否已存在。读取器不存在时(旧宿主 / 精简 fixture)退回内存记录,不会让瀑布报错。
|
|
32
|
+
|
|
33
|
+
### Removed
|
|
34
|
+
|
|
35
|
+
- `chat-subagent-model` 会话视图定义、`SubagentModelNoticeRow` 渲染器、
|
|
36
|
+
`CHAT_MODEL_NODE_KIND` 常量、`row.chatModelInitial` / `row.chatModelChange` /
|
|
37
|
+
`row.chatModelResume` / `row.noticeLabel` 四条 locale 词条与 `.dsm-notice-*` 样式。
|
|
38
|
+
轨迹视图(`trajectory-subagent-model`)保留:它渲染的是 `request/context` 帧,
|
|
39
|
+
宿主不会自己呈现。
|
|
40
|
+
|
|
41
|
+
## 2.2.3 (2026-11-13)
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
**切换后自动续跑:故障转移选中的健康路由,现在真的会被用上。**
|
|
46
|
+
|
|
47
|
+
2.2.2 修好了「在 0.2.2 上不再抛错」,但只做到一半。`agent.model.select()` 的结果要到**下一步**的准备阶段才被读取,而一次性 `subagent` 没有下一步——于是选中的健康路由**从未被使用**,任务照样以 `error` 结束。
|
|
48
|
+
|
|
49
|
+
实机复现(池里 `minmax` 已耗尽额度、`dsh-opencode-go` 健康):子代理被派到 `minmax`,返回
|
|
50
|
+
`429 … 已达到 Token Plan 用量上限`,失败转移把下一条路由选好了,会话却只有 **1 个 turn** 就结束;再手动发一条消息,同一个子代理立刻在 `dsh-opencode-go` 上跑完。**切换是自动的,续跑不是**——这就是缺口。
|
|
51
|
+
|
|
52
|
+
现在失败转移在 `select()` 真正落地之后,通过 `agent.followup()` 唤醒子代理一轮,让新路由被用到:
|
|
53
|
+
|
|
54
|
+
- **只在真的切换成功时唤醒**。唤醒由失败转移路径直接回调触发(不是在同一个瀑布上再加一个监听器),所以池耗尽、或宿主拒绝了 `select()` 时都不会唤醒——那种情况下下一轮只会撞同一个错误,白烧一次请求。`failoverView` 还会按 `provider+model+effort` 去重,因为重复路由会让 `model.select()` 静默变成空操作。
|
|
55
|
+
- **唤醒消息的 `source.kind` 是 `plugin:dsh-subagent-default-model`,不是 `user`**。否则转录会把它渲染成人自己敲的消息:用户没说过这句话,也无从分辨。
|
|
56
|
+
- **不唤醒 fork 子代理**。判据是 `header.isSeeded === true`——header 没有 `backend` 字段,这是「带 fork 继承前缀」唯一的持久证据。它那 14 万 token 的继承前缀换到新供应商要全额重算,正是本插件在 `applyToForkChildren` 上已经拒绝付的代价。
|
|
57
|
+
- **不唤醒主代理**,同所有其他功能的 `origin === "subagent"` 门禁。
|
|
58
|
+
- **排队时机是这套机制的关键**,同时受两条硬约束夹击:
|
|
59
|
+
- **不能太早**:`failureAt`(由紧随其后的 `agent/error` 置位)会让宿主的收敛判断短路成 `"ready"`,排进去的消息连同收件箱一起被清掉。
|
|
60
|
+
- **不能太晚**:宿主判定 `"ready"` 后立刻销毁 agent,任何定时器醒来时对象都已不在。
|
|
61
|
+
- **不能在 `turn/end` 里排**:`session/event` 监听器是在 `Session.append()` **内部**同步调用的,此时存储仍标记该条目为「发布中」,任何嵌套 append 都会被拒——实测报错 `session append cannot reenter while another append is being published`,于是唤醒抛异常、被日志吞掉、续跑全部消失。(这一版曾用 `setImmediate` 侥幸绕开,那依赖持久化刷盘时的 I/O 让出,不是排序保证。)
|
|
62
|
+
- **正确时机是 `agent/status` 变为 `idle`**:`setPhase()` 在 `kick()` 的 `finally` 里同步发出它,此时候选的 `turn/end` 已提交(`failureAt` 已清除)、且不在任何 append 期间、又早于管理器的收敛检查。在此时排入收件箱,既不会被清除,也不会被销毁。
|
|
63
|
+
- **不重复唤醒**:判据是**收件箱**(`inbox.nextTurn` 是否已有排队),而不是 `agent.status`——后者在失败瞬间恒为 `running`,用它把关会拦掉每一次唤醒。
|
|
64
|
+
- **有上限**:`maxAutoContinues`(默认 2,0 关闭)。真实边界仍是池子大小(N 条最多切 N-1 次);这个上限只为「运行中改配置」这种极端情况兜底。
|
|
65
|
+
|
|
66
|
+
### Configuration
|
|
67
|
+
|
|
68
|
+
两个新键:
|
|
69
|
+
|
|
70
|
+
| 键 | 默认 | 含义 |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| `continueAfterFailover` | `true` | 切换后是否唤醒子代理再跑一轮。设 `false` 恢复 2.2.2 的行为(只切不续) |
|
|
73
|
+
| `maxAutoContinues` | `2` | 单个子代理运行最多连续自动续跑几次;`0` 等于关闭 |
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
|
|
77
|
+
**`strategy: "random"` 会把刚失败的那条路由再抽一次,导致整条切换链静默失效。**
|
|
78
|
+
|
|
79
|
+
随机分支原来是一句朴素的
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
return Math.floor(Math.random() * entries.length);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
它既不查 `tried`,也不排除**刚刚失败的那条**。抽中死路由时,`model.select()` 把「新选择」与当前选择一比,相等,于是直接返回、**不写 `model/selection`**——切换等于没发生:续跑的那一轮仍请求同一条死路由,子代理再次失败。
|
|
86
|
+
|
|
87
|
+
实机诊断把两种结果并排拍了下来:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
selecting minmax/MiniMax-M3.1-Flash (before=minmax/MiniMax-M3.1-Flash)
|
|
91
|
+
after select, current() 未变, seq 未变 ← 判等跳过,切换白做
|
|
92
|
+
|
|
93
|
+
selecting dsh-opencode-go/deepseek-v4.1-flash (before=minmax/MiniMax-M3.1-Flash)
|
|
94
|
+
after select, current() 已变, seq 33→34 ← 真正写入,切换生效
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
修法:随机也只在**真正可用**的候选里抽——先剔除本次运行已试过的,再剔除当前正在服务(即刚失败)的那条;都剔完了才退回朴素随机,让调用方自己的池耗尽判断如实报错。
|
|
98
|
+
|
|
99
|
+
同时补了 3 项回归测试:两条路线的池重复 200 次不得抽回死路由、三条路线的池重复 100 次同理,并把原有的随机用例从「不查重」改成「不得重选」。
|
|
100
|
+
|
|
101
|
+
### Fixed(代码审查发现,均已补回归测试)
|
|
102
|
+
|
|
103
|
+
1. **`random` 仍会抽回已经失败过的路由。** `tried` 只记录「切换到的」索引,最初失败的那条从未进入。于是从第二次切换起,它既不是 `served`、也不在 `tried`,又能被抽中——实测三条路线的池:**300 次第二次切换里有 136 次回到最初那条死路由**,而 `entries.length - 1` 的上限使第三条路线**从未被尝试**。修法:切换前把「刚失败的那条」也记入 `tried`(新旧宿主两条路径都修)。
|
|
104
|
+
2. **`installAutoContinue` 被安装两次。** 重构(定时器改为回调)留下的旧调用还在 `installFailover` 末尾,导致两套引擎、两套监听器,且第一个引擎的返回值被丢弃。已删除。
|
|
105
|
+
3. **唤醒时机改为订阅 `agent/status` 的 `idle` 转换。** 原先的 `setImmediate` 能成功,靠的是「管理器在 `flushFinalState()` 里 await 持久化刷盘、因此让出一次 I/O」——这是持久化层的副作用,不是排序保证。中途曾改成订阅 `turn/end`,但那**更糟**:`session/event` 监听器运行在 `Session.append()` 内部,`agent.followup()` 的嵌套 append 被存储的重入守卫直接拒绝(实测 `session append cannot reenter while another append is being published`),唤醒抛异常后被日志吞掉,续跑全部消失——而在测试夹具里这个错误完全看不见。`agent/status` 是唯一同时满足「`turn/end` 已提交」「不在 append 期间」「早于收敛检查」的时机。
|
|
106
|
+
4. **`maxAutoContinues` 实际是每 turn 而非每 run。** 引擎原本在每个 `agent/pre-step` 删除计数器,而续跑的一轮必然从这个钩子开始,等于每轮重置预算:`maxAutoContinues: 1` 仍会排第二次续跑。已改为只在 `agent/disposed` 释放。
|
|
107
|
+
5. **重复路由的池会让 `select()` 静默失效。** 池里两条解析出同一个 provider/model 时(如 `["a","a"]`),宿主比较相等后不写 `model/selection`,插件却仍记一次切换并唤醒。已在 `failoverView` 按 provider+model+effort 去重。
|
|
108
|
+
10. **续跑轮无法再次切换(本轮引入又修复)。** 失败转移的分步守卫只比较 `step`、不比较 `turn`,而续跑的一轮从 `step 1` 重新开始——于是新一轮的首个失败被当成「这一 step 已经切过」而被拒,**一次性子代理因此最多只能切一次**,池里第三条路线永远用不到。实测三条路线只切到第二条;守卫改为同时比较 `turn` 与 `step` 后恢复正常(四条池可依次切到第三、第四条)。
|
|
109
|
+
9. **仅 effort 不同的池会选中它当前所在的那一条。** `session.requestContext()` 不带 `reasoningEffort`,只按 provider+model 定位服务路由会指到错误的条目,于是选回子代理已经在用的 effort——宿主比较 effort,判等后静默跳过。改为用 `agent.model.current()`(含 effort)定位。
|
|
110
|
+
6. **唤醒消息曾断言「你现在跑在不同且健康的供应商上」**——当选择是空操作、或目标立刻也失败时,这句话是假的。已改为不声称健康状况。
|
|
111
|
+
7. **英文 README 未同步**:`continueAfterFailover` / `maxAutoContinues` 与续跑说明只写进了中文版。已补齐。
|
|
112
|
+
8. **测试大面积空转**:多个「不会唤醒」的用例在延迟回调执行前就断言,把守卫删掉仍然全绿;池耗尽用例三次派发都在同一步,根本没走到耗尽分支。已全部修正,并对每个守卫做了变异验证(删掉即红)。
|
|
113
|
+
|
|
114
|
+
### End-to-end verification (live, 2026-11-13)
|
|
115
|
+
|
|
116
|
+
池中 `minmax/MiniMax-M3.1-Flash` 已耗尽额度、`dsh-opencode-go/deepseek-v4.1-flash` 健康。一次派发三个子代理(`strategy: random`),三者呈现完全相同的预期轨迹:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
turn 1 -> error (命中 minmax,429 用量上限)
|
|
120
|
+
turn 2 -> completed (自动切到 dsh-opencode-go 并跑完)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
会话日志逐帧核对:
|
|
124
|
+
|
|
125
|
+
| 帧 | 路由 |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `request/header` seq 13 | `minmax/MiniMax-M3.1-Flash` |
|
|
128
|
+
| `request/context` seq 14 | `minmax/MiniMax-M3.1-Flash` |
|
|
129
|
+
| `model/selection` seq 33 | `dsh-opencode-go/deepseek-v4.1-flash` |
|
|
130
|
+
| `request/header` seq 43 | `dsh-opencode-go/deepseek-v4.1-flash` |
|
|
131
|
+
| `request/context` seq 44 | `dsh-opencode-go/deepseek-v4.1-flash` |
|
|
132
|
+
| `assistant/message` seq 45 | 由 `dsh-opencode-go/deepseek-v4.1-flash` 生成 |
|
|
133
|
+
|
|
134
|
+
**全程没有任何人工干预**:第 2 轮由插件自己唤醒,切换由插件自己完成。这就是「一个代理不能用时切到另一个并继续工作」的完整闭环。
|
|
135
|
+
|
|
136
|
+
### Verified
|
|
137
|
+
|
|
138
|
+
206 项测试全绿,其中约 15 项覆盖续跑:正常唤醒、池耗尽不唤醒、主代理不唤醒、fork 不唤醒、开关关闭、失败码不合格、已在排队的收件箱不重复排队、上限为 0。
|
|
139
|
+
|
|
140
|
+
## 2.2.2 (2026-11-13)
|
|
141
|
+
|
|
142
|
+
### Fixed
|
|
143
|
+
|
|
144
|
+
**宿主 0.2.2-rc.2 把 `startActivation(spec)` 的 spec 扁平化了,默认模型注入因此静默失效。**
|
|
145
|
+
|
|
146
|
+
rc.2 起 `SubagentActivationSpec` 不再嵌套 `request`,而是直接继承 `SubagentStartRequest`:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
// <= 0.2.2-rc.1
|
|
150
|
+
{ provider, label, signal, delivery, request: { prompt, parent, agentOptions, … } }
|
|
151
|
+
// >= 0.2.2-rc.2
|
|
152
|
+
{ provider, label, signal, delivery, prompt, parent, agentOptions, … }
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
插件包装的正是这个方法,而它只读 `spec.request`。在 rc.2 上拿到 `undefined` 后,`applyDefaultModelFor` 首行原样返回,**spec 原封不动透传给宿主**——子代理退回继承父路由,两处池配置一条都没生效。
|
|
156
|
+
|
|
157
|
+
**为什么没被测试拦住**:夹具只造嵌套形状,`183/183` 全绿;这个缺陷也没有升级指南(`docs/upgrade-guide/` 里没有 `v0.2.2-rc.2` 目录),只能靠逐包 `npm pack` + `diff` 发布物发现。
|
|
158
|
+
|
|
159
|
+
**为什么在界面上看不出来**:`injectRouteContext` 仍然工作,它读的是会话自己的 `request/context`,所以「当前供应商/模型」照常渲染——只是显示的永远是父路由。两个功能一个坏一个正常,反而更像「配置没写对」。
|
|
160
|
+
|
|
161
|
+
实机证据(升级后立即复现):子代理会话的派发描述符为
|
|
162
|
+
`{"provider":"spawn","agentProvider":"workbuddy","agentModel":"deepseek-v4.1-flash"}`,
|
|
163
|
+
而 `workbuddy` 是父会话路由,配置池里只有 `minmax/MiniMax-M3.1-Flash` 与 `dsh-opencode-go/deepseek-v4.1-flash`。升级前的同类描述符是正确的 `minmax/MiniMax-M3.1-Flash`。
|
|
164
|
+
|
|
165
|
+
### Changed
|
|
166
|
+
|
|
167
|
+
注入改为**形状自适应**,一个构建同时服务新旧宿主:
|
|
168
|
+
|
|
169
|
+
- 读:`activationRequestOf(spec)` 探测键用 `prompt`(`SubagentStartRequest` 里的必填字段),顶层有它就是扁平;有嵌套 `request` 则优先用它。
|
|
170
|
+
- 写:`withActivationRequest()` 按原形状还原——扁平宿主拿到的是注入后的对象本身,嵌套宿主拿到 `{ ...spec, request }`。
|
|
171
|
+
- 不注入时仍返回**原 spec 引用**:宿主会比较 spec/request 的身份,无谓的拷贝是静默的行为变更。
|
|
172
|
+
|
|
173
|
+
### Tests
|
|
174
|
+
|
|
175
|
+
`188/188`(183 → 188),`skip 0`。新增 5 条扁平 spec 用例:注入 / 显式路由优先 / 空配置继承 / fork 默认不注入 / fork 打开 `applyToForkChildren` 后跟随池。
|
|
176
|
+
|
|
177
|
+
变异验证 2/2 命中:把读法改回 `spec.request`、或回写时不还原扁平形状,都会让其中 2 条失败。
|
|
178
|
+
|
|
179
|
+
`ADMITTED_HOST_VERSIONS` 补入 `0.2.2-rc.2`,并**删除从未存在过的 `0.2.5-rc.1`**(npm 上没有任何 `@deepseek-ai/dsh*` 发布过该版本;它一直匹配 peer 区间,所以从未报错,只是虚增了「已评审版本」集合)。
|
|
180
|
+
|
|
181
|
+
`peer-range` 的「running host must be admitted」用例在修复前按预期失败:`the running host 0.2.2-rc.2 must be listed in ADMITTED_HOST_VERSIONS`——这条护栏第五次发挥作用的记录在 `DEVELOPMENT.md`。
|
|
182
|
+
|
|
3
183
|
## 2.2.1 (2026-11-10)
|
|
4
184
|
|
|
5
185
|
### Fixed
|
package/README.en.md
CHANGED
|
@@ -35,6 +35,13 @@ With `failoverEnabled` (on by default), when a subagent hits a **connection-clas
|
|
|
35
35
|
- **Inherited reasoning strength is dropped** — after switching, the new provider/model is not sent the previous route's `reasoningEffort`; it resolves its own default. Otherwise a target that rejects that level can fail every request and burn through all remaining candidates.
|
|
36
36
|
- **Sticky within a run** — after a switch, later steps of that same subagent stay on the new model instead of flip-flopping every step.
|
|
37
37
|
- **Exhaustion passes the real error through** — once every candidate in the list has been tried, the real error surfaces; there is no infinite retry.
|
|
38
|
+
- **Automatic continuation after a switch** — once the new route is chosen, the plugin **wakes the subagent for one more turn** so that route is actually used, instead of being selected and never read.
|
|
39
|
+
- **Why this step is needed**: DSH 0.2.2+ fixes the route during each step's preparation, so `agent.model.select()` only takes effect on the **next** step. A one-shot `subagent` never starts one, so the healthy route would be **selected and never used** and the task would still end in an error (measured: the switch had selected `dsh-opencode-go` while the subagent still ended after a single turn).
|
|
40
|
+
- **Only wakes after a switch really landed**: not when the pool is exhausted, and not when the host refused the selection — another turn would just hit the same error.
|
|
41
|
+
- **Never wakes `fork` children**: they carry the parent's inherited prefix, which a provider change would re-bill in full; the test is `header.isSeeded`.
|
|
42
|
+
- **Never wakes the main agent**, and **never stacks a duplicate wake** — the test is whether the inbox already holds a runnable next turn, not `agent.status`.
|
|
43
|
+
- **The timing matters**: the wake must be queued once the failed turn has fully retired and **outside any session write** — the moment `agent/status` becomes `idle`. Queuing synchronously lets the host's settlement check clear the inbox along with the message; a timer of any length is far too late, because the agent is already disposed; and queuing inside a `turn/end` listener is rejected by the store's reentrancy guard (a nested append throws).
|
|
44
|
+
- Controlled by `continueAfterFailover` (on by default) and `maxAutoContinues` (default 2).
|
|
38
45
|
- **Requires 2+ routes**, and **applies to subagents only** — the main agent loop is never touched.
|
|
39
46
|
|
|
40
47
|
### Capability 3 — Route visibility: you can see it, and so can the subagent
|
|
@@ -221,6 +228,8 @@ To pin a **single** model, use `model` instead of `models` (never both in the sa
|
|
|
221
228
|
| `models` | array | `[]` | List of model entries (string or `{provider, model, reasoningEffort?}` pair). Only meaningful for Capabilities 1 and 2 with 2+ entries. |
|
|
222
229
|
| `strategy` | string | `round-robin` | Capability 1's distribution strategy: `round-robin` (sequential) or `random`. |
|
|
223
230
|
| `failoverEnabled` | boolean | `true` | Capability 2: switch models **across providers** inside the `models` list when a subagent hits a connection failure (subagents only). |
|
|
231
|
+
| `continueAfterFailover` | boolean | `true` | Capability 2: wake the subagent for one more turn after a switch, so the selected healthy route is actually used. |
|
|
232
|
+
| `maxAutoContinues` | number | `2` | Capability 2: maximum consecutive automatic continuations per subagent run; `0` disables it. |
|
|
224
233
|
| `injectRouteContext` | boolean | `true` | Capability 3 channel 2: inject a real one-line prompt stating the live provider/model into each subagent’s **own context** (subagents only). |
|
|
225
234
|
| `reasoningEffort` | string | — | Optional reasoning strength for a model entry (e.g. `high`, `max`). |
|
|
226
235
|
|
|
@@ -259,12 +268,14 @@ Capability 3 has **two independent channels**. See [Capability 3](#capability-3-
|
|
|
259
268
|
|
|
260
269
|
### Channel 1: UI rows (for the user)
|
|
261
270
|
|
|
262
|
-
| View | What it shows | Source
|
|
271
|
+
| View | What it shows | Source |
|
|
263
272
|
| --- | --- | --- |
|
|
264
|
-
|
|
|
265
|
-
|
|
|
273
|
+
| Conversation | The Host's own "Context injection · dsh-subagent-default-model · `provider/model`" | the injected message's `source.summary`, rendered natively by `ContextInjectionRow` |
|
|
274
|
+
| Trajectory | A row "Current provider/model: `provider/model`" | the plugin's own `trajectory-subagent-model` definition (over the official `request/context` frame) |
|
|
266
275
|
|
|
267
|
-
|
|
276
|
+
> **The conversation row is drawn by the Host, not by this plugin.**
|
|
277
|
+
>
|
|
278
|
+
> Older versions hand-drew it with a plugin-owned node kind (`chat-subagent-model-notice`) plus a `conversation.chat.node` renderer. That workaround existed because DSH 0.1.7's `isVisibleChatNode()` hard-excluded `node.kind === "context"`; the current Host (0.2.2) only excludes `system-prompt`, so `context` is visible. And once an injection is a **real** injection (a `user/message` persisted into the session), the Host draws its native row for it — hand-drawing a second one would show the user two identical "context injection" rows. That whole hand-drawn path has therefore been removed.
|
|
268
279
|
|
|
269
280
|
### Channel 2: Prompt injection (for the subagent)
|
|
270
281
|
|
|
@@ -275,9 +286,17 @@ See the full description and sample text above. Implementation:
|
|
|
275
286
|
| Value source | the `{provider, model}` returned by the `agent/request` waterfall **after** it settles (including a failover swap) |
|
|
276
287
|
| Injection point | the following `agent/pre-step`, where that step's message list is still mutable |
|
|
277
288
|
| Dedupe | an unchanged route injects nothing; a changed route replaces the stale line |
|
|
278
|
-
| Scope |
|
|
289
|
+
| Scope | a subagent reports **the route it is actually running on**; the main agent reports **the model its delegations will use** (see below) |
|
|
279
290
|
| Setting | `injectRouteContext`, on by default |
|
|
280
|
-
| Message source | `plugin:dsh-subagent-default-model` + `form: "
|
|
291
|
+
| Message source | `plugin:dsh-subagent-default-model` + `form: "notice"` + `summary` (v4 requires a producer-owned `source.kind`; the `form` must be one the Host knows or the row renders as a raw JSON dump) |
|
|
292
|
+
|
|
293
|
+
#### The main agent is told its DELEGATION target, not its own route
|
|
294
|
+
|
|
295
|
+
The main agent cannot read this plugin's settings, so "which model do your subagents run on?" has no answer in its context. It therefore receives one line describing the configured pool (with the strategy when there are several, e.g. `a/x / b/y (round-robin)`). It deliberately does **not** report the main agent's own provider/model — the main agent is not the one being routed, and repeating it would be noise.
|
|
296
|
+
|
|
297
|
+
That line is injected only when its content changes, and it **does not advance the round-robin cursor**: it is a report, and looking at it must not change which route the next delegation gets.
|
|
298
|
+
|
|
299
|
+
Dedupe survives restarts: besides the in-run memory record, it reads `session.deriveMessages()` — the session's own derived-history fold, i.e. what the model is sent — to see whether the same line is already there. In-memory tracking alone is not enough: a main conversation outlives many restarts, and appending a row on each one would pile up three or four identical notices in a single session (the failure `dsh-ldvh` shows in the wild).
|
|
281
300
|
|
|
282
301
|
> **The line only appears once the route is known.**
|
|
283
302
|
>
|
package/README.md
CHANGED
|
@@ -35,6 +35,13 @@
|
|
|
35
35
|
- **切换时丢弃继承的推理强度** —— 换到新 provider/model 后不沿用旧路由的 `reasoningEffort`,按目标自己的默认档位请求;否则目标模型可能因「不支持该强度」而直接拒绝请求,导致把剩余候选全部烧光。
|
|
36
36
|
- **同一次运行内粘住** —— 切换后该子代理后续步骤继续跑在新模型上,不会每步来回跳。
|
|
37
37
|
- **耗尽即放行** —— 列表内全部候选都试过仍失败,就抛出真实错误,不做无限重试。
|
|
38
|
+
- **切换后自动续跑** —— 换好路由之后,插件会**唤醒子代理再跑一轮**,让新路由真正被用上,而不是「切好了却没人用」。
|
|
39
|
+
- **为什么需要这一步**:宿主 0.2.2+ 把路由锁死在每个 step 的准备阶段,`agent.model.select()` 的结果要到**下一步**才被读取;一次性 `subagent` 没有下一步,于是选中的健康路由会**从未被使用**、任务照样以错误结束(实测:切换已选中 `dsh-opencode-go`,子代理仍只有 1 个 turn 就失败)。
|
|
40
|
+
- **只在真的切换成功时唤醒**:池耗尽、或宿主拒绝选择时不唤醒——那种情况下一轮只会撞同一个错误。
|
|
41
|
+
- **不唤醒 `fork` 子代理**:它带着父会话的继承前缀,换供应商要全额重算;判据是 `header.isSeeded`。
|
|
42
|
+
- **不唤醒主代理**,也**不会重复排队**——判据是收件箱里是否已有待执行的下一轮,而不是 `agent.status`。
|
|
43
|
+
- **排队时机很讲究**:必须等失败的 turn 完全退役、且**不在任何 session 写入期间**——即 `agent/status` 变为 `idle` 的那一刻。同步排队会被宿主的收敛判断连同收件箱一起清掉;延迟若干毫秒则 agent 早已被销毁;而在 `turn/end` 监听器里排队会被存储的重入守卫拒绝(嵌套 append 会抛错)。
|
|
44
|
+
- 由 `continueAfterFailover`(默认开)与 `maxAutoContinues`(默认 2)控制。
|
|
38
45
|
- **需要 ≥ 2 条路由**,且**仅对子代理生效** —— 主代理循环不受影响。
|
|
39
46
|
|
|
40
47
|
### 功能三:当前路由可见 —— 界面看得见,子代理也知道
|
|
@@ -235,6 +242,8 @@ CI 在 `ubuntu-latest`、`windows-latest`、`macos-latest` 三个平台上同时
|
|
|
235
242
|
| `models` | array | `[]` | 模型条目列表(string 或 `{provider, model, reasoningEffort?}` 对)。≥2 项时功能一、二才有意义。 |
|
|
236
243
|
| `strategy` | string | `round-robin` | 功能一的分配策略:`round-robin`(顺序轮换)或 `random`(随机)。 |
|
|
237
244
|
| `failoverEnabled` | boolean | `true` | 功能二:子代理连接类失败时在 `models` 列表内**跨供应商**切换模型(仅 subagent)。 |
|
|
245
|
+
| `continueAfterFailover` | boolean | `true` | 功能二:切换后唤醒子代理再跑一轮,让选中的健康路由真正被用上。 |
|
|
246
|
+
| `maxAutoContinues` | number | `2` | 功能二:单个子代理运行最多连续自动续跑几次;`0` 等于关闭。 |
|
|
238
247
|
| `injectRouteContext` | boolean | `true` | 功能三通路二:向子代理**自己的上下文**注入一行「当前 provider/model」的真实提示词(仅 subagent)。 |
|
|
239
248
|
| `reasoningEffort` | string | — | 可选推理强度(如 `high`、`max`)。 |
|
|
240
249
|
|
|
@@ -259,12 +268,19 @@ CI 在 `ubuntu-latest`、`windows-latest`、`macos-latest` 三个平台上同时
|
|
|
259
268
|
|
|
260
269
|
### 通路一:界面行(给用户)
|
|
261
270
|
|
|
262
|
-
| 视图 | 呈现内容 |
|
|
271
|
+
| 视图 | 呈现内容 | 依据 |
|
|
263
272
|
| --- | --- | --- |
|
|
264
|
-
|
|
|
265
|
-
|
|
|
273
|
+
| 对话视图 | 宿主自己画的「上下文注入 · dsh-subagent-default-model · `provider/model`」 | 注入消息的 `source.summary`,由 `ContextInjectionRow` 原生渲染 |
|
|
274
|
+
| 轨迹视图 | 一行「当前供应商/模型:`provider/model`」 | 插件自有定义 `trajectory-subagent-model`(依据官方 `request/context` 帧) |
|
|
266
275
|
|
|
267
|
-
|
|
276
|
+
> **对话视图那一行是宿主画的,不是本插件画的。**
|
|
277
|
+
>
|
|
278
|
+
> 旧版本用一本自有节点 kind(`chat-subagent-model-notice`)+ 一个
|
|
279
|
+
> `conversation.chat.node` 渲染器自绘对话行。这个绕过的前提是 DSH 0.1.7 的
|
|
280
|
+
> `isVisibleChatNode()` 会硬排除 `node.kind === "context"`;当前宿主(0.2.2)
|
|
281
|
+
> 只排除 `system-prompt`,`context` 本身可见。而只要注入是**真注入**(落进
|
|
282
|
+
> session 的 `user/message`),宿主就会为它画原生行——再自绘一条,用户会看到
|
|
283
|
+
> 两条一模一样的「上下文注入」。所以自绘那一套已整段删除。
|
|
268
284
|
|
|
269
285
|
### 通路二:提示词注入(给子代理)
|
|
270
286
|
|
|
@@ -275,9 +291,17 @@ CI 在 `ubuntu-latest`、`windows-latest`、`macos-latest` 三个平台上同时
|
|
|
275
291
|
| 取值来源 | `agent/request` 瀑布**结算后**返回的 `{provider, model}`(含故障转移切换结果) |
|
|
276
292
|
| 注入时机 | 下一步的 `agent/pre-step`,此时该步消息列表仍可修改 |
|
|
277
293
|
| 去重 | 路由不变则不重复注入;路由变化则替换旧行 |
|
|
278
|
-
| 作用域 |
|
|
294
|
+
| 作用域 | 子代理报**自己实际在跑的路由**;主代理报**子代理会被派发到的默认模型**(见下) |
|
|
279
295
|
| 开关 | `injectRouteContext`,默认开启 |
|
|
280
|
-
| 消息来源 | `plugin:dsh-subagent-default-model` + `form: "
|
|
296
|
+
| 消息来源 | `plugin:dsh-subagent-default-model` + `form: "notice"` + `summary`(v4 要求生产者自有 `source.kind`;`form` 必须是宿主认识的值,否则只渲染一坨原始 JSON) |
|
|
297
|
+
|
|
298
|
+
#### 主代理收到的是「派发目标」,不是它自己的路由
|
|
299
|
+
|
|
300
|
+
主代理读不到本插件的设置,所以「你的子代理跑在哪个模型上」这个问题在它的上下文里没有答案。为此主代理会收到一行说明,内容来自设置里的模型池(多模型时连策略一起列出,如 `a/x / b/y (round-robin)`)。它**不会**报主代理自己的 provider/model——主代理不是被路由的那一方,重复一遍只是噪音。
|
|
301
|
+
|
|
302
|
+
这一行同样只在这行内容变化时注入,且**不推进轮换游标**:它是一份报告,读一眼不应该改变下一次派发拿到哪条路由。
|
|
303
|
+
|
|
304
|
+
去重是**跨重启**的:除了本轮内存里的记录,还会读 `session.deriveMessages()`(会话自己的派生历史折叠,也就是发给模型的那份)判断同一行是否已经存在。只靠内存记录不够——主对话能活过很多次重启,每次重启都追加一行,就会像 `dsh-ldvh` 那样在一个会话里堆出三四条一模一样的通知。
|
|
281
305
|
|
|
282
306
|
> **注入是有前提的:路由已知才会注入。**
|
|
283
307
|
>
|
package/lib/client.js
CHANGED
|
@@ -30,7 +30,7 @@ window.__ModuleLoader__.load({
|
|
|
30
30
|
|
|
31
31
|
// ── plugin icon (LD brand logo, 64px) ────────────────────────────────
|
|
32
32
|
var DSM_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAXGUlEQVR4nH1bC7BdVXn+1tr7nHPvzb3JvUloSAQp0JHWoAMttKOCFrWU8irQSbCTQYG21IahnTJUUTsM0FJhZCzCSIcKImOpDkhrhQ5YC7ROB3lUBU3EyCuBFBIIedzcx3ntvTr/a621TwIns3P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qijO+MPYACb+efjwdiYsqIewMk+d8tbro1b1uXXehPrYahmn+hZmGgtefqsalNFvU1BpAhM8QXhUlCmgCmihAUnBUQixk6J2eSYqwvM9Iz5sfrApM7LDF7W651oILbef3Tky0Nk2vcfeed0dxp3Nu7h6EYr2sgOL/Aa5OuMdnE5sWAAAAAElFTkSuQmCC";
|
|
33
|
-
var SETTINGS_CSS = ".dsm-model-settings{display:flex;flex-direction:column;gap:14px;margin:0;padding:0}.dsm-model-settings-list{display:flex;flex-direction:column;gap:10px}.dsm-model-settings-route{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:8px;align-items:end;padding:10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:10px;background:var(--dsw-alias-bg-layer-3,#202126)}.dsm-model-settings-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-select{width:100%;max-width:220px;height:32px;padding:0 28px 0 10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:var(--dsw-alias-bg-layer-2,#232529);color:var(--dsw-alias-label-primary,#e6e6e6);font:inherit;font-size:13px;line-height:1.5}.dsm-model-settings-select:focus{outline:2px solid var(--dsw-alias-state-business-primary,#5686fe);outline-offset:1px}.dsm-model-settings-select:disabled{color:var(--dsw-alias-label-tertiary,#999);cursor:default}.dsm-model-settings-remove{height:32px;min-width:32px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer;font-size:16px;line-height:1}.dsm-model-settings-remove:hover{color:var(--dsw-alias-state-error-primary,#ef4444);background:var(--dsw-alias-interactive-bg-hover-danger,rgba(242,90,90,.15))}.dsm-model-settings-options{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dsm-model-settings-strategy{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-strategy .dsm-model-settings-select{max-width:150px}.dsm-model-settings-failover{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-failover input[type=checkbox]{cursor:pointer}.dsm-failover-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999);white-space:nowrap}.dsm-model-settings-inject-route{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-inject-route input[type=checkbox]{cursor:pointer}.dsm-inject-route-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999)}.dsm-model-settings-apply-fork{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-apply-fork input[type=checkbox]{cursor:pointer}.dsm-apply-fork-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999)}.dsm-model-settings-footer{border-top:1px solid var(--dsw-alias-border-l2,#36373b);display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:12px 0 4px}.dsm-model-settings-footer-left{display:flex;align-items:center;gap:10px;flex:1;min-width:0}.dsm-model-settings-footer-status{flex:1;min-width:0;color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:1.5}.dsm-model-settings-footer-error{flex:1;min-width:0;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:1.5}.dsm-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid transparent;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}.dsm-btn:disabled{opacity:.4;cursor:default}.dsm-btn-outline{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:transparent;font-weight:500}.dsm-btn-outline:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed);background:rgba(255,255,255,.04)}.dsm-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.dsm-btn-primary:hover:not(:disabled){opacity:.9}.dsm-model-settings-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-plugin-card{border:1px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-3,#202126);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}.dsm-plugin-card:hover{border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-open{background:var(--dsw-alias-bg-layer-2,#25262b);border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:transparent;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}.dsm-plugin-card-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:-2px}.dsm-plugin-card-head{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.dsm-plugin-card-title{color:var(--dsw-alias-label-primary,#e6e6e6);font-size:15px;font-weight:600;line-height:1.4}.dsm-plugin-card-description{color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5}.dsm-plugin-card-chevron{color:var(--dsw-alias-label-tertiary,#999);flex:none;display:inline-flex;transition:transform .16s}.dsm-plugin-card-chevron-open{transform:rotate(180deg)}.dsm-plugin-card-caret{color:inherit;font-size:12px;line-height:1;display:inline-flex}.dsm-plugin-card-body{border-top:1px solid var(--dsw-alias-border-l2,#36373b);margin:0 16px;padding:0 0 8px}.dsm-plugin-card-body .dsm-model-settings{margin:0;padding:12px 0 0;background:transparent;border:0;border-radius:0}.dsm-plugin-card-body .dsm-model-settings-head{display:none}.dsm-plugin-card-icon{width:32px;height:32px;flex:none;border-radius:7px}.dsm-model-settings-cheer{display:inline-flex;align-items:center;gap:4px;flex:none;text-decoration:underline;text-underline-offset:2px;color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5;transition:color .16s}.dsm-model-settings-cheer-star{font-size:12px;line-height:1;display:inline-flex}.dsm-model-settings-cheer:hover{color:var(--dsw-alias-label-primary,#e6e6e6)}.dsm-model-settings-cheer:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}.dsm-model-settings-warn{grid-column:1/-1;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-model-settings-warn-list{display:flex;flex-direction:column;gap:4px;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-
|
|
33
|
+
var SETTINGS_CSS = ".dsm-model-settings{display:flex;flex-direction:column;gap:14px;margin:0;padding:0}.dsm-model-settings-list{display:flex;flex-direction:column;gap:10px}.dsm-model-settings-route{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:8px;align-items:end;padding:10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:10px;background:var(--dsw-alias-bg-layer-3,#202126)}.dsm-model-settings-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-select{width:100%;max-width:220px;height:32px;padding:0 28px 0 10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:var(--dsw-alias-bg-layer-2,#232529);color:var(--dsw-alias-label-primary,#e6e6e6);font:inherit;font-size:13px;line-height:1.5}.dsm-model-settings-select:focus{outline:2px solid var(--dsw-alias-state-business-primary,#5686fe);outline-offset:1px}.dsm-model-settings-select:disabled{color:var(--dsw-alias-label-tertiary,#999);cursor:default}.dsm-model-settings-remove{height:32px;min-width:32px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer;font-size:16px;line-height:1}.dsm-model-settings-remove:hover{color:var(--dsw-alias-state-error-primary,#ef4444);background:var(--dsw-alias-interactive-bg-hover-danger,rgba(242,90,90,.15))}.dsm-model-settings-options{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dsm-model-settings-strategy{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-strategy .dsm-model-settings-select{max-width:150px}.dsm-model-settings-failover{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-failover input[type=checkbox]{cursor:pointer}.dsm-failover-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999);white-space:nowrap}.dsm-model-settings-inject-route{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-inject-route input[type=checkbox]{cursor:pointer}.dsm-inject-route-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999)}.dsm-model-settings-apply-fork{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-apply-fork input[type=checkbox]{cursor:pointer}.dsm-apply-fork-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999)}.dsm-model-settings-footer{border-top:1px solid var(--dsw-alias-border-l2,#36373b);display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:12px 0 4px}.dsm-model-settings-footer-left{display:flex;align-items:center;gap:10px;flex:1;min-width:0}.dsm-model-settings-footer-status{flex:1;min-width:0;color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:1.5}.dsm-model-settings-footer-error{flex:1;min-width:0;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:1.5}.dsm-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid transparent;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}.dsm-btn:disabled{opacity:.4;cursor:default}.dsm-btn-outline{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:transparent;font-weight:500}.dsm-btn-outline:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed);background:rgba(255,255,255,.04)}.dsm-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.dsm-btn-primary:hover:not(:disabled){opacity:.9}.dsm-model-settings-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-plugin-card{border:1px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-3,#202126);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}.dsm-plugin-card:hover{border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-open{background:var(--dsw-alias-bg-layer-2,#25262b);border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:transparent;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}.dsm-plugin-card-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:-2px}.dsm-plugin-card-head{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.dsm-plugin-card-title{color:var(--dsw-alias-label-primary,#e6e6e6);font-size:15px;font-weight:600;line-height:1.4}.dsm-plugin-card-description{color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5}.dsm-plugin-card-chevron{color:var(--dsw-alias-label-tertiary,#999);flex:none;display:inline-flex;transition:transform .16s}.dsm-plugin-card-chevron-open{transform:rotate(180deg)}.dsm-plugin-card-caret{color:inherit;font-size:12px;line-height:1;display:inline-flex}.dsm-plugin-card-body{border-top:1px solid var(--dsw-alias-border-l2,#36373b);margin:0 16px;padding:0 0 8px}.dsm-plugin-card-body .dsm-model-settings{margin:0;padding:12px 0 0;background:transparent;border:0;border-radius:0}.dsm-plugin-card-body .dsm-model-settings-head{display:none}.dsm-plugin-card-icon{width:32px;height:32px;flex:none;border-radius:7px}.dsm-model-settings-cheer{display:inline-flex;align-items:center;gap:4px;flex:none;text-decoration:underline;text-underline-offset:2px;color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5;transition:color .16s}.dsm-model-settings-cheer-star{font-size:12px;line-height:1;display:inline-flex}.dsm-model-settings-cheer:hover{color:var(--dsw-alias-label-primary,#e6e6e6)}.dsm-model-settings-cheer:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}.dsm-model-settings-warn{grid-column:1/-1;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-model-settings-warn-list{display:flex;flex-direction:column;gap:4px;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-model-settings-section{display:flex;flex-direction:column;gap:14px}.dsm-settings-heading{margin:0;font-size:16px;font-weight:600;line-height:24px;color:var(--dsw-alias-label-primary,#e6e6e6)}.dsm-settings-intro{margin:0;font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-section .dsm-model-settings{margin:0;padding:0;background:transparent;border:0;border-radius:0}.dsm-settings-values{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-settings-values li::marker{color:var(--dsw-alias-label-tertiary,#999)}.dsm-model-settings-diag{display:flex;flex-direction:column;gap:4px}.dsm-model-settings-diag-toggle{appearance:none;font:inherit;cursor:pointer;background:transparent;border:0;padding:2px 0;display:flex;align-items:center;gap:6px;color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px;text-align:left;min-width:0}.dsm-model-settings-diag-toggle:hover{color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-diag-toggle:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px;border-radius:3px}.dsm-model-settings-diag-caret{flex:none;font-size:10px;line-height:1;display:inline-flex}.dsm-model-settings-diag-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-caption,#777)}";
|
|
34
34
|
|
|
35
35
|
if (typeof document !== "undefined") {
|
|
36
36
|
var cssId = "dsh-subagent-default-model/client.css";
|
|
@@ -46,22 +46,25 @@ window.__ModuleLoader__.load({
|
|
|
46
46
|
// ── locale ───────────────────────────────────────────────────────────
|
|
47
47
|
var SUBAGENT_ROW_LOCALE = "settings.subagentModel";
|
|
48
48
|
|
|
49
|
-
// ──
|
|
49
|
+
// ── 为什么这里**没有**自绘的对话流行 ─────────────────────────────────
|
|
50
50
|
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
// (注释明写「Exclude system prompts, ordinary Context, and permission
|
|
55
|
-
// commands from visible Chat rows」)。故本插件的注入只进轨迹。
|
|
51
|
+
// 曾经有:一个自有节点 kind(`chat-subagent-model-notice`)+ 一个
|
|
52
|
+
// `conversation.chat.node` 渲染器 + 一套配套样式,用来在对话流里画
|
|
53
|
+
// 「上下文注入 · dsh-subagent-default-model · provider/model」。
|
|
56
54
|
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
// `
|
|
55
|
+
// 它存在的前提已经失效。那段绕过针对的是 DSH 0.1.7 的
|
|
56
|
+
// `isVisibleChatNode()`——它当时硬排除 `node.kind === "context"`,于是插件
|
|
57
|
+
// 注入的 `user/message` 在对话流里永远不可见,只能靠自有 kind 才显示。
|
|
58
|
+
// 当前宿主(0.2.2)的可见性规则只排除 `visibility !== "visible"` 与
|
|
59
|
+
// `system-prompt`,`context` 本身是**可见**的,并由
|
|
60
|
+
// `ContextMessageNodeView` → `ContextInjectionRow` 渲染成
|
|
61
|
+
// 「上下文注入 · <producer> · <summary>」,其中 summary 读自
|
|
62
|
+
// `source.summary`、form 只决定展开后的正文。
|
|
60
63
|
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
|
|
64
|
+
// 也就是说:只要注入是真注入(落进 session 的 `user/message`),宿主自己就
|
|
65
|
+
// 会画那一行;再画一条一模一样的,用户会看到两行「上下文注入」。所以自绘
|
|
66
|
+
// 那一套已整段删除,界面行由宿主统一负责,本插件的注入只提供
|
|
67
|
+
// `source.kind` / `form: "notice"` / `summary`。
|
|
65
68
|
var SUBAGENT_ROW_ZH = {
|
|
66
69
|
"row.title": "子代理默认模型(dsh-subagent-default-model)",
|
|
67
70
|
"row.desc": "为 subagent / subagent_fork 选择一个或多个默认路由;清空后子代理继承父会话路由。",
|
|
@@ -103,11 +106,7 @@ window.__ModuleLoader__.load({
|
|
|
103
106
|
"row.injectRouteContextHint": "(子代理从第 2 步起能回答自己跑在哪个模型上;这是一行真实提示词,不是界面显示)。",
|
|
104
107
|
"row.applyToForkChildren": "让 subagent_fork 子代理也使用这里设定的模型",
|
|
105
108
|
"row.applyToForkChildrenHint": "(默认关闭。fork 子代理会继承父会话的完整对话,宿主因此让它留在父路由上,好让这段前缀能复用缓存;开启后它会改用这里的模型,代价是那段继承的上下文要在新模型上重新算一次)。",
|
|
106
|
-
"row.trajectoryModel": "当前供应商/模型"
|
|
107
|
-
"row.chatModelInitial": "当前供应商/模型",
|
|
108
|
-
"row.chatModelChange": "已切换到",
|
|
109
|
-
"row.chatModelResume": "当前使用",
|
|
110
|
-
"row.noticeLabel": "上下文注入 · dsh-subagent-default-model"
|
|
109
|
+
"row.trajectoryModel": "当前供应商/模型"
|
|
111
110
|
};
|
|
112
111
|
var SUBAGENT_ROW_EN = {
|
|
113
112
|
"row.title": "Subagent default model (dsh-subagent-default-model)",
|
|
@@ -150,11 +149,7 @@ window.__ModuleLoader__.load({
|
|
|
150
149
|
"row.injectRouteContextHint": "(from step 2 a subagent can answer which model it is; a real prompt line, not a display row).",
|
|
151
150
|
"row.applyToForkChildren": "Also apply these models to subagent_fork children",
|
|
152
151
|
"row.applyToForkChildrenHint": "(off by default. A fork child inherits the parent's full conversation, so the host keeps it on the parent's route to preserve cache reuse of that prefix; turning this on moves it to the configured model and re-runs the inherited context once on the new model).",
|
|
153
|
-
"row.trajectoryModel": "Current provider/model"
|
|
154
|
-
"row.chatModelInitial": "Current provider/model",
|
|
155
|
-
"row.chatModelChange": "Switched to",
|
|
156
|
-
"row.chatModelResume": "Currently using",
|
|
157
|
-
"row.noticeLabel": "Context injection · dsh-subagent-default-model"
|
|
152
|
+
"row.trajectoryModel": "Current provider/model"
|
|
158
153
|
};
|
|
159
154
|
|
|
160
155
|
// ── helpers ──────────────────────────────────────────────────────────
|
|
@@ -1072,63 +1067,6 @@ window.__ModuleLoader__.load({
|
|
|
1072
1067
|
);
|
|
1073
1068
|
}
|
|
1074
1069
|
|
|
1075
|
-
// ── 对话流注入行的渲染器(自有节点 kind)─────────────────────────────
|
|
1076
|
-
//
|
|
1077
|
-
// 宿主按 `entryKey = node.kind` 在 `conversation.chat.node` 槽位**运行时分派**
|
|
1078
|
-
// 渲染器(`ChatNodeSeat` 传 `entryKey: routedNode.kind`)。该分派是 keyed 槽位:
|
|
1079
|
-
// 没有占用者的 kind 走 `ChatNodeSeat` 传入的 `fallback`——一个 `JsonBlock`
|
|
1080
|
-
// (标签 "unknown surface" + 节点数据原样 JSON)。所以只改 kind 而不注册渲染器
|
|
1081
|
-
// 不是「行消失」,而是**对话流里出现一行原始 JSON**(比不可见更糟)。
|
|
1082
|
-
//
|
|
1083
|
-
// 渲染器收到的是 `{ node }`(`ChatNodeOwnerProps`),节点数据即 `start()` 的
|
|
1084
|
-
// state(`buildViewNode` 把它放进 `data`)。这里只读 content / source.summary,
|
|
1085
|
-
// 不依赖任何宿主内部工具。
|
|
1086
|
-
function SubagentModelNoticeRow(props) {
|
|
1087
|
-
var node = props.node;
|
|
1088
|
-
var data = node && node.data ? node.data : {};
|
|
1089
|
-
// `t` is the framework-injected locale seat: this registration declares
|
|
1090
|
-
// `locale:`, so the renderer receives it. Keep the label in the
|
|
1091
|
-
// dictionary rather than inlining one language (the plugin ships zh+en).
|
|
1092
|
-
var t = props.t || function (key) { return key; };
|
|
1093
|
-
var openState = React.useState(false);
|
|
1094
|
-
var open = openState[0];
|
|
1095
|
-
var setOpen = openState[1];
|
|
1096
|
-
var blocks = Array.isArray(data.content) ? data.content : [];
|
|
1097
|
-
var text = blocks.map(function (block) {
|
|
1098
|
-
return block && typeof block.text === "string" ? block.text : "";
|
|
1099
|
-
}).join("\n");
|
|
1100
|
-
var summary = data.source && typeof data.source.summary === "string" ? data.source.summary : "";
|
|
1101
|
-
return React.createElement("div", { className: "dsm-notice-row" },
|
|
1102
|
-
React.createElement("button", {
|
|
1103
|
-
type: "button",
|
|
1104
|
-
className: "dsm-notice-toggle",
|
|
1105
|
-
"aria-expanded": open,
|
|
1106
|
-
onClick: function () { setOpen(!open); }
|
|
1107
|
-
},
|
|
1108
|
-
React.createElement("span", { className: "dsm-notice-dot", "aria-hidden": "true" }),
|
|
1109
|
-
React.createElement("span", { className: "dsm-notice-label" }, t("row.noticeLabel")),
|
|
1110
|
-
summary ? React.createElement("span", { className: "dsm-notice-summary" }, summary) : null
|
|
1111
|
-
),
|
|
1112
|
-
open ? React.createElement("pre", { className: "dsm-notice-body" }, text) : null
|
|
1113
|
-
);
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
/** 注册自有 kind 的渲染器;返回卸载函数。槽位缺失时静默跳过。 */
|
|
1117
|
-
function registerSubagentModelNotice(ctx) {
|
|
1118
|
-
try {
|
|
1119
|
-
return ctx.slots.inject("conversation.chat.node", function () {
|
|
1120
|
-
return ctx.slots.register({
|
|
1121
|
-
name: "conversation.chat.node",
|
|
1122
|
-
key: CHAT_MODEL_NODE_KIND,
|
|
1123
|
-
locale: SUBAGENT_ROW_LOCALE
|
|
1124
|
-
}, SubagentModelNoticeRow);
|
|
1125
|
-
});
|
|
1126
|
-
} catch (error) {
|
|
1127
|
-
console.error("[dsh-subagent-default-model] notice renderer failed to register (chat row absent):", error);
|
|
1128
|
-
return function () { };
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
1070
|
// ── apply: inject settings row ───────────────────────────────────────
|
|
1133
1071
|
// `settingsScope` service was REMOVED in DSH 0.1.7 (settings moved to
|
|
1134
1072
|
// `configForms` + the plugin's own `Config`). Hard-injecting it would keep
|
|
@@ -1308,77 +1246,7 @@ window.__ModuleLoader__.load({
|
|
|
1308
1246
|
return ctx.uiConversation.events.register(modelContextDefinition);
|
|
1309
1247
|
}, "dsh-subagent-default-model: trajectory model row");
|
|
1310
1248
|
|
|
1311
|
-
// ── chat: surface the subagent model in the conversation view ──
|
|
1312
|
-
// agent-loop writes a `request/header` frame with a `reason` the first
|
|
1313
|
-
// time the subagent builds a request ("initial"), on every provider /
|
|
1314
|
-
// model change ("change" — including failover switches), and when a
|
|
1315
|
-
// persisted session resumes ("resume"). The frame header carries the
|
|
1316
|
-
// full config (provider/model), so the conversation can show exactly
|
|
1317
|
-
// which route is in use — no host-side changes required.
|
|
1318
|
-
// 节点 kind 用**自有值**(`CHAT_MODEL_NODE_KIND`),不复用内置 `context`。
|
|
1319
|
-
// 旧注释曾写「复用内置注入行(ContextMessageNodeView)」——该复用目标在
|
|
1320
|
-
// 宿主 0.1.7 已不存在:`dsh-client-ui-chat` 的 `isVisibleChatNode()` 明确
|
|
1321
|
-
// 排除 `node.kind === "context"`(除非含 tool-addition/removal 块),故
|
|
1322
|
-
// 复用 `context` 的结果是**行永远不可见**。自有 kind 不在黑名单内,配一个
|
|
1323
|
-
// 自有渲染器即可见。trajectory 侧不受影响(该黑名单只在 ui-chat)。
|
|
1324
|
-
var chatT = ctx.locale.bind(SUBAGENT_ROW_LOCALE);
|
|
1325
|
-
var chatModelDefinition = {
|
|
1326
|
-
kind: "chat-subagent-model",
|
|
1327
|
-
target: "chat",
|
|
1328
|
-
match: function (event) {
|
|
1329
|
-
if (event.type !== "request/header") return null;
|
|
1330
|
-
// DSH 0.1.2 also appends a "series" header when a follow-up
|
|
1331
|
-
// turn starts a new request series with an UNCHANGED config:
|
|
1332
|
-
// no route change to surface, and claiming it would add one
|
|
1333
|
-
// redundant "Current provider/model" row per turn.
|
|
1334
|
-
if ((event.data || {}).reason === "series") return null;
|
|
1335
|
-
return { id: String(event.seq), role: "start" };
|
|
1336
|
-
},
|
|
1337
|
-
start: function (_context, match) {
|
|
1338
|
-
var event = match.event;
|
|
1339
|
-
var data = event.data || {};
|
|
1340
|
-
var header = data.header || {};
|
|
1341
|
-
var config = header.config || {};
|
|
1342
|
-
var reason = data.reason === "change" ? "row.chatModelChange" : data.reason === "resume" ? "row.chatModelResume" : "row.chatModelInitial";
|
|
1343
|
-
var label = chatT(reason) + ":" + (config.provider ? config.provider + (config.model ? "/" + config.model : "") : (config.model || ""));
|
|
1344
|
-
return {
|
|
1345
|
-
kind: CHAT_MODEL_NODE_KIND,
|
|
1346
|
-
seq: event.seq,
|
|
1347
|
-
time: event.time,
|
|
1348
|
-
content: [{ type: "text", text: label }],
|
|
1349
|
-
// `summary` is the collapsed row's one-line account (notice form):
|
|
1350
|
-
// without it the row only shows the provenance label and hides the
|
|
1351
|
-
// model behind expansion.
|
|
1352
|
-
source: { kind: "plugin:dsh-subagent-default-model", form: "notice", summary: label },
|
|
1353
|
-
provenance: { role: "inject", label: "dsh-subagent-default-model" },
|
|
1354
|
-
form: "notice"
|
|
1355
|
-
};
|
|
1356
|
-
},
|
|
1357
|
-
update: function (context) { return context.state; },
|
|
1358
|
-
buildViewNode: function (context) {
|
|
1359
|
-
if (context.state === void 0) return null;
|
|
1360
|
-
return {
|
|
1361
|
-
key: context.key,
|
|
1362
|
-
kind: CHAT_MODEL_NODE_KIND,
|
|
1363
|
-
id: context.id,
|
|
1364
|
-
target: "chat",
|
|
1365
|
-
anchorSeq: context.state.seq,
|
|
1366
|
-
location: context.start && context.start.location ? context.start.location : { kind: "unresolved" },
|
|
1367
|
-
visibility: "visible",
|
|
1368
|
-
data: context.state
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
ctx.effect(function () {
|
|
1373
|
-
return ctx.uiConversation.events.register(chatModelDefinition);
|
|
1374
|
-
}, "dsh-subagent-default-model: chat model row");
|
|
1375
1249
|
|
|
1376
|
-
// 自有节点 kind 必须配自己的渲染器(宿主按 `entryKey = node.kind` 分派)。
|
|
1377
|
-
// 缺这一步,该行会落到 `ChatNodeSeat` 的 `fallback`(JsonBlock)——用户看到
|
|
1378
|
-
// 的不是「模型行」,而是一坨原始 JSON。
|
|
1379
|
-
ctx.effect(function () {
|
|
1380
|
-
return registerSubagentModelNotice(ctx);
|
|
1381
|
-
}, "dsh-subagent-default-model: chat notice row");
|
|
1382
1250
|
}
|
|
1383
1251
|
|
|
1384
1252
|
// The card's settings scope. The `configForms` block below assigns a
|