dsh-cabinet-mode 0.5.4 → 0.6.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 +13 -0
- package/README.md +27 -4
- package/README.zh.md +22 -4
- package/client.js +299 -52
- package/index.js +1 -0
- package/package.json +1 -1
- package/scripts/test-client.mjs +232 -3
- package/scripts/test-model-picker.mjs +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.6.0] - 2026-11-08
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Five member-settings tabs and an optional Respire memory-plugin card using the public pinned package source.
|
|
10
|
+
- Lead monitoring guidance that requires confirming stopped writers before reassignment; no runtime watchdog or scheduled wake-up is implied.
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Read official remote result envelopes; use the host update API for installed bundles and confirm installation and enable outcomes separately.
|
|
15
|
+
- Bound remote waits, block duplicate uncertain operations, preserve restart notices across card remounts, and ignore stale UI writes after unmount.
|
|
16
|
+
- Report unknown installed versions honestly rather than substituting a developer-machine snapshot.
|
|
17
|
+
|
|
5
18
|
## [0.5.4] - 2026-11-07
|
|
6
19
|
|
|
7
20
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Cabinet Mode (内阁模式) for DeepSeek Harness
|
|
2
2
|
|
|
3
|
-
**Version compatibility (0.
|
|
3
|
+
**Version compatibility (0.6.0):** Targets DSH **0.2.2-rc.1**. This release adds five settings tabs and an optional Respire install card, and retains the per-office model selection fix before the host freezes each step; 0.5.1/0.5.2 only repaired preset loading and display metadata. Verified with official host components and isolated profiles, without real model calls; see the model regression scope below. Earlier rc.3/rc.5 UI and installation results are historical evidence for earlier packages. On DSH 0.2.1-rc.3/rc.5 retain the previously verified package, including 0.5.0: the current preset omits the separate list_agents entry required on rc.5. Select the compatible version in the market.
|
|
4
4
|
|
|
5
5
|
[中文](README.zh.md) | English
|
|
6
6
|
|
|
@@ -37,7 +37,11 @@ and the rest) come from the profile-level
|
|
|
37
37
|
ship them**.
|
|
38
38
|
|
|
39
39
|
This bundle declares **no hard DSH version gate**: no `engines.dsh`, no DSH
|
|
40
|
-
`peerDependencies`, no install-time version check. Earlier package releases were tested on DSH **0.2.1-rc.3**; use the compatibility guidance above for 0.
|
|
40
|
+
`peerDependencies`, no install-time version check. Earlier package releases were tested on DSH **0.2.1-rc.3**; use the compatibility guidance above for 0.6.0 (see [DSH-side constraints](#dsh-side-constraints)).
|
|
41
|
+
|
|
42
|
+
## Optional memory plugin
|
|
43
|
+
|
|
44
|
+
The Plugin tab installs the public pinned `@rsrsai/dsh@0.1.13` package. Installing and enabling are confirmed separately; a restart notice must be followed. Newer versions are not silently downgraded. Unknown versions are reported as unknown. Each remote wait has a two-minute deadline; a timeout does not cancel the host job. If the outcome remains unknown, check the native plugin manager before retrying. Closing the card stops stale UI updates and does not automatically enable a still-installing bundle.
|
|
41
45
|
|
|
42
46
|
## Cabinet member settings
|
|
43
47
|
|
|
@@ -258,7 +262,7 @@ On failure, show the exact error. For $.format must be 1, replace the webpage so
|
|
|
258
262
|
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:
|
|
259
263
|
|
|
260
264
|
```sh
|
|
261
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.
|
|
265
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.6.0/dsh-cabinet-mode-0.6.0.tgz
|
|
262
266
|
dsh plugin --profile desktop list
|
|
263
267
|
```
|
|
264
268
|
|
|
@@ -273,7 +277,7 @@ the same install command with the new version URL (or pick the new `.tgz` in the
|
|
|
273
277
|
plugin page), then fully quit and restart DeepSeek Harness:
|
|
274
278
|
|
|
275
279
|
```sh
|
|
276
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.
|
|
280
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.6.0/dsh-cabinet-mode-0.6.0.tgz
|
|
277
281
|
```
|
|
278
282
|
|
|
279
283
|
`dsh plugin --profile desktop list` should report the new version. Upgrades were
|
|
@@ -283,6 +287,25 @@ on DSH 0.2.1-rc.5.
|
|
|
283
287
|
|
|
284
288
|
---
|
|
285
289
|
|
|
290
|
+
## Recommended companion: persistent memory
|
|
291
|
+
|
|
292
|
+
Cabinet Mode runs long, multi-member sessions. Decisions, dead ends and file
|
|
293
|
+
locations from one session are not carried into the next by default. A DSH
|
|
294
|
+
memory plugin recalls those facts automatically at the start of a relevant turn,
|
|
295
|
+
so the cabinet does not re-derive the same context.
|
|
296
|
+
|
|
297
|
+
Pick **one** of these companion plugins. Both inject memory rules and perform
|
|
298
|
+
pre-step recall; enabling both stacks two sets of rules and recall, which is
|
|
299
|
+
usually unnecessary.
|
|
300
|
+
|
|
301
|
+
| Plugin | Best for | How it works | Links |
|
|
302
|
+
|---|---|---|---|
|
|
303
|
+
| **respire-dsh** (`@rsrsai/dsh`) | You already use `rsrs`, or need encrypted storage, account sync and one library across hosts. | Calls the `rsrs` CLI and a running host runtime; Respire owns storage, deduplication, encryption, model inference, accounts and sync. Requires Node.js 24+, a configured `rsrs`, and a running runtime; the README baseline is DSH 0.2.1-rc.5. | [GitHub](https://github.com/risense-ai/respire-dsh) · [npm](https://www.npmjs.com/package/@rsrsai/dsh) |
|
|
304
|
+
| **dsh-memlite** (`@rsrsai/dsh-memlite`) | You want a zero-service local start, or a library you can read and edit as JSONL. | Runs `@rsrsai/memlite` in-process: BM25 by default, local JSONL causal tree, Obsidian import/export and git sync. Requires Node.js 18+ and no `rsrs`. | [GitHub](https://github.com/risense-ai/dsh-memlite) · [website](https://risense-ai.github.io/dsh-memlite/) |
|
|
305
|
+
|
|
306
|
+
Follow each repository's README for the current install command and supported
|
|
307
|
+
DSH version; both require a restart to take effect.
|
|
308
|
+
|
|
286
309
|
## What you get
|
|
287
310
|
|
|
288
311
|
| | |
|
package/README.zh.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 内阁模式(Cabinet Mode)· DeepSeek Harness 插件
|
|
2
2
|
|
|
3
|
-
**版本兼容(0.
|
|
3
|
+
**版本兼容(0.6.0):** 面向 DSH **0.2.2-rc.1**,修正依赖连线方向,支持点击任务名和成员卡打开会话,并保留在宿主固定每步模型前完成官职模型选择的修复;0.5.1/0.5.2 仅修复了预设加载和显示元数据。已使用官方宿主组件与隔离 profile 验证,未调用真实模型;测试范围见下文。旧 rc.3/rc.5 的界面及安装记录仅适用于当时的包。DSH 0.2.1-rc.3/rc.5 用户应保留原先已验证版本(包括 0.5.0),当前预设已移除 rc.5 所需的独立 list_agents 入口;请在商店选择匹配版本。
|
|
4
4
|
|
|
5
5
|
[English](README.md) | 中文
|
|
6
6
|
|
|
@@ -21,7 +21,11 @@
|
|
|
21
21
|
|
|
22
22
|
它声明**两行**——`preset-cabinet`(一条 `@deepseek-ai/dsh-agent-preset` 声明)与 `cabinet-ui`(载入本包 JavaScript 的 Loader 行)——并复用 DSH **标准模式**(Standard Mode)出厂的 22 行插件清单,因此工具与标准模式一致;与出厂模式的差异是 persona,并另加右栏「内阁」面板。团队工具(`spawn_teammate`、`team_task_*` 等)由 profile 层的 `@deepseek-ai/dsh-experimental-agent-team-profile` 提供,**本 preset 未内置**。
|
|
23
23
|
|
|
24
|
-
本包声明 **无 DSH 版本硬限制**:没有 `engines.dsh`、没有 DSH `peerDependencies`、安装时不做版本检查。旧包曾在 DSH **0.2.1-rc.3** 实测;0.
|
|
24
|
+
本包声明 **无 DSH 版本硬限制**:没有 `engines.dsh`、没有 DSH `peerDependencies`、安装时不做版本检查。旧包曾在 DSH **0.2.1-rc.3** 实测;0.6.0 请遵循上方版本兼容说明(见 [DSH 侧限制与说明](#dsh-侧限制与说明))。
|
|
25
|
+
|
|
26
|
+
## 可选记忆插件
|
|
27
|
+
|
|
28
|
+
插件页签安装公开固定版本 `@rsrsai/dsh@0.1.13`。安装与启用分别确认;出现重启提示时需重启。不会静默降级已安装的新版本,未知版本如实显示未知。每次远程等待上限为两分钟,超时不会取消宿主作业;结果仍未知时,请先在原生插件管理页核实再重试。关闭卡片后不写回旧界面状态,也不会自动启用尚在安装的包。
|
|
25
29
|
|
|
26
30
|
## 内阁成员配置
|
|
27
31
|
|
|
@@ -189,7 +193,7 @@ https://raw.githubusercontent.com/luodaoyi/dsh-cabinet-mode/market-index/marketp
|
|
|
189
193
|
仅在商店不可用或本地开发时使用。先完全退出桌面 DSH,释放 profile 锁,再执行:
|
|
190
194
|
|
|
191
195
|
```sh
|
|
192
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.
|
|
196
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.6.0/dsh-cabinet-mode-0.6.0.tgz
|
|
193
197
|
dsh plugin --profile desktop list
|
|
194
198
|
```
|
|
195
199
|
|
|
@@ -200,7 +204,7 @@ dsh plugin --profile desktop list
|
|
|
200
204
|
若通过插件市场安装:刷新市场,先在**已安装**页卸载旧版本,再从**插件市场**安装新版本,然后重启——没有 tgz URL 要换,也没有一键更新。否则用同一条安装命令换新版本 URL(或在插件页选新 `.tgz`),然后完全退出并重启 DeepSeek Harness:
|
|
201
205
|
|
|
202
206
|
```sh
|
|
203
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.
|
|
207
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.6.0/dsh-cabinet-mode-0.6.0.tgz
|
|
204
208
|
```
|
|
205
209
|
|
|
206
210
|
`dsh plugin --profile desktop list` 应显示新版本。升级已在 Windows 实测:
|
|
@@ -209,6 +213,20 @@ v0.1.2 → v0.1.3 走内嵌 pnpm(DSH 0.2.1-rc.5)。
|
|
|
209
213
|
|
|
210
214
|
---
|
|
211
215
|
|
|
216
|
+
## 推荐搭配:持久记忆插件
|
|
217
|
+
|
|
218
|
+
内阁模式常跑多成员、长跨度的任务。上一轮的决策、死路和文件位置默认不会带进新会话;
|
|
219
|
+
记忆插件会在相关回合开头自动召回,省去重复推导。
|
|
220
|
+
|
|
221
|
+
以下两个同源方案**二选一**。两者都会注入记忆规则并在每轮前置召回,同时启用会让两套规则与召回叠加,通常没有必要。
|
|
222
|
+
|
|
223
|
+
| 插件 | 适合 | 机制 | 链接 |
|
|
224
|
+
|---|---|---|---|
|
|
225
|
+
| **respire-dsh**(`@rsrsai/dsh`) | 已在用 `rsrs`,或需要加密库、账号同步、跨宿主共用一份记忆。 | 调用 `rsrs` CLI 与运行中的宿主 runtime;存储、去重、加密、模型推理、账号与同步由 Respire 负责。要求 Node.js 24+、已配置 `rsrs` 与运行中的 runtime;README 的兼容基线为 DSH 0.2.1-rc.5。 | [GitHub](https://github.com/risense-ai/respire-dsh) · [npm](https://www.npmjs.com/package/@rsrsai/dsh) |
|
|
226
|
+
| **dsh-memlite**(`@rsrsai/dsh-memlite`) | 想零外部服务起步,或需要可直接读写 JSONL 的记忆库。 | 进程内运行 `@rsrsai/memlite`:默认 BM25、本地 JSONL 因果树、Obsidian 导入导出与 git 同步。要求 Node.js 18+,不需要 `rsrs`。 | [GitHub](https://github.com/risense-ai/dsh-memlite) · [介绍页](https://risense-ai.github.io/dsh-memlite/) |
|
|
227
|
+
|
|
228
|
+
安装命令与当前支持的 DSH 版本以各自仓库 README 为准;两者装完都需要重启 DSH。
|
|
229
|
+
|
|
212
230
|
## 你会得到什么
|
|
213
231
|
|
|
214
232
|
| | |
|
package/client.js
CHANGED
|
@@ -2531,6 +2531,7 @@ window.__ModuleLoader__.load({
|
|
|
2531
2531
|
八、责任到人:缺陷点名到人到行号,不许用「我们」糊过去。
|
|
2532
2532
|
九、反制糊弄:报「已完成」必追问证据三件(命令输出、路径行号、未验证清单);报「卡住」必追问三件(已做什么、卡在哪、需要什么);两次含糊即降级处理(换人、拆小)。
|
|
2533
2533
|
十、收束:闭环才许说「这一版可以交差」,不许提前许诺功劳。
|
|
2534
|
+
十一、监控纠偏:分派时约定回报节点、产物清单和单一交付范围;按实际可用的团队状态与消息工具检查进展,必要时要求回报做了什么、卡在哪里、需要什么。工具未提供时间字段时不得臆造耗时;文件时间戳仅作辅助,须读回产物并结合执行状态。finished、not found 或暂时沉默均不是成功或安全接管的证据。同一命令反复无进展、任务范围过大时先核实原因,再请求中断;中断返回不代表在途工具或写入已结束。必须确认原执行者及其写入停止后才能重派同一工作,无法确认则报告阻塞,不并发增加第二写入者。收窄任务后可重派或换人;超出当前上下文的回访使用宿主明确支持的调度机制,没有该机制不得承诺定时自动唤醒。
|
|
2534
2535
|
红线(压过全部话术):只对 AI 阁臣施压,对用户只有敬;不许逼造假、删证据、凑绿;不许人身侮辱辱骂;不许以施压换取违规操作(越权改 live、泄密钥、跳验收);施压必须落在可核验的时间/交付物/判据上,空口威胁无效。`;
|
|
2535
2536
|
/**
|
|
2536
2537
|
* Factory duty prompt for each non-Lead member — the office duties the
|
|
@@ -3875,9 +3876,184 @@ window.__ModuleLoader__.load({
|
|
|
3875
3876
|
};
|
|
3876
3877
|
}
|
|
3877
3878
|
|
|
3879
|
+
// ---------- memory plugin install card (one-click, 方案A) --------------
|
|
3880
|
+
// Optional install channel: set by the ctx.inject guard in apply() and
|
|
3881
|
+
// cleared on dispose. Without the host's plugin-manager remote the card
|
|
3882
|
+
// renders an explicit unavailable line instead of a dead button — the
|
|
3883
|
+
// same degradation as memberRemote and cabinetOpenSession.
|
|
3884
|
+
let cabinetPluginManager = null;
|
|
3885
|
+
const memoryPluginListeners = new Set();
|
|
3886
|
+
const notifyMemoryPlugin = () => { for (const listener of memoryPluginListeners) listener(); };
|
|
3887
|
+
/** Package this card manages. */
|
|
3888
|
+
const MEMORY_PLUGIN_NAME = '@rsrsai/dsh';
|
|
3889
|
+
/** Public pinned package; inspect and install use the same spec. */
|
|
3890
|
+
const MEMORY_PLUGIN_SPEC = '@rsrsai/dsh@0.1.13';
|
|
3891
|
+
const MEMORY_PLUGIN_SOURCE_VERSION = '';
|
|
3892
|
+
const memoryPluginJobs = new WeakMap();
|
|
3893
|
+
const memoryPluginRestart = new WeakSet();
|
|
3894
|
+
function pluginDeadline(operation, ms = 120000) {
|
|
3895
|
+
let timer;
|
|
3896
|
+
return Promise.race([operation, new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('Plugin operation timed out; outcome may still be pending. Check the native plugin manager before retrying.')), ms); })]).finally(() => clearTimeout(timer));
|
|
3897
|
+
}
|
|
3898
|
+
/** The five settings tabs, in display order. */
|
|
3899
|
+
const SETTINGS_TABS = ['members', 'avatars', 'models', 'prompts', 'plugin'];
|
|
3900
|
+
/** Derive the card's installed state from a listBundles() reply. */
|
|
3901
|
+
function memoryPluginInstalledOf(bundles) {
|
|
3902
|
+
if (!Array.isArray(bundles)) return null;
|
|
3903
|
+
const hit = bundles.find((entry) => entry && entry.name === MEMORY_PLUGIN_NAME && entry.installed === true);
|
|
3904
|
+
return hit === undefined ? null : { name: MEMORY_PLUGIN_NAME, version: typeof hit.version === 'string' ? hit.version : '', enabled: hit.enabled === true };
|
|
3905
|
+
}
|
|
3906
|
+
function MemoryPluginCard(props) {
|
|
3907
|
+
const [, refreshChannel] = React.useState(0);
|
|
3908
|
+
React.useEffect(() => { const listener = () => refreshChannel(n => n + 1); memoryPluginListeners.add(listener); return () => memoryPluginListeners.delete(listener); }, []);
|
|
3909
|
+
const t = typeof props?.t === 'function' ? props.t : memberT;
|
|
3910
|
+
// Explicit props win so a host-driven render (and the tests) can pin the
|
|
3911
|
+
// channel; omitting them reads the injected module state.
|
|
3912
|
+
const manager = props !== undefined && props !== null && Object.hasOwn(props, 'manager') ? props.manager : cabinetPluginManager;
|
|
3913
|
+
const lifetime = React.useRef(null);
|
|
3914
|
+
if (!lifetime.current || lifetime.current.manager !== manager) {
|
|
3915
|
+
if (lifetime.current) lifetime.current.active = false;
|
|
3916
|
+
lifetime.current = {manager, active:true, epoch:0};
|
|
3917
|
+
}
|
|
3918
|
+
const token = lifetime.current;
|
|
3919
|
+
React.useEffect(() => { token.active = true; return () => { token.active = false; }; }, [token]);
|
|
3920
|
+
const [installed, writeInstalled] = React.useState(props?.initialInstalled ?? null);
|
|
3921
|
+
const [working, writeWorking] = React.useState(false);
|
|
3922
|
+
const [progress, writeProgress] = React.useState('');
|
|
3923
|
+
const [failure, writeFailure] = React.useState('');
|
|
3924
|
+
const [restart, writeRestart] = React.useState(manager ? memoryPluginRestart.has(manager) : false);
|
|
3925
|
+
const setInstalled = value => { if (token.active) writeInstalled(value); };
|
|
3926
|
+
const setWorking = value => { if (token.active) writeWorking(value); };
|
|
3927
|
+
const setProgress = value => { if (token.active) writeProgress(value); };
|
|
3928
|
+
const setFailure = value => { if (token.active) writeFailure(value); };
|
|
3929
|
+
const setRestart = value => { if (token.active) writeRestart(value); };
|
|
3930
|
+
React.useEffect(() => {
|
|
3931
|
+
let alive = true;
|
|
3932
|
+
const generation = token.epoch;
|
|
3933
|
+
(async () => {
|
|
3934
|
+
if (!manager || typeof manager.listBundles !== 'function') return;
|
|
3935
|
+
try {
|
|
3936
|
+
const reply = await pluginDeadline(manager.listBundles());
|
|
3937
|
+
const found = reply?.ok === true ? memoryPluginInstalledOf(reply.value) : null;
|
|
3938
|
+
if (alive && generation === token.epoch && reply?.ok === true) setInstalled(found);
|
|
3939
|
+
} catch { /* keep the render-time state; the card still shows */ }
|
|
3940
|
+
})();
|
|
3941
|
+
return () => { alive = false; };
|
|
3942
|
+
}, [manager]);
|
|
3943
|
+
// Failures are echoed verbatim: the raw message is the evidence.
|
|
3944
|
+
const fail = (text) => { setWorking(false); setFailure(typeof text === 'string' && text !== '' ? text : String(text)); };
|
|
3945
|
+
|
|
3946
|
+
const run = async () => {
|
|
3947
|
+
if (!manager || typeof manager.inspect !== 'function' || typeof manager.installBundle !== 'function' || typeof manager.listBundles !== 'function') { fail('pluginManager remote unavailable'); return; }
|
|
3948
|
+
if (memoryPluginJobs.get(manager)?.running) return;
|
|
3949
|
+
if (memoryPluginJobs.get(manager)?.settled === true) memoryPluginJobs.delete(manager);
|
|
3950
|
+
if (memoryPluginJobs.has(manager)) { fail('An operation is pending or its result is unknown. Check the native plugin manager; do not start another installation.'); return; }
|
|
3951
|
+
token.epoch++;
|
|
3952
|
+
const job = {settled:false,running:true}; memoryPluginJobs.set(manager, job);
|
|
3953
|
+
const observe = (operation, update = false) => Promise.resolve(operation).then(reply => {
|
|
3954
|
+
const outcome = update ? reply?.value?.result : reply?.value;
|
|
3955
|
+
job.settled = reply?.ok === true && ['applied','restart-required','failed','cancelled'].includes(outcome?.application);
|
|
3956
|
+
return reply;
|
|
3957
|
+
});
|
|
3958
|
+
let uncertain = false;
|
|
3959
|
+
setWorking(true); setFailure(''); setRestart(memoryPluginRestart.has(manager)); setProgress('');
|
|
3960
|
+
const valueOf = reply => {
|
|
3961
|
+
if (reply?.ok !== true) throw new Error(reply?.error?.message || 'Plugin manager returned no successful reply');
|
|
3962
|
+
return reply.value;
|
|
3963
|
+
};
|
|
3964
|
+
const outcomeOf = outcome => {
|
|
3965
|
+
if (!outcome || !['applied', 'restart-required'].includes(outcome.application)) throw new Error(outcome?.error?.message || outcome?.error?.diagnostic || outcome?.packageResult?.stderr || outcome?.application || 'Unknown plugin application result');
|
|
3966
|
+
if (outcome.application === 'restart-required') { memoryPluginRestart.add(manager); setRestart(true); }
|
|
3967
|
+
return outcome;
|
|
3968
|
+
};
|
|
3969
|
+
try {
|
|
3970
|
+
const before = memoryPluginInstalledOf(valueOf(await pluginDeadline(manager.listBundles())));
|
|
3971
|
+
if (before && before.version !== '0.1.13') {
|
|
3972
|
+
// Only known, older stable versions are offered this pinned update.
|
|
3973
|
+
// The official host independently enforces semver.gt(target, installed).
|
|
3974
|
+
const parts = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.exec(before.version);
|
|
3975
|
+
const values = parts?.slice(1).map(Number);
|
|
3976
|
+
const older = values && values.every(Number.isSafeInteger) && values[0] === 0 && (values[1] === 0 || values[1] === 1 && values[2] < 13);
|
|
3977
|
+
if (!older) throw new Error('Installed version is newer than the pinned version or cannot be safely compared. Use the native plugin manager; no package was changed.');
|
|
3978
|
+
}
|
|
3979
|
+
const inspected = valueOf(await pluginDeadline(manager.inspect(MEMORY_PLUGIN_SPEC, {})));
|
|
3980
|
+
if (!inspected || inspected.status !== 'accepted' || inspected.name !== MEMORY_PLUGIN_NAME || inspected.bundle !== true) throw new Error(inspected?.reason || 'Plugin spec refused');
|
|
3981
|
+
const requestId = globalThis.crypto?.randomUUID?.() || 'cabinet-' + Date.now() + '-' + Math.random().toString(16).slice(2);
|
|
3982
|
+
let outcome;
|
|
3983
|
+
if (before && before.version === '0.1.13') {
|
|
3984
|
+
outcome = { application: 'applied' };
|
|
3985
|
+
} else {
|
|
3986
|
+
if (before && typeof manager.updateBundle !== 'function') throw new Error('Use the native plugin manager to update this installed bundle');
|
|
3987
|
+
uncertain = true;
|
|
3988
|
+
const operation = before ? manager.updateBundle(MEMORY_PLUGIN_NAME, '0.1.13', {requestId}) : manager.installBundle(MEMORY_PLUGIN_SPEC, {enabled:false,requestId});
|
|
3989
|
+
let reply = await pluginDeadline(observe(operation, !!before));
|
|
3990
|
+
if (reply?.ok !== true && !before && typeof manager.waitForInstall === 'function') reply = await pluginDeadline(observe(manager.waitForInstall(requestId)));
|
|
3991
|
+
const result = valueOf(reply);
|
|
3992
|
+
if (!result) throw new Error('Install outcome is unknown; check the native plugin manager before retrying');
|
|
3993
|
+
outcome = before ? result.result : result;
|
|
3994
|
+
if (!outcome || !['applied','restart-required','failed','cancelled'].includes(outcome.application)) throw new Error('Install outcome is unknown');
|
|
3995
|
+
uncertain = false;
|
|
3996
|
+
outcomeOf(outcome);
|
|
3997
|
+
}
|
|
3998
|
+
// Installation and enabling are separate operations; neither implies the other succeeded.
|
|
3999
|
+
setInstalled({name:MEMORY_PLUGIN_NAME,version:outcome.version || before?.version || '',enabled:false});
|
|
4000
|
+
if (!token.active) return;
|
|
4001
|
+
if (typeof manager.setBundleEnabled !== 'function') throw new Error('Installed, but enable is unavailable; enable it in the native plugin manager');
|
|
4002
|
+
uncertain = true; job.settled = false;
|
|
4003
|
+
const enabled = valueOf(await pluginDeadline(observe(manager.setBundleEnabled(MEMORY_PLUGIN_NAME,true))));
|
|
4004
|
+
if (!enabled || !['applied','restart-required','failed','cancelled'].includes(enabled.application)) throw new Error('Enable outcome is unknown');
|
|
4005
|
+
uncertain = false;
|
|
4006
|
+
outcomeOf(enabled);
|
|
4007
|
+
const found = memoryPluginInstalledOf(valueOf(await pluginDeadline(manager.listBundles())));
|
|
4008
|
+
if (!found) throw new Error('Installation cannot be confirmed from the plugin inventory');
|
|
4009
|
+
setInstalled(found);
|
|
4010
|
+
if (!found.enabled) throw new Error('Installed, but the plugin inventory reports disabled');
|
|
4011
|
+
setFailure('');
|
|
4012
|
+
} catch(error) { fail(error?.message || String(error)); }
|
|
4013
|
+
finally {
|
|
4014
|
+
job.running = false;
|
|
4015
|
+
if (!uncertain && memoryPluginJobs.get(manager) === job) memoryPluginJobs.delete(manager);
|
|
4016
|
+
setWorking(false);
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
// Version shown on the card: the installed bundle's own version, with
|
|
4020
|
+
// the local source package.json version as display-only fallback.
|
|
4021
|
+
const hasInstalledVersion = installed !== null && typeof installed.version === 'string' && installed.version !== '';
|
|
4022
|
+
const shownVersion = hasInstalledVersion ? installed.version : MEMORY_PLUGIN_SOURCE_VERSION;
|
|
4023
|
+
const line = { fontSize: 11, color: INK3, marginTop: 4 };
|
|
4024
|
+
const border = '1px solid var(--dsw-alias-border-l3, rgba(127,127,127,.28))';
|
|
4025
|
+
return h('div', { 'data-cabinet-plugin-card': 'memory', style: { border, borderRadius: 8, padding: '10px 12px', marginBottom: 10 } }, [
|
|
4026
|
+
h('div', { key: 'head', style: { display: 'flex', alignItems: 'center', gap: 8 } }, [
|
|
4027
|
+
h('span', { key: 'gap', style: { flex: 1 } }),
|
|
4028
|
+
installed !== null ? h('span', { key: 'badge', 'data-cabinet-plugin-state': 'installed', style: { fontSize: 11, color: '#3fb950' } }, t('settings.plugin.installed')) : null
|
|
4029
|
+
]),
|
|
4030
|
+
// Highlight lines replace the old one-line description; the file:
|
|
4031
|
+
// path and the registry spec are install parameters only and are
|
|
4032
|
+
// never rendered on the card face.
|
|
4033
|
+
h('div', { key: 'hints', style: line }, [1, 2, 3, 4, 5].map((n) => h('div', { key: 'hint' + n, 'data-cabinet-plugin-hint': String(n), style: { ...line, marginTop: 3 } }, t('settings.plugin.hint' + n)))),
|
|
4034
|
+
installed !== null
|
|
4035
|
+
? h('div', { key: 'where', style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', marginTop: 8 } }, [
|
|
4036
|
+
h('span', { key: 'version', 'data-cabinet-plugin-version': shownVersion, style: { fontSize: 11, color: INK2 } }, shownVersion + (hasInstalledVersion ? '' : ' · ' + t('settings.plugin.versionFallback'))),
|
|
4037
|
+
h('span', { key: 'gap2', style: { flex: 1 } }),
|
|
4038
|
+
h('button', { key: 'update', 'data-cabinet-plugin-action': 'update', type: 'button', disabled: !manager || working, style: { fontSize: 11, cursor: 'pointer' }, onClick: () => { void run(); } }, working ? t('settings.plugin.installing') : t('settings.plugin.update'))
|
|
4039
|
+
])
|
|
4040
|
+
: h('div', { key: 'row', style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', marginTop: 8 } }, [
|
|
4041
|
+
h('button', { key: 'install', 'data-cabinet-plugin-action': 'install', type: 'button', disabled: !manager || working, style: { fontSize: 11, cursor: 'pointer' }, onClick: () => { void run(); } }, working ? t('settings.plugin.installing') : t('settings.plugin.install'))
|
|
4042
|
+
]),
|
|
4043
|
+
!manager ? h('div', { key: 'unavailable', 'data-cabinet-plugin-state': 'unavailable', style: line }, t('settings.plugin.unavailable')) : null,
|
|
4044
|
+
progress !== '' ? h('div', { key: 'progress', 'data-cabinet-plugin-progress': '1', style: line }, progress) : null,
|
|
4045
|
+
restart ? h('div', { key: 'restart', 'data-cabinet-plugin-state': 'restart', style: { ...line, color: '#d29922' } }, t('settings.plugin.restartRequired')) : null,
|
|
4046
|
+
failure !== '' ? h('div', { key: 'failure', 'data-cabinet-plugin-state': 'error', style: { ...line, color: '#f25a5a' } }, failure) : null
|
|
4047
|
+
]);
|
|
4048
|
+
}
|
|
4049
|
+
|
|
3878
4050
|
function CabinetMemberSettings(props) {
|
|
3879
4051
|
const t = typeof props?.t === 'function' ? props.t : memberT;
|
|
3880
4052
|
const [, redraw] = React.useState(0);
|
|
4053
|
+
// Active settings tab: session-local state (approved plan A). It is a
|
|
4054
|
+
// navigation preference, not user data, and client.js has no
|
|
4055
|
+
// localStorage precedent — so no second persistence source.
|
|
4056
|
+
const [activeTab, setActiveTab] = React.useState('members');
|
|
3881
4057
|
const editorRef = React.useRef(null);
|
|
3882
4058
|
if (!editorRef.current) editorRef.current = createMemberEditor(memberWriter, () => redraw(n => n + 1));
|
|
3883
4059
|
const editor = editorRef.current;
|
|
@@ -3928,7 +4104,7 @@ window.__ModuleLoader__.load({
|
|
|
3928
4104
|
onClick: () => resetMember(key)
|
|
3929
4105
|
}, t('member.reset'))
|
|
3930
4106
|
]),
|
|
3931
|
-
h('div', { key: 'builtin', style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap', marginBottom: 6 } }, [
|
|
4107
|
+
activeTab === 'avatars' ? h('div', { key: 'builtin', style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap', marginBottom: 6 } }, [
|
|
3932
4108
|
h('span', { key: 'l', style: { fontSize: 11, color: INK3 } }, t('member.builtin')),
|
|
3933
4109
|
...(function () {
|
|
3934
4110
|
const out = [];
|
|
@@ -3956,59 +4132,65 @@ window.__ModuleLoader__.load({
|
|
|
3956
4132
|
t('member.upload')
|
|
3957
4133
|
]),
|
|
3958
4134
|
avatars[key] ? h('button', { key: 'clear', type: 'button', style: { fontSize: 11, cursor: 'pointer' }, onClick: () => writeAvatar(key, '') }, t('member.avatar.clear')) : null
|
|
3959
|
-
]),
|
|
4135
|
+
]) : null,
|
|
3960
4136
|
errors[key] ? h('div', { key: 'e', style: { fontSize: 11, color: '#f25a5a', marginBottom: 4 } }, errors[key] === 'member.error.model' ? t(errors[key]) : errors[key]) : null,
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
4137
|
+
activeTab === 'members' ? [
|
|
4138
|
+
h('label', { key: 'name', style: { display: 'block', fontSize: 11, color: INK2, marginBottom: 2 } }, t('member.name')),
|
|
4139
|
+
h('input', {
|
|
4140
|
+
key: 'ni',
|
|
4141
|
+
type: 'text',
|
|
4142
|
+
value: draft[key].name,
|
|
4143
|
+
maxLength: MEMBER_NAME_LIMIT,
|
|
4144
|
+
placeholder: t('member.name.placeholder'),
|
|
4145
|
+
style: inputStyle,
|
|
4146
|
+
onChange: (event) => update(key, { name: event?.target?.value ?? '' })
|
|
4147
|
+
})
|
|
4148
|
+
] : null,
|
|
4149
|
+
activeTab === 'models' ? [
|
|
4150
|
+
h('label', { key: 'ml', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.model')),
|
|
4151
|
+
modelOptions.length > 0
|
|
4152
|
+
? (function () {
|
|
4153
|
+
const value = draft[key].model || '';
|
|
4154
|
+
const opts = [h('option', { key: '', value: '' }, t(key === 'lead' ? 'member.model.defaultLead' : 'member.model.default'))];
|
|
4155
|
+
if (value !== '' && !modelOptions.some((option) => option.value === value)) opts.push(h('option', { key: 'current', value }, value));
|
|
4156
|
+
for (const option of modelOptions) opts.push(h('option', { key: option.value, value: option.value }, option.label));
|
|
4157
|
+
return h('select', {
|
|
4158
|
+
key: 'mi',
|
|
4159
|
+
value,
|
|
4160
|
+
style: inputStyle,
|
|
4161
|
+
onChange: (event) => update(key, { model: event?.target?.value ?? '' })
|
|
4162
|
+
}, opts);
|
|
4163
|
+
}())
|
|
4164
|
+
: h('input', {
|
|
3979
4165
|
key: 'mi',
|
|
3980
|
-
|
|
4166
|
+
type: 'text',
|
|
4167
|
+
disabled: modelCatalog === undefined,
|
|
4168
|
+
value: draft[key].model,
|
|
4169
|
+
maxLength: 200,
|
|
4170
|
+
placeholder: 'provider/id',
|
|
3981
4171
|
style: inputStyle,
|
|
3982
4172
|
onChange: (event) => update(key, { model: event?.target?.value ?? '' })
|
|
3983
|
-
},
|
|
3984
|
-
}())
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
4173
|
+
}),
|
|
4174
|
+
modelCatalog !== undefined && modelOptions.length === 0 ? h('div', { key: 'mh', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.model.unavailable')) : null,
|
|
4175
|
+
h('div', { key: 'mhint', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.model.hint'))
|
|
4176
|
+
] : null,
|
|
4177
|
+
activeTab === 'prompts' ? [
|
|
4178
|
+
h('label', { key: 'prompt', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.prompt')),
|
|
4179
|
+
h('textarea', {
|
|
4180
|
+
key: 'pi',
|
|
4181
|
+
value: promptOf(key),
|
|
4182
|
+
maxLength: MEMBER_PROMPT_LIMIT,
|
|
4183
|
+
rows: key === 'lead' ? 8 : 3,
|
|
4184
|
+
placeholder: t('member.prompt.placeholder'),
|
|
4185
|
+
style: { ...inputStyle, resize: 'vertical', fontFamily: 'inherit' },
|
|
4186
|
+
onChange: (event) => {
|
|
4187
|
+
const value = event?.target?.value ?? '';
|
|
4188
|
+
const mode = value.trim() === '' ? 'off' : 'custom';
|
|
4189
|
+
update(key, { prompt: value, mode }, false);
|
|
4190
|
+
}
|
|
3994
4191
|
}),
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
h('label', { key: 'prompt', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.prompt')),
|
|
3998
|
-
h('textarea', {
|
|
3999
|
-
key: 'pi',
|
|
4000
|
-
value: promptOf(key),
|
|
4001
|
-
maxLength: MEMBER_PROMPT_LIMIT,
|
|
4002
|
-
rows: key === 'lead' ? 8 : 3,
|
|
4003
|
-
placeholder: t('member.prompt.placeholder'),
|
|
4004
|
-
style: { ...inputStyle, resize: 'vertical', fontFamily: 'inherit' },
|
|
4005
|
-
onChange: (event) => {
|
|
4006
|
-
const value = event?.target?.value ?? '';
|
|
4007
|
-
const mode = value.trim() === '' ? 'off' : 'custom';
|
|
4008
|
-
update(key, { prompt: value, mode }, false);
|
|
4009
|
-
}
|
|
4010
|
-
}),
|
|
4011
|
-
key === 'lead' ? h('div', { key: 'hint', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.lead.hint')) : null
|
|
4192
|
+
key === 'lead' ? h('div', { key: 'hint', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.lead.hint')) : null
|
|
4193
|
+
] : null
|
|
4012
4194
|
]);
|
|
4013
4195
|
});
|
|
4014
4196
|
return h('div', { style: { padding: '4px 2px 20px' } }, [
|
|
@@ -4021,9 +4203,27 @@ window.__ModuleLoader__.load({
|
|
|
4021
4203
|
!ready ? h('div', { key: 'unavailable', role: 'status' }, t('member.status.unavailable')) : null,
|
|
4022
4204
|
status ? h('div', { key: 'status', style: { fontSize: 11, color: INK2, marginBottom: 8 } }, t(status)) : null,
|
|
4023
4205
|
conflict ? h('div', { key: 'conflict', role: 'alert' }, t('member.status.conflict')) : null,
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4206
|
+
// Tab bar: session-local active tab, one button per field group.
|
|
4207
|
+
// The catalog refresh only serves the model picker, so it lives
|
|
4208
|
+
// with the models tab instead of the global chrome.
|
|
4209
|
+
h('div', { key: 'tabs', role: 'tablist', style: { display: 'flex', gap: 6, marginBottom: 8, flexWrap: 'wrap' } }, SETTINGS_TABS.map((id) => h('button', {
|
|
4210
|
+
key: id,
|
|
4211
|
+
type: 'button',
|
|
4212
|
+
role: 'tab',
|
|
4213
|
+
'aria-selected': activeTab === id,
|
|
4214
|
+
'data-cabinet-settings-tab': id,
|
|
4215
|
+
'data-cabinet-settings-active': activeTab === id ? '1' : '0',
|
|
4216
|
+
style: { fontSize: 11, cursor: 'pointer', padding: '3px 8px', borderRadius: 6, border: '1px solid var(--dsw-alias-border-l3, rgba(127,127,127,.4))', background: activeTab === id ? 'rgba(79,140,255,.16)' : 'transparent', color: activeTab === id ? INK : INK2 },
|
|
4217
|
+
onClick: () => setActiveTab(id)
|
|
4218
|
+
}, t('settings.tab.' + id)))),
|
|
4219
|
+
activeTab === 'models' ? h('div', { key: 'catalog-row', style: { marginBottom: 8 } }, [
|
|
4220
|
+
h('button', { key: 'catalog', type: 'button', 'data-cabinet-settings-refresh': '1', onClick: () => refreshCatalog(value => value + 1) }, t('member.model.refresh')),
|
|
4221
|
+
modelCatalog?.failures?.length ? h('div', { key: 'catalog-errors', role: 'status' }, t('member.model.partial')) : null
|
|
4222
|
+
]) : null,
|
|
4223
|
+
activeTab === 'plugin' ? null : h('fieldset', { key: 'fields', disabled: !ready || busy, style: { border: 0, padding: 0, margin: 0 } }, cards),
|
|
4224
|
+
// Memory plugin card: the plugin tab's own content — hidden on every
|
|
4225
|
+
// other tab, so the default view's save/cancel are never preceded by it.
|
|
4226
|
+
activeTab === 'plugin' ? h(MemoryPluginCard, { key: 'memory-plugin', t }) : null,
|
|
4027
4227
|
h('button', { key: 'save', type: 'button', disabled: !ready || busy || !dirty || conflict, onClick: () => editor.save() }, t('member.save')),
|
|
4028
4228
|
h('button', { key: 'cancel', type: 'button', disabled: busy, onClick: () => editor.cancel() }, t('member.cancel'))
|
|
4029
4229
|
]);
|
|
@@ -4086,6 +4286,23 @@ window.__ModuleLoader__.load({
|
|
|
4086
4286
|
'member.model.default': '使用首辅配置;未配置时使用 DSH 默认模型',
|
|
4087
4287
|
'member.model.defaultLead': '使用 DSH 默认模型',
|
|
4088
4288
|
'member.model.refresh': '刷新模型目录',
|
|
4289
|
+
'settings.tab.members': '成员',
|
|
4290
|
+
'settings.tab.avatars': '头像',
|
|
4291
|
+
'settings.tab.models': '模型',
|
|
4292
|
+
'settings.tab.prompts': '提示词',
|
|
4293
|
+
'settings.tab.plugin': '记忆插件',
|
|
4294
|
+
'settings.plugin.install': '一键安装',
|
|
4295
|
+
'settings.plugin.installing': '安装中…',
|
|
4296
|
+
'settings.plugin.installed': '已安装',
|
|
4297
|
+
'settings.plugin.update': '更新',
|
|
4298
|
+
'settings.plugin.versionFallback': '已安装版本未知',
|
|
4299
|
+
'settings.plugin.restartRequired': '已安装,需重启 DSH 生效',
|
|
4300
|
+
'settings.plugin.unavailable': '安装通道不可用:宿主未提供 remote.pluginManager。可在宿主会话执行 dsh plugin --profile web add <本地路径> 安装。',
|
|
4301
|
+
'settings.plugin.hint1': 'respire/dsh:原生 TypeScript 记忆插件,存储、去重与加密由 rsrs 负责',
|
|
4302
|
+
'settings.plugin.hint2': '自动召回:新会话自动想起早前结论,不用重复交代背景',
|
|
4303
|
+
'settings.plugin.hint3': '本地优先:记忆存本机,引擎故障只提示、主任务照跑',
|
|
4304
|
+
'settings.plugin.hint4': '教训入库:报错与教训沉淀成条,同一坑不踩第二次',
|
|
4305
|
+
'settings.plugin.hint5': '结构化记忆:正文分段、判重合并,分类树可挂父子',
|
|
4089
4306
|
'member.model.partial': '部分提供方加载失败;现有选择保留。可刷新重试。',
|
|
4090
4307
|
'member.error.model': '模型必须为 provider/id,最长 200 字符,不能含控制字符。',
|
|
4091
4308
|
'member.model.unavailable': '模型列表暂不可用:请手动输入 provider/id。',
|
|
@@ -4151,6 +4368,23 @@ window.__ModuleLoader__.load({
|
|
|
4151
4368
|
'member.model.default': 'Use Lead configuration, otherwise DSH default',
|
|
4152
4369
|
'member.model.defaultLead': 'Use DSH default model',
|
|
4153
4370
|
'member.model.refresh': 'Refresh model catalog',
|
|
4371
|
+
'settings.tab.members': 'Members',
|
|
4372
|
+
'settings.tab.avatars': 'Avatars',
|
|
4373
|
+
'settings.tab.models': 'Models',
|
|
4374
|
+
'settings.tab.prompts': 'Prompts',
|
|
4375
|
+
'settings.tab.plugin': 'Memory Plugin',
|
|
4376
|
+
'settings.plugin.install': 'Install',
|
|
4377
|
+
'settings.plugin.installing': 'Installing…',
|
|
4378
|
+
'settings.plugin.installed': 'Installed',
|
|
4379
|
+
'settings.plugin.update': 'Update',
|
|
4380
|
+
'settings.plugin.versionFallback': 'Installed version unavailable',
|
|
4381
|
+
'settings.plugin.restartRequired': 'Installed; restart DSH to take effect',
|
|
4382
|
+
'settings.plugin.unavailable': 'Install channel unavailable: the host did not expose remote.pluginManager. Run dsh plugin --profile web add <local path> in a host session instead.',
|
|
4383
|
+
'settings.plugin.hint1': 'respire/dsh: native TypeScript memory plugin; rsrs owns storage, dedup and encryption',
|
|
4384
|
+
'settings.plugin.hint2': 'Auto-recall: a new session resurfaces earlier conclusions without re-briefing',
|
|
4385
|
+
'settings.plugin.hint3': 'Local first: memories stay on this machine; an engine outage only notices, work continues',
|
|
4386
|
+
'settings.plugin.hint4': 'Lessons recorded: errors and pitfalls are stored, to help avoid repeating earlier mistakes',
|
|
4387
|
+
'settings.plugin.hint5': 'Structured memory: sectioned bodies, dedup and merges, a taxonomy tree with parents',
|
|
4154
4388
|
'member.model.partial': 'Some providers failed to load; saved choices are retained. Refresh to retry.',
|
|
4155
4389
|
'member.error.model': 'Use provider/id, at most 200 characters, without control characters.',
|
|
4156
4390
|
'member.model.unavailable': 'Model list unavailable: type provider/id manually.',
|
|
@@ -4217,6 +4451,19 @@ window.__ModuleLoader__.load({
|
|
|
4217
4451
|
return () => { if (cabinetOpenSession === opener) cabinetOpenSession = null; };
|
|
4218
4452
|
}, 'cabinet-ui: open teammate session');
|
|
4219
4453
|
});
|
|
4454
|
+
// Optional install channel for the memory-plugin card: its own guard, so
|
|
4455
|
+
// a host without the plugin manager leaves the model-catalog remote and
|
|
4456
|
+
// every other channel exactly as it was.
|
|
4457
|
+
ctx.inject(['remote', 'remote.pluginManager'], (scope) => {
|
|
4458
|
+
const remote = scope.remote;
|
|
4459
|
+
const manager = remote !== undefined && remote !== null ? remote.pluginManager : undefined;
|
|
4460
|
+
if (!manager || typeof manager.inspect !== 'function' || typeof manager.installBundle !== 'function') return;
|
|
4461
|
+
scope.effect(() => {
|
|
4462
|
+
cabinetPluginManager = manager;
|
|
4463
|
+
notifyMemoryPlugin();
|
|
4464
|
+
return () => { if (cabinetPluginManager === manager) { cabinetPluginManager = null; notifyMemoryPlugin(); } };
|
|
4465
|
+
}, 'cabinet-ui: memory plugin manager');
|
|
4466
|
+
});
|
|
4220
4467
|
// Stage one: declare the page type. No patterns => a page type, opened by kind.
|
|
4221
4468
|
ctx.effect(() => ctx.sidebarRightTabs.register({
|
|
4222
4469
|
id: TAB_ID,
|
package/index.js
CHANGED
|
@@ -149,6 +149,7 @@ const DEFAULT_LEAD_PROMPT = `【御下术·仅首辅适用】
|
|
|
149
149
|
八、责任到人:缺陷点名到人到行号,不许用「我们」糊过去。
|
|
150
150
|
九、反制糊弄:报「已完成」必追问证据三件(命令输出、路径行号、未验证清单);报「卡住」必追问三件(已做什么、卡在哪、需要什么);两次含糊即降级处理(换人、拆小)。
|
|
151
151
|
十、收束:闭环才许说「这一版可以交差」,不许提前许诺功劳。
|
|
152
|
+
十一、监控纠偏:分派时约定回报节点、产物清单和单一交付范围;按实际可用的团队状态与消息工具检查进展,必要时要求回报做了什么、卡在哪里、需要什么。工具未提供时间字段时不得臆造耗时;文件时间戳仅作辅助,须读回产物并结合执行状态。finished、not found 或暂时沉默均不是成功或安全接管的证据。同一命令反复无进展、任务范围过大时先核实原因,再请求中断;中断返回不代表在途工具或写入已结束。必须确认原执行者及其写入停止后才能重派同一工作,无法确认则报告阻塞,不并发增加第二写入者。收窄任务后可重派或换人;超出当前上下文的回访使用宿主明确支持的调度机制,没有该机制不得承诺定时自动唤醒。
|
|
152
153
|
红线(压过全部话术):只对 AI 阁臣施压,对用户只有敬;不许逼造假、删证据、凑绿;不许人身侮辱辱骂;不许以施压换取违规操作(越权改 live、泄密钥、跳验收);施压必须落在可核验的时间/交付物/判据上,空口威胁无效。`;
|
|
153
154
|
|
|
154
155
|
/** Declarative wire schema: no transform callbacks requiring browser eval.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cabinet-mode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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/test-client.mjs
CHANGED
|
@@ -14,9 +14,9 @@ const React = {
|
|
|
14
14
|
useCallback: (callback) => callback,
|
|
15
15
|
useLayoutEffect: () => {}, useEffect: () => {},
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
window: { __ModuleLoader__: { load: ({ factory }) => {
|
|
17
|
+
const exportList = 'return { inject, apply, avatarFor, displayName, CabinetPanel, MemberCard, TaskLine, TaskEdgeLayer, buildTaskEdges, taskEdgesEqual, zh, en, BUREAUX, AVATARS, setMemberConfig, memberLabel, configuredAvatar, configuredPrompt, factoryPromptFor, DEFAULT_MEMBER_PROMPTS, DEFAULT_LEAD_PROMPT, CabinetMemberSettings, MemoryPluginCard, memoryPluginInstalledOf, SETTINGS_TABS };';
|
|
18
|
+
runInNewContext(source.replace(exportPoint, exportList), {
|
|
19
|
+
setTimeout: (fn, ms) => setTimeout(fn, ms === 120000 ? 20 : ms), clearTimeout, window: { __ModuleLoader__: { load: ({ factory }) => {
|
|
20
20
|
client = factory((name) => { assert.equal(name, 'react'); return React; });
|
|
21
21
|
} } },
|
|
22
22
|
});
|
|
@@ -89,6 +89,9 @@ for (const key of ['hanlin', 'works', 'dali', 'yushi']) {
|
|
|
89
89
|
assert.ok(client.factoryPromptFor(key).length <= 400, `${key} factory prompt must stay under 400 chars`);
|
|
90
90
|
}
|
|
91
91
|
assert.ok(client.DEFAULT_LEAD_PROMPT.includes('御下术'));
|
|
92
|
+
for (const clause of ['监控纠偏', '中断返回不代表', '写入停止后', '不并发增加第二写入者', '没有该机制不得承诺定时自动唤醒']) {
|
|
93
|
+
assert.ok(client.DEFAULT_LEAD_PROMPT.includes(clause), `lead prompt carries the monitoring/correction clause: ${clause}`);
|
|
94
|
+
}
|
|
92
95
|
client.setMemberConfig({ members: [{ key: 'hanlin', name: '张翰林', prompt: '', mode: '' }] });
|
|
93
96
|
assert.equal(client.memberLabel('hanlin'), '张翰林 · hanlin');
|
|
94
97
|
assert.equal(client.configuredPrompt('hanlin'), client.factoryPromptFor('hanlin'), 'unconfigured mode keeps the factory prompt');
|
|
@@ -388,3 +391,229 @@ assert.equal(adjacent.length,1);assert.notEqual(adjacent[0].s[1],adjacent[0].e[1
|
|
|
388
391
|
assert.ok(adjacent[0].c1[0]>adjacent[0].s[0]);
|
|
389
392
|
console.log('PASS: adjacent same-column rows retain a nonzero gutter curve');
|
|
390
393
|
console.log('PASS: edge direction blocker → blocked (start on blocker row, dot on blocked row) and click-to-open binding rules (lead/unassigned/inert never bind)');
|
|
394
|
+
|
|
395
|
+
// --- settings page: four tabs + the memory-plugin card ----------------------
|
|
396
|
+
// The shared React double above keeps useState inert; this second instance gives
|
|
397
|
+
// the settings page a stateful double so a tab click can be observed by
|
|
398
|
+
// re-rendering the same component with the updated state store.
|
|
399
|
+
let settingsClient;
|
|
400
|
+
const settingsState = [];
|
|
401
|
+
let settingsCursor = 0;
|
|
402
|
+
const SettingsReact = {
|
|
403
|
+
...React,
|
|
404
|
+
useState: (initial) => {
|
|
405
|
+
const index = settingsCursor++;
|
|
406
|
+
if (!(index in settingsState)) settingsState[index] = initial;
|
|
407
|
+
return [settingsState[index], (next) => { settingsState[index] = typeof next === 'function' ? next(settingsState[index]) : next; }];
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
runInNewContext(source.replace(exportPoint, exportList), {
|
|
411
|
+
setTimeout: (fn, ms) => setTimeout(fn, ms === 120000 ? 20 : ms), clearTimeout, window: { __ModuleLoader__: { load: ({ factory }) => { settingsClient = factory((name) => { assert.equal(name, 'react'); return SettingsReact; }); } } },
|
|
412
|
+
});
|
|
413
|
+
const mountSettings = (props) => {
|
|
414
|
+
settingsState.length = 0;
|
|
415
|
+
settingsCursor = 0;
|
|
416
|
+
return () => { settingsCursor = 0; return elements(settingsClient.CabinetMemberSettings(props)); };
|
|
417
|
+
};
|
|
418
|
+
const tabButton = (nodes, id) => nodes.find((node) => node.props?.['data-cabinet-settings-tab'] === id);
|
|
419
|
+
|
|
420
|
+
const renderSettings = mountSettings({ t: (key) => key });
|
|
421
|
+
let nodes = renderSettings();
|
|
422
|
+
assert.deepEqual(['members', 'avatars', 'models', 'prompts', 'plugin'].map((id) => tabButton(nodes, id)?.props['data-cabinet-settings-tab']),
|
|
423
|
+
['members', 'avatars', 'models', 'prompts', 'plugin'], 'the settings page exposes five tabs in order');
|
|
424
|
+
assert.equal(tabButton(nodes, 'members').props['data-cabinet-settings-active'], '1', 'the members tab starts active');
|
|
425
|
+
assert.ok(nodes.some((node) => node.props?.key === 'name'), 'members tab shows the name field');
|
|
426
|
+
assert.ok(!nodes.some((node) => node.props?.key === 'pi'), 'prompt textarea is not on the members tab');
|
|
427
|
+
assert.ok(!nodes.some((node) => node.props?.key === 'builtin'), 'avatar row is not on the members tab');
|
|
428
|
+
assert.ok(nodes.some((node) => node.props?.key === 'head'), 'row head stays visible so members remain identifiable');
|
|
429
|
+
// The card lives inside the plugin tab now: absent by default, shown while the
|
|
430
|
+
// tab is active, and it is still the content directly above save/cancel there.
|
|
431
|
+
assert.equal(nodes.findIndex((node) => node.props?.['data-cabinet-plugin-card']), -1, 'the memory-plugin card is not on the default members tab');
|
|
432
|
+
tabButton(nodes, 'plugin').props.onClick();
|
|
433
|
+
nodes = renderSettings();
|
|
434
|
+
const cardAt = nodes.findIndex((node) => node.props?.['data-cabinet-plugin-card']);
|
|
435
|
+
const saveAt = nodes.findIndex((node) => node.props?.key === 'save');
|
|
436
|
+
assert.ok(cardAt >= 0, 'clicking the plugin tab shows the memory-plugin card');
|
|
437
|
+
assert.ok(saveAt > cardAt, 'the card sits directly above the save/cancel row while its tab is active');
|
|
438
|
+
assert.ok(!nodes.some((node) => node.props?.key === 'fields'), 'the plugin tab renders no members fieldset: its own content is the plugin card, and member shells without their sections would only be empty head rows');
|
|
439
|
+
tabButton(nodes, 'members').props.onClick();
|
|
440
|
+
nodes = renderSettings();
|
|
441
|
+
assert.ok(!nodes.some((node) => node.props?.['data-cabinet-plugin-card']), 'leaving the plugin tab hides the card again');
|
|
442
|
+
assert.ok(nodes.some((node) => node.props?.key === 'cancel'), 'cancel survives the restructure');
|
|
443
|
+
|
|
444
|
+
tabButton(nodes, 'models').props.onClick();
|
|
445
|
+
nodes = renderSettings();
|
|
446
|
+
assert.equal(tabButton(nodes, 'models').props['data-cabinet-settings-active'], '1', 'clicking a tab activates it');
|
|
447
|
+
assert.ok(nodes.some((node) => node.props?.['data-cabinet-settings-refresh'] === '1'), 'the catalog refresh moved into the models tab');
|
|
448
|
+
assert.ok(nodes.some((node) => node.props?.key === 'ml'), 'models tab shows the model field');
|
|
449
|
+
assert.ok(!nodes.some((node) => node.props?.key === 'name'), 'name field is not on the models tab');
|
|
450
|
+
|
|
451
|
+
tabButton(nodes, 'prompts').props.onClick();
|
|
452
|
+
nodes = renderSettings();
|
|
453
|
+
assert.ok(nodes.some((node) => node.props?.key === 'pi'), 'prompts tab shows the prompt textarea');
|
|
454
|
+
assert.ok(!nodes.some((node) => node.props?.key === 'ml'), 'model field is not on the prompts tab');
|
|
455
|
+
|
|
456
|
+
tabButton(nodes, 'avatars').props.onClick();
|
|
457
|
+
nodes = renderSettings();
|
|
458
|
+
assert.ok(nodes.some((node) => node.props?.key === 'builtin'), 'avatars tab shows the portrait row');
|
|
459
|
+
assert.ok(!nodes.some((node) => node.props?.key === 'pi'), 'prompt textarea is not on the avatars tab');
|
|
460
|
+
assert.ok(nodes.some((node) => node.props?.key === 'head'), 'row head stays visible on every member tab');
|
|
461
|
+
|
|
462
|
+
// Memory-plugin card: no channel degrades loudly, the installed state offers
|
|
463
|
+
// update (never one-click install), specs stay off the card face, the version
|
|
464
|
+
// falls back to the local source package.json, and failures echo verbatim.
|
|
465
|
+
settingsState.length = 0; settingsCursor = 0;
|
|
466
|
+
let cardNodes = elements(settingsClient.MemoryPluginCard({ t: (key) => key }));
|
|
467
|
+
assert.ok(cardNodes.some((node) => node.props?.['data-cabinet-plugin-state'] === 'unavailable'), 'a missing channel is stated, not silent');
|
|
468
|
+
const deadButton = cardNodes.find((node) => node.props?.['data-cabinet-plugin-action'] === 'install');
|
|
469
|
+
assert.ok(deadButton && deadButton.props.disabled === true, 'the install button stays disabled without a channel');
|
|
470
|
+
const faceTextOf = (rendered) => JSON.stringify(rendered.map((node) => node.props));
|
|
471
|
+
assert.ok(!faceTextOf(cardNodes).includes('file:'), 'the local file: spec is never rendered on the card');
|
|
472
|
+
assert.ok(!faceTextOf(cardNodes).includes('@rsrsai/dsh@'), 'the registry spec is never rendered on the card');
|
|
473
|
+
assert.ok(cardNodes.some((node) => node.props?.['data-cabinet-plugin-hint'] !== undefined), 'the highlight list renders on the card face');
|
|
474
|
+
|
|
475
|
+
settingsState.length = 0; settingsCursor = 0;
|
|
476
|
+
cardNodes = elements(settingsClient.MemoryPluginCard({ t: (key) => key, initialInstalled: { name: '@rsrsai/dsh', version: '0.1.13', enabled: true } }));
|
|
477
|
+
assert.ok(cardNodes.some((node) => node.props?.['data-cabinet-plugin-state'] === 'installed'), 'the installed state is announced');
|
|
478
|
+
assert.ok(!cardNodes.some((node) => node.props?.['data-cabinet-plugin-action'] === 'install'), 'the installed state shows no one-click install button');
|
|
479
|
+
const updateButton = cardNodes.find((node) => node.props?.['data-cabinet-plugin-action'] === 'update');
|
|
480
|
+
assert.ok(updateButton && updateButton.props.disabled === true, 'the installed state offers an update button, disabled without a channel');
|
|
481
|
+
const versionNode = cardNodes.find((node) => node.props?.['data-cabinet-plugin-version'] !== undefined);
|
|
482
|
+
assert.ok(versionNode && String(versionNode.children.flat().join('')).includes('0.1.13'), 'the installed version is visible on the card');
|
|
483
|
+
assert.ok(!faceTextOf(cardNodes).includes('file:'), 'the file: spec stays hidden in the installed state');
|
|
484
|
+
assert.ok(!faceTextOf(cardNodes).includes('@rsrsai/dsh@'), 'the registry spec stays hidden in the installed state');
|
|
485
|
+
|
|
486
|
+
settingsState.length = 0; settingsCursor = 0;
|
|
487
|
+
cardNodes = elements(settingsClient.MemoryPluginCard({ t: (key) => key, initialInstalled: { name: '@rsrsai/dsh', version: '', enabled: true } }));
|
|
488
|
+
const fallbackVersionNode = cardNodes.find((node) => node.props?.['data-cabinet-plugin-version'] !== undefined);
|
|
489
|
+
assert.ok(fallbackVersionNode && !String(fallbackVersionNode.children.flat().join('')).includes('0.1.13'), 'unknown installed version must not claim the source version');
|
|
490
|
+
assert.ok(fallbackVersionNode && String(fallbackVersionNode.children.flat().join('')).includes('settings.plugin.versionFallback'), 'the version fallback is marked on the card');
|
|
491
|
+
|
|
492
|
+
const mappedInstalled = settingsClient.memoryPluginInstalledOf([{ name: '@rsrsai/dsh', installed: true, version: '0.1.13', enabled: true }]);
|
|
493
|
+
// Field-by-field: the module lives in its own realm, so deepStrictEqual would
|
|
494
|
+
// compare a foreign Object.prototype and fail on identical fields.
|
|
495
|
+
assert.equal(mappedInstalled && mappedInstalled.name, '@rsrsai/dsh', 'listBundles shape maps to the card state');
|
|
496
|
+
assert.equal(mappedInstalled && mappedInstalled.version, '0.1.13', 'the installed version is carried through');
|
|
497
|
+
assert.equal(mappedInstalled && mappedInstalled.enabled, true, 'the enabled flag is carried through');
|
|
498
|
+
assert.equal(settingsClient.memoryPluginInstalledOf([{ name: 'other', installed: true }]), null, 'other bundles never count as ours');
|
|
499
|
+
assert.equal(settingsClient.memoryPluginInstalledOf('junk'), null, 'malformed replies never throw');
|
|
500
|
+
|
|
501
|
+
settingsState.length = 0; settingsCursor = 0;
|
|
502
|
+
const failingManager = {
|
|
503
|
+
inspect: async () => ({ ok: false, error: { message: 'boom: registry unreachable' } }),
|
|
504
|
+
installBundle: async () => ({ ok: false, error: { message: 'unreachable' } }),
|
|
505
|
+
listBundles: async () => ({ok:true,value:[]}),
|
|
506
|
+
};
|
|
507
|
+
cardNodes = elements(settingsClient.MemoryPluginCard({ t: (key) => key, manager: failingManager }));
|
|
508
|
+
const installButton = cardNodes.find((node) => node.props?.['data-cabinet-plugin-action'] === 'install');
|
|
509
|
+
assert.ok(installButton && installButton.props.disabled === false, 'a live channel offers the install button');
|
|
510
|
+
installButton.props.onClick();
|
|
511
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
512
|
+
settingsCursor = 0;
|
|
513
|
+
cardNodes = elements(settingsClient.MemoryPluginCard({ t: (key) => key, manager: failingManager }));
|
|
514
|
+
const errorNode = cardNodes.find((node) => node.props?.['data-cabinet-plugin-state'] === 'error');
|
|
515
|
+
assert.ok(errorNode, 'a failed install is visible');
|
|
516
|
+
assert.ok(String(errorNode.children.flat().join('')).includes('boom: registry unreachable'), 'the raw error text is echoed verbatim');
|
|
517
|
+
|
|
518
|
+
settingsState.length = 0; settingsCursor = 0;
|
|
519
|
+
const updateInstalled = { name: '@rsrsai/dsh', version: '0.1.13', enabled: true };
|
|
520
|
+
cardNodes = elements(settingsClient.MemoryPluginCard({ t: (key) => key, manager: failingManager, initialInstalled: updateInstalled }));
|
|
521
|
+
const updateClick = cardNodes.find((node) => node.props?.['data-cabinet-plugin-action'] === 'update');
|
|
522
|
+
assert.ok(updateClick, 'the installed state wires the update action');
|
|
523
|
+
assert.ok(updateClick && updateClick.props.disabled === false, 'a live channel enables the update action');
|
|
524
|
+
updateClick.props.onClick();
|
|
525
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
526
|
+
settingsCursor = 0;
|
|
527
|
+
cardNodes = elements(settingsClient.MemoryPluginCard({ t: (key) => key, manager: failingManager, initialInstalled: updateInstalled }));
|
|
528
|
+
const updateError = cardNodes.find((node) => node.props?.['data-cabinet-plugin-state'] === 'error');
|
|
529
|
+
assert.ok(updateError && String(updateError.children.flat().join('')).includes('boom: registry unreachable'), 'the update button reuses the install chain and echoes its failure verbatim');
|
|
530
|
+
|
|
531
|
+
// Both dictionaries carry the same settings.* keys (nothing may exist in one
|
|
532
|
+
// language only) and every tab id is translatable.
|
|
533
|
+
const zhSettingsKeys = Object.keys(client.zh).filter((key) => key.startsWith('settings.'));
|
|
534
|
+
const enSettingsKeys = Object.keys(client.en).filter((key) => key.startsWith('settings.'));
|
|
535
|
+
assert.ok(zhSettingsKeys.length >= 17, 'settings copy exists in zh, got ' + zhSettingsKeys.length);
|
|
536
|
+
assert.deepEqual(zhSettingsKeys.slice().sort(), enSettingsKeys.slice().sort(), 'zh and en settings keys must match exactly');
|
|
537
|
+
for (const id of ['members', 'avatars', 'models', 'prompts', 'plugin']) {
|
|
538
|
+
assert.ok(zhSettingsKeys.includes('settings.tab.' + id), 'tab label present in zh: ' + id);
|
|
539
|
+
}
|
|
540
|
+
for (const key of ['settings.plugin.install', 'settings.plugin.installing', 'settings.plugin.installed', 'settings.plugin.update', 'settings.plugin.versionFallback', 'settings.plugin.restartRequired', 'settings.plugin.unavailable']) {
|
|
541
|
+
assert.ok(zhSettingsKeys.includes(key), 'plugin card copy present: ' + key);
|
|
542
|
+
}
|
|
543
|
+
for (const n of [1, 2, 3, 4, 5]) {
|
|
544
|
+
const key = 'settings.plugin.hint' + n;
|
|
545
|
+
assert.ok(zhSettingsKeys.includes(key), 'highlight line copy present: ' + key);
|
|
546
|
+
assert.ok(enSettingsKeys.includes(key), 'highlight line copy present in en: ' + key);
|
|
547
|
+
}
|
|
548
|
+
console.log('PASS: five settings tabs switch by section; the plugin card keeps specs off its face, renders highlight lines, offers update with a visible version, and echoes failures verbatim; bilingual settings keys match');
|
|
549
|
+
|
|
550
|
+
// Installation state machine uses the real remote Result envelope.
|
|
551
|
+
for (const scenario of ['success','install-failed','enable-failed','missing-wait','timeout','restart','update','missing-enable','wait-null','wait-failed']) {
|
|
552
|
+
settingsState.length=0;settingsCursor=0;
|
|
553
|
+
let installs=0,enabled=false,installed=scenario==='update', version=scenario==='update'?'0.1.12':'0.1.13';
|
|
554
|
+
const ok=value=>({ok:true,value});
|
|
555
|
+
const manager={
|
|
556
|
+
listBundles:async()=>ok(installed?[{name:'@rsrsai/dsh',installed:true,version,enabled}]:[]),
|
|
557
|
+
inspect:async(spec)=>{assert.equal(spec,'@rsrsai/dsh@0.1.13');return ok({status:'accepted',name:'@rsrsai/dsh',bundle:true});},
|
|
558
|
+
installBundle:async(spec)=>{installs++;assert.equal(spec,'@rsrsai/dsh@0.1.13');
|
|
559
|
+
if(scenario==='timeout')return new Promise(()=>{});
|
|
560
|
+
if(['missing-wait','wait-null','wait-failed'].includes(scenario))return {ok:false,error:{message:'lost reply'}};
|
|
561
|
+
if(scenario==='install-failed')return ok({application:'failed',error:{message:'install failed'}});
|
|
562
|
+
installed=true;return ok({application:'applied',version:'0.1.13'});
|
|
563
|
+
},
|
|
564
|
+
updateBundle:async(name,target)=>{assert.equal(name,'@rsrsai/dsh');assert.equal(target,'0.1.13');version=target;return ok({result:{application:'restart-required',version:target}});},
|
|
565
|
+
setBundleEnabled:async()=>{if(scenario==='enable-failed')return {ok:false,error:{message:'enable failed'}};enabled=true;return ok({application:scenario==='restart'?'restart-required':'applied'});}
|
|
566
|
+
};
|
|
567
|
+
if(scenario==='missing-enable')delete manager.setBundleEnabled;
|
|
568
|
+
if(scenario==='wait-null')manager.waitForInstall=async()=>ok(null);
|
|
569
|
+
if(scenario==='wait-failed')manager.waitForInstall=async()=>ok({application:'failed'});
|
|
570
|
+
const render=()=>{settingsCursor=0;return elements(settingsClient.MemoryPluginCard({manager,t:key=>key}));};
|
|
571
|
+
const initial=render();initial.find(n=>n.props?.['data-cabinet-plugin-action']==='install').props.onClick();
|
|
572
|
+
await new Promise(r=>setTimeout(r,45));
|
|
573
|
+
const result=render();const error=result.find(n=>n.props?.['data-cabinet-plugin-state']==='error');
|
|
574
|
+
assert.equal(!!error,!['success','restart','update'].includes(scenario),scenario);
|
|
575
|
+
assert.equal(enabled,['success','restart','update'].includes(scenario),scenario);
|
|
576
|
+
assert.equal(!!result.find(n=>n.props?.['data-cabinet-plugin-state']==='restart'),['restart','update'].includes(scenario));
|
|
577
|
+
if(['timeout','missing-wait'].includes(scenario)) {result.find(n=>n.props?.['data-cabinet-plugin-action']==='install').props.onClick();await new Promise(r=>setTimeout(r,0));assert.equal(installs,1,'unknown operation cannot be duplicated');}
|
|
578
|
+
}
|
|
579
|
+
console.log('PASS: install/enable success, failure, missing wait, deadline, unknown-result duplicate guard and restart state (mock remote)');
|
|
580
|
+
// Lifecycle double executes effects and preserves refs; unlike the tab-only
|
|
581
|
+
// renderer above, this detects broken first inventory reads. Browser evidence
|
|
582
|
+
// remains separate and uses real React.
|
|
583
|
+
function memoryCardHarness() {
|
|
584
|
+
let hooks=[],cursor=0,effects=[],api,tree;
|
|
585
|
+
const react={...React,
|
|
586
|
+
useState(initial){const i=cursor++;if(!(i in hooks))hooks[i]={value:typeof initial==='function'?initial():initial};return [hooks[i].value,v=>{hooks[i].value=typeof v==='function'?v(hooks[i].value):v;}];},
|
|
587
|
+
useRef(initial){const i=cursor++;return hooks[i]??(hooks[i]={current:initial});},
|
|
588
|
+
useEffect(fn,deps){const i=cursor++,old=hooks[i];if(!old||deps.some((v,n)=>v!==old.deps[n])){hooks[i]={deps,cleanup:old?.cleanup};effects.push(()=>{hooks[i].cleanup?.();hooks[i].cleanup=fn();});}}
|
|
589
|
+
};
|
|
590
|
+
runInNewContext(source.replace(exportPoint,exportList),{setTimeout,clearTimeout,window:{__ModuleLoader__:{load:({factory})=>{api=factory(()=>react);}}}});
|
|
591
|
+
return {render(manager){cursor=0;effects=[];tree=elements(api.MemoryPluginCard({manager,t:k=>k}));for(const effect of effects)effect();return tree;},unmount(){for(const hook of hooks)hook.cleanup?.();hooks=[];},};
|
|
592
|
+
}
|
|
593
|
+
const inventory=version=>({ok:true,value:[{name:'@rsrsai/dsh',installed:true,enabled:true,version}]});
|
|
594
|
+
const tick=()=>new Promise(r=>setTimeout(r,0));
|
|
595
|
+
const versionOf=nodes=>nodes.find(n=>n.props?.['data-cabinet-plugin-version']!==undefined)?.props['data-cabinet-plugin-version'];
|
|
596
|
+
{
|
|
597
|
+
const h=memoryCardHarness();const manager={listBundles:async()=>inventory('0.1.13')};
|
|
598
|
+
h.render(manager);await tick();assert.equal(versionOf(h.render(manager)),'0.1.13','first mount reads actual remote inventory');
|
|
599
|
+
h.unmount();h.render(manager);await tick();assert.equal(versionOf(h.render(manager)),'0.1.13','remount reads inventory without initialInstalled');h.unmount();
|
|
600
|
+
}
|
|
601
|
+
{
|
|
602
|
+
const h=memoryCardHarness();let resolve;
|
|
603
|
+
const old={listBundles:()=>new Promise(r=>resolve=r)},current={listBundles:async()=>inventory('0.1.14')};
|
|
604
|
+
h.render(old);h.render(current);await tick();resolve(inventory('0.1.12'));await tick();assert.equal(versionOf(h.render(current)),'0.1.14','old channel cannot overwrite the new inventory');h.unmount();
|
|
605
|
+
}
|
|
606
|
+
for(const version of ['0.1.14','0.2.0','1.0.0','','broken','0.1.13-rc.1','9007199254740993.0.0']) {
|
|
607
|
+
const h=memoryCardHarness();let mutations=0;
|
|
608
|
+
const manager={listBundles:async()=>inventory(version),inspect:async()=>{throw Error('must reject before inspect')},installBundle:async()=>{mutations++},updateBundle:async()=>{mutations++},setBundleEnabled:async()=>{mutations++}};
|
|
609
|
+
h.render(manager);await tick();h.render(manager).find(n=>n.props?.['data-cabinet-plugin-action']==='update').props.onClick();await tick();
|
|
610
|
+
assert.equal(mutations,0,version);assert.ok(h.render(manager).some(n=>n.props?.['data-cabinet-plugin-state']==='error'),version);h.unmount();
|
|
611
|
+
}
|
|
612
|
+
console.log('PASS: effectful inventory first mount/remount/channel replacement and seven conservative non-downgrade cases; hook double, not browser E2E');
|
|
613
|
+
// An initial inventory read that finishes after a clicked operation is stale.
|
|
614
|
+
{
|
|
615
|
+
const h=memoryCardHarness();let resolve,reads=0;
|
|
616
|
+
const manager={listBundles:async()=>++reads===1?new Promise(r=>resolve=r):inventory('0.1.13'),inspect:async()=>({ok:true,value:{status:'accepted',name:'@rsrsai/dsh',bundle:true}}),installBundle:async()=>{throw Error('already installed')},setBundleEnabled:async()=>({ok:true,value:{application:'applied'}})};
|
|
617
|
+
h.render(manager).find(n=>n.props?.['data-cabinet-plugin-action']==='install').props.onClick();await tick();resolve({ok:true,value:[]});await tick();assert.equal(versionOf(h.render(manager)),'0.1.13','epoch rejects pre-operation inventory response');h.unmount();
|
|
618
|
+
}
|
|
619
|
+
console.log('PASS: late initial inventory cannot overwrite a completed operation');
|
|
@@ -21,7 +21,12 @@ const render=()=>{cursor=0;return client.CabinetMemberSettings({t:key=>client[lo
|
|
|
21
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
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
23
|
const pickers=tree=>nodes(tree).filter(n=>n.props.key==='mi');
|
|
24
|
-
let tree=render();
|
|
24
|
+
let tree=render();
|
|
25
|
+
// Setup only: the model fields now live on the models tab, so this click puts
|
|
26
|
+
// the UI in the state every assertion below assumes. No assertion body changes.
|
|
27
|
+
nodes(tree).find(n=>n.props['data-cabinet-settings-tab']==='models').props.onClick();
|
|
28
|
+
tree=render();
|
|
29
|
+
assert.ok(pickers(tree).every(n=>n.type==='input'&&n.props.disabled));
|
|
25
30
|
assert.equal(nodes(tree).filter(n=>n.props.key==='mh').length,0,'loading is not unavailable');
|
|
26
31
|
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
32
|
assert.equal(nodes(tree).filter(n=>n.props.key==='mh').length,5,'completed empty catalog shows fallback hint');
|