dsh-subagent-default-model 2.2.1 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.2 (2026-11-13)
4
+
5
+ ### Fixed
6
+
7
+ **宿主 0.2.2-rc.2 把 `startActivation(spec)` 的 spec 扁平化了,默认模型注入因此静默失效。**
8
+
9
+ rc.2 起 `SubagentActivationSpec` 不再嵌套 `request`,而是直接继承 `SubagentStartRequest`:
10
+
11
+ ```ts
12
+ // <= 0.2.2-rc.1
13
+ { provider, label, signal, delivery, request: { prompt, parent, agentOptions, … } }
14
+ // >= 0.2.2-rc.2
15
+ { provider, label, signal, delivery, prompt, parent, agentOptions, … }
16
+ ```
17
+
18
+ 插件包装的正是这个方法,而它只读 `spec.request`。在 rc.2 上拿到 `undefined` 后,`applyDefaultModelFor` 首行原样返回,**spec 原封不动透传给宿主**——子代理退回继承父路由,两处池配置一条都没生效。
19
+
20
+ **为什么没被测试拦住**:夹具只造嵌套形状,`183/183` 全绿;这个缺陷也没有升级指南(`docs/upgrade-guide/` 里没有 `v0.2.2-rc.2` 目录),只能靠逐包 `npm pack` + `diff` 发布物发现。
21
+
22
+ **为什么在界面上看不出来**:`injectRouteContext` 仍然工作,它读的是会话自己的 `request/context`,所以「当前供应商/模型」照常渲染——只是显示的永远是父路由。两个功能一个坏一个正常,反而更像「配置没写对」。
23
+
24
+ 实机证据(升级后立即复现):子代理会话的派发描述符为
25
+ `{"provider":"spawn","agentProvider":"workbuddy","agentModel":"deepseek-v4.1-flash"}`,
26
+ 而 `workbuddy` 是父会话路由,配置池里只有 `minmax/MiniMax-M3.1-Flash` 与 `dsh-opencode-go/deepseek-v4.1-flash`。升级前的同类描述符是正确的 `minmax/MiniMax-M3.1-Flash`。
27
+
28
+ ### Changed
29
+
30
+ 注入改为**形状自适应**,一个构建同时服务新旧宿主:
31
+
32
+ - 读:`activationRequestOf(spec)` 探测键用 `prompt`(`SubagentStartRequest` 里的必填字段),顶层有它就是扁平;有嵌套 `request` 则优先用它。
33
+ - 写:`withActivationRequest()` 按原形状还原——扁平宿主拿到的是注入后的对象本身,嵌套宿主拿到 `{ ...spec, request }`。
34
+ - 不注入时仍返回**原 spec 引用**:宿主会比较 spec/request 的身份,无谓的拷贝是静默的行为变更。
35
+
36
+ ### Tests
37
+
38
+ `188/188`(183 → 188),`skip 0`。新增 5 条扁平 spec 用例:注入 / 显式路由优先 / 空配置继承 / fork 默认不注入 / fork 打开 `applyToForkChildren` 后跟随池。
39
+
40
+ 变异验证 2/2 命中:把读法改回 `spec.request`、或回写时不还原扁平形状,都会让其中 2 条失败。
41
+
42
+ `ADMITTED_HOST_VERSIONS` 补入 `0.2.2-rc.2`,并**删除从未存在过的 `0.2.5-rc.1`**(npm 上没有任何 `@deepseek-ai/dsh*` 发布过该版本;它一直匹配 peer 区间,所以从未报错,只是虚增了「已评审版本」集合)。
43
+
44
+ `peer-range` 的「running host must be admitted」用例在修复前按预期失败:`the running host 0.2.2-rc.2 must be listed in ADMITTED_HOST_VERSIONS`——这条护栏第五次发挥作用的记录在 `DEVELOPMENT.md`。
45
+
3
46
  ## 2.2.1 (2026-11-10)
4
47
 
5
48
  ### Fixed
package/lib/index.js CHANGED
@@ -840,6 +840,65 @@ function installRouteContextInjector(ctx, state) {
840
840
  }, "dsh-subagent-default-model: route context injector");
841
841
  }
842
842
 
843
+ /**
844
+ * Read the delegation request out of one `startActivation` spec, in either
845
+ * shape the host has shipped.
846
+ *
847
+ * 0.2.2-rc.2 changed `SubagentActivationSpec` from a nested object to one that
848
+ * extends `SubagentStartRequest`:
849
+ *
850
+ * <= 0.2.2-rc.1 : { provider, label, signal, delivery, request: { prompt, parent, agentOptions, … } }
851
+ * >= 0.2.2-rc.2 : { provider, label, signal, delivery, prompt, parent, agentOptions, … }
852
+ *
853
+ * Both are still in the wild (the peer range spans the whole 0.2.x line), so
854
+ * the shape is DETECTED, never assumed. Reading `spec.request` alone on rc.2
855
+ * yields `undefined`, the wrapper then passes the spec through untouched, and
856
+ * every child silently inherits the parent route while the route-visibility
857
+ * line keeps rendering correctly — a failure with no error and no log line.
858
+ *
859
+ * The probe is `prompt`, not `request`: `prompt` is REQUIRED on
860
+ * `SubagentStartRequest` in every version, so its presence at the top level is
861
+ * what makes the spec flat. A nested spec could in principle carry an
862
+ * unrelated `request` key; a flat one cannot exist without `prompt`.
863
+ *
864
+ * @param spec - the activation spec handed to `startActivation`.
865
+ * @returns the request-shaped object carrying `agentOptions`, or undefined.
866
+ */
867
+ function activationRequestOf(spec) {
868
+ if (spec === void 0 || spec === null) return void 0;
869
+ const nested = spec.request;
870
+ if (nested !== void 0 && nested !== null && typeof nested === "object") {
871
+ // Nested host. Prefer it even when `prompt` also sits at the top level
872
+ // (a spec built by copying fields around must not be re-shaped).
873
+ return nested;
874
+ }
875
+ if (spec.prompt !== void 0) return spec;
876
+ return void 0;
877
+ }
878
+
879
+ /**
880
+ * Rebuild one `startActivation` spec with an injected route, preserving the
881
+ * shape the host used.
882
+ *
883
+ * Identity is preserved whenever nothing is injected: host code compares spec
884
+ * and request identity, and a needless clone would be a silent behaviour
885
+ * change.
886
+ *
887
+ * @param spec - the original activation spec.
888
+ * @param injected - the possibly-updated request-shaped object.
889
+ * @param request - the original request-shaped object, for identity checks.
890
+ * @returns the spec to hand to the host.
891
+ */
892
+ function withActivationRequest(spec, injected, request) {
893
+ if (injected === request) return spec;
894
+ if (request === spec) {
895
+ // Flat spec: the request IS the spec, so the injected copy already
896
+ // carries provider / label / signal / delivery.
897
+ return injected;
898
+ }
899
+ return { ...spec, request: injected };
900
+ }
901
+
843
902
  function installSubagentWrapper(ctx, state) {
844
903
  // `ctx.subagents` is a per-call Cordis traceable proxy, so reach the raw
845
904
  // service object behind it for a stable handle and to install own methods.
@@ -871,13 +930,17 @@ function installSubagentWrapper(ctx, state) {
871
930
  if (spec === void 0 || spec === null) return originalStartActivation.call(raw, spec);
872
931
  // `spec.provider` names the delegation backend (`spawn` / `fork`), which
873
932
  // is what decides whether this child inherits the parent conversation.
874
- const request = applyDefaultModelFor(ctx, state, spec.request, spec.provider);
933
+ //
934
+ // The request is NOT always `spec.request`: 0.2.2-rc.2 flattened the
935
+ // spec, so on that host the fields live at the top level and
936
+ // `spec.request` is undefined. Reading the wrong one does not throw —
937
+ // it makes `applyDefaultModelFor` return early, so the child silently
938
+ // runs on the parent route. See `activationRequestOf`.
939
+ const request = activationRequestOf(spec);
940
+ const injected = applyDefaultModelFor(ctx, state, request, spec.provider);
875
941
  // Keep the spec reference when nothing was injected: host code compares
876
942
  // identity and a needless clone would be a silent behaviour change.
877
- return originalStartActivation.call(raw, request === spec.request ? spec : {
878
- ...spec,
879
- request
880
- });
943
+ return originalStartActivation.call(raw, withActivationRequest(spec, injected, request));
881
944
  }
882
945
  : void 0;
883
946
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-subagent-default-model",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "为 DeepSeek Harness 子代理配置默认模型:多模型顺序/随机分配、跨供应商连接失败故障转移,并在轨迹/对话视图显示当前供应商与模型,同时以一行真实提示词把当前路由注入子代理上下文。",
5
5
  "keywords": [
6
6
  "deepseek-harness",