@linxin666/dsh-client-ui-preset-center 0.3.24 → 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/README.i18n.yaml +2 -2
- package/README.md +23 -19
- package/README.zh.md +24 -20
- package/icon.svg +3 -0
- package/lib/client.js +79 -86
- package/lib/client.js.map +1 -1
- package/lib/index.js +632 -254
- package/package.json +15 -12
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# node scripts/verify-docs.mjs --write <dir>
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 333c21e52da08f914e0dbe133dd7af8a0c35b8c2
|
|
6
|
+
README.zh.md: e01bf9c10f288f00ab4ee37a27b9758915fbfe23
|
package/README.md
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
Community agent-preset manager for the DSH Web GUI: the Workshop's **Presets** panel and the host library that installs,
|
|
5
|
+
Community agent-preset manager for the DSH Web GUI: the Workshop's **Presets** panel and the host library that installs, declares, disables and uninstalls presets downloaded from [dsh-market.com](https://dsh-market.com). A preset is only listed under **Settings → Agent presets** once this plugin declares it to the agent-preset registry; everything else stays in the Workshop.
|
|
6
6
|
|
|
7
7
|
## What it does
|
|
8
8
|
|
|
9
9
|
- Adds a **Presets** tab to the Workshop store card (contributed through the card's `dsh-workshop.panel` child slot) that lists the community catalog with install state, version updates and install counts.
|
|
10
|
-
- Installs a preset into an inert library at `$DSH_HOME/agent-presets/<id>/`. Nothing scans that directory, so
|
|
11
|
-
-
|
|
12
|
-
- Shows a **composition profile** computed from the installed bytes — the plugin names the composition mounts, whether it ships local code files or `!!js` expressions — and requires an explicit confirmation before
|
|
13
|
-
- Refuses
|
|
10
|
+
- Installs a preset into an inert library at `$DSH_HOME/agent-presets/<id>/`. Nothing scans that directory: the harness discovers no preset on disk, so a downloaded composition never loads by itself.
|
|
11
|
+
- Declares an installed preset to `ctx.agentPresets` (`@deepseek-ai/dsh-agent-preset-registry`). The host half reads `preset.yml` for the display text and `agent.cordis.yml` for the child plugin rows, then calls `register`, so a declared preset composes new sessions immediately without restarting `dsh web`. Disabling withdraws the declaration; uninstalling withdraws it and deletes the library directory.
|
|
12
|
+
- Shows a **composition profile** computed from the installed bytes — the plugin names the composition mounts, whether it ships local code files or `!!js` expressions — and requires an explicit confirmation before it declares anything executable. A read-only viewer renders `agent.cordis.yml` first.
|
|
13
|
+
- Refuses a preset whose id another declaration already supplies (the registry rejects a duplicate, so declaring would look like a successful install and do nothing), and refuses to disable or uninstall the preset the registry's default names (a default naming a missing preset fails every new session).
|
|
14
14
|
- Verifies market provenance on every state read: per-file sha256 pinned to `https://dsh-market.com`, so a locally edited preset is reported as modified and an update never silently overwrites it.
|
|
15
15
|
|
|
16
16
|
## Install
|
|
@@ -23,36 +23,40 @@ The Workshop card (`@linxin666/dsh-client-ui-market`) declares the panel slot an
|
|
|
23
23
|
|
|
24
24
|
## Config
|
|
25
25
|
|
|
26
|
-
None. The panel is the only surface, and every behavior is derived from the catalog and the
|
|
26
|
+
None. The panel is the only surface, and every behavior is derived from the catalog, the library directory and the live declarations. The plugin registers no settings namespace and injects nothing into the agent system prompt.
|
|
27
27
|
|
|
28
28
|
## Security model
|
|
29
29
|
|
|
30
|
-
A preset is code, not an asset: its composition may name npm plugins, load files that travel inside the preset directory, and evaluate `!!js` expressions — all inside the DSH host process
|
|
30
|
+
A preset is code, not an asset: its composition may name npm plugins, load files that travel inside the preset directory, and evaluate `!!js` expressions — all inside the DSH host process once it is declared. The harness states the trust plainly: a preset carries the same trust as shell access. This plugin therefore never treats a download as running:
|
|
31
31
|
|
|
32
|
-
- **
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
32
|
+
- **The download is inert.** The market installer writes into `$DSH_HOME/agent-presets/<id>/`, which no discovery root scans. The plugin declares nothing when it loads.
|
|
33
|
+
- **The declaration is the consent boundary.** Declaring registers the composition with the registry, which eagerly mounts its rows in the host process. The panel requires an explicit confirmation whenever the composition carries local code, relative rows or inline expressions, and shows what those are.
|
|
34
|
+
- **The declaration is pre-checked and rolled back.** The id is checked against the live roster, and a preset the registry reports broken is unregistered with the reason shown instead of being left half-declared.
|
|
35
35
|
- **Provenance is the integrity anchor.** The market's per-file sha256 record is re-verified on every read; a mismatch is reported, never repaired silently.
|
|
36
36
|
- **Routes are loopback-only.** `/api/preset-center/*` answers only loopback requests, the same fence the market gateway uses, so a remote browser cannot drive the library.
|
|
37
|
-
- **Unmanaged directories are untouchable.** A preset that has no market provenance (hand-authored, or installed by another tool) is listed as such and refused by
|
|
37
|
+
- **Unmanaged directories are untouchable.** A preset that has no market provenance (hand-authored, or installed by another tool) is listed as such and refused by uninstall.
|
|
38
38
|
|
|
39
39
|
## Known limitations
|
|
40
40
|
|
|
41
|
-
- **
|
|
42
|
-
- **
|
|
41
|
+
- **Declaring is not sandboxing.** The confirmation and the composition profile reduce accidental risk; they do not make an untrusted preset safe. Review at the publish gate is the real control.
|
|
42
|
+
- **Declarations live with the host process.** Nothing is declared while the plugin loads, so after a `dsh web` restart every installed preset is inert again and is enabled with one click per preset in the Workshop. Persisting enablement would make a restart the moment a downloaded composition becomes live, which is the consent this panel exists to collect.
|
|
43
|
+
- **The official settings section may lag.** It re-reads on its own actions, `settings/document-updated` and `connection/reset`, so a preset declared in the Workshop can require a page refresh before it appears under **Settings → Agent presets**. New sessions pick it up immediately.
|
|
43
44
|
- **Running sessions keep their preset.** A session's composition is fixed at creation, so disabling or uninstalling a preset never changes a session already using it.
|
|
44
|
-
- **
|
|
45
|
+
- **The composition subset is deliberately small.** Compositions are read by a reader that understands the YAML a preset ships (block maps and sequences, quoted and plain scalars, literal and folded blocks, `!!js`) and refuses anything else — anchors, aliases, flow collections, extra tags — rather than guessing. A refused composition is reported as such and stays undeclared.
|
|
45
46
|
- **The catalog is empty until presets are published.** `packages/dsh-preset-center/presets/catalog.json` is the publishing source; see its README for the contribution format.
|
|
46
47
|
|
|
47
48
|
## Architecture
|
|
48
49
|
|
|
49
|
-
- `src/index.ts` — host half: mounts the loopback gateway once per process.
|
|
50
|
-
- `src/routes.ts` — `GET /api/preset-center/state`, `GET /api/preset-center/composition?id=`, `POST /api/preset-center/{
|
|
51
|
-
- `src/
|
|
52
|
-
- `src/core/
|
|
50
|
+
- `src/index.ts` — host half: owns the live declarations and mounts the loopback gateway once per process.
|
|
51
|
+
- `src/routes.ts` — `GET /api/preset-center/state`, `GET /api/preset-center/composition?id=`, `POST /api/preset-center/{install,disable,uninstall}`; the only layer that reads the roster, so the reserved-id and default-preset policies live here.
|
|
52
|
+
- `src/host/declarations.ts` — the registry declarations: register on install, unregister on disable/uninstall and on plugin unload.
|
|
53
|
+
- `src/core/paths.ts` — the library path contract and the preset id rule.
|
|
54
|
+
- `src/core/library.ts` — the library state: scan, the declaration-derived `enabled` flag, and uninstall.
|
|
55
|
+
- `src/core/yaml.ts` — the composition reader (fail-closed YAML subset, `!!js` preserved as data).
|
|
56
|
+
- `src/core/definition.ts` — the registry definition read from the installed bytes.
|
|
53
57
|
- `src/core/provenance.ts` — the market provenance reader and per-file verification.
|
|
54
58
|
- `src/core/profile.ts` — the composition profile.
|
|
55
59
|
- `src/client/PresetPanel.tsx` — the panel the Workshop card renders.
|
|
56
60
|
- `presets/` — the publishing source read by `scripts/market-build` (catalog plus one directory per preset).
|
|
57
61
|
|
|
58
|
-
The library
|
|
62
|
+
The library path is a cross-package contract: the market installer writes `preset` assets into `$DSH_HOME/agent-presets/<id>/` and neither package imports the other; the path name and the `dsh-market.provenance.json` format are mirrored constants, the same way the Skin Center mirrors the market's provenance.
|
package/README.zh.md
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
DSH Web GUI 的社区 agent
|
|
5
|
+
DSH Web GUI 的社区 agent 预设管理器:创意工坊的**预设**面板,以及负责安装、声明、停用、卸载从 [dsh-market.com](https://dsh-market.com) 下载的预设的 host 侧库。预设只有被本插件**声明**进 agent-preset 注册表后才会出现在**设置 → Agent 预设**;其余都留在创意工坊。
|
|
6
6
|
|
|
7
7
|
## 能力
|
|
8
8
|
|
|
9
9
|
- 在创意工坊商店卡新增**预设**标签页(通过卡片声明的 `dsh-workshop.panel` 子槽位注入),列出社区目录,带安装状态、版本更新提示与安装计数。
|
|
10
|
-
- 把预设安装到惰性库 `$DSH_HOME/agent-presets/<id
|
|
11
|
-
-
|
|
12
|
-
- 显示由**已安装字节**算出的**组合画像**——组合挂载的插件名、是否携带本地代码文件或 `!!js`
|
|
13
|
-
-
|
|
10
|
+
- 把预设安装到惰性库 `$DSH_HOME/agent-presets/<id>/`。没有任何东西扫描该目录:harness 不再从磁盘发现预设,因此下载下来的组合不会自行加载。
|
|
11
|
+
- 把已安装预设**声明**给 `ctx.agentPresets`(`@deepseek-ai/dsh-agent-preset-registry`)。host 半区从 `preset.yml` 读显示文案、从 `agent.cordis.yml` 读子插件行,然后调用 `register`,因此已声明的预设无需重启 `dsh web` 就能立即组合新会话。停用会撤回声明,卸载会撤回声明并删除库目录。
|
|
12
|
+
- 显示由**已安装字节**算出的**组合画像**——组合挂载的插件名、是否携带本地代码文件或 `!!js` 表达式——并在声明任何可执行内容前要求显式确认;声明前可用只读查看器阅读 `agent.cordis.yml`。
|
|
13
|
+
- 拒绝 id 已被其它声明占用的预设(注册表会拒绝重复 id,声明看起来成功却毫无效果),也拒绝停用或卸载注册表当前默认值指向的预设(默认值指向不存在的预设会让每个新会话创建失败)。
|
|
14
14
|
- 每次读取状态都校验市场 provenance:逐文件 sha256 锚定 `https://dsh-market.com`,因此本地改动过的预设会被标为「本地已修改」,更新也绝不静默覆盖它。
|
|
15
15
|
|
|
16
16
|
## 安装
|
|
@@ -23,36 +23,40 @@ dsh plugin --profile web add @linxin666/dsh-client-ui-preset-center
|
|
|
23
23
|
|
|
24
24
|
## 配置
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
无。面板是唯一界面,所有行为都由目录清单、库目录与实时声明推导。插件不注册设置命名空间,也不向 agent 系统提示注入任何内容。
|
|
27
27
|
|
|
28
28
|
## 安全模型
|
|
29
29
|
|
|
30
|
-
预设是代码,不是资源:它的组合可以引用 npm 插件、加载随预设目录分发的文件,并在 DSH 主进程内求值 `!!js`
|
|
30
|
+
预设是代码,不是资源:它的组合可以引用 npm 插件、加载随预设目录分发的文件,并在 DSH 主进程内求值 `!!js` 表达式——全部发生在它被声明之后。harness 对此的表述很直白:预设拥有与 shell 访问同等的信任。因此本插件从不把「下载」当作「运行」:
|
|
31
31
|
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
32
|
+
- **下载是惰性的。** 市场安装器写入 `$DSH_HOME/agent-presets/<id>/`,没有任何发现根扫描它。插件加载时也不声明任何预设。
|
|
33
|
+
- **声明才是授权边界。** 声明会把组合注册进注册表,注册表随即在主进程内急切挂载它的行。只要组合携带本地代码、相对路径行或内联表达式,面板就要求显式确认,并展示这些内容是什么。
|
|
34
|
+
- **声明前校验、失败回滚。** id 会与实时 roster 比对;roster 报告为 broken 的预设会被注销并显示原因,而不是留在半声明状态。
|
|
35
35
|
- **provenance 是完整性锚。** 每次读取都重新校验市场记录的逐文件 sha256;不匹配会被报告,绝不静默修复。
|
|
36
36
|
- **路由仅限 loopback。** `/api/preset-center/*` 只应答 loopback 请求,与市场网关同一道栅栏,远程浏览器无法驱动该库。
|
|
37
|
-
- **未托管目录不可触碰。** 没有市场 provenance
|
|
37
|
+
- **未托管目录不可触碰。** 没有市场 provenance 的预设(自建或由其它工具安装)会被标注,并被卸载拒绝。
|
|
38
38
|
|
|
39
39
|
## 已知限制
|
|
40
40
|
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
41
|
+
- **声明不是沙箱。** 确认与组合画像降低的是误操作风险,并不能让不可信预设变安全。发布环节的人工审查才是真正的控制点。
|
|
42
|
+
- **声明随 host 进程存续。** 插件加载时不声明任何预设,因此 `dsh web` 重启后每个已安装预设都回到惰性状态,需要在创意工坊里逐个点击启用。若把启用状态持久化,重启就会成为下载内容自动生效的时刻,而那正是本面板要收集的授权。
|
|
43
|
+
- **官方设置分区可能滞后。** 它只在自身动作、`settings/document-updated` 与 `connection/reset` 时重读,因此在创意工坊声明的预设可能需要刷新页面才出现在**设置 → Agent 预设**;新建会话会立即看到它。
|
|
44
|
+
- **运行中的会话保留原预设。** 会话的组合在创建时固定,停用或卸载不会改变正在使用它的会话。
|
|
45
|
+
- **组合子集刻意收窄。** 组合由只读懂预设所用 YAML 的读取器解析(块映射与块序列、引号与普通标量、字面块与折叠块、`!!js`),遇到其它构造——锚点、别名、流式集合、额外标签——一律拒绝而不是猜测。被拒绝的组合会被如实报告,并保持未声明。
|
|
45
46
|
- **目录为空直到有预设发布。** `packages/dsh-preset-center/presets/catalog.json` 是发布源,贡献格式见该目录的 README。
|
|
46
47
|
|
|
47
48
|
## 架构
|
|
48
49
|
|
|
49
|
-
- `src/index.ts` —— host
|
|
50
|
-
- `src/routes.ts` —— `GET /api/preset-center/state`、`GET /api/preset-center/composition?id=`、`POST /api/preset-center/{
|
|
51
|
-
- `src/
|
|
52
|
-
- `src/core/
|
|
50
|
+
- `src/index.ts` —— host 半区:持有实时声明,每进程挂载一次 loopback 网关。
|
|
51
|
+
- `src/routes.ts` —— `GET /api/preset-center/state`、`GET /api/preset-center/composition?id=`、`POST /api/preset-center/{install,disable,uninstall}`;唯一读取 roster 的层,因此保留 id 与默认预设两条策略在这里。
|
|
52
|
+
- `src/host/declarations.ts` —— 注册表声明:安装时注册,停用/卸载与插件卸载时注销。
|
|
53
|
+
- `src/core/paths.ts` —— 库路径契约与预设 id 规则。
|
|
54
|
+
- `src/core/library.ts` —— 库状态:扫描、由声明推导的 `enabled` 标志、卸载。
|
|
55
|
+
- `src/core/yaml.ts` —— 组合读取器(fail-closed 的 YAML 子集,`!!js` 保留为数据)。
|
|
56
|
+
- `src/core/definition.ts` —— 由已安装字节读出的注册表定义。
|
|
53
57
|
- `src/core/provenance.ts` —— 市场 provenance 读取与逐文件校验。
|
|
54
58
|
- `src/core/profile.ts` —— 组合画像。
|
|
55
59
|
- `src/client/PresetPanel.tsx` —— 创意工坊卡片渲染的面板。
|
|
56
60
|
- `presets/` —— `scripts/market-build` 读取的发布源(catalog 加每个预设一个目录)。
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
库路径是跨包契约:市场安装器把 `preset` 资产写进 `$DSH_HOME/agent-presets/<id>/`,两个包互不 import;路径名与 `dsh-market.provenance.json` 格式是镜像常量,与皮肤中心镜像市场 provenance 的方式一致。
|
package/icon.svg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
2
|
+
<path fill="#4d6bfe" fill-rule="evenodd" d="M 67.5 120 L 70.5 120 L 72.5 121 L 80.5 129 L 81.5 129 L 84.5 132 L 85.5 132 L 90.5 136 L 93.5 137 L 95.5 139 L 101.5 142 L 103.5 142 L 106.5 144 L 111.5 145 L 112.5 146 L 115.5 146 L 119.5 148 Q 122.75 147.25 123.5 149 L 127.5 149 L 128.5 150 L 133.5 150 L 134.5 151 L 140.5 151 L 141.5 152 L 150.5 152 L 151.5 153 L 160.5 153 L 161.5 154 L 171.5 154 L 172.5 155 L 178.5 155 L 179.5 156 Q 183.5 155 184.5 157 L 189.5 157 Q 190.5 159 194.5 158 L 195.5 159 L 197.5 159 L 198.5 160 L 200.5 160 L 201.5 161 L 206.5 162 L 209.5 164 L 211.5 164 L 219.5 168 L 224.5 172 L 227.5 173 L 247 191.5 L 247 192.5 L 253 199.5 L 255.5 204 L 258 201.5 L 263 193.5 L 272.5 183 L 273.5 183 L 280.5 176 L 281.5 176 L 292.5 168 L 300.5 164 L 302.5 164 L 305.5 162 L 307.5 162 L 308.5 161 L 310.5 161 L 314.5 159 L 317.5 159 L 318.5 158 Q 321.75 158.75 322.5 157 L 326.5 157 L 327.5 156 L 331.5 156 L 332.5 155 L 337.5 155 L 338.5 154 L 348.5 154 L 349.5 153 L 358.5 153 L 359.5 152 L 368.5 152 L 369.5 151 L 376.5 151 L 377.5 150 L 383.5 150 L 384.5 149 L 388.5 149 L 389.5 148 L 392.5 148 L 393.5 147 L 396.5 147 L 397.5 146 L 399.5 146 L 400.5 145 L 405.5 144 L 423.5 135 L 426.5 132 L 431.5 129 L 439.5 121 L 441.5 120 L 444.5 120 L 448 123.5 L 448 140.5 L 447 141.5 L 447 149.5 L 446 150.5 L 446 154.5 L 445 155.5 Q 445.75 158.75 444 159.5 L 444 163.5 Q 442.25 164.25 443 167.5 L 440 173.5 L 439 178.5 L 435 185.5 L 435 187.5 L 432 193.5 L 430 195.5 L 429 198.5 L 427 200.5 L 425 204.5 L 419 211.5 L 419 212.5 L 402.5 229 L 401.5 229 L 394.5 235 L 393.5 235 L 388.5 239 L 385.5 240 L 383.5 242 L 371.5 248 L 369.5 248 L 364.5 251 L 362.5 251 L 361.5 252 L 359.5 252 L 358.5 253 L 356.5 253 L 355.5 254 L 353.5 254 L 349.5 256 L 342.5 257 L 338.5 259 L 335.5 259 L 334.5 260 L 327.5 261 L 326.5 262 L 324.5 262 L 323.5 263 L 321.5 263 L 320.5 264 L 318.5 264 L 317.5 265 L 312.5 266 L 309.5 268 L 307.5 268 L 295.5 275 L 288 282.5 Q 287.5 286 285 287.5 Q 285.5 290 284 290.5 L 284 293.5 L 283 294.5 L 283 311.5 L 284 312.5 L 284 318.5 L 285 319.5 L 285 323.5 L 286 324.5 L 286 328.5 Q 288 329.5 287 333.5 L 288 334.5 L 288 337.5 L 289 338.5 L 289 341.5 L 290 342.5 L 290 345.5 L 291 346.5 L 292 353.5 L 293 354.5 L 293 356.5 L 295 360.5 L 295 363.5 L 296 364.5 L 296 367.5 L 297 368.5 L 297 370.5 L 298 371.5 L 298 373.5 L 299 374.5 L 299 376.5 L 301 380.5 L 301 386.5 L 298.5 389 L 294.5 391 Q 292 390.5 291.5 392 L 286.5 392 L 285.5 393 L 272.5 393 L 271.5 394 L 240.5 394 L 239.5 393 L 227.5 393 L 226.5 392 L 221.5 392 Q 220.75 390.25 217.5 391 L 212 387.5 L 211 385.5 L 211 381.5 L 212 380.5 Q 211.5 378 213 377.5 L 213 374.5 L 214 373.5 L 214 371.5 L 216 367.5 L 216 364.5 L 217 363.5 L 217 361.5 L 219 357.5 L 219 354.5 L 221 350.5 L 221 347.5 L 222 346.5 L 222 343.5 L 223 342.5 L 223 339.5 L 224 338.5 L 224 335.5 L 225 334.5 Q 224.25 331.25 226 330.5 L 226 326.5 L 227 325.5 Q 226 321.5 228 320.5 L 228 315.5 L 229 314.5 L 229 292.5 L 228 291.5 L 227 286.5 L 225 284.5 L 223 280.5 L 219.5 277 L 218.5 277 L 212.5 272 L 202.5 267 L 200.5 267 L 197.5 265 L 194.5 265 L 193.5 264 L 191.5 264 L 190.5 263 L 188.5 263 L 184.5 261 L 181.5 261 L 180.5 260 L 173.5 259 L 172.5 258 L 170.5 258 L 166.5 256 L 159.5 255 L 158.5 254 L 156.5 254 L 155.5 253 L 150.5 252 L 147.5 250 L 145.5 250 L 142.5 248 L 140.5 248 L 128.5 242 L 123.5 238 L 120.5 237 L 109.5 228 L 108.5 228 L 95 214.5 L 95 213.5 L 87 204.5 L 84 198.5 L 82 196.5 L 80 191.5 L 77 187.5 L 77 185.5 L 72 175.5 L 72 173.5 L 71 172.5 L 71 170.5 L 69 166.5 L 69 163.5 L 68 162.5 Q 68.75 159.25 67 158.5 L 67 154.5 L 66 153.5 L 66 148.5 L 65 147.5 L 65 139.5 L 64 138.5 L 64 124.5 L 67.5 120 Z"/>
|
|
3
|
+
</svg>
|
package/lib/client.js
CHANGED
|
@@ -48,14 +48,14 @@ window.__ModuleLoader__.load({
|
|
|
48
48
|
//#region src/client/PresetPanel.tsx
|
|
49
49
|
/**
|
|
50
50
|
* The Workshop's Presets panel: browse the community preset catalog and drive
|
|
51
|
-
* the host library (install into `$DSH_HOME/agent-presets/<id
|
|
52
|
-
* the
|
|
53
|
-
* shown before anything executable is
|
|
51
|
+
* the host library (install into `$DSH_HOME/agent-presets/<id>` and declare it
|
|
52
|
+
* to the agent-preset registry, disable, uninstall), with the composition
|
|
53
|
+
* profile shown before anything executable is declared.
|
|
54
54
|
*
|
|
55
55
|
* The panel owns no catalog fetch: the Workshop card already fetches
|
|
56
56
|
* `manifest/presets.json` and passes the records down, so one store section
|
|
57
57
|
* makes one catalog request. Preset state comes from the preset-center host
|
|
58
|
-
* routes, which derive it from disk on every read.
|
|
58
|
+
* routes, which derive it from disk and the live declarations on every read.
|
|
59
59
|
* @module @linxin666/dsh-client-ui-preset-center/client/PresetPanel
|
|
60
60
|
*/
|
|
61
61
|
const EMPTY_PROFILE = {
|
|
@@ -127,7 +127,7 @@ window.__ModuleLoader__.load({
|
|
|
127
127
|
}
|
|
128
128
|
/** Whether the catalog advertises a version newer than the installed one. */
|
|
129
129
|
function hasUpdate(record, row) {
|
|
130
|
-
if (row === void 0 || !row.installed
|
|
130
|
+
if (row === void 0 || !row.installed) return false;
|
|
131
131
|
if (record.version === void 0 || row.assetVersion === void 0) return false;
|
|
132
132
|
return compareVersions(record.version, row.assetVersion) > 0;
|
|
133
133
|
}
|
|
@@ -140,7 +140,7 @@ window.__ModuleLoader__.load({
|
|
|
140
140
|
const [busy, setBusy] = (0, react.useState)(null);
|
|
141
141
|
const [notes, setNotes] = (0, react.useState)({});
|
|
142
142
|
const [viewer, setViewer] = (0, react.useState)(null);
|
|
143
|
-
const [
|
|
143
|
+
const [confirmInstall, setConfirmInstall] = (0, react.useState)(null);
|
|
144
144
|
const [confirmUninstall, setConfirmUninstall] = (0, react.useState)(null);
|
|
145
145
|
const [reload, setReload] = (0, react.useState)(0);
|
|
146
146
|
(0, react.useEffect)(() => {
|
|
@@ -190,6 +190,42 @@ window.__ModuleLoader__.load({
|
|
|
190
190
|
setBusy(null);
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
|
+
/** Declare one installed preset, asking for confirmation when it carries code. */
|
|
194
|
+
const declareNow = async (record, confirm, success) => {
|
|
195
|
+
const res = await postJson("/api/preset-center/install", {
|
|
196
|
+
id: record.id,
|
|
197
|
+
confirm
|
|
198
|
+
});
|
|
199
|
+
if (res.data.ok === true) {
|
|
200
|
+
setConfirmInstall(null);
|
|
201
|
+
note(record.id, t(success, {}));
|
|
202
|
+
refresh();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (res.data.error === "confirmation-required") {
|
|
206
|
+
setConfirmInstall({
|
|
207
|
+
id: record.id,
|
|
208
|
+
name: displayName(record),
|
|
209
|
+
profile: res.data.profile ?? EMPTY_PROFILE
|
|
210
|
+
});
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (res.data.error === "broken" || res.data.error === "invalid-composition") {
|
|
214
|
+
note(record.id, t("note.broken", { reason: res.data.message ?? "" }));
|
|
215
|
+
refresh();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (res.data.error === "shadowed") {
|
|
219
|
+
note(record.id, t("note.shadowed", {}));
|
|
220
|
+
refresh();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (res.data.error === "roster-unavailable") {
|
|
224
|
+
note(record.id, t("note.rosterUnavailable", {}));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
note(record.id, t("note.actionFailed", { reason: res.data.message ?? res.data.error ?? "HTTP " + res.status }));
|
|
228
|
+
};
|
|
193
229
|
const install = (record, force) => run(record.id, "install", async () => {
|
|
194
230
|
if (props.install === void 0) return;
|
|
195
231
|
try {
|
|
@@ -203,8 +239,8 @@ window.__ModuleLoader__.load({
|
|
|
203
239
|
return;
|
|
204
240
|
}
|
|
205
241
|
props.reportInstall?.(record.id).catch(() => {});
|
|
206
|
-
note(record.id, force ? t("note.updated", {}) : t("state.installed", {}));
|
|
207
242
|
refresh();
|
|
243
|
+
await declareNow(record, false, force ? "note.updated" : "note.enabled");
|
|
208
244
|
});
|
|
209
245
|
const update = (record, row) => run(record.id, "update", async () => {
|
|
210
246
|
if (props.install === void 0) return;
|
|
@@ -225,52 +261,14 @@ window.__ModuleLoader__.load({
|
|
|
225
261
|
}
|
|
226
262
|
props.reportInstall?.(record.id).catch(() => {});
|
|
227
263
|
if (wasEnabled) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
confirm: true
|
|
231
|
-
});
|
|
232
|
-
if (on.data.ok !== true) {
|
|
233
|
-
note(record.id, t("note.broken", { reason: on.data.message ?? on.data.error ?? "HTTP " + on.status }));
|
|
234
|
-
refresh();
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
264
|
+
await declareNow(record, true, "note.updated");
|
|
265
|
+
return;
|
|
237
266
|
}
|
|
238
267
|
note(record.id, t("note.updated", {}));
|
|
239
268
|
refresh();
|
|
240
269
|
});
|
|
241
|
-
const enable = (record,
|
|
242
|
-
|
|
243
|
-
id: record.id,
|
|
244
|
-
confirm
|
|
245
|
-
});
|
|
246
|
-
if (res.data.ok === true) {
|
|
247
|
-
setConfirmEnable(null);
|
|
248
|
-
note(record.id, t("note.enabled", {}));
|
|
249
|
-
refresh();
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
if (res.data.error === "confirmation-required") {
|
|
253
|
-
setConfirmEnable({
|
|
254
|
-
id: record.id,
|
|
255
|
-
name: displayName(record),
|
|
256
|
-
profile: res.data.profile ?? row.profile
|
|
257
|
-
});
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
if (res.data.error === "broken") {
|
|
261
|
-
note(record.id, t("note.broken", { reason: res.data.message ?? "" }));
|
|
262
|
-
refresh();
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
if (res.data.error === "shadowed") {
|
|
266
|
-
note(record.id, t("note.shadowed", {}));
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (res.data.error === "roster-unavailable") {
|
|
270
|
-
note(record.id, t("note.rosterUnavailable", {}));
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
note(record.id, t("note.actionFailed", { reason: res.data.message ?? res.data.error ?? "HTTP " + res.status }));
|
|
270
|
+
const enable = (record, confirm) => run(record.id, "enable", async () => {
|
|
271
|
+
await declareNow(record, confirm, "note.enabled");
|
|
274
272
|
});
|
|
275
273
|
const disable = (record) => run(record.id, "disable", async () => {
|
|
276
274
|
const res = await postJson("/api/preset-center/disable", { id: record.id });
|
|
@@ -337,10 +335,6 @@ window.__ModuleLoader__.load({
|
|
|
337
335
|
key: "state.local",
|
|
338
336
|
tone: preset_center_module_css_default.badgeWarn
|
|
339
337
|
};
|
|
340
|
-
if (row.conflict) return {
|
|
341
|
-
key: "state.conflict",
|
|
342
|
-
tone: preset_center_module_css_default.badgeWarn
|
|
343
|
-
};
|
|
344
338
|
if (row.integrity === "modified") return {
|
|
345
339
|
key: "state.modified",
|
|
346
340
|
tone: preset_center_module_css_default.badgeWarn
|
|
@@ -398,7 +392,7 @@ window.__ModuleLoader__.load({
|
|
|
398
392
|
const profile = row?.profile ?? EMPTY_PROFILE;
|
|
399
393
|
const updateAvailable = hasUpdate(record, row);
|
|
400
394
|
const busyHere = busy === record.id;
|
|
401
|
-
const blockedByLocal = row !== void 0 && !row.managed &&
|
|
395
|
+
const blockedByLocal = row !== void 0 && !row.managed && row.installed;
|
|
402
396
|
const installable = gateway && props.install !== void 0 && !occupied.has(record.id) && !blockedByLocal;
|
|
403
397
|
const installs = props.installs?.[record.id] ?? 0;
|
|
404
398
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
@@ -471,11 +465,11 @@ window.__ModuleLoader__.load({
|
|
|
471
465
|
className: preset_center_module_css_default.primary,
|
|
472
466
|
disabled: !gateway || busyNow || occupied.has(record.id),
|
|
473
467
|
onClick: () => {
|
|
474
|
-
enable(record,
|
|
468
|
+
enable(record, false);
|
|
475
469
|
},
|
|
476
470
|
children: busyHere ? t("installing", {}) : t("action.enable", {})
|
|
477
471
|
}) : null,
|
|
478
|
-
row !== void 0 && row.managed && row.enabled
|
|
472
|
+
row !== void 0 && row.managed && row.enabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
479
473
|
className: preset_center_module_css_default.secondary,
|
|
480
474
|
disabled: !gateway || busyNow,
|
|
481
475
|
onClick: () => {
|
|
@@ -538,34 +532,33 @@ window.__ModuleLoader__.load({
|
|
|
538
532
|
}),
|
|
539
533
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
540
534
|
title: t("confirm.title", {}),
|
|
541
|
-
open:
|
|
535
|
+
open: confirmInstall !== null,
|
|
542
536
|
onClose: () => {
|
|
543
|
-
|
|
537
|
+
setConfirmInstall(null);
|
|
544
538
|
},
|
|
545
539
|
closeLabel: t("action.cancel", {}),
|
|
546
540
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("confirm.text", {
|
|
547
|
-
name:
|
|
541
|
+
name: confirmInstall?.name ?? "",
|
|
548
542
|
detail: t("code.detail", {
|
|
549
|
-
files: String(
|
|
550
|
-
expressions: String(
|
|
551
|
-
plugins: String(
|
|
543
|
+
files: String(confirmInstall?.profile.codeFiles.length ?? 0),
|
|
544
|
+
expressions: String(confirmInstall?.profile.inlineExpressions ?? 0),
|
|
545
|
+
plugins: String(confirmInstall?.profile.plugins.length ?? 0)
|
|
552
546
|
})
|
|
553
547
|
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
554
548
|
className: preset_center_module_css_default.modalActions,
|
|
555
549
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
556
550
|
className: preset_center_module_css_default.primary,
|
|
557
551
|
onClick: () => {
|
|
558
|
-
const target =
|
|
559
|
-
|
|
552
|
+
const target = confirmInstall;
|
|
553
|
+
setConfirmInstall(null);
|
|
560
554
|
const record = rows.find((entry) => entry.id === target?.id);
|
|
561
|
-
|
|
562
|
-
if (record !== void 0 && row !== void 0) enable(record, row, true);
|
|
555
|
+
if (record !== void 0) enable(record, true);
|
|
563
556
|
},
|
|
564
557
|
children: t("action.enable", {})
|
|
565
558
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
566
559
|
className: preset_center_module_css_default.secondary,
|
|
567
560
|
onClick: () => {
|
|
568
|
-
|
|
561
|
+
setConfirmInstall(null);
|
|
569
562
|
},
|
|
570
563
|
children: t("action.cancel", {})
|
|
571
564
|
})]
|
|
@@ -616,13 +609,13 @@ window.__ModuleLoader__.load({
|
|
|
616
609
|
"state.modified": "本地已修改",
|
|
617
610
|
"state.conflict": "目录状态异常",
|
|
618
611
|
"state.local": "本地自建同名预设",
|
|
619
|
-
"state.shadowed": "id
|
|
612
|
+
"state.shadowed": "id 已被其它插件声明的预设占用",
|
|
620
613
|
"state.newVersion": "有新版本 {version}",
|
|
621
614
|
"state.broken": "无法加载",
|
|
622
615
|
"action.install": "安装",
|
|
623
616
|
"action.update": "更新",
|
|
624
617
|
"action.enable": "启用",
|
|
625
|
-
"action.disable": "
|
|
618
|
+
"action.disable": "停用",
|
|
626
619
|
"action.uninstall": "卸载",
|
|
627
620
|
"action.view": "查看组合",
|
|
628
621
|
"action.cancel": "取消",
|
|
@@ -631,23 +624,23 @@ window.__ModuleLoader__.load({
|
|
|
631
624
|
"code.inline": "含内联表达式",
|
|
632
625
|
"code.none": "仅组合已安装插件",
|
|
633
626
|
"code.detail": "{files} 个代码文件 · {expressions} 个 !!js 表达式 · {plugins} 个插件",
|
|
634
|
-
"confirm.title": "
|
|
635
|
-
"confirm.text": "「{name}
|
|
627
|
+
"confirm.title": "安装可执行预设",
|
|
628
|
+
"confirm.text": "「{name}」安装后会在 DSH 主进程内加载其组合内容,权限等同 shell 访问。{detail} 确认继续?",
|
|
636
629
|
"uninstall.title": "卸载预设",
|
|
637
|
-
"uninstall.text": "
|
|
630
|
+
"uninstall.text": "将注销「{name}」并删除其本地文件($DSH_HOME/agent-presets 中的副本)。已使用该预设的会话不受影响。",
|
|
638
631
|
"viewer.title": "{name} · agent.cordis.yml",
|
|
639
632
|
"viewer.empty": "(组合文件为空或不可读)",
|
|
640
633
|
"note.installFailed": "安装失败:{reason}",
|
|
641
634
|
"note.conflict": "本地已存在同名目录,未覆盖任何文件",
|
|
642
635
|
"note.actionFailed": "操作失败:{reason}",
|
|
643
|
-
"note.enabled": "
|
|
644
|
-
"note.disabled": "
|
|
636
|
+
"note.enabled": "已安装并启用;刷新页面后在「设置 → Agent 预设」中可见",
|
|
637
|
+
"note.disabled": "已停用;文件仍保留在预设库中,可随时重新启用",
|
|
645
638
|
"note.uninstalled": "已卸载",
|
|
646
639
|
"note.updated": "已更新到最新版本",
|
|
647
|
-
"note.broken": "
|
|
648
|
-
"note.shadowed": "该 id
|
|
640
|
+
"note.broken": "无法加载:{reason}",
|
|
641
|
+
"note.shadowed": "该 id 已被另一插件声明的预设占用,无法声明",
|
|
649
642
|
"note.defaultPreset": "这是当前默认预设,请先在「设置 → Agent 预设」切换默认值",
|
|
650
|
-
"note.rosterUnavailable": "宿主未提供 agent-
|
|
643
|
+
"note.rosterUnavailable": "宿主未提供 agent-preset 注册表服务,无法声明预设",
|
|
651
644
|
"note.gatewayUnavailable": "本机网关不可用:远程浏览器或 host 路由未挂载,无法安装或启用",
|
|
652
645
|
"note.loadFailed": "读取预设状态失败:{reason}",
|
|
653
646
|
"note.emptyCatalog": "社区预设目录为空",
|
|
@@ -664,7 +657,7 @@ window.__ModuleLoader__.load({
|
|
|
664
657
|
"state.modified": "Modified locally",
|
|
665
658
|
"state.conflict": "Directory state conflict",
|
|
666
659
|
"state.local": "Local preset with this id",
|
|
667
|
-
"state.shadowed": "Id taken by a
|
|
660
|
+
"state.shadowed": "Id taken by a preset another plugin declares",
|
|
668
661
|
"state.newVersion": "Update {version} available",
|
|
669
662
|
"state.broken": "Cannot load",
|
|
670
663
|
"action.install": "Install",
|
|
@@ -679,23 +672,23 @@ window.__ModuleLoader__.load({
|
|
|
679
672
|
"code.inline": "Has inline expressions",
|
|
680
673
|
"code.none": "Composes installed plugins only",
|
|
681
674
|
"code.detail": "{files} code files - {expressions} !!js expressions - {plugins} plugins",
|
|
682
|
-
"confirm.title": "
|
|
683
|
-
"confirm.text": "
|
|
675
|
+
"confirm.title": "Install an executable preset",
|
|
676
|
+
"confirm.text": "Installing \"{name}\" loads its composition inside the DSH host process, which carries the same trust as shell access. {detail} Continue?",
|
|
684
677
|
"uninstall.title": "Uninstall preset",
|
|
685
|
-
"uninstall.text": "
|
|
678
|
+
"uninstall.text": "Unregisters \"{name}\" and deletes its local files (the copy under $DSH_HOME/agent-presets). Sessions already using it keep running.",
|
|
686
679
|
"viewer.title": "{name} - agent.cordis.yml",
|
|
687
680
|
"viewer.empty": "(composition file is empty or unreadable)",
|
|
688
681
|
"note.installFailed": "Install failed: {reason}",
|
|
689
682
|
"note.conflict": "A directory with this id already exists locally; nothing was overwritten",
|
|
690
683
|
"note.actionFailed": "Action failed: {reason}",
|
|
691
|
-
"note.enabled": "
|
|
692
|
-
"note.disabled": "Disabled; the preset
|
|
684
|
+
"note.enabled": "Installed and enabled; refresh the page to see it under Settings - Agent presets",
|
|
685
|
+
"note.disabled": "Disabled; the files stay in the preset library and can be enabled again",
|
|
693
686
|
"note.uninstalled": "Uninstalled",
|
|
694
687
|
"note.updated": "Updated to the newest version",
|
|
695
|
-
"note.broken": "Cannot
|
|
696
|
-
"note.shadowed": "A
|
|
688
|
+
"note.broken": "Cannot load: {reason}",
|
|
689
|
+
"note.shadowed": "A preset another plugin declares already owns this id, so it cannot be declared",
|
|
697
690
|
"note.defaultPreset": "This is the current default preset; change the default under Settings - Agent presets first",
|
|
698
|
-
"note.rosterUnavailable": "The host exposes no agent-
|
|
691
|
+
"note.rosterUnavailable": "The host exposes no agent-preset registry service, so presets cannot be declared",
|
|
699
692
|
"note.gatewayUnavailable": "Local gateway unavailable: remote browser or host routes not mounted; install and enable are disabled",
|
|
700
693
|
"note.loadFailed": "Reading preset state failed: {reason}",
|
|
701
694
|
"note.emptyCatalog": "The community preset catalog is empty",
|