dsh-subagent-default-model 2.1.4 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.5 (2026-10-17)
4
+
5
+ ### 兼容性核查:DSH Desktop 0.2.1-rc.1
6
+
7
+ 当前宿主为 `0.2.1-rc.1`(此前为 `0.2.0-rc.2`)。逐项核查的结论是**插件仍可正常运行**,但独立评审在复核中发现两个**与版本升级无关的既有缺陷**(恢复会话误报、半知路径渲染),已一并修复,见下节。
8
+
9
+ | 检查项 | 结论 |
10
+ | --- | --- |
11
+ | 插件加载与注入 | ✅ 派发子代理实测,注入行内容与实际路由一致(会话 `be5bae6b` / `b7df5721`) |
12
+ | 4 个事件钩子 | ✅ `agent/pre-step`、`agent/request`、`agent/request-error`、`agent/disposed` 全部仍在 |
13
+ | `preStep()` → `buildRequest()` 时序 | ✅ 未变(0.2.1-rc.1 中 `:956` → `:1075`) |
14
+ | `inbox.claim()` 先抽干 | ✅ 未变 |
15
+ | `session.requestContext()` 语义 | ⚠️ 未变 —— 但复核发现它在**恢复会话**下返回上一轮的路由,已修 |
16
+ | peer 区间覆盖 | ✅ 宿主 `evaluatePluginCompatibility()` 返回「无未满足要求」 |
17
+
18
+ 宿主的 `{{provider}}` / `{{model}}` 系统提示词变量仍读 `agent.options`(派发时值,`dsh-agent-loop` 注册处即 `context.agent?.options.provider`),不含 provider 的实时性 —— 这正是本插件注入行仍有价值的原因。
19
+
20
+ ### Fixed(独立评审发现)
21
+
22
+ - **恢复(resume)的子代理会被标上「上一轮」的路由**。`Session.fromRestore` 用上一轮的日志做种子,而 `requestContext()` 折叠的是**整段日志** —— 于是新一轮第 1 步、还没发出任何请求时,折叠结果就已经是旧路由。此时注入等于把一个**比派发种子更旧**的值当成现状。修法:仅当会话被恢复(`header.isSeeded`)**且**本轮尚未结算过请求时,不采信折叠值,保持沉默;本轮请求结算后折叠重新可信。
23
+ - **半知的路径被渲染成 `model=unknown`**。原先判定是「provider 或 model 有一个非空即采用」,于是 `{provider:"workbuddy", model:""}` 会输出 `model=unknown`,而模型可能把它当事实复述。改为**两半都已知才报告**,与服务端(`agent/request` 侧)的判定口径一致。
24
+ - **上一轮补的「直连宿主评估器」用例其实从未执行**。它 `import` 了 `app.asar` 内的路径 —— 普通 Node ESM 无法导入 asar(`ERR_MODULE_NOT_FOUND`,asar 是单个归档文件不是目录),于是走 `return` 分支**被计为 pass**,且是静默的。修法:改为**读取宿主源码文本**,在 `vm` 沙箱里用真实 `semver` 运行宿主的 `unmetRequirements`;找不到宿主时用 `t.skip` **显式跳过**,不再伪装成通过。同时该用例现在会断言「一个只拒绝 `0.2.1-rc.1` 的区间必须被宿主判为不满足」,即它要防的那个回归。
25
+
26
+ ### Tests
27
+
28
+ - **补上 `0.2.1-rc.1` 到「应当通过」的版本清单**。原先该清单从 `0.2.0-rc.2` 直接跳到稳定的 `0.2.1`,**真实在运行的 `0.2.1-rc.1` 从未被断言过**;一个只拒绝 `0.2.1-rc.1` 的区间回归会让护栏保持全绿。
29
+ - **新增直连宿主 `evaluatePluginCompatibility()` 的用例**:不再靠本地模型复述宿主规则,而是直接 `import` 宿主那个函数来断言 `0.2.1-rc.1` / `0.2.0-rc.2` / `0.2.1` / `0.1.7-rc.1` 均被接受。环境无 DSH 时自动跳过,不构成硬依赖。
30
+ - 变异验证:把上界改回 `<0.2.0-0` → 2 项失败;只让 `dsh-llm` 单独偏离区间 → 「every declared peer」用例失败。
31
+
32
+ ### Docs
33
+
34
+ `DEVELOPMENT.md` 补充两条实测结论:
35
+
36
+ 1. **`peerDependenciesMeta` 不参与宿主校验** —— `unmetRequirements()` 只遍历 `peerDependencies`。标了 `optional: true` 的 peer 区间不匹配时**照样挡住整个插件**。
37
+ 2. **校验必须用宿主的调用方式** —— 用 `semver.satisfies` 时漏掉 `{ includePrerelease: true }`,会把 `0.2.1-rc.1` 误判为不满足,从而得出「peer 区间坏了」的错误结论(本次排查即发生过)。
38
+
3
39
  ## 2.1.4 (2026-10-02)
4
40
 
5
41
  ### Fixed
package/README.en.md CHANGED
@@ -158,7 +158,7 @@ Notes:
158
158
 
159
159
  ## Host version requirement
160
160
 
161
- All eight `@deepseek-ai/*` peers are declared as **`>=0.1.7-rc.1 <0.3.0-0`**: the 0.1.7 line and the **entire 0.2.x line** (prereleases and stable releases alike) are supported; 0.3.0 and later are not declared.
161
+ All nine `@deepseek-ai/*` peers are declared as **`>=0.1.7-rc.1 <0.3.0-0`**: the 0.1.7 line and the **entire 0.2.x line** (prereleases and stable releases alike) are supported; 0.3.0 and later are not declared.
162
162
 
163
163
  To see why the range has this shape, look at how DSH **validates** it. For every `@deepseek-ai/dsh` / `dsh-*` peer, `@deepseek-ai/dsh-app-boot` runs:
164
164
 
package/README.md CHANGED
@@ -158,7 +158,7 @@ npm install dsh-subagent-default-model
158
158
 
159
159
  ## 宿主版本要求
160
160
 
161
- 全部 8 个 `@deepseek-ai/*` peer 声明为 **`>=0.1.7-rc.1 <0.3.0-0`**:支持 0.1.7 线及其后的**整个 0.2.x 线**(prerelease 与正式版都放行),0.3.0 起不再声明支持。
161
+ 全部 9 个 `@deepseek-ai/*` peer 声明为 **`>=0.1.7-rc.1 <0.3.0-0`**:支持 0.1.7 线及其后的**整个 0.2.x 线**(prerelease 与正式版都放行),0.3.0 起不再声明支持。
162
162
 
163
163
  要理解这个区间为什么长这样,得先知道 DSH **怎么校验**它。`@deepseek-ai/dsh-app-boot` 对每个 `@deepseek-ai/dsh` / `dsh-*` peer 执行:
164
164
 
package/lib/index.js CHANGED
@@ -444,6 +444,32 @@ function isRouteContextMessage(message) {
444
444
  return message?.source?.kind === ROUTE_CONTEXT_SOURCE && message.source.form === ROUTE_CONTEXT_FORM;
445
445
  }
446
446
 
447
+ /**
448
+ * Has this agent built a request yet in the CURRENT run?
449
+ *
450
+ * `session.requestContext()` folds over the session's whole event log, and a
451
+ * RESTORED session (`Session.fromRestore`) starts with the PREVIOUS run's log as
452
+ * its seed. So on step 1 of a resumed subagent the fold already returns the old
453
+ * run's route — before this run has chosen anything. Trusting it would label the
454
+ * new run with the previous run's provider/model: the same "authoritative but
455
+ * wrong" failure as the dispatch-seed bug, only older.
456
+ *
457
+ * The plugin's own `agent/request` listener records a route only once a request
458
+ * settles, so a per-agent "has requested" flag separates "this run has chosen"
459
+ * from "history says something".
460
+ *
461
+ * @param {object} agent - the loop agent.
462
+ * @param {Map} settled - per-agent settled-seed cache (its key presence is the flag).
463
+ * @returns {boolean} true when the fold can only be describing an earlier run.
464
+ */
465
+ function isStaleFold(agent, settled) {
466
+ // Only a actually-restored session can carry another run's log. A fresh
467
+ // session's fold is always produced by this run, so never second-guess it.
468
+ const seeded = agent?.session?.header?.isSeeded;
469
+ if (seeded !== true) return false;
470
+ return settled.has(agent?.id) === false;
471
+ }
472
+
447
473
  /**
448
474
  * Resolve the route the agent is ACTUALLY using, or `undefined` when that is
449
475
  * not yet knowable.
@@ -470,12 +496,18 @@ function isRouteContextMessage(message) {
470
496
  */
471
497
  function routeForInjection(agent, settled) {
472
498
  // The session's fold of the latest `request/context` — authoritative and
473
- // current, and what the host itself treats as "the latest resolved route".
499
+ // current FOR THE RUN THAT PRODUCED IT, and what the host itself treats as
500
+ // "the latest resolved route".
501
+ //
502
+ // BOTH halves must be known: a half-filled fold (`{provider:"workbuddy",
503
+ // model:""}`) used to render as `model=unknown`, which is exactly the
504
+ // "report a guess" failure this function exists to avoid. The request side
505
+ // rejects the same shape, so both ends agree on what a route is.
474
506
  const live = agent?.session?.requestContext?.();
475
507
  if (live !== void 0 && live !== null) {
476
508
  const provider = typeof live.provider === "string" ? live.provider : "";
477
509
  const model = typeof live.model === "string" ? live.model : "";
478
- if (provider !== "" || model !== "") return { provider, model };
510
+ if (provider !== "" && model !== "" && !isStaleFold(agent, settled)) return { provider, model };
479
511
  }
480
512
  // A request already built by this plugin's own waterfall: still authoritative
481
513
  // for that request, and normally identical to the fold above.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-subagent-default-model",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "为 DeepSeek Harness 子代理配置默认模型:多模型顺序/随机分配、跨供应商连接失败故障转移,并在轨迹/对话视图显示当前供应商与模型,同时以一行真实提示词把当前路由注入子代理上下文。",
5
5
  "keywords": [
6
6
  "deepseek-harness",