dsh-subagent-default-model 1.0.0 → 1.1.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/CHANGELOG.md +23 -0
- package/lib/client.js +119 -13
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.0 (2026-08-31)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- **轨迹视图显示模型路由**: 子代理每次请求实际用的 provider/model 会显示在**轨迹视图**里——换模型(含 failover 切换)后自动多出一行「子代理模型:`provider/model`」。基于官方 `request/context` 帧(`trajectory-subagent-model` 定义),零宿主改动。
|
|
8
|
+
- **对话视图新增模型提示行**: 子代理**对话视图**新增上下文注入行(`chat-subagent-model` 定义,基于官方 `request/header` 帧的 `reason`):
|
|
9
|
+
- 子代理开始第一句:`子代理模型:provider/model`(写清当前用的供应商与模型)
|
|
10
|
+
- failover 切换成功后:`已切换到:provider/model`(展示现在用的是哪个模型)
|
|
11
|
+
- 会话恢复时:`继续使用:provider/model`
|
|
12
|
+
- 折叠态即可见(`source.summary`),复用 DSH 原生 `ContextInjectionRow`。
|
|
13
|
+
- **切换提示文案改为 Provider**: 「连接失败时按队列与策略切换模型」的提示从「需配置 ≥2 个模型」改为「需配置 ≥2 个 Provider」。实测确认:官方重试按 `provider` 记账(`dsh-llm-retry`),同一 Provider 下多模型共享重试配额、第二个模型不重试;**每个模型配独立 Provider 时,各拿满自己的重试次数,全部失败才停**。
|
|
14
|
+
|
|
15
|
+
### Docs
|
|
16
|
+
|
|
17
|
+
- 新增 `docs/mock-failover-test.md`:本地 mock 模拟连接失败的完整测试指南(SSE 支持、`MOCK_ALL_FAIL=1` 全失败模式)。
|
|
18
|
+
- 新增 `docs/per-model-retry-design.md`:「每个模型独立重试 + 逐个切换 + 全部失败才停」的需求、根因分析(官方重试按 provider 记账)与实现方案;方案 B(每模型一个 provider)已实测通过。
|
|
19
|
+
|
|
20
|
+
### Testing / Scripts
|
|
21
|
+
|
|
22
|
+
- 新增 `plugin/test/client-trajectory.test.mjs`:轨迹 + 对话定义的单测(匹配、三种 reason 文案、节点结构、buildViewNode),测试 **36/36 通过**。
|
|
23
|
+
- 新增 `plugin/scripts/mock-llm-server.mjs`:本地 OpenAI 兼容 mock,支持 SSE 流式响应与全失败模式。
|
|
24
|
+
- 新增 `plugin/scripts/simulate-retry.mjs`:端到端 failover 模拟,输出轨迹/对话视图渲染预览。
|
|
25
|
+
|
|
3
26
|
## 1.0.0 (2026-08-29)
|
|
4
27
|
|
|
5
28
|
### Features
|
package/lib/client.js
CHANGED
|
@@ -14,7 +14,7 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
|
|
15
15
|
// ── plugin icon (LD brand logo, 64px) ────────────────────────────────
|
|
16
16
|
var DSM_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAXGUlEQVR4nH1bC7BdVXn+1tr7nHPvzb3JvUloSAQp0JHWoAMttKOCFrWU8irQSbCTQYG21IahnTJUUTsM0FJhZCzCSIcKImOpDkhrhQ5YC7ROB3lUBU3EyCuBFBIIedzcx3ntvTr/a621TwIns3PO3mfvddf/+v7v/9c6DvYKoYBz1cZNYfJpVBcNBm7dcIhj3TBM15VzqAE6XAWEGggVADroOl0byDW+PtRr9E732rl9r2PxOMNsrCogVE7PA0Kge4Lcz5/TGI6v00UaK+h98u4QUA9quIDg4Pe2i2LTsknc++mzZu9cv37VHNaFAveSJICj/9aFUNzrXHXSTwdnznl/Y+X9MaEP1D0A/ToKaUdDASoAK0YVYcLad/G88S6C1aQcOkI2Nj9HylBFBRMYqPUeFp6EDXQfKcIUoud6LQQP59rwrsBEOdhy9KGDK/7j9mUPmBKcCf++Z4YbF6eKLw+6QFioKl/DoYILlXMsHE2KPCCzwlsqoNb3oUw4Kq+2a0k4G4MtXOX3J4HN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CNmod3T3W7Asc+Puc5D1JKRbpRJnFYgZAI9iQub7EvY9gxc9yW1vW+HgME3KkwSkNDs0EVnXqWqARIG3X1y3XDq0xbPbTS4q7vVcCN7qwGWM73/HV3P0t7iwImoOhlMZpe0rc8q7tblaE9vxzJaTCJa3nC/iZp6QFTgNGi/0mC9TvOTukUNLUG8Y6hZte7e/2l52Iu8ar6qXalR6hrhq5P0+LI7/DaYBgrHnMve1HEhYu6RkWgq2bvKDJ3cVGOfhZLOdYkaq8xPIYX2zVV72uyPBEN01XnTDuy2WLL33w+rG7/PpT3NyvrQ4bx9tww8qT1ejHNHFPQEJ6Ke0E1LJd2FmhR90g04xpP+tfKCjmYKaWIU/ImhcpTpXi2q7UfLeH9fXVqSVsTNiMD+Rh4uraDT2mlpXu8BNaG1etcnN+3T2huPcvWg8dubS6dHJJUfD6bFVXrq5rrw3+tCaXOuGmBENzAzHpu0tvL63uNj8bykdeoCkt8QHL+SqAkRxz60wJcQ9BFh6p7CX8CYEQLtShKocTfmbpRLHs3d1LT7u+9dA99tNZ+yHxBTcNztz0mr9x74I/hnZXhD7F/PCAn6bJz+U0vrPr7K5VJUJZf5/v040NDcG02LGGJVmfOsuxdifg03U9vUZHrPz0fl7p5caGjNkiEmTFUXBooUDbjWGs5TE+Pdyy6vjqijO+MPYACb+efjwdiYsqIewMk+d8tbro1b1uXXehPrYahmn+hZmGgtefqsalNFvU1BpAhM8QXhUlCmgCmihAUnBUQixk6J2eSYqwvM9Iz5sfrApM7LDF7W651oILbef3Tky0Nk2vcfeed0dxp3Nu7h6EYr2sgOL/Aa5OuMdnE5sWAAAAAElFTkSuQmCC";
|
|
17
|
-
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-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}.dsm-btn-outline:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}.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-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}";
|
|
17
|
+
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-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}.dsm-btn-outline:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}.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-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}";
|
|
18
18
|
|
|
19
19
|
if (typeof document !== "undefined") {
|
|
20
20
|
var cssId = "dsh-subagent-default-model/client.css";
|
|
@@ -50,7 +50,12 @@ window.__ModuleLoader__.load({
|
|
|
50
50
|
"row.incomplete": "请为每个模型路由选择 Provider 和 Model。",
|
|
51
51
|
"row.saveFailed": "保存失败,请重试。",
|
|
52
52
|
"row.toastSaved": "子代理默认模型设置已保存。",
|
|
53
|
-
"row.failoverEnabled": "连接失败时按队列与策略切换模型"
|
|
53
|
+
"row.failoverEnabled": "连接失败时按队列与策略切换模型",
|
|
54
|
+
"row.failoverHint": "(需配置 ≥2 个 Provider,切换才会生效)。",
|
|
55
|
+
"row.trajectoryModel": "子代理模型",
|
|
56
|
+
"row.chatModelInitial": "子代理模型",
|
|
57
|
+
"row.chatModelChange": "已切换到",
|
|
58
|
+
"row.chatModelResume": "继续使用"
|
|
54
59
|
};
|
|
55
60
|
var SUBAGENT_ROW_EN = {
|
|
56
61
|
"row.title": "Subagent default model (dsh-subagent-default-model)",
|
|
@@ -73,7 +78,12 @@ window.__ModuleLoader__.load({
|
|
|
73
78
|
"row.incomplete": "Choose a provider and model for every route.",
|
|
74
79
|
"row.saveFailed": "Could not save the setting. Try again.",
|
|
75
80
|
"row.toastSaved": "Subagent default model settings saved.",
|
|
76
|
-
"row.failoverEnabled": "Switch models by queue and strategy on connection failure"
|
|
81
|
+
"row.failoverEnabled": "Switch models by queue and strategy on connection failure",
|
|
82
|
+
"row.failoverHint": "(requires at least 2 configured providers).",
|
|
83
|
+
"row.trajectoryModel": "Subagent model",
|
|
84
|
+
"row.chatModelInitial": "Subagent model",
|
|
85
|
+
"row.chatModelChange": "Switched to",
|
|
86
|
+
"row.chatModelResume": "Resumed on"
|
|
77
87
|
};
|
|
78
88
|
|
|
79
89
|
// ── helpers ──────────────────────────────────────────────────────────
|
|
@@ -336,15 +346,16 @@ window.__ModuleLoader__.load({
|
|
|
336
346
|
React.createElement("option", { value: "round-robin" }, t("row.roundRobin")),
|
|
337
347
|
React.createElement("option", { value: "random" }, t("row.random"))
|
|
338
348
|
)
|
|
339
|
-
) : null
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
)
|
|
349
|
+
) : null
|
|
350
|
+
),
|
|
351
|
+
React.createElement("label", { className: "dsm-model-settings-failover" },
|
|
352
|
+
React.createElement("input", {
|
|
353
|
+
type: "checkbox",
|
|
354
|
+
checked: failoverEnabledState[0],
|
|
355
|
+
onChange: function (event) { failoverEnabledState[1](event.target.checked); savedState[1](false); saveErrorState[1](false); dirtyState[1](true); }
|
|
356
|
+
}),
|
|
357
|
+
React.createElement("span", null, t("row.failoverEnabled")),
|
|
358
|
+
React.createElement("span", { className: "dsm-failover-hint" }, t("row.failoverHint"))
|
|
348
359
|
),
|
|
349
360
|
hasIncompleteRoute ? React.createElement("div", { className: "dsm-model-settings-hint" }, t("row.incomplete")) : null,
|
|
350
361
|
React.createElement("div", { className: "dsm-model-settings-footer" },
|
|
@@ -397,7 +408,7 @@ window.__ModuleLoader__.load({
|
|
|
397
408
|
}
|
|
398
409
|
|
|
399
410
|
// ── apply: inject settings row ───────────────────────────────────────
|
|
400
|
-
var inject = ["sessions", "connection", "slots", "locale", "settingsScope", "remote"];
|
|
411
|
+
var inject = ["sessions", "connection", "slots", "locale", "settingsScope", "remote", "conversationEvents"];
|
|
401
412
|
|
|
402
413
|
function apply(ctx) {
|
|
403
414
|
var api = ctx.connection.api;
|
|
@@ -406,6 +417,101 @@ window.__ModuleLoader__.load({
|
|
|
406
417
|
ctx.locale.register(SUBAGENT_ROW_LOCALE, "zh", SUBAGENT_ROW_ZH);
|
|
407
418
|
ctx.locale.register(SUBAGENT_ROW_LOCALE, "en", SUBAGENT_ROW_EN);
|
|
408
419
|
|
|
420
|
+
// ── trajectory: surface the subagent model per request ──────────────
|
|
421
|
+
// agent-loop appends a `request/context` frame (provider/model) whenever
|
|
422
|
+
// the provider or model changes — failover switches trigger it with zero
|
|
423
|
+
// host changes. Register a trajectory definition that renders that frame
|
|
424
|
+
// as a compact "Subagent model" row inside the subagent's trajectory view.
|
|
425
|
+
if (ctx.conversationEvents && typeof ctx.conversationEvents.register === "function") {
|
|
426
|
+
var trajectoryT = ctx.locale.bind(SUBAGENT_ROW_LOCALE);
|
|
427
|
+
var modelContextDefinition = {
|
|
428
|
+
kind: "trajectory-subagent-model",
|
|
429
|
+
target: "trajectory",
|
|
430
|
+
match: function (event) {
|
|
431
|
+
return event.type === "request/context" ? { id: String(event.seq), role: "start" } : null;
|
|
432
|
+
},
|
|
433
|
+
start: function (_context, match) {
|
|
434
|
+
var event = match.event;
|
|
435
|
+
var data = event.data || {};
|
|
436
|
+
var label = trajectoryT("row.trajectoryModel") + ":" + (data.provider ? data.provider + (data.model ? "/" + data.model : "") : (data.model || ""));
|
|
437
|
+
return {
|
|
438
|
+
kind: "context",
|
|
439
|
+
seq: event.seq,
|
|
440
|
+
time: event.time,
|
|
441
|
+
content: [{ type: "text", text: label }],
|
|
442
|
+
source: { kind: "plugin", plugin: "dsh-subagent-default-model", form: "notice" }
|
|
443
|
+
};
|
|
444
|
+
},
|
|
445
|
+
update: function (context) { return context.state; },
|
|
446
|
+
buildViewNode: function (context) {
|
|
447
|
+
if (context.state === void 0) return null;
|
|
448
|
+
return {
|
|
449
|
+
key: context.key,
|
|
450
|
+
kind: context.kind,
|
|
451
|
+
id: context.id,
|
|
452
|
+
target: "trajectory",
|
|
453
|
+
anchorSeq: context.state.seq,
|
|
454
|
+
location: context.start && context.start.location ? context.start.location : { kind: "unresolved" },
|
|
455
|
+
data: { kind: "node", node: context.state }
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
ctx.conversationEvents.register(modelContextDefinition);
|
|
460
|
+
|
|
461
|
+
// ── chat: surface the subagent model in the conversation view ──
|
|
462
|
+
// agent-loop writes a `request/header` frame with a `reason` the first
|
|
463
|
+
// time the subagent builds a request ("initial"), on every provider /
|
|
464
|
+
// model change ("change" — including failover switches), and when a
|
|
465
|
+
// persisted session resumes ("resume"). The frame header carries the
|
|
466
|
+
// full config (provider/model), so the conversation can show exactly
|
|
467
|
+
// which route is in use — no host-side changes required.
|
|
468
|
+
// The chat view renders `kind: "context"` nodes via ContextMessageNodeView
|
|
469
|
+
// (content/source/provenance/form), reusing the built-in injection row.
|
|
470
|
+
var chatT = ctx.locale.bind(SUBAGENT_ROW_LOCALE);
|
|
471
|
+
var chatModelDefinition = {
|
|
472
|
+
kind: "chat-subagent-model",
|
|
473
|
+
target: "chat",
|
|
474
|
+
match: function (event) {
|
|
475
|
+
return event.type === "request/header" ? { id: String(event.seq), role: "start" } : null;
|
|
476
|
+
},
|
|
477
|
+
start: function (_context, match) {
|
|
478
|
+
var event = match.event;
|
|
479
|
+
var data = event.data || {};
|
|
480
|
+
var header = data.header || {};
|
|
481
|
+
var config = header.config || {};
|
|
482
|
+
var reason = data.reason === "change" ? "row.chatModelChange" : data.reason === "resume" ? "row.chatModelResume" : "row.chatModelInitial";
|
|
483
|
+
var label = chatT(reason) + ":" + (config.provider ? config.provider + (config.model ? "/" + config.model : "") : (config.model || ""));
|
|
484
|
+
return {
|
|
485
|
+
kind: "context",
|
|
486
|
+
seq: event.seq,
|
|
487
|
+
time: event.time,
|
|
488
|
+
content: [{ type: "text", text: label }],
|
|
489
|
+
// `summary` is the collapsed row's one-line account (notice form):
|
|
490
|
+
// without it the row only shows the provenance label and hides the
|
|
491
|
+
// model behind expansion.
|
|
492
|
+
source: { kind: "plugin", plugin: "dsh-subagent-default-model", form: "notice", summary: label },
|
|
493
|
+
provenance: { role: "inject", label: "dsh-subagent-default-model" },
|
|
494
|
+
form: "notice"
|
|
495
|
+
};
|
|
496
|
+
},
|
|
497
|
+
update: function (context) { return context.state; },
|
|
498
|
+
buildViewNode: function (context) {
|
|
499
|
+
if (context.state === void 0) return null;
|
|
500
|
+
return {
|
|
501
|
+
key: context.key,
|
|
502
|
+
kind: "context",
|
|
503
|
+
id: context.id,
|
|
504
|
+
target: "chat",
|
|
505
|
+
anchorSeq: context.state.seq,
|
|
506
|
+
location: context.start && context.start.location ? context.start.location : { kind: "unresolved" },
|
|
507
|
+
visibility: "visible",
|
|
508
|
+
data: context.state
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
ctx.conversationEvents.register(chatModelDefinition);
|
|
513
|
+
}
|
|
514
|
+
|
|
409
515
|
var subagentScope = ctx.settingsScope.bind({ namespace: SUBAGENT_MODEL_SETTINGS_NS });
|
|
410
516
|
var subagentRowInjected = function () {
|
|
411
517
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-subagent-default-model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Configure default model routes for DeepSeek Harness subagents, with single-model, round-robin, random, and per-route reasoning-effort options.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
@@ -44,7 +44,9 @@
|
|
|
44
44
|
"CHANGELOG.md"
|
|
45
45
|
],
|
|
46
46
|
"scripts": {
|
|
47
|
-
"test": "node --test test/*.test.mjs"
|
|
47
|
+
"test": "node --test test/*.test.mjs",
|
|
48
|
+
"mock": "node scripts/mock-llm-server.mjs",
|
|
49
|
+
"simulate": "node scripts/simulate-retry.mjs"
|
|
48
50
|
},
|
|
49
51
|
"dsh": {
|
|
50
52
|
"bundle": {
|