dsh-cabinet-mode 0.3.1 → 0.4.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 +21 -0
- package/README.md +27 -2
- package/README.zh.md +20 -2
- package/client.js +125 -9
- package/index.js +188 -2
- package/package.json +1 -1
- package/scripts/market-index.mjs +2 -2
- package/scripts/test-member-settings.mjs +51 -2
- package/scripts/test-model-picker.mjs +42 -0
- package/scripts/test-model-routing.mjs +22 -0
- package/scripts/test-model-selection.cjs +71 -0
- package/scripts/verify.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.4.0] - 2026-11-05
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Per-office model settings from the official live model catalog, with explicit
|
|
10
|
+
Save/Cancel, refresh, retained unavailable choices and opaque model IDs.
|
|
11
|
+
- Cabinet-only route policy: member override, configured Lead fallback, then
|
|
12
|
+
the DSH deployment default. Clearing actively restores that default.
|
|
13
|
+
- Scoped prompt/request snapshots keyed by AgentLoop turn signal, actual role
|
|
14
|
+
checks, live preset gating and native selection ordering/effort compatibility.
|
|
15
|
+
- Regression coverage with official Cordis/SystemPrompt/model-selection and
|
|
16
|
+
catalog components, without external model calls. Isolated browser checks
|
|
17
|
+
cover catalog selection, Save, reload, Cancel and clear.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Declare the optional browser Remote services before access, preventing the
|
|
22
|
+
plugin boot failure in the initial implementation.
|
|
23
|
+
- Reject invalid model input before Save instead of silently deleting a choice.
|
|
24
|
+
- Keep the published 0.3.0/0.3.1 changelog entries unchanged.
|
|
25
|
+
|
|
5
26
|
## [0.3.1] - 2026-11-05
|
|
6
27
|
|
|
7
28
|
### Changed
|
package/README.md
CHANGED
|
@@ -50,6 +50,31 @@ atomically using the revision that was loaded. If another page changes settings,
|
|
|
50
50
|
cancel/reload before editing again; a stale draft cannot overwrite it. Editing is
|
|
51
51
|
disabled until settings have loaded. Changes apply to the next prompt assembly.
|
|
52
52
|
|
|
53
|
+
Each office has a **Model** picker populated by the official runtime
|
|
54
|
+
`session.modelCatalog`. Use **Refresh model catalog** after changing providers.
|
|
55
|
+
Saved choices absent from the current catalog remain visible; partial provider
|
|
56
|
+
failures do not erase them. If the catalog is unavailable, a manual
|
|
57
|
+
`provider/id` field is offered. IDs may contain +, @, spaces and further slashes;
|
|
58
|
+
only the first slash separates the provider. Invalid input blocks Save.
|
|
59
|
+
|
|
60
|
+
In **Cabinet mode**, the profile policy takes precedence over the native
|
|
61
|
+
session picker: an explicit member model wins; an empty teammate selection
|
|
62
|
+
uses the configured Lead model, otherwise the current **DSH deployment default**.
|
|
63
|
+
An empty Lead selection uses that deployment default. This is not inheritance
|
|
64
|
+
of a different session's last request. Clearing actively restores this default,
|
|
65
|
+
even when the previous request header recorded an overridden model.
|
|
66
|
+
|
|
67
|
+
Routes are snapshotted at prompt assembly and paired with the same AgentLoop
|
|
68
|
+
turn signal for requests. Save affects the next assembly, including already-live
|
|
69
|
+
members; in-flight requests keep their snapshot. Actual team roles and the live
|
|
70
|
+
Cabinet preset gate the policy; a teammate named lead cannot gain Lead policy.
|
|
71
|
+
Different models use their adapter's reasoning default; matching routes retain
|
|
72
|
+
native effort. Mode changes during a step abort that step rather than route a
|
|
73
|
+
mismatched prompt. On a live mode exit, a retained plugin override is restored
|
|
74
|
+
to the route recorded before Cabinet took over. Unloading cancels any active routed turn while retaining queued input, then
|
|
75
|
+
removes its listeners; it does not rewrite persisted session history. The default model
|
|
76
|
+
must be available; missing defaults fail explicitly instead of keeping a stale override.
|
|
77
|
+
|
|
53
78
|
Upload PNG/JPEG/WebP up to 2 MB; the browser crops it to a 96×96 PNG (at most
|
|
54
79
|
48 KB data URL). Saved portraits apply to Cabinet cards and native team avatars.
|
|
55
80
|
Restore default resets that office's name, portrait and factory prompt; Reset all
|
|
@@ -193,7 +218,7 @@ On failure, show the exact error. For $.format must be 1, replace the webpage so
|
|
|
193
218
|
Use this only when the market is unavailable or for local development. Fully quit desktop DSH first to release the profile lock, then install the release bundle:
|
|
194
219
|
|
|
195
220
|
```sh
|
|
196
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.
|
|
221
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.4.0/dsh-cabinet-mode-0.4.0.tgz
|
|
197
222
|
dsh plugin --profile desktop list
|
|
198
223
|
```
|
|
199
224
|
|
|
@@ -208,7 +233,7 @@ the same install command with the new version URL (or pick the new `.tgz` in the
|
|
|
208
233
|
plugin page), then fully quit and restart DeepSeek Harness:
|
|
209
234
|
|
|
210
235
|
```sh
|
|
211
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.
|
|
236
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.4.0/dsh-cabinet-mode-0.4.0.tgz
|
|
212
237
|
```
|
|
213
238
|
|
|
214
239
|
`dsh plugin --profile desktop list` should report the new version. Upgrades were
|
package/README.zh.md
CHANGED
|
@@ -30,6 +30,24 @@
|
|
|
30
30
|
冲突,须取消重读后再编辑,不会用旧草稿覆盖。配置尚未加载时禁止编辑。
|
|
31
31
|
保存的提示词在下一次提示词装配时生效。
|
|
32
32
|
|
|
33
|
+
每个官职都有 **模型** 下拉,读取官方 `session.modelCatalog`。修改提供方后可点击
|
|
34
|
+
**刷新模型目录**;目录中暂时不存在的已存选择仍保留,部分提供方失败不会清空配置。
|
|
35
|
+
目录不可用时提供手动 `provider/id` 输入。模型 ID 支持 +、@、空格及额外斜杠,
|
|
36
|
+
仅第一个斜杠分隔提供方;格式错误会阻止保存。
|
|
37
|
+
|
|
38
|
+
仅在 **内阁模式** 中,profile 策略优先于原生会话模型选择:成员显式模型优先;
|
|
39
|
+
阁臣留空时使用已配置的首辅模型,首辅未配置时使用当前 **DSH 部署默认模型**。
|
|
40
|
+
首辅留空也使用部署默认模型,并非继承另一个会话最后使用的模型。清空会主动恢复
|
|
41
|
+
该默认路由,即使历史请求头仍记录上次覆盖模型也不会继续沿用它。
|
|
42
|
+
|
|
43
|
+
路由在提示词装配时快照,并通过同一 AgentLoop turn signal 关联请求。保存影响
|
|
44
|
+
下一次装配,已存活成员同样生效;正在进行的请求保持原快照。实时 cabinet preset
|
|
45
|
+
和真实团队角色共同限定范围,名为 lead 的阁臣不会获得首辅策略。换模型时使用
|
|
46
|
+
新模型适配器的 reasoning 默认值,同路由保留原生 effort。步骤中途切换模式会
|
|
47
|
+
中止该步骤,避免提示词与路由错配;运行期间切出内阁时,将残留插件覆盖恢复到
|
|
48
|
+
接管前记录的路由。卸载会中止仍在运行的受管轮次、保留排队输入并移除监听器,但不会改写会话历史。默认模型不可用时明确
|
|
49
|
+
报错,不会静默保留旧覆盖。
|
|
50
|
+
|
|
33
51
|
可上传不超过 2 MB 的 PNG/JPEG/WebP;浏览器居中裁成 96×96 PNG,data URL 不超过
|
|
34
52
|
48 KB。保存后头像同时用于内阁面板和原生团队列表。**恢复默认** 将该官职组的
|
|
35
53
|
显示名、头像、提示词恢复出厂状态;**重置全部** 重置五员草稿,二者都须再点保存。
|
|
@@ -140,7 +158,7 @@ https://raw.githubusercontent.com/luodaoyi/dsh-cabinet-mode/market-index/marketp
|
|
|
140
158
|
仅在商店不可用或本地开发时使用。先完全退出桌面 DSH,释放 profile 锁,再执行:
|
|
141
159
|
|
|
142
160
|
```sh
|
|
143
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.
|
|
161
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.4.0/dsh-cabinet-mode-0.4.0.tgz
|
|
144
162
|
dsh plugin --profile desktop list
|
|
145
163
|
```
|
|
146
164
|
|
|
@@ -151,7 +169,7 @@ dsh plugin --profile desktop list
|
|
|
151
169
|
若通过插件市场安装:刷新市场,先在**已安装**页卸载旧版本,再从**插件市场**安装新版本,然后重启——没有 tgz URL 要换,也没有一键更新。否则用同一条安装命令换新版本 URL(或在插件页选新 `.tgz`),然后完全退出并重启 DeepSeek Harness:
|
|
152
170
|
|
|
153
171
|
```sh
|
|
154
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.
|
|
172
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.4.0/dsh-cabinet-mode-0.4.0.tgz
|
|
155
173
|
```
|
|
156
174
|
|
|
157
175
|
`dsh plugin --profile desktop list` 应显示新版本。升级已在 Windows 实测:
|
package/client.js
CHANGED
|
@@ -2538,8 +2538,10 @@ window.__ModuleLoader__.load({
|
|
|
2538
2538
|
/** Image data URLs accepted for a member avatar; anything else is ignored. */
|
|
2539
2539
|
const MEMBER_AVATAR_PREFIXES = ['data:image/png;', 'data:image/jpeg;', 'data:image/webp;'];
|
|
2540
2540
|
const MEMBER_AVATAR_FIELDS = { lead: 'avatarLead', hanlin: 'avatarHanlin', works: 'avatarWorks', dali: 'avatarDali', yushi: 'avatarYushi' };
|
|
2541
|
-
let memberConfig = { names: new Map(), prompts: new Map(), modes: new Map(), avatars: new Map() };
|
|
2541
|
+
let memberConfig = { names: new Map(), prompts: new Map(), modes: new Map(), models: new Map(), avatars: new Map() };
|
|
2542
2542
|
let memberWriter = null;
|
|
2543
|
+
/** Host remote handle for the model catalog; null degrades the picker to text. */
|
|
2544
|
+
let memberRemote = null;
|
|
2543
2545
|
const MEMBER_LISTENERS = new Set();
|
|
2544
2546
|
let memberT = (key) => key;
|
|
2545
2547
|
function clampMemberText(value, limit) {
|
|
@@ -2547,6 +2549,40 @@ window.__ModuleLoader__.load({
|
|
|
2547
2549
|
const trimmed = value.trim();
|
|
2548
2550
|
return trimmed.length > limit ? trimmed.slice(0, limit) : trimmed;
|
|
2549
2551
|
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Coerce a stored per-member model route to `provider/id` or '', using
|
|
2554
|
+
* the same rule as the host half (index.js clampModel) so a value saved
|
|
2555
|
+
* here survives the host's field-level validation unchanged. Model ids
|
|
2556
|
+
* may contain slashes; only the first one separates provider from id.
|
|
2557
|
+
*/
|
|
2558
|
+
function clampMemberModel(value) {
|
|
2559
|
+
if (typeof value !== 'string') return '';
|
|
2560
|
+
const trimmed = value;
|
|
2561
|
+
if (trimmed === '' || trimmed.length > 200) return '';
|
|
2562
|
+
if (!/^[^/\s\x00-\x1f\x7f]+\/[^\x00-\x1f\x7f]+$/.test(trimmed)) return '';
|
|
2563
|
+
return trimmed;
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* Flatten one runtime model catalog (the official session.modelCatalog
|
|
2567
|
+
* response value) into [{value,label}] picker options. Nothing here is
|
|
2568
|
+
* a hard-coded model id: every entry comes from the host response.
|
|
2569
|
+
*/
|
|
2570
|
+
function modelOptionsOf(catalog) {
|
|
2571
|
+
const options = [];
|
|
2572
|
+
if (catalog === null || typeof catalog !== 'object' || !Array.isArray(catalog.groups)) return options;
|
|
2573
|
+
for (const group of catalog.groups) {
|
|
2574
|
+
if (group === null || typeof group !== 'object' || typeof group.id !== 'string' || !Array.isArray(group.models)) continue;
|
|
2575
|
+
if (!/^[^/\s\x00-\x1f\x7f]+$/.test(group.id)) continue;
|
|
2576
|
+
for (const model of group.models) {
|
|
2577
|
+
if (model === null || typeof model !== 'object' || typeof model.id !== 'string') continue;
|
|
2578
|
+
const value = group.id + '/' + model.id;
|
|
2579
|
+
if (clampMemberModel(value) !== value || options.some(option => option.value === value)) continue;
|
|
2580
|
+
const name = typeof model.name === 'string' && model.name !== '' && model.name !== model.id ? model.name : '';
|
|
2581
|
+
options.push({ value, label: name === '' ? value : value + ' — ' + name });
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
return options;
|
|
2585
|
+
}
|
|
2550
2586
|
/** Runtime member name -> bureau key, mirroring the host half's matching. */
|
|
2551
2587
|
function bureauOfName(name) { return bureauOf(name).key; }
|
|
2552
2588
|
/** Tolerant read of one settings namespace value; anything odd is ignored. */
|
|
@@ -2554,6 +2590,7 @@ window.__ModuleLoader__.load({
|
|
|
2554
2590
|
const names = new Map();
|
|
2555
2591
|
const prompts = new Map();
|
|
2556
2592
|
const modes = new Map();
|
|
2593
|
+
const models = new Map();
|
|
2557
2594
|
const avatars = new Map();
|
|
2558
2595
|
const members = raw !== null && typeof raw === 'object' && Array.isArray(raw.members) ? raw.members : [];
|
|
2559
2596
|
for (const entry of members) {
|
|
@@ -2565,6 +2602,7 @@ window.__ModuleLoader__.load({
|
|
|
2565
2602
|
names.set(key, name);
|
|
2566
2603
|
prompts.set(key, prompt);
|
|
2567
2604
|
modes.set(key, entry.mode === 'off' || entry.mode === 'custom' ? entry.mode : '');
|
|
2605
|
+
models.set(key, clampMemberModel(entry.model));
|
|
2568
2606
|
}
|
|
2569
2607
|
for (const key of AVATAR_KEYS) {
|
|
2570
2608
|
const value = raw !== null && typeof raw === 'object' ? raw[MEMBER_AVATAR_FIELDS[key]] : undefined;
|
|
@@ -2572,7 +2610,7 @@ window.__ModuleLoader__.load({
|
|
|
2572
2610
|
const url = value.trim();
|
|
2573
2611
|
if (url.length <= 48 * 1024 && /^data:image\/(?:png|jpeg|webp);base64,(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(url) && url.length > url.indexOf(',') + 1) avatars.set(key, url);
|
|
2574
2612
|
}
|
|
2575
|
-
return { names, prompts, modes, avatars };
|
|
2613
|
+
return { names, prompts, modes, models, avatars };
|
|
2576
2614
|
}
|
|
2577
2615
|
function setMemberConfig(raw) {
|
|
2578
2616
|
memberConfig = normalizeMemberConfig(raw);
|
|
@@ -2637,12 +2675,12 @@ window.__ModuleLoader__.load({
|
|
|
2637
2675
|
|
|
2638
2676
|
/** Build the members array the settings schema expects. */
|
|
2639
2677
|
function membersPayload(draft) {
|
|
2640
|
-
return AVATAR_KEYS.map((key) => ({ key, name: draft[key].name, prompt: draft[key].prompt, mode: draft[key].mode }));
|
|
2678
|
+
return AVATAR_KEYS.map((key) => ({ key, name: draft[key].name, prompt: draft[key].prompt, mode: draft[key].mode, model: clampMemberModel(draft[key].model) }));
|
|
2641
2679
|
}
|
|
2642
2680
|
/** Default draft: runtime names, built-in avatars, Lead 御下术 on. */
|
|
2643
2681
|
function emptyMemberDraft() {
|
|
2644
2682
|
const draft = {};
|
|
2645
|
-
for (const key of AVATAR_KEYS) draft[key] = { name: '', prompt: '', mode: '' };
|
|
2683
|
+
for (const key of AVATAR_KEYS) draft[key] = { name: '', prompt: '', mode: '', model: '' };
|
|
2646
2684
|
return draft;
|
|
2647
2685
|
}
|
|
2648
2686
|
/** Draft from the mirrored snapshot (what the form starts with). */
|
|
@@ -2652,7 +2690,8 @@ window.__ModuleLoader__.load({
|
|
|
2652
2690
|
draft[key] = {
|
|
2653
2691
|
name: memberConfig.names.get(key) || '',
|
|
2654
2692
|
prompt: memberConfig.prompts.get(key) || '',
|
|
2655
|
-
mode: memberConfig.modes.get(key) || ''
|
|
2693
|
+
mode: memberConfig.modes.get(key) || '',
|
|
2694
|
+
model: memberConfig.models.get(key) || ''
|
|
2656
2695
|
};
|
|
2657
2696
|
}
|
|
2658
2697
|
return draft;
|
|
@@ -3442,7 +3481,7 @@ window.__ModuleLoader__.load({
|
|
|
3442
3481
|
const config = normalizeMemberConfig(s?.value);
|
|
3443
3482
|
state.draft = emptyMemberDraft(); state.avatars = {}; state.errors = {};
|
|
3444
3483
|
for (const key of AVATAR_KEYS) {
|
|
3445
|
-
state.draft[key] = { name: config.names.get(key) || '', prompt: config.prompts.get(key) || '', mode: config.modes.get(key) || '' };
|
|
3484
|
+
state.draft[key] = { name: config.names.get(key) || '', prompt: config.prompts.get(key) || '', mode: config.modes.get(key) || '', model: config.models.get(key) || '' };
|
|
3446
3485
|
state.avatars[key] = config.avatars.get(key) || '';
|
|
3447
3486
|
}
|
|
3448
3487
|
state.revision = s?.revision; state.ready = ready(s); state.dirty = false; state.conflict = false;
|
|
@@ -3475,12 +3514,17 @@ window.__ModuleLoader__.load({
|
|
|
3475
3514
|
if (!editable()) return;
|
|
3476
3515
|
epoch++; uploads = {};
|
|
3477
3516
|
const keys = key ? [key] : AVATAR_KEYS;
|
|
3478
|
-
for (const k of keys) { state.draft[k] = { name: '', prompt: '', mode: '' }; state.avatars[k] = ''; }
|
|
3517
|
+
for (const k of keys) { state.draft[k] = { name: '', prompt: '', mode: '', model: '' }; state.avatars[k] = ''; }
|
|
3479
3518
|
state.draft = { ...state.draft }; state.avatars = { ...state.avatars }; state.errors = {}; changed();
|
|
3480
3519
|
},
|
|
3481
3520
|
cancel() { if (!active || state.busy) return; adopt(form?.getSnapshot()); state.status = ''; emit(); },
|
|
3482
3521
|
async save() {
|
|
3483
3522
|
if (!editable() || !state.dirty) return false;
|
|
3523
|
+
for (const key of AVATAR_KEYS) {
|
|
3524
|
+
if (state.draft[key].model && clampMemberModel(state.draft[key].model) !== state.draft[key].model) {
|
|
3525
|
+
state.errors[key] = 'member.error.model'; emit(); return false;
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3484
3528
|
const current = form.getSnapshot();
|
|
3485
3529
|
if (!ready(current) || current.revision !== state.revision) { state.conflict = true; state.status = 'member.status.conflict'; emit(); return false; }
|
|
3486
3530
|
const ops = [{ op: 'set', path: ['members'], value: membersPayload(state.draft) }];
|
|
@@ -3506,6 +3550,25 @@ window.__ModuleLoader__.load({
|
|
|
3506
3550
|
if (!editorRef.current) editorRef.current = createMemberEditor(memberWriter, () => redraw(n => n + 1));
|
|
3507
3551
|
const editor = editorRef.current;
|
|
3508
3552
|
React.useEffect(() => editor.connect(), [editor]);
|
|
3553
|
+
// Model catalog for the per-member picker: the official
|
|
3554
|
+
// session.modelCatalog remote (host LLM registry). undefined =
|
|
3555
|
+
// still loading, null = unavailable — both degrade to a plain
|
|
3556
|
+
// provider/id text field; the option list is never hard-coded.
|
|
3557
|
+
const [modelCatalog, setModelCatalog] = React.useState(undefined);
|
|
3558
|
+
const [catalogRevision, refreshCatalog] = React.useState(0);
|
|
3559
|
+
React.useEffect(() => {
|
|
3560
|
+
let alive = true;
|
|
3561
|
+
setModelCatalog(undefined);
|
|
3562
|
+
(async () => {
|
|
3563
|
+
try {
|
|
3564
|
+
if (!memberRemote || typeof memberRemote.session?.modelCatalog !== 'function') throw new Error('modelCatalog remote unavailable');
|
|
3565
|
+
const response = await memberRemote.session.modelCatalog();
|
|
3566
|
+
if (alive) setModelCatalog(response?.ok && Array.isArray(response.value?.groups) ? response.value : null);
|
|
3567
|
+
} catch { if (alive) setModelCatalog(null); }
|
|
3568
|
+
})();
|
|
3569
|
+
return () => { alive = false; };
|
|
3570
|
+
}, [catalogRevision]);
|
|
3571
|
+
const modelOptions = modelOptionsOf(modelCatalog !== undefined && modelCatalog !== null ? modelCatalog : null);
|
|
3509
3572
|
const { draft, avatars, errors, ready, busy, dirty, conflict, status } = editor.state;
|
|
3510
3573
|
const update = (key, patch) => editor.update(key, patch);
|
|
3511
3574
|
const writeAvatar = (key, url) => editor.avatar(key, url);
|
|
@@ -3562,7 +3625,7 @@ window.__ModuleLoader__.load({
|
|
|
3562
3625
|
]),
|
|
3563
3626
|
avatars[key] ? h('button', { key: 'clear', type: 'button', style: { fontSize: 11, cursor: 'pointer' }, onClick: () => writeAvatar(key, '') }, t('member.avatar.clear')) : null
|
|
3564
3627
|
]),
|
|
3565
|
-
errors[key] ? h('div', { key: 'e', style: { fontSize: 11, color: '#f25a5a', marginBottom: 4 } }, errors[key]) : null,
|
|
3628
|
+
errors[key] ? h('div', { key: 'e', style: { fontSize: 11, color: '#f25a5a', marginBottom: 4 } }, errors[key] === 'member.error.model' ? t(errors[key]) : errors[key]) : null,
|
|
3566
3629
|
h('label', { key: 'name', style: { display: 'block', fontSize: 11, color: INK2, marginBottom: 2 } }, t('member.name')),
|
|
3567
3630
|
h('input', {
|
|
3568
3631
|
key: 'ni',
|
|
@@ -3573,6 +3636,32 @@ window.__ModuleLoader__.load({
|
|
|
3573
3636
|
style: inputStyle,
|
|
3574
3637
|
onChange: (event) => update(key, { name: event?.target?.value ?? '' })
|
|
3575
3638
|
}),
|
|
3639
|
+
h('label', { key: 'ml', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.model')),
|
|
3640
|
+
modelOptions.length > 0
|
|
3641
|
+
? (function () {
|
|
3642
|
+
const value = draft[key].model || '';
|
|
3643
|
+
const opts = [h('option', { key: '', value: '' }, t(key === 'lead' ? 'member.model.defaultLead' : 'member.model.default'))];
|
|
3644
|
+
if (value !== '' && !modelOptions.some((option) => option.value === value)) opts.push(h('option', { key: 'current', value }, value));
|
|
3645
|
+
for (const option of modelOptions) opts.push(h('option', { key: option.value, value: option.value }, option.label));
|
|
3646
|
+
return h('select', {
|
|
3647
|
+
key: 'mi',
|
|
3648
|
+
value,
|
|
3649
|
+
style: inputStyle,
|
|
3650
|
+
onChange: (event) => update(key, { model: event?.target?.value ?? '' })
|
|
3651
|
+
}, opts);
|
|
3652
|
+
}())
|
|
3653
|
+
: h('input', {
|
|
3654
|
+
key: 'mi',
|
|
3655
|
+
type: 'text',
|
|
3656
|
+
disabled: modelCatalog === undefined,
|
|
3657
|
+
value: draft[key].model,
|
|
3658
|
+
maxLength: 200,
|
|
3659
|
+
placeholder: 'provider/id',
|
|
3660
|
+
style: inputStyle,
|
|
3661
|
+
onChange: (event) => update(key, { model: event?.target?.value ?? '' })
|
|
3662
|
+
}),
|
|
3663
|
+
modelCatalog !== undefined && modelOptions.length === 0 ? h('div', { key: 'mh', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.model.unavailable')) : null,
|
|
3664
|
+
h('div', { key: 'mhint', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.model.hint')),
|
|
3576
3665
|
h('label', { key: 'prompt', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.prompt')),
|
|
3577
3666
|
h('textarea', {
|
|
3578
3667
|
key: 'pi',
|
|
@@ -3600,7 +3689,9 @@ window.__ModuleLoader__.load({
|
|
|
3600
3689
|
!ready ? h('div', { key: 'unavailable', role: 'status' }, t('member.status.unavailable')) : null,
|
|
3601
3690
|
status ? h('div', { key: 'status', style: { fontSize: 11, color: INK2, marginBottom: 8 } }, t(status)) : null,
|
|
3602
3691
|
conflict ? h('div', { key: 'conflict', role: 'alert' }, t('member.status.conflict')) : null,
|
|
3603
|
-
h('
|
|
3692
|
+
h('button', { key: 'catalog', type: 'button', onClick: () => refreshCatalog(value => value + 1) }, t('member.model.refresh')),
|
|
3693
|
+
modelCatalog?.failures?.length ? h('div', { key: 'catalog-errors', role: 'status' }, t('member.model.partial')) : null,
|
|
3694
|
+
h('fieldset', { key: 'fields', disabled: !ready || busy, style: { border: 0, padding: 0, margin: 0 } }, cards),
|
|
3604
3695
|
h('button', { key: 'save', type: 'button', disabled: !ready || busy || !dirty || conflict, onClick: () => editor.save() }, t('member.save')),
|
|
3605
3696
|
h('button', { key: 'cancel', type: 'button', disabled: busy, onClick: () => editor.cancel() }, t('member.cancel'))
|
|
3606
3697
|
]);
|
|
@@ -3659,6 +3750,14 @@ window.__ModuleLoader__.load({
|
|
|
3659
3750
|
'member.status.failed': '保存失败,请重试',
|
|
3660
3751
|
'member.status.unavailable': '设置通道不可用',
|
|
3661
3752
|
'member.lead.hint': '清空此框 = 关闭御下术(不注入该段);「恢复默认」还原出厂定稿。',
|
|
3753
|
+
'member.model': '模型(每成员独立)',
|
|
3754
|
+
'member.model.default': '使用首辅配置;未配置时使用 DSH 默认模型',
|
|
3755
|
+
'member.model.defaultLead': '使用 DSH 默认模型',
|
|
3756
|
+
'member.model.refresh': '刷新模型目录',
|
|
3757
|
+
'member.model.partial': '部分提供方加载失败;现有选择保留。可刷新重试。',
|
|
3758
|
+
'member.error.model': '模型必须为 provider/id,最长 200 字符,不能含控制字符。',
|
|
3759
|
+
'member.model.unavailable': '模型列表暂不可用:请手动输入 provider/id。',
|
|
3760
|
+
'member.model.hint': '保存后在下一次提示词装配生效;正在进行的请求不变。仅内阁模式应用,清空后主动恢复默认模型。',
|
|
3662
3761
|
'member.error.type': '格式不支持:只接受 PNG / JPEG / WebP',
|
|
3663
3762
|
'member.error.size': '文件过大:源文件不超过 2MB',
|
|
3664
3763
|
'member.error.decode': '图片读取失败,请换一张',
|
|
@@ -3716,6 +3815,14 @@ window.__ModuleLoader__.load({
|
|
|
3716
3815
|
'member.status.failed': 'Save failed, try again',
|
|
3717
3816
|
'member.status.unavailable': 'Settings channel unavailable',
|
|
3718
3817
|
'member.lead.hint': 'Clearing this box turns the Lead policy off (nothing injected); "Restore default" brings back the factory text.',
|
|
3818
|
+
'member.model': 'Model (per member)',
|
|
3819
|
+
'member.model.default': 'Use Lead configuration, otherwise DSH default',
|
|
3820
|
+
'member.model.defaultLead': 'Use DSH default model',
|
|
3821
|
+
'member.model.refresh': 'Refresh model catalog',
|
|
3822
|
+
'member.model.partial': 'Some providers failed to load; saved choices are retained. Refresh to retry.',
|
|
3823
|
+
'member.error.model': 'Use provider/id, at most 200 characters, without control characters.',
|
|
3824
|
+
'member.model.unavailable': 'Model list unavailable: type provider/id manually.',
|
|
3825
|
+
'member.model.hint': 'Applies at the next prompt assembly after Save; in-flight requests stay unchanged. Cabinet mode only. Clearing actively restores the default model.',
|
|
3719
3826
|
'member.error.type': 'Unsupported format: PNG / JPEG / WebP only',
|
|
3720
3827
|
'member.error.size': 'File too large: source must be at most 2MB',
|
|
3721
3828
|
'member.error.decode': 'Could not read the image, try another file',
|
|
@@ -3756,6 +3863,15 @@ window.__ModuleLoader__.load({
|
|
|
3756
3863
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'cabinet-ui: dictionaries');
|
|
3757
3864
|
const t = ctx.locale.bind(NS);
|
|
3758
3865
|
memberT = t;
|
|
3866
|
+
// Model catalog remote for the settings picker; absent remotes
|
|
3867
|
+
// degrade the picker to a provider/id text field at render time.
|
|
3868
|
+
ctx.inject(['remote', 'remote.session'], scope => {
|
|
3869
|
+
const remote = scope.remote;
|
|
3870
|
+
scope.effect(() => {
|
|
3871
|
+
memberRemote = remote;
|
|
3872
|
+
return () => { if (memberRemote === remote) memberRemote = null; };
|
|
3873
|
+
}, 'cabinet-ui: model catalog remote');
|
|
3874
|
+
});
|
|
3759
3875
|
// Stage one: declare the page type. No patterns => a page type, opened by kind.
|
|
3760
3876
|
ctx.effect(() => ctx.sidebarRightTabs.register({
|
|
3761
3877
|
id: TAB_ID,
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Profile-wide settings; prompt rendering is restricted to live Cabinet agents. */
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
3
4
|
|
|
4
5
|
/** Prompt section carrying the configured member block (empty when unset). */
|
|
5
6
|
const MEMBER_SECTION = 'cabinet:member';
|
|
@@ -87,6 +88,48 @@ const MAX_NAME_LENGTH = 40;
|
|
|
87
88
|
const MAX_PROMPT_LENGTH = 4000;
|
|
88
89
|
/** One avatar data URL must stay a small field (96x96 PNG, browser-normalized). */
|
|
89
90
|
const MAX_AVATAR_LENGTH = 48 * 1024;
|
|
91
|
+
/** One model route bound; a longer value is treated as corrupt and reset. */
|
|
92
|
+
const MAX_MODEL_LENGTH = 200;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Coerce a stored per-member model route to `provider/id` or ''.
|
|
96
|
+
* Wrong shapes (a number, an object), a missing slash, control characters or
|
|
97
|
+
* an over-long value all degrade to '' — the member then follows the Lead
|
|
98
|
+
* default, matching the field-level tolerance used for name/prompt/mode.
|
|
99
|
+
*/
|
|
100
|
+
function clampModel(value) {
|
|
101
|
+
if (typeof value !== 'string') return '';
|
|
102
|
+
const trimmed = value;
|
|
103
|
+
if (trimmed === '' || trimmed.length > MAX_MODEL_LENGTH) return '';
|
|
104
|
+
// Model IDs are opaque (including +, @, spaces and additional slashes).
|
|
105
|
+
if (!/^[^/\s\x00-\x1f\x7f]+\/[^\x00-\x1f\x7f]+$/.test(trimmed)) return '';
|
|
106
|
+
return trimmed;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Parse a configured `provider/id` route into the {provider, model} pair the
|
|
111
|
+
* agent/request waterfall expects. Model ids may themselves contain slashes,
|
|
112
|
+
* so only the first slash splits (provider before it, model id after it).
|
|
113
|
+
* Undefined for an empty or corrupt value; the caller resolves the default.
|
|
114
|
+
*/
|
|
115
|
+
function modelRoute(value) {
|
|
116
|
+
const route = clampModel(value);
|
|
117
|
+
if (route === '') return undefined;
|
|
118
|
+
const cut = route.indexOf('/');
|
|
119
|
+
const provider = route.slice(0, cut);
|
|
120
|
+
const model = route.slice(cut + 1);
|
|
121
|
+
if (provider === '' || model === '') return undefined;
|
|
122
|
+
return { provider, model };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The configured model route for one bureau key, read fresh on every call so a
|
|
127
|
+
* saved setting applies at the next request boundary of an already-running
|
|
128
|
+
* member instead of only after a restart.
|
|
129
|
+
*/
|
|
130
|
+
function memberModel(config, key) {
|
|
131
|
+
return modelRoute(memberEntries(config).get(key)?.model);
|
|
132
|
+
}
|
|
90
133
|
|
|
91
134
|
/**
|
|
92
135
|
* Factory default prompt for the Lead (御下术). This text is product copy: the
|
|
@@ -149,7 +192,8 @@ function memberEntries(config) {
|
|
|
149
192
|
entries.set(key, {
|
|
150
193
|
name: clampText(entry.name, MAX_NAME_LENGTH),
|
|
151
194
|
prompt: clampText(entry.prompt, MAX_PROMPT_LENGTH),
|
|
152
|
-
mode: entry.mode === 'off' || entry.mode === 'custom' ? entry.mode : ''
|
|
195
|
+
mode: entry.mode === 'off' || entry.mode === 'custom' ? entry.mode : '',
|
|
196
|
+
model: clampModel(entry.model)
|
|
153
197
|
});
|
|
154
198
|
}
|
|
155
199
|
return entries;
|
|
@@ -229,6 +273,115 @@ function sectionText(ctx, config, agent) {
|
|
|
229
273
|
}
|
|
230
274
|
}
|
|
231
275
|
|
|
276
|
+
/** Resolve current composition and actual team role, never a cached name. */
|
|
277
|
+
function memberKeyOf(ctx, agent) {
|
|
278
|
+
if (ctx.get('agentPresets')?.composedPreset(agent.ctx) !== 'cabinet') return undefined;
|
|
279
|
+
const member = membershipOf(ctx, agent);
|
|
280
|
+
if (member === undefined) return undefined;
|
|
281
|
+
if (member.role === 'lead') return 'lead';
|
|
282
|
+
if (member.role !== 'teammate') return undefined;
|
|
283
|
+
const key = bureauOf(member.name).key;
|
|
284
|
+
return key !== '' && key !== 'lead' ? key : undefined;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** Couple one live Cabinet route to one AgentLoop turn signal. */
|
|
288
|
+
function attachMemberModel(ctx, config, agent, attached, routeMemory = new Map()) {
|
|
289
|
+
if (!agent || typeof agent.ctx?.on !== 'function') return undefined;
|
|
290
|
+
if (agent.id !== undefined && attached.has(agent.id)) return undefined;
|
|
291
|
+
let active = true;
|
|
292
|
+
let controlledSignal;
|
|
293
|
+
const turns = new WeakMap();
|
|
294
|
+
let disposeNotice;
|
|
295
|
+
const sameRoute = (a, b) => !!a && !!b && a.provider === b.provider && a.model === b.model;
|
|
296
|
+
const keyFor = () => { try { return memberKeyOf(ctx, agent); } catch { return undefined; } };
|
|
297
|
+
const defaultRoute = () => {
|
|
298
|
+
const value = ctx.get('agentDefaultModel')?.currentSelection?.() ?? agent.options;
|
|
299
|
+
return value?.provider && value?.model ? { provider: value.provider, model: value.model, ...(value.reasoningEffort === undefined ? {} : { reasoningEffort: value.reasoningEffort }) } : undefined;
|
|
300
|
+
};
|
|
301
|
+
const disposeAssembly = agent.ctx.on('system-prompt/assemble', async (_assembly, context, next) => {
|
|
302
|
+
// Native setup may register its own prepended notice before this assembly.
|
|
303
|
+
// Install our final-route notice last, after all selection setup has run.
|
|
304
|
+
disposeNotice?.();
|
|
305
|
+
disposeNotice = installNotice();
|
|
306
|
+
const key = keyFor();
|
|
307
|
+
const route = key === undefined ? undefined : memberModel(config, key) ?? (key === 'lead' ? undefined : memberModel(config, 'lead')) ?? defaultRoute();
|
|
308
|
+
const signal = context?.signal;
|
|
309
|
+
// AgentLoop serializes steps within one turn. Reject ambiguous concurrent
|
|
310
|
+
// assemblies on that signal instead of sending a mismatched model/prompt.
|
|
311
|
+
if (signal && turns.get(signal)?.pending) throw new Error('Cabinet: overlapping prompt assembly for one turn');
|
|
312
|
+
const state = { key, route, pending: true };
|
|
313
|
+
if (signal) turns.set(signal, state);
|
|
314
|
+
try {
|
|
315
|
+
const assembled = await next();
|
|
316
|
+
if (!active) return assembled;
|
|
317
|
+
if (keyFor() !== key || signal?.aborted) throw new Error('Cabinet: membership or mode changed during prompt assembly');
|
|
318
|
+
const previous = routeMemory.get(agent.id);
|
|
319
|
+
if (key === undefined && previous && sameRoute(assembled.variables, previous.override)) state.route = previous.baseline;
|
|
320
|
+
if (key !== undefined && !state.route) throw new Error('Cabinet: no default model available to clear the member override');
|
|
321
|
+
state.pending = false;
|
|
322
|
+
if (signal) controlledSignal = state.route ? signal : undefined;
|
|
323
|
+
return state.route ? { ...assembled, variables: { ...assembled.variables, provider: state.route.provider, model: state.route.model } } : assembled;
|
|
324
|
+
} catch (error) { if (signal && turns.get(signal) === state) turns.delete(signal); throw error; }
|
|
325
|
+
}, { prepend: true });
|
|
326
|
+
const disposeRequest = agent.ctx.on('agent/request', async (payload, next) => {
|
|
327
|
+
const state = payload?.signal ? turns.get(payload.signal) : undefined;
|
|
328
|
+
const resolved = await next();
|
|
329
|
+
if (!active) {
|
|
330
|
+
if (state?.route) throw new Error('Cabinet: model policy unloaded during request');
|
|
331
|
+
return resolved;
|
|
332
|
+
}
|
|
333
|
+
if (!state || state.pending) {
|
|
334
|
+
const key = keyFor();
|
|
335
|
+
if (key !== undefined && (memberModel(config, key) || memberModel(config, 'lead'))) throw new Error('Cabinet: model request has no matching prompt assembly');
|
|
336
|
+
return resolved;
|
|
337
|
+
}
|
|
338
|
+
if (state.key !== keyFor() || payload.signal.aborted) throw new Error('Cabinet: membership or mode changed before request');
|
|
339
|
+
if (!state.route) return resolved;
|
|
340
|
+
if (state.key !== undefined) {
|
|
341
|
+
const previous = routeMemory.get(agent.id);
|
|
342
|
+
const baseline = previous && sameRoute(resolved, previous.override) ? previous.baseline : {
|
|
343
|
+
provider: resolved.provider, model: resolved.model,
|
|
344
|
+
...(resolved.reasoningEffort === undefined ? {} : { reasoningEffort: resolved.reasoningEffort })
|
|
345
|
+
};
|
|
346
|
+
routeMemory.set(agent.id, { baseline, override: state.route });
|
|
347
|
+
} else routeMemory.delete(agent.id);
|
|
348
|
+
// Preserve native effort on the same route; a different model must use
|
|
349
|
+
// its own adapter default rather than another model's effort identifier.
|
|
350
|
+
if (sameRoute(state.route, resolved)) return resolved;
|
|
351
|
+
const { reasoningEffort: _oldEffort, ...rest } = resolved;
|
|
352
|
+
return { ...rest, ...state.route };
|
|
353
|
+
}, { prepend: true });
|
|
354
|
+
const installNotice = () => agent.ctx.on('agent/pre-step', async (payload, next) => {
|
|
355
|
+
const decision = await next();
|
|
356
|
+
const state = payload.signal ? turns.get(payload.signal) : undefined;
|
|
357
|
+
if (!active || !state?.route || decision.kind === 'reject' || payload.signal.aborted) return decision;
|
|
358
|
+
if (state.key !== keyFor()) throw new Error('Cabinet: membership or mode changed before step');
|
|
359
|
+
// Replace the native selection's notice with the route actually assembled.
|
|
360
|
+
const messages = decision.messages.filter(message => message.source?.kind !== 'model-selection');
|
|
361
|
+
if (!messages.length && (payload.step === 1 || payload.messages.length)) return { ...decision, messages };
|
|
362
|
+
const previous = agent.session?.requestHeader?.()?.config;
|
|
363
|
+
if (!previous || sameRoute(previous, state.route)) return { ...decision, messages };
|
|
364
|
+
const from = previous.provider + '/' + previous.model;
|
|
365
|
+
const to = state.route.provider + '/' + state.route.model;
|
|
366
|
+
return { ...decision, messages: [...messages, {
|
|
367
|
+
id: randomUUID(), role: 'user',
|
|
368
|
+
content: [{ type: 'text', text: '[model changed: assistant turns above this point were generated by ' + from + '; the session continues with ' + to + ']' }],
|
|
369
|
+
source: { kind: 'model-selection', form: 'notice', summary: (from + ' → ' + to).slice(0, 200) }
|
|
370
|
+
}] };
|
|
371
|
+
}, { prepend: true });
|
|
372
|
+
const dispose = () => {
|
|
373
|
+
active = false;
|
|
374
|
+
// Removing hooks between assembly and request must not send the already
|
|
375
|
+
// rendered prompt through a different route. Preserve queued user input.
|
|
376
|
+
if (controlledSignal && !controlledSignal.aborted) agent.cancel?.({ kind: 'hook', reason: 'Cabinet model policy unloaded' }, { keepInbox: true });
|
|
377
|
+
try { disposeAssembly(); } catch { /* already disposed */ }
|
|
378
|
+
try { disposeRequest(); } catch { /* already disposed */ }
|
|
379
|
+
try { disposeNotice?.(); } catch { /* already disposed */ }
|
|
380
|
+
};
|
|
381
|
+
if (agent.id !== undefined) attached.set(agent.id, dispose);
|
|
382
|
+
return dispose;
|
|
383
|
+
}
|
|
384
|
+
|
|
232
385
|
/** Host plugin entry. */
|
|
233
386
|
const name = 'cabinet-ui';
|
|
234
387
|
/** Services read by this entry; `agentTeams` is resolved lazily in apply(). */
|
|
@@ -245,6 +398,39 @@ function apply(ctx, config) {
|
|
|
245
398
|
// User prompts are free text; never treat `{{...}}` in them as variables.
|
|
246
399
|
interpolate: false
|
|
247
400
|
}), 'cabinet-member: prompt section');
|
|
401
|
+
// Per-member model selection: attach the assemble/request waterfall to each
|
|
402
|
+
// Cabinet member agent as it is announced (and to agents already live when
|
|
403
|
+
// this plugin mounts), dispose it with the agent. Agents created before
|
|
404
|
+
// roster registration are resolved lazily at their first assembly.
|
|
405
|
+
const attached = new Map();
|
|
406
|
+
// Keep the pre-Cabinet route across same-session Agent recreation on mode switches.
|
|
407
|
+
const routeMemory = new Map();
|
|
408
|
+
const attach = (agent) => {
|
|
409
|
+
try {
|
|
410
|
+
attachMemberModel(ctx, config, agent, attached, routeMemory);
|
|
411
|
+
} catch (error) {
|
|
412
|
+
try { ctx.logger?.warn?.(`cabinet-ui: model selection attach failed: ${String(error)}`); } catch { /* logger unavailable */ }
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
ctx.effect(() => {
|
|
416
|
+
const offCreated = ctx.on('agent/created', ({ agent }) => attach(agent));
|
|
417
|
+
const offDisposed = ctx.on('agent/disposed', ({ agent }) => {
|
|
418
|
+
const dispose = agent === undefined || agent === null ? undefined : attached.get(agent.id);
|
|
419
|
+
if (dispose === undefined) return;
|
|
420
|
+
attached.delete(agent.id);
|
|
421
|
+
dispose();
|
|
422
|
+
});
|
|
423
|
+
try {
|
|
424
|
+
for (const agent of ctx.get('agents')?.list?.() ?? []) attach(agent);
|
|
425
|
+
} catch { /* registry unavailable: announce listener still covers new agents */ }
|
|
426
|
+
return () => {
|
|
427
|
+
try { offCreated?.(); } catch { /* already disposed */ }
|
|
428
|
+
try { offDisposed?.(); } catch { /* already disposed */ }
|
|
429
|
+
for (const dispose of Array.from(attached.values())) dispose();
|
|
430
|
+
attached.clear();
|
|
431
|
+
routeMemory.clear();
|
|
432
|
+
};
|
|
433
|
+
}, 'cabinet-member: model selection');
|
|
248
434
|
}
|
|
249
435
|
|
|
250
|
-
export { bureauOf, sectionText, memberBlock, Config, DEFAULT_LEAD_PROMPT, DEFAULT_MEMBER_PROMPTS, MEMBER_KEYS, MEMBER_LABELS, MEMBER_SECTION, MAX_AVATAR_LENGTH, MAX_NAME_LENGTH, MAX_PROMPT_LENGTH, apply, inject, name };
|
|
436
|
+
export { bureauOf, sectionText, memberBlock, memberModel, modelRoute, clampModel, attachMemberModel, Config, DEFAULT_LEAD_PROMPT, DEFAULT_MEMBER_PROMPTS, MEMBER_KEYS, MEMBER_LABELS, MEMBER_SECTION, MAX_AVATAR_LENGTH, MAX_MODEL_LENGTH, MAX_NAME_LENGTH, MAX_PROMPT_LENGTH, apply, inject, name };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cabinet-mode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Cabinet Mode (内阁模式) for DeepSeek Harness: a declarative DSH bundle that adds a dual-identity Lead/teammate agent preset for the Great Ming Research Bureau cabinet team.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"icon": "./icon.svg",
|
package/scripts/market-index.mjs
CHANGED
|
@@ -284,8 +284,8 @@ const index = {
|
|
|
284
284
|
name: MANIFEST.name,
|
|
285
285
|
title: { en: 'Cabinet Mode', zh: '内阁模式' },
|
|
286
286
|
description: {
|
|
287
|
-
en: 'Adds the “内阁模式” preset: one persona shared by the Lead and the bureau members (翰林院 / 工部 / 大理寺 / 都察院), research-first rules, and evidence-anchored reporting. Includes the Cabinet sidebar, member avatars and profile-wide settings; since 0.3.0 it uses @deepseek-ai/schemastery for its settings schema.',
|
|
288
|
-
zh: '新增「内阁模式」preset:首辅与阁臣(翰林院 / 工部 / 大理寺 / 都察院)共享同一段 persona
|
|
287
|
+
en: 'Adds the “内阁模式” preset: one persona shared by the Lead and the bureau members (翰林院 / 工部 / 大理寺 / 都察院), research-first rules, and evidence-anchored reporting. Includes the Cabinet sidebar, member avatars and profile-wide settings with per-office model selection; since 0.3.0 it uses @deepseek-ai/schemastery for its settings schema.',
|
|
288
|
+
zh: '新增「内阁模式」preset:首辅与阁臣(翰林院 / 工部 / 大理寺 / 都察院)共享同一段 persona,默认只调研不改码、结论必须锚定证据。包含内阁侧边栏、成员头像与支持各官职独立模型选择的 profile 共享设置;自 0.3.0 起使用 @deepseek-ai/schemastery 作为设置 schema 依赖。',
|
|
289
289
|
},
|
|
290
290
|
icon: './icon.svg',
|
|
291
291
|
author: MANIFEST.author,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
2
|
import {readFileSync} from 'node:fs';
|
|
3
3
|
import vm from 'node:vm';
|
|
4
|
-
import {sectionText, bureauOf, Config, DEFAULT_MEMBER_PROMPTS} from '../index.js';
|
|
4
|
+
import {sectionText, bureauOf, Config, DEFAULT_MEMBER_PROMPTS, memberModel, modelRoute, clampModel, MAX_MODEL_LENGTH, apply} from '../index.js';
|
|
5
5
|
let client;
|
|
6
6
|
const source=readFileSync(new URL('../client.js',import.meta.url),'utf8');
|
|
7
7
|
const sandbox = {
|
|
8
8
|
window:{__ModuleLoader__:{load:({factory})=>{client=factory(()=>({createElement(){}}));}}},
|
|
9
9
|
};
|
|
10
|
-
vm.runInNewContext(source.replace('return { inject, apply };','return { createMemberEditor, setMemberConfig, configuredPrompt, memberLabel, avatarFor, memberAvatarOf, BUREAUX, AVATARS };'),sandbox);
|
|
10
|
+
vm.runInNewContext(source.replace('return { inject, apply };','return { createMemberEditor, setMemberConfig, configuredPrompt, memberLabel, avatarFor, memberAvatarOf, clampMemberModel, modelOptionsOf, BUREAUX, AVATARS };'),sandbox);
|
|
11
11
|
function form(value, revision='1') {
|
|
12
12
|
let s={value,revision,writable:value!==undefined,status:value===undefined?'loading':'ready'}; const listeners=new Set();
|
|
13
13
|
const f={writes:[],getSnapshot:()=>s,subscribe:fn=>{listeners.add(fn);return()=>listeners.delete(fn);},
|
|
@@ -76,3 +76,52 @@ for(const action of ['cancel','reset','close','newer']) {
|
|
|
76
76
|
assert.equal(f.writes.length,0);
|
|
77
77
|
}
|
|
78
78
|
console.log('PASS async upload lifecycle: cancel, reset, unmount and newer choice reject stale decode results');
|
|
79
|
+
|
|
80
|
+
// ---- per-member model selection: schema clamp, waterfall injection, catalog ----
|
|
81
|
+
// Schema validation, four samples: valid route, missing slash, wrong type, over-long.
|
|
82
|
+
const modelSamples = [
|
|
83
|
+
{input:'prov-a/model-one', route:{provider:'prov-a',model:'model-one'}},
|
|
84
|
+
{input:'no-slash-here', route:undefined},
|
|
85
|
+
{input:12345, route:undefined},
|
|
86
|
+
{input:'p/'+'x'.repeat(300), route:undefined}
|
|
87
|
+
];
|
|
88
|
+
for (const sample of modelSamples) {
|
|
89
|
+
assert.equal(clampModel(sample.input), sample.route===undefined?'':sample.input, 'clamp '+JSON.stringify(sample.input));
|
|
90
|
+
assert.deepEqual(modelRoute(sample.input), sample.route, 'route '+JSON.stringify(sample.input));
|
|
91
|
+
}
|
|
92
|
+
assert.ok(MAX_MODEL_LENGTH>=200,'model bound exported');
|
|
93
|
+
assert.equal(memberModel({members:[{key:'works',model:'prov/m'}]},'works').provider,'prov','configured member resolves');
|
|
94
|
+
assert.equal(memberModel({members:[{key:'works',model:42}]},'works'),undefined,'corrupt stored value degrades to inherit');
|
|
95
|
+
|
|
96
|
+
// Real waterfall ordering/signal correlation is covered by test-model-selection.cjs.
|
|
97
|
+
|
|
98
|
+
// Settings half: adopt/save round trip and corrupt-value fallback.
|
|
99
|
+
const mf=form({members:[{key:'works',name:'',prompt:'',mode:'',model:'prov/ok'}]});
|
|
100
|
+
const me=client.createMemberEditor(mf,()=>{});me.connect();
|
|
101
|
+
assert.equal(me.state.draft.works.model,'prov/ok','adopt reads the stored model');
|
|
102
|
+
me.update('works',{model:'prov/other'});
|
|
103
|
+
assert.equal(await me.save(),true);
|
|
104
|
+
assert.equal(mf.getSnapshot().value.members.find(x=>x.key==='works').model,'prov/other','save persists the model');
|
|
105
|
+
assert.equal(client.clampMemberModel('bad value!'),'','browser clamp rejects corrupt input');
|
|
106
|
+
assert.equal(client.clampMemberModel('prov/m'),'prov/m','browser clamp keeps a valid route');
|
|
107
|
+
|
|
108
|
+
// Enumeration is data-driven: catalog -> options, and no hard-coded model ids.
|
|
109
|
+
assert.ok(!/(deepseek-v4|opencode-go|gpt-4o|claude-3-5)/.test(source),'client.js carries no hard-coded model id');
|
|
110
|
+
const opts=JSON.parse(JSON.stringify(client.modelOptionsOf({groups:[{id:'prov-a',models:[{id:'m1',name:'Model One'}]}]})));
|
|
111
|
+
assert.deepEqual(opts,[{value:'prov-a/m1',label:'prov-a/m1 — Model One'}],'catalog flattens to provider/id options');
|
|
112
|
+
assert.equal(client.modelOptionsOf(null).length,0,'no catalog yields no options (picker degrades to text)');
|
|
113
|
+
assert.equal(client.modelOptionsOf({groups:'bad'}).length,0,'malformed catalog yields no options');
|
|
114
|
+
console.log('PASS per-member model: schema clamp (4 samples), settings round trip, data-driven catalog');
|
|
115
|
+
|
|
116
|
+
for (const id of ['model+variant','@org/model','model normal','org/model',' trailing ']) {
|
|
117
|
+
const value='local/'+id;
|
|
118
|
+
assert.equal(clampModel(value),value);assert.equal(client.clampMemberModel(value),value);
|
|
119
|
+
assert.deepEqual(modelRoute(value),{provider:'local',model:id});
|
|
120
|
+
const options=client.modelOptionsOf({groups:[{id:'local',models:[{id}]}],failures:[{id:'broken'}]});
|
|
121
|
+
assert.equal(options[0].value,value);
|
|
122
|
+
me.update('works',{model:value});assert.equal(await me.save(),true);assert.equal(mf.getSnapshot().value.members.find(x=>x.key==='works').model,value);
|
|
123
|
+
}
|
|
124
|
+
me.update('works',{model:'not-a-route'});assert.equal(await me.save(),false);assert.equal(me.state.errors.works,'member.error.model');
|
|
125
|
+
me.cancel();assert.notEqual(me.state.draft.works.model,'not-a-route');
|
|
126
|
+
me.update('works',{model:''});assert.equal(await me.save(),true);assert.equal(mf.getSnapshot().value.members.find(x=>x.key==='works').model,'');
|
|
127
|
+
console.log('PASS opaque IDs round-trip, failed providers isolated, invalid route rejects Save, cancel and clear persist');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import {readFileSync} from 'node:fs';
|
|
3
|
+
import vm from 'node:vm';
|
|
4
|
+
let client, cursor=0, effects=[];
|
|
5
|
+
const hooks=[];
|
|
6
|
+
const React={
|
|
7
|
+
createElement:(type,props,...children)=>({type,props:props||{},children}),
|
|
8
|
+
useState(initial){const i=cursor++;hooks[i]??={value:initial};return[hooks[i].value,v=>{hooks[i].value=typeof v==='function'?v(hooks[i].value):v;}];},
|
|
9
|
+
useRef(initial){const i=cursor++;return(hooks[i]??={current:initial});},
|
|
10
|
+
useEffect(fn,deps){const i=cursor++,old=hooks[i];if(!old||deps.some((v,k)=>v!==old.deps[k])){const entry=hooks[i]={deps};effects.push(()=>{old?.cleanup?.();entry.cleanup=fn();});}}
|
|
11
|
+
};
|
|
12
|
+
let value={members:[{key:'lead',model:'old/kept'}]},revision='1';const listeners=new Set();
|
|
13
|
+
const form={getSnapshot:()=>({status:'ready',writable:true,value,revision}),subscribe:fn=>{listeners.add(fn);return()=>listeners.delete(fn);},async mutate(ops,expected){assert.equal(expected,revision);for(const op of ops)value[op.path[0]]=op.value;revision=String(+revision+1);for(const fn of listeners)fn();return true;}};
|
|
14
|
+
let response={ok:true,value:{groups:[]}},calls=0;
|
|
15
|
+
const remote={session:{modelCatalog:async()=>{calls++;return response;}}};
|
|
16
|
+
const source=readFileSync(new URL('../client.js',import.meta.url),'utf8');
|
|
17
|
+
vm.runInNewContext(source.replace('return { inject, apply };','return { CabinetMemberSettings, zh, en, setup(form,remote) { memberWriter=form; memberRemote=remote; } };'),{window:{__ModuleLoader__:{load:({factory})=>client=factory(()=>React)}}});
|
|
18
|
+
client.setup(form,remote);
|
|
19
|
+
let locale='en';
|
|
20
|
+
const render=()=>{cursor=0;return client.CabinetMemberSettings({t:key=>client[locale][key]??key});};
|
|
21
|
+
const settle=async()=>{let tree;for(let i=0;i<4;i++){tree=render();const jobs=effects;effects=[];for(const job of jobs)job();await new Promise(r=>setImmediate(r));}return tree;};
|
|
22
|
+
const nodes=tree=>{const all=[];function walk(n){if(!n||typeof n!=='object')return;if(Array.isArray(n)){n.forEach(walk);return;}all.push(n);n.children?.forEach(walk);}walk(tree);return all;};
|
|
23
|
+
const pickers=tree=>nodes(tree).filter(n=>n.props.key==='mi');
|
|
24
|
+
let tree=render();assert.ok(pickers(tree).every(n=>n.type==='input'&&n.props.disabled));
|
|
25
|
+
assert.equal(nodes(tree).filter(n=>n.props.key==='mh').length,0,'loading is not unavailable');
|
|
26
|
+
tree=await settle();assert.equal(pickers(tree).length,5);assert.ok(pickers(tree).every(n=>n.type==='input'&&!n.props.disabled));assert.equal(pickers(tree)[0].props.value,'old/kept');
|
|
27
|
+
assert.equal(nodes(tree).filter(n=>n.props.key==='mh').length,5,'completed empty catalog shows fallback hint');
|
|
28
|
+
async function refresh(next){response=next;nodes(tree).find(n=>n.props.key==='catalog').props.onClick();tree=await settle();}
|
|
29
|
+
await refresh({ok:true,value:{groups:[],failures:[{id:'offline'}]}});assert.ok(pickers(tree).every(n=>n.type==='input'));assert.equal(pickers(tree)[0].props.value,'old/kept');
|
|
30
|
+
await refresh({ok:true,value:{groups:[{id:'local',models:[{id:'model+variant'}]}]}});assert.ok(pickers(tree).every(n=>n.type==='select'));assert.equal(pickers(tree)[0].props.value,'old/kept');assert.ok(nodes(pickers(tree)[0]).some(n=>n.type==='option'&&n.props.value==='old/kept'));
|
|
31
|
+
await refresh({ok:false,error:{message:'offline'}});assert.ok(pickers(tree).every(n=>n.type==='input'));assert.equal(pickers(tree)[0].props.value,'old/kept');
|
|
32
|
+
pickers(tree)[0].props.onChange({target:{value:'manual/model+id'}});tree=await settle();await nodes(tree).find(n=>n.props.key==='save').props.onClick();tree=await settle();assert.equal(value.members[0].model,'manual/model+id');
|
|
33
|
+
await refresh({ok:true,value:{groups:[]}});assert.equal(pickers(tree)[0].props.value,'manual/model+id');assert.equal(calls,5);
|
|
34
|
+
pickers(tree)[0].props.onChange({target:{value:'invalid-route'}});tree=await settle();await nodes(tree).find(n=>n.props.key==='save').props.onClick();
|
|
35
|
+
for(locale of ['en','zh']) {
|
|
36
|
+
tree=await settle();const error=nodes(tree).find(n=>n.props.key==='e');
|
|
37
|
+
assert.equal(error.children[0],client[locale]['member.error.model']);
|
|
38
|
+
assert.notEqual(error.children[0],'member.error.model','display translated copy, not the key');
|
|
39
|
+
}
|
|
40
|
+
assert.equal(value.members[0].model,'manual/model+id','invalid Save does not overwrite persisted selection');
|
|
41
|
+
for(const hook of hooks)hook?.cleanup?.();
|
|
42
|
+
console.log('PASS model picker render: loading hint, empty/failure fallback, refresh, retained choices, manual Save and Chinese/English error translation');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import {attachMemberModel, apply} from '../index.js';
|
|
3
|
+
let preset='cabinet',member={role:'lead',name:'lead'},defaults={provider:'native',model:'default'};
|
|
4
|
+
const callbacks={};const agent={id:'test',ctx:{on:(name,fn)=>{callbacks[name]=fn;return()=>delete callbacks[name];}}};
|
|
5
|
+
const services={agentPresets:{composedPreset:()=>preset},agentTeams:{tryMembership:()=>member},agentDefaultModel:{currentSelection:()=>defaults}};
|
|
6
|
+
const config={members:[{key:'lead',model:'local/model+variant'},{key:'dali',model:'local/@org/model'}]};
|
|
7
|
+
const off=attachMemberModel({get:key=>services[key]},config,agent,new Map());
|
|
8
|
+
const route=async()=>{const signal=new AbortController().signal;const a=await callbacks['system-prompt/assemble']({}, {signal},async()=>({variables:{provider:'seed',model:'seed'}}));const r=await callbacks['agent/request']({signal},async()=>({provider:'seed',model:'seed',reasoningEffort:'high'}));return{a,r};};
|
|
9
|
+
assert.equal((await route()).r.model,'model+variant');
|
|
10
|
+
for(const name of ['dalisi-pingshi','dalisi.qing','大理寺评事','大理寺卿']){member={role:'teammate',name};assert.equal((await route()).r.model,'@org/model');}
|
|
11
|
+
for(const name of ['lead','dalisiX','x-dalisi']){member={role:'teammate',name};assert.equal((await route()).r.model,'seed');}
|
|
12
|
+
member={role:'lead',name:'lead'};preset='standard';assert.equal((await route()).r.model,'seed');
|
|
13
|
+
preset='cabinet';config.members=[];assert.deepEqual((await route()).r,defaults);
|
|
14
|
+
services.agentPresets=undefined;assert.equal((await route()).r.model,'seed');
|
|
15
|
+
off();assert.equal(Object.keys(callbacks).length,0);
|
|
16
|
+
const effects=[],events={};services.agents={list:()=>[agent]};
|
|
17
|
+
apply({get:key=>services[key],effect:fn=>effects.push(fn()),on:(name,fn)=>{events[name]=fn;return()=>delete events[name];},systemPrompt:{getSectionOrder:()=>0,section:()=>()=>{}}},config);
|
|
18
|
+
assert.equal(typeof callbacks['agent/request'],'function','backfill existing agents');
|
|
19
|
+
events['agent/disposed']({agent});assert.equal(Object.keys(callbacks).length,0);
|
|
20
|
+
events['agent/created']({agent});assert.equal(typeof callbacks['agent/request'],'function','attach before membership is available');
|
|
21
|
+
for(const effect of effects)effect?.();assert.equal(Object.keys(callbacks).length,0);assert.equal(Object.keys(events).length,0);
|
|
22
|
+
console.log('PASS routing: aliases, real role/preset gate, default restoration, missing service and disposal');
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const assert=require('node:assert/strict'),path=require('node:path');
|
|
2
|
+
const base=path.join(process.env.DSH_MODULE_ROOT,'@deepseek-ai')+'/';
|
|
3
|
+
const {Context}=require(base+'cordis'),{SystemPrompt}=require(base+'dsh-system-prompt');
|
|
4
|
+
const {createScope}=require(base+'dsh-scope'),{installModelSelection,agentEvents,assembleContextFor}=require(base+'dsh-agent');
|
|
5
|
+
const {attachMemberModel}=require('../index.js');
|
|
6
|
+
(async()=>{
|
|
7
|
+
let passed=0;
|
|
8
|
+
const {buildModelCatalog}=require(base+'dsh-api-session-controller');
|
|
9
|
+
const catalog=await buildModelCatalog({agentDefaultModel:{currentSelection:()=>({provider:'local',model:'model+variant'})},llm:{
|
|
10
|
+
listProviders:()=>[{id:'local',name:'Local'},{id:'broken',name:'Broken'}],
|
|
11
|
+
listModels:async id=>{if(id==='broken')throw Error('offline fixture');return ['model+variant','@org/model','model normal','org/model'].map(id=>({id,name:id}));},
|
|
12
|
+
resolveModelInfo:async(provider,id)=>({provider,id,name:id})
|
|
13
|
+
}});
|
|
14
|
+
assert.equal(catalog.groups.length,1);assert.equal(catalog.groups[0].models.length,4);assert.equal(catalog.failures.length,1);passed++;
|
|
15
|
+
|
|
16
|
+
for(const order of ['official-first','cabinet-first','no-official']){
|
|
17
|
+
const ctx=new Context();new SystemPrompt(ctx,{});
|
|
18
|
+
let preset='cabinet',member={role:'lead',name:'lead'},defaults={provider:'default',model:'model',reasoningEffort:'low'};
|
|
19
|
+
ctx.provide('agentPresets',{composedPreset:()=>preset});ctx.provide('agentTeams',{tryMembership:()=>member});ctx.provide('agentDefaultModel',{currentSelection:()=>defaults});
|
|
20
|
+
const cancellations=[];const agent={id:order,cancel:(cause,options)=>cancellations.push({cause,options}),session:{requestHeader:()=>({config:{provider:'old',model:'old'}})}};
|
|
21
|
+
const scope=createScope(ctx,agent);agent.ctx=scope.ctx;
|
|
22
|
+
const config={members:[{key:'lead',model:'cabinet/lead'},{key:'hanlin',model:'cabinet/member'}]};
|
|
23
|
+
const native={current:{provider:'official',model:'native',reasoningEffort:'high'}};
|
|
24
|
+
let off;const install=()=>installModelSelection(agent.ctx,native);
|
|
25
|
+
if(order==='official-first')install();off=attachMemberModel(ctx,config,agent,new Map());if(order==='cabinet-first')install();
|
|
26
|
+
const events=agentEvents(ctx,agent);
|
|
27
|
+
async function check(expected){const signal=new AbortController().signal;const assembly=await ctx.systemPrompt.assemble(assembleContextFor(agent,signal));const request=await events.waterfall('agent/request',{signal,turn:1,step:1},async()=>({provider:'seed',model:'seed',reasoningEffort:'high'}));assert.equal(assembly.variables.provider,expected.provider);assert.equal(assembly.variables.model,expected.model);assert.deepEqual(request,expected);passed++;return{signal,assembly};}
|
|
28
|
+
const initial=await check({provider:'cabinet',model:'lead'});
|
|
29
|
+
{
|
|
30
|
+
const decision=await events.waterfall('agent/pre-step',{signal:initial.signal,step:2,messages:[]},async()=>({kind:'enter',messages:[]}));
|
|
31
|
+
assert.equal(decision.messages.length,1);assert.match(decision.messages[0].content[0].text,/cabinet\/lead/);assert.doesNotMatch(decision.messages[0].content[0].text,/official\/native/);passed++;
|
|
32
|
+
}
|
|
33
|
+
if(order!=='no-official') {
|
|
34
|
+
const saved=native.current;native.current={provider:'cabinet',model:'lead'};preset='standard';
|
|
35
|
+
await check(saved);native.current=saved; preset='cabinet';await check({provider:'cabinet',model:'lead'});
|
|
36
|
+
}
|
|
37
|
+
preset='standard';if(order==='no-official'){const signal=new AbortController().signal;const assembly=await ctx.systemPrompt.assemble(assembleContextFor(agent,signal));assert.notEqual(assembly.variables.model,'lead');assert.deepEqual(await events.waterfall('agent/request',{signal},async()=>({provider:'seed',model:'seed'})),{provider:'seed',model:'seed'});passed++;}else await check(native.current);
|
|
38
|
+
preset='cabinet';member={role:'teammate',name:'lead'};if(order!=='no-official')await check(native.current);
|
|
39
|
+
member={role:'teammate',name:'hanlin-bianxiu'};await check({provider:'cabinet',model:'member'});
|
|
40
|
+
config.members=[{key:'lead',model:'cabinet/lead'}];await check({provider:'cabinet',model:'lead'});
|
|
41
|
+
config.members=[];await check(defaults);
|
|
42
|
+
if(order!=='no-official') {
|
|
43
|
+
defaults={...native.current,reasoningEffort:'low'};
|
|
44
|
+
await check(native.current); // Same route keeps native high, not deployment low.
|
|
45
|
+
}
|
|
46
|
+
defaults={provider:'new-default',model:'next'};await check(defaults);
|
|
47
|
+
config.members=[{key:'hanlin',model:'official/native'}];if(order!=='no-official')await check(native.current);
|
|
48
|
+
// Different turns and signal-free previews never overwrite each other's snapshot.
|
|
49
|
+
config.members=[{key:'hanlin',model:'p/A'}];let release,entered;const ready=new Promise(r=>entered=r);
|
|
50
|
+
const a=new AbortController().signal,b=new AbortController().signal;
|
|
51
|
+
const unblock=agent.ctx.on('system-prompt/assemble',async(_,c,next)=>{if(c.signal===a){entered();await new Promise(r=>release=r);}return next();});
|
|
52
|
+
const first=ctx.systemPrompt.assemble(assembleContextFor(agent,a));await ready;
|
|
53
|
+
config.members=[{key:'hanlin',model:'p/B'}];await ctx.systemPrompt.assemble(assembleContextFor(agent,b));
|
|
54
|
+
config.members=[{key:'hanlin',model:'p/preview'}];await ctx.systemPrompt.assemble(assembleContextFor(agent));release();
|
|
55
|
+
assert.equal((await first).variables.model,'A');
|
|
56
|
+
for(const [signal,model]of [[a,'A'],[b,'B']])assert.equal((await events.waterfall('agent/request',{signal},async()=>({provider:'x',model:'x'}))).model,model);
|
|
57
|
+
unblock();passed++;
|
|
58
|
+
preset='standard';await assert.rejects(events.waterfall('agent/request',{signal:a},async()=>({provider:'x',model:'x'})),/mode changed/);passed++;
|
|
59
|
+
preset='cabinet';
|
|
60
|
+
const live=new AbortController();
|
|
61
|
+
agent.cancel=(cause,options)=>{cancellations.push({cause,options});live.abort(cause);};
|
|
62
|
+
config.members=[{key:'hanlin',model:'p/override'}];
|
|
63
|
+
assert.equal((await ctx.systemPrompt.assemble(assembleContextFor(agent,live.signal))).variables.model,'override');
|
|
64
|
+
await ctx.systemPrompt.assemble(assembleContextFor(agent)); // Preview AFTER live assembly.
|
|
65
|
+
off();assert.equal(cancellations.length,1);assert.equal(cancellations[0].cause.kind,'hook');assert.equal(cancellations[0].options.keepInbox,true);
|
|
66
|
+
assert.equal(live.signal.aborted,true,'AgentLoop must abort before sending a differently routed request');
|
|
67
|
+
passed++;
|
|
68
|
+
await scope.dispose();
|
|
69
|
+
}
|
|
70
|
+
console.log('PASS '+passed+' official Cordis/SystemPrompt/installModelSelection combinations; identity/default services stubbed, no model calls');
|
|
71
|
+
})().catch(e=>{console.error(e);process.exitCode=1;});
|
package/scripts/verify.mjs
CHANGED
|
@@ -369,7 +369,7 @@ if (existsSync(PATCH_PATH)) {
|
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
// ---------- fallback scripts ----------
|
|
372
|
-
for (const test of ['test-member-settings.mjs', 'test-install.mjs', 'test-client.mjs', 'test-avatars.mjs', 'test-roster.mjs']) {
|
|
372
|
+
for (const test of ['test-member-settings.mjs', 'test-model-routing.mjs', 'test-model-picker.mjs', 'test-install.mjs', 'test-client.mjs', 'test-avatars.mjs', 'test-roster.mjs']) {
|
|
373
373
|
const result = spawnSync(process.execPath, [join(ROOT, 'scripts', test)], {
|
|
374
374
|
encoding: 'utf8', timeout: 30000, windowsHide: true,
|
|
375
375
|
});
|