@linxin666/dsh-client-ui-plugin-manager 0.4.8 → 0.4.10
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 +3 -3
- package/README.zh.md +3 -3
- package/lib/client.js +69 -7
- package/lib/client.js.map +1 -1
- package/lib/index.js +80 -26
- package/lib/types/client/PluginListToolbar.d.ts +7 -3
- package/lib/types/client/PluginUpdatePatch.d.ts +7 -3
- package/lib/types/client/locales.d.ts +3 -0
- package/lib/types/core/protocol.d.ts +34 -0
- package/lib/types/host/gateway.d.ts +47 -12
- package/lib/types/host/loopback.d.ts +21 -0
- package/package.json +13 -13
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: 5d35d6f70cb0a3d917c56cab48e34e1c9592d8db
|
|
6
|
+
README.zh.md: cb538a8fb9b665d762c5b44698c88285a3027da8
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ English | [中文](README.zh.md)
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<img src="https://img.shields.io/npm/v/@linxin666/dsh-client-ui-plugin-manager?style=flat-square" alt="Version">
|
|
7
7
|
|
|
8
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.3-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
9
9
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
@@ -71,7 +71,7 @@ The contract source of truth is `src/core/service.ts` (`PluginManagerService`).
|
|
|
71
71
|
- An application-owned profile (the packaged Desktop client) runs installs, updates and removals through the official in-process plugin manager the host mounts, the same writer that profile's official Plugins page drives: the CLI refuses `--profile desktop` outright, and the launcher hands that manager its bundled package-manager invocation. The job, its status polling and its verification are identical to the CLI path — an install must add a dependency the profile did not carry, a removal must drop one, and an update must still report the version the route resolved — while the CLI-specific guards (duplicate-mount stripping, insert-row and boot preflight) stay with the CLI writer, because there the official manager validates and applies the bundle itself. The manager's own verdict is read before the profile is: it resolves a refused run with `application: 'failed'` instead of rejecting, so the job reports that run's real reason (the pnpm diagnostic, or the packages an incompatible-version refusal names) rather than a no-op after an unchanged profile. Since 0.2.1-rc.2 that manager also refuses to install a dependency the profile already carries while the host mounts `hmr` — every profile host — so an update there runs as its two phases instead: remove the installed bundle, then install the target spec through the same manager, and a second phase that fails reinstalls the spec the profile carried before the run, so a failed update leaves a working plugin rather than an empty slot. The single call stays first, so an upstream in-place update would need no change here. Every other runtime keeps the CLI as the single writer of installs, updates and removals.
|
|
72
72
|
- Compatibility gating applies only when the target manifest declares a minimum DSH version; packages without `dsh.engines.dsh` update unchecked, and official-installer runtimes (DSHCode and the checkout web) are not gated here because their updates go through the official installer. The running DSH version is read from the installation's own `@deepseek-ai/dsh` manifest, which the launcher publishes as the profile's install anchor — no subprocess, no PATH, and therefore an answer on a packaged Desktop host — with `dsh --version` kept as the fallback for a runtime that publishes no anchor. A requirement the host cannot verify at all is reported as unverified rather than as a version below the minimum: both hold the update back, but only the second sends the user to upgrade DSH.
|
|
73
73
|
- Enablement on the npm runtime reports the effective next-start value: a profile override row wins where present, otherwise the installed bundle's own `disabled` rows decide (the aggregate's inactive-by-default families), and rows no layer mentions are enabled. Enabling a row the bundle disables writes an explicit `disabled: false` override, because deleting the user row would only restore the bundle default; the runtime's loader honors these rows at the next start, but this path is less exercised than the official desktop writer's.
|
|
74
|
-
- Restart is explicit, user-clicked and three-mode. The route is method-aware: `GET /api/plugin-manager/restart` reads the plan (no side effects, so a prefetch or a typed URL can never stop a host) and `POST` carries it out; every other method is refused with 405. The toolbar reads the plan first, so the confirmation names the same consequence the host will produce. On a terminal launch (`dsh web`) the host starts a detached helper that waits for the outgoing process to exit and then re-executes the same command line, so the port is free before the replacement binds it, and the replacement's output goes to `$DSH_HOME/logs/plugin-manager-restart.log`. Under the packaged Desktop app the plugin cannot relaunch anything — Electron owns the process tree, a detached respawn would fight the shell for the same port, and the shell
|
|
74
|
+
- Restart is explicit, user-clicked and three-mode. The route is method-aware: `GET /api/plugin-manager/restart` reads the plan (no side effects, so a prefetch or a typed URL can never stop a host) and `POST` carries it out; every other method is refused with 405. The toolbar reads the plan first, so the confirmation names the same consequence the host will produce. On a terminal launch (`dsh web`) the host starts a detached helper that waits for the outgoing process to exit and then re-executes the same command line, so the port is free before the replacement binds it, and the replacement's output goes to `$DSH_HOME/logs/plugin-manager-restart.log`. Under the packaged Desktop app the plugin cannot relaunch anything — Electron owns the process tree, a detached respawn would fight the shell for the same port, and the official shell answers a host exit with `fail("dsh desktop host stopped")` and an error page, because it exposes no way to ask the shell to restart — so the host exits there only when the shell exports `DSH_SHELL_RESTARTS_HOST=1`, its own declaration that an exiting host is brought back. Without that guarantee the restart panel states that this process cannot restart itself, names the manual way out (quit DeepSeek Harness and open it again), and offers no confirmation button: that path would not restart anything. A launch with no terminal (a supervisor, an editor task) is left running and the toolbar says to restart manually. Without a restart, updated plugin code is loaded at the next start.
|
|
75
75
|
- On the npm runtime, duplicate insert-id claims are detected after install and the new plugin is rolled back automatically (a shared id can never be `disabled` away: the loader's duplicate check has no disabled exemption).
|
|
76
76
|
- The npm runtime's boot preflight (`--dump-config`) catches composition failures, and the static insert check catches insert rows naming packages that resolve nowhere; runtime import/apply failures still surface only at the next real start.
|
|
77
77
|
- Duplicate-mount safeguard (gateway mode): the official CLI's bundle reconciliation re-adds every bundle-declaring dependency to `dsh.profile.bundles` after any install/remove — including packages the composition already mounts through a patch row (a bundle that mounts an external plugin by row), which would double-mount and fail the next boot (`duplicate prefix route`). After every successful CLI mutation the gateway strips exactly the newly added, already-row-mounted bundles entries back out (the manifest write goes through backup + tmp + atomic rename), reports one notice per stripped entry on the job result, and leaves normal installs' bundles entries — and every entry the user had before — untouched.
|
|
@@ -80,7 +80,7 @@ The contract source of truth is `src/core/service.ts` (`PluginManagerService`).
|
|
|
80
80
|
## Security model
|
|
81
81
|
|
|
82
82
|
- Trust boundary is the loopback fence: every gateway route requires a loopback socket address, a loopback Host header, and a non-cross-site origin (socket + Host + Origin + `sec-fetch-site`), the same authority the official installer channels enforce. There is no browser-reachable path from a remote origin; rejected requests receive HTTP 403 with `{ ok: false, error: "forbidden: loopback-only" }`.
|
|
83
|
-
- Mutation routes (install / update / remove / set-enabled / restart) carry no token: the loopback authority *is* the local user, matching the official channels. The restart route is the one route whose effect is process-level: it never invents a command line (it re-executes this process's own `execPath` + argv, dropping inspector flags), it refuses to relaunch anything it cannot identify as a terminal launch, and under the packaged Desktop app it
|
|
83
|
+
- Mutation routes (install / update / remove / set-enabled / restart) carry no token: the loopback authority *is* the local user, matching the official channels. The restart route is the one route whose effect is process-level: it never invents a command line (it re-executes this process's own `execPath` + argv, dropping inspector flags), it refuses to relaunch anything it cannot identify as a terminal launch, and under the packaged Desktop app it stops this process only when the shell declares `DSH_SHELL_RESTARTS_HOST=1`. Any local process can therefore drive plugin installs and removals, and npm installs run package install scripts — treat the gateway as local code execution by design and never expose it beyond loopback.
|
|
84
84
|
- Install specs and package ids are rejected when they contain command-shell expansion characters or control characters. On Windows, npm shims are resolved to `node.exe` plus the package `bin.js`; packaged Desktop shims have no adjacent npm layout, so they run through `cmd.exe /d /s /c` with a pre-quoted, verbatim argument envelope. That command processor is addressed by absolute path (`ComSpec`, otherwise `%SystemRoot%\System32\cmd.exe`) instead of by bare name, so a host whose PATH omits the system directories still runs the shim; a spawn that still fails settles as a failed job carrying the reason instead of taking the dsh host process down. Desktop profile discovery reads the packaged launcher's profile environment value or persisted profile selection, and application-owned profile installs, updates and removals run in the host half through the mounted official `pluginManager` service — the same writer that profile's official Plugins page drives through its own RPC face — under the same loopback fence and user click.
|
|
85
85
|
- Mutations are serialized through one queue, so concurrent jobs never interleave their before/after profile captures. An install is only `done` when the new dependency actually landed in the profile (and a removal only when it is gone); a success exit code alone is never trusted.
|
|
86
86
|
- Enablement re-reads the current profile manifest under that mutation queue and rejects stale or unknown package ids with `404` before writing, so a panel row left behind by an uninstall cannot create an orphan `disabled` override.
|
package/README.zh.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<img src="https://img.shields.io/npm/v/@linxin666/dsh-client-ui-plugin-manager?style=flat-square" alt="Version">
|
|
7
7
|
|
|
8
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.3-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
9
9
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
@@ -71,7 +71,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
|
|
|
71
71
|
- 应用自有 profile(打包桌面客户端)的安装、更新与卸载走宿主挂载的官方进程内插件管理器——即该 profile 官方插件页所用的同一个写入器:CLI 直接拒绝 `--profile desktop`,启动器则把自带的包管理器调用交给该管理器。任务、状态轮询与校验与 CLI 路径一致:安装必须新增一条此前没有的依赖、卸载必须删除一条依赖、更新必须报告路由解析出的版本;而 CLI 专属的守卫(重复挂载剥离、insert 行与启动预检)仍留在 CLI 写入器一侧,因为该路径下官方管理器会自行校验并应用 bundle。管理器返回的判定会先于 profile 被读取:被拒绝的运行以 `application: 'failed'` 解析而不是抛错,因此任务上报该运行的真实原因(pnpm 诊断文本,或 `incompatible-version` 拒绝点名的包),而不是在 profile 未变之后给出一句空转文案。自 0.2.1-rc.2 起,该管理器在宿主挂载 `hmr` 时还会拒绝安装 profile 已携带的依赖——而那是每个 profile 宿主——因此那里的更新改为按两个阶段执行:先移除已安装的组合包,再用同一个管理器安装目标 spec;第二阶段失败时,装回运行前 profile 携带的 spec,使失败的更新留下可用的插件而不是空槽。单次调用仍排在最前,因此上游哪天接受原地更新,这里无需改动。其余运行时的安装、更新与卸载仍以 CLI 为唯一写入器。
|
|
72
72
|
- 兼容性门禁只在目标清单声明了最低 DSH 版本时生效;未声明 `dsh.engines.dsh` 的包更新不被检查,官方安装器运行时(DSHCode 与 checkout 版 web)不经过本门禁(其更新走官方安装器)。运行中的 DSH 版本读取安装自身的 `@deepseek-ai/dsh` 清单——启动器把它作为 profile 的 install anchor 发布——无需子进程、无需 PATH,因此打包桌面端也能作答;运行时不发布 anchor 时回退到 `dsh --version`。宿主完全无法核验的要求按「无法确认」呈现,而不是报成低于下限:两者都拦住更新,但只有后者会让用户去升级 DSH。
|
|
73
73
|
- npm 运行时上的启停显示下次启动的真实生效值:profile 覆盖行优先,其次由所装 bundle 自带的 `disabled` 行决定(聚合包的按需开启家族),两层都未提及的行视为启用。开启一个被 bundle 停用的行会写入显式 `disabled: false` 覆盖行——只删除用户行只会退回 bundle 默认值;该运行时 loader 在下次启动时认读这些行,但这条路径不如官方桌面写入器经过充分锻炼。
|
|
74
|
-
- 重启是显式、需用户点击且有三种模式的动作,路由按方法区分:`GET /api/plugin-manager/restart` 只读「重启方案」(无副作用,因此浏览器预取或直接输入 URL 都不会停掉宿主),`POST` 才执行;其他方法一律 405 拒绝。工具条先读方案,确认面板说的后果与实际执行的一致。终端启动(`dsh web`)时宿主启动一个 detached helper:等旧进程退出后按原命令行重新拉起,端口先释放再被替换进程绑定,替换进程的输出写入 `$DSH_HOME/logs/plugin-manager-restart.log`。打包桌面应用下本插件无法重启任何东西——进程树归 Electron,detached
|
|
74
|
+
- 重启是显式、需用户点击且有三种模式的动作,路由按方法区分:`GET /api/plugin-manager/restart` 只读「重启方案」(无副作用,因此浏览器预取或直接输入 URL 都不会停掉宿主),`POST` 才执行;其他方法一律 405 拒绝。工具条先读方案,确认面板说的后果与实际执行的一致。终端启动(`dsh web`)时宿主启动一个 detached helper:等旧进程退出后按原命令行重新拉起,端口先释放再被替换进程绑定,替换进程的输出写入 `$DSH_HOME/logs/plugin-manager-restart.log`。打包桌面应用下本插件无法重启任何东西——进程树归 Electron,detached 重拉只会与桌面外壳抢同一端口,而官方外壳对宿主退出只做 `fail("dsh desktop host stopped")` 并显示错误页,没有「请壳重启宿主」的通道——因此桌面端只在壳导出 `DSH_SHELL_RESTARTS_HOST=1`(宣告会把退出的宿主重新拉起)时才让宿主退出;壳没有这个保证时,重启面板如实写「当前进程无法自动重启,请手动重启 DSH。」、给出替代路径——退出 DeepSeek Harness 后重新打开,并且不提供确认按钮。无终端的启动(受监督进程、编辑器任务)同样保持不动,工具条提示手动重启。不重启时,更新后的插件代码在下次启动生效。
|
|
75
75
|
- npm 运行时上重复 insert id 认领在安装后即被检出并自动回滚新插件(共享 id 写 disabled 无法阻止 loader 的重复检查,只会误伤现有插件)。
|
|
76
76
|
- npm 运行时的启动预检(`--dump-config`)能抓组合失败,静态 insert 检查能抓引用不存在包的 insert 行;真正的运行时 import/apply 失败仍要到下次启动才暴露。
|
|
77
77
|
- 重复挂载保护(网关模式):官方 CLI 的 bundle 对账会在任何安装/卸载后把所有声明 `dsh.bundle` 的依赖重新加进 `dsh.profile.bundles`——包括组合树里已由 patch 行挂载的包(bundle 以 patch 行挂载外部插件时),下次启动会重复挂载而失败(`duplicate prefix route`)。每次 CLI 变更成功后,网关只把「本次新增且已被 patch 行挂载」的 bundles 条目剥除(清单写入走备份 + tmp + 原子 rename),并在任务结果上为每个被剥除的条目发一条 notice;正常安装的 bundles 条目与用户此前已有的条目一律不动。
|
|
@@ -80,7 +80,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
|
|
|
80
80
|
## 安全模型
|
|
81
81
|
|
|
82
82
|
- 信任边界是 loopback 门禁:每条网关路由都要求 loopback socket 地址、loopback Host 头与非跨站来源(socket + Host + Origin + `sec-fetch-site` 四重),与官方安装器通道同一权威。远程来源的浏览器没有可达路径;被拒请求返回 HTTP 403 与 `{ ok: false, error: "forbidden: loopback-only" }`。
|
|
83
|
-
- 变更类路由(install / update / remove / set-enabled / restart)不带 token:loopback 权威即本机用户,与官方通道同模型。重启路由是唯一作用在进程层面的路由:它绝不臆造命令行(只重放本进程自身的 `execPath` + argv,并剔除 inspector
|
|
83
|
+
- 变更类路由(install / update / remove / set-enabled / restart)不带 token:loopback 权威即本机用户,与官方通道同模型。重启路由是唯一作用在进程层面的路由:它绝不臆造命令行(只重放本进程自身的 `execPath` + argv,并剔除 inspector 开关),对无法确认为终端启动的宿主拒绝重拉,在打包桌面应用下只在壳声明 `DSH_SHELL_RESTARTS_HOST=1` 时才让本进程退出。因此任何本机进程都能驱动插件安装与卸载,且 npm 安装会执行包的 install 脚本——请将本网关视为「设计上即本机代码执行」,绝不暴露到 loopback 之外。
|
|
84
84
|
- 安装 spec 与包 id 含命令行展开字符或控制字符时一律拒绝。Windows 下,npm shim 会解析为 `node.exe` 加包内 `bin.js`;DSH Desktop 打包 shim 附近没有 npm 布局,因此通过带完整预引用、逐字参数封套的 `cmd.exe /d /s /c` 执行;该命令解释器按绝对路径定位(`ComSpec`,其次 `%SystemRoot%\System32\cmd.exe`)而不再依赖裸名的 PATH 查找,因此 PATH 缺系统目录的宿主仍能执行 shim;若 spawn 仍失败,则该次作业以失败结算并带出原因,绝不带走 dsh 宿主进程。桌面 profile 从打包启动器环境值或持久化的 profile 选择中读取;应用自有 profile 的安装、更新与卸载由 host 半区直接调用宿主挂载的官方 `pluginManager` 服务(与官方插件页经自身 RPC 面驱动的是同一个写入器),其权威同样是 loopback 门禁加用户点击。
|
|
85
85
|
- 变更经同一队列串行,并发任务的 before/after profile 快照绝不交错。安装只有在依赖真实落入 profile 后才判 done(卸载以依赖消失为准),绝不轻信成功退出码。
|
|
86
86
|
- 启停操作会在该变更队列内重新读取最新 profile 清单,并在写入前以 `404` 拒绝过期或未知的包 id,因此卸载后遗留在面板里的旧行不会制造孤儿 `disabled` 覆盖。
|
package/lib/client.js
CHANGED
|
@@ -25,7 +25,7 @@ window.__ModuleLoader__.load({
|
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region \0dsh-css:packages/dsh-plugin-manager/src/client/plugin-manager.module.css.mjs
|
|
28
|
-
const css = ".ZsMDKq_section{max-width:760px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:10px;display:flex}.ZsMDKq_title{margin:0;font-size:13px;font-weight:600;line-height:20px}.ZsMDKq_notice{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:8px;flex-direction:column;gap:8px;padding:16px;display:flex}.ZsMDKq_notice p{color:var(--dsw-alias-label-secondary);margin:0}.ZsMDKq_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px}.ZsMDKq_actionRow{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.ZsMDKq_button{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm,6px);color:var(--dsw-alias-label-primary);background:0 0;padding:5px 12px;font-size:12.5px;line-height:18px}.ZsMDKq_button:hover:enabled{background:var(--dsw-alias-interactive-bg-hover)}.ZsMDKq_button:disabled{cursor:default;opacity:.55}.ZsMDKq_button:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.ZsMDKq_primary{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-primary-fill);border-color:var(--dsw-alias-button-primary-fill)}.ZsMDKq_primary:hover:enabled{background:var(--dsw-alias-button-primary-hover);border-color:var(--dsw-alias-button-primary-hover)}.ZsMDKq_latest{color:var(--dsw-alias-state-business-primary);font-size:12px}.ZsMDKq_compatHint{color:var(--dsw-alias-label-tertiary);font-size:12px}.ZsMDKq_compatBlocked{color:var(--dsw-alias-label-danger);font-size:12px}.ZsMDKq_ok{color:var(--dsw-alias-state-success-primary);margin:0;font-size:12px}.ZsMDKq_error{color:var(--dsw-alias-label-danger);word-break:break-word;margin:0;font-size:12px}.ZsMDKq_progressRow{flex-direction:column;gap:6px;display:flex}.ZsMDKq_progressTrack{background:var(--dsw-alias-bg-layer-2);border-radius:3px;height:6px;overflow:hidden}.ZsMDKq_progressBar{background:var(--dsw-alias-state-business-primary);height:100%;transition:width .2s}.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:1.2s ease-in-out infinite ZsMDKq_pluginManagerIndeterminate}@keyframes ZsMDKq_pluginManagerIndeterminate{0%{transform:translate(-100%)}to{transform:translate(250%)}}@media (prefers-reduced-motion:reduce){.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:none}}.ZsMDKq_restartRow{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-brand);border-radius:8px;padding:10px 12px}.ZsMDKq_restartRow p{color:var(--dsw-alias-brand-primary);margin:0}.ZsMDKq_mount{align-self:center;margin-left:auto;position:relative}.ZsMDKq_toolbar{color:var(--dsw-alias-label-primary);align-items:center;gap:8px;font-size:12.5px;line-height:18px;display:flex;position:relative}.ZsMDKq_toolbarButton{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm,6px);color:var(--dsw-alias-label-primary);background:0 0;padding:3px 10px}.ZsMDKq_toolbarButton:hover:enabled{background:var(--dsw-alias-interactive-bg-hover)}.ZsMDKq_toolbarButton:disabled{cursor:default;opacity:.55}.ZsMDKq_toolbarButton:focus-visible,.ZsMDKq_toolbarSummary:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.ZsMDKq_toolbarSummary{font:inherit;cursor:pointer;color:var(--dsw-alias-label-secondary);background:0 0;border:0;padding:3px 2px}.ZsMDKq_toolbarSummary:hover{color:var(--dsw-alias-label-primary)}.ZsMDKq_toolbarHint{max-width:320px;color:var(--dsw-alias-label-tertiary)}.ZsMDKq_panel{z-index:40;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);width:max-content;min-width:260px;max-width:min(440px,60vw);max-height:320px;box-shadow:var(--dsw-shadow-lv3,0 8px 24px #00000024);text-align:left;border-radius:10px;flex-direction:column;gap:8px;padding:12px;display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:auto}.ZsMDKq_panelActions{justify-content:flex-end;gap:8px;display:flex}.ZsMDKq_panelList{flex-direction:column;gap:6px;margin:0;padding:0;list-style:none;display:flex}.ZsMDKq_panelRow{flex-wrap:wrap;align-items:baseline;gap:6px;display:flex}.ZsMDKq_panelName{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);word-break:break-all;font-size:12px}.ZsMDKq_panelVersion{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:12px}";
|
|
28
|
+
const css = ".ZsMDKq_section{max-width:760px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:10px;display:flex}.ZsMDKq_title{margin:0;font-size:13px;font-weight:600;line-height:20px}.ZsMDKq_notice{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:8px;flex-direction:column;gap:8px;padding:16px;display:flex}.ZsMDKq_notice p{color:var(--dsw-alias-label-secondary);margin:0}.ZsMDKq_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px}.ZsMDKq_actionRow{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.ZsMDKq_button{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm,6px);color:var(--dsw-alias-label-primary);background:0 0;padding:5px 12px;font-size:12.5px;line-height:18px}.ZsMDKq_button:hover:enabled{background:var(--dsw-alias-interactive-bg-hover)}.ZsMDKq_button:disabled{cursor:default;opacity:.55}.ZsMDKq_button:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.ZsMDKq_primary{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-primary-fill);border-color:var(--dsw-alias-button-primary-fill)}.ZsMDKq_primary:hover:enabled{background:var(--dsw-alias-button-primary-hover);border-color:var(--dsw-alias-button-primary-hover)}.ZsMDKq_latest{color:var(--dsw-alias-state-business-primary);font-size:12px}.ZsMDKq_compatHint{color:var(--dsw-alias-label-tertiary);font-size:12px}.ZsMDKq_compatBlocked{color:var(--dsw-alias-label-danger);font-size:12px}.ZsMDKq_ok{color:var(--dsw-alias-state-success-primary);margin:0;font-size:12px}.ZsMDKq_error{color:var(--dsw-alias-label-danger);word-break:break-word;margin:0;font-size:12px}.ZsMDKq_progressRow{flex-direction:column;gap:6px;display:flex}.ZsMDKq_progressTrack{background:var(--dsw-alias-bg-layer-2);border-radius:3px;height:6px;overflow:hidden}.ZsMDKq_progressBar{background:var(--dsw-alias-state-business-primary);height:100%;transition:width .2s}.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:1.2s ease-in-out infinite ZsMDKq_pluginManagerIndeterminate}@keyframes ZsMDKq_pluginManagerIndeterminate{0%{transform:translate(-100%)}to{transform:translate(250%)}}@media (prefers-reduced-motion:reduce){.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:none}}.ZsMDKq_restartRow{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-brand);border-radius:8px;padding:10px 12px}.ZsMDKq_restartRow p{color:var(--dsw-alias-brand-primary);margin:0}.ZsMDKq_mount{align-self:center;margin-left:auto;position:relative}.ZsMDKq_toolbar{color:var(--dsw-alias-label-primary);align-items:center;gap:8px;font-size:12.5px;line-height:18px;display:flex;position:relative}.ZsMDKq_toolbarButton{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm,6px);color:var(--dsw-alias-label-primary);background:0 0;padding:3px 10px}.ZsMDKq_toolbarButton:hover:enabled{background:var(--dsw-alias-interactive-bg-hover)}.ZsMDKq_toolbarButton:disabled{cursor:default;opacity:.55}.ZsMDKq_toolbarButton:focus-visible,.ZsMDKq_toolbarSummary:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.ZsMDKq_toolbarSummary{font:inherit;cursor:pointer;color:var(--dsw-alias-label-secondary);background:0 0;border:0;padding:3px 2px}.ZsMDKq_toolbarSummary:hover{color:var(--dsw-alias-label-primary)}.ZsMDKq_toolbarHint{max-width:320px;color:var(--dsw-alias-label-tertiary)}.ZsMDKq_panel{z-index:40;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);width:max-content;min-width:260px;max-width:min(440px,60vw);max-height:320px;box-shadow:var(--dsw-shadow-lv3,0 8px 24px #00000024);text-align:left;border-radius:10px;flex-direction:column;gap:8px;padding:12px;display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:auto}.ZsMDKq_panelActions{justify-content:flex-end;gap:8px;display:flex}.ZsMDKq_panelList{flex-direction:column;gap:6px;margin:0;padding:0;list-style:none;display:flex}.ZsMDKq_panelRow{flex-wrap:wrap;align-items:baseline;gap:6px;display:flex}.ZsMDKq_panelName{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);word-break:break-all;font-size:12px}.ZsMDKq_panelVersion{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:12px}.ZsMDKq_restartRequired{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.ZsMDKq_restartRequiredLine{color:var(--dsw-alias-label-secondary);font-size:12px}";
|
|
29
29
|
const tagId = "@linxin666/dsh-client-ui-plugin-manager/packages/dsh-plugin-manager/src/client/plugin-manager.module.css";
|
|
30
30
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
31
31
|
const tag = document.createElement("style");
|
|
@@ -56,6 +56,8 @@ window.__ModuleLoader__.load({
|
|
|
56
56
|
"progressBar": "ZsMDKq_progressBar",
|
|
57
57
|
"progressRow": "ZsMDKq_progressRow",
|
|
58
58
|
"progressTrack": "ZsMDKq_progressTrack",
|
|
59
|
+
"restartRequired": "ZsMDKq_restartRequired",
|
|
60
|
+
"restartRequiredLine": "ZsMDKq_restartRequiredLine",
|
|
59
61
|
"restartRow": "ZsMDKq_restartRow",
|
|
60
62
|
"section": "ZsMDKq_section",
|
|
61
63
|
"title": "ZsMDKq_title",
|
|
@@ -127,6 +129,8 @@ window.__ModuleLoader__.load({
|
|
|
127
129
|
stage: "fetch"
|
|
128
130
|
});
|
|
129
131
|
const [dirty, setDirty] = (0, react.useState)(false);
|
|
132
|
+
/** Version the update landed on when this process cannot load it without a restart. */
|
|
133
|
+
const [restartRequired, setRestartRequired] = (0, react.useState)(void 0);
|
|
130
134
|
/** Synchronous in-flight mirror of `busy`: the render guard alone lets a click and an Enter land in the same frame and double-fire. */
|
|
131
135
|
const busyRef = (0, react.useRef)(false);
|
|
132
136
|
const name = subject.kind === "bundle" ? subject.pkg.name : void 0;
|
|
@@ -179,10 +183,11 @@ window.__ModuleLoader__.load({
|
|
|
179
183
|
busyRef.current = true;
|
|
180
184
|
setBusy("update");
|
|
181
185
|
setError(void 0);
|
|
182
|
-
update(found.id).then(() => {
|
|
186
|
+
update(found.id).then((result) => {
|
|
183
187
|
setFound(void 0);
|
|
184
188
|
setChecked(false);
|
|
185
189
|
setDirty(true);
|
|
190
|
+
setRestartRequired(result.restartRequired.length > 0 ? result.plugin.version : void 0);
|
|
186
191
|
}).catch((reason) => {
|
|
187
192
|
setError(t("failed", { reason: messageOf$1(reason) }));
|
|
188
193
|
}).finally(() => {
|
|
@@ -263,7 +268,11 @@ window.__ModuleLoader__.load({
|
|
|
263
268
|
"data-update-error": true,
|
|
264
269
|
children: error
|
|
265
270
|
}),
|
|
266
|
-
|
|
271
|
+
restartRequired !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
272
|
+
className: plugin_manager_module_css_default.restartRow,
|
|
273
|
+
"data-update-restart-required": "yes",
|
|
274
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("updateRestartRequired", { version: restartRequired }) })
|
|
275
|
+
}) : dirty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
267
276
|
className: plugin_manager_module_css_default.restartRow,
|
|
268
277
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("restartHint") })
|
|
269
278
|
})
|
|
@@ -417,6 +426,13 @@ window.__ModuleLoader__.load({
|
|
|
417
426
|
const [found, setFound] = (0, react.useState)(0);
|
|
418
427
|
const [rows, setRows] = (0, react.useState)([]);
|
|
419
428
|
const [applied, setApplied] = (0, react.useState)([]);
|
|
429
|
+
/**
|
|
430
|
+
* Updates this run applied whose new version the running host has not loaded,
|
|
431
|
+
* with the version that landed. They stay in `applied` — the update did go
|
|
432
|
+
* through — and are listed as needing a restart instead of leaving the panel
|
|
433
|
+
* claiming a plain success.
|
|
434
|
+
*/
|
|
435
|
+
const [restartRequired, setRestartRequired] = (0, react.useState)([]);
|
|
420
436
|
const [cursor, setCursor] = (0, react.useState)(void 0);
|
|
421
437
|
const [error, setError] = (0, react.useState)(void 0);
|
|
422
438
|
const [panel, setPanel] = (0, react.useState)("none");
|
|
@@ -448,6 +464,7 @@ window.__ModuleLoader__.load({
|
|
|
448
464
|
setRows(thirdParty);
|
|
449
465
|
setFound(thirdParty.length);
|
|
450
466
|
setApplied([]);
|
|
467
|
+
setRestartRequired([]);
|
|
451
468
|
setChecked(true);
|
|
452
469
|
setPanel("list");
|
|
453
470
|
}).catch((reason) => {
|
|
@@ -474,7 +491,11 @@ window.__ModuleLoader__.load({
|
|
|
474
491
|
total: queue.length
|
|
475
492
|
});
|
|
476
493
|
try {
|
|
477
|
-
await update(row.id);
|
|
494
|
+
const result = await update(row.id);
|
|
495
|
+
if (result.restartRequired.length > 0) setRestartRequired((current) => [...current, {
|
|
496
|
+
id: row.id,
|
|
497
|
+
version: result.plugin.version
|
|
498
|
+
}]);
|
|
478
499
|
} catch (reason) {
|
|
479
500
|
setError(t("failed", { reason: messageOf(reason) }));
|
|
480
501
|
break;
|
|
@@ -609,6 +630,21 @@ window.__ModuleLoader__.load({
|
|
|
609
630
|
"data-update-applied": true,
|
|
610
631
|
children: t("updateAllDone")
|
|
611
632
|
}),
|
|
633
|
+
restartRequired.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
634
|
+
className: plugin_manager_module_css_default.restartRequired,
|
|
635
|
+
"data-update-restart-required": true,
|
|
636
|
+
children: restartRequired.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
637
|
+
className: plugin_manager_module_css_default.panelRow,
|
|
638
|
+
"data-update-restart-row": item.id,
|
|
639
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
640
|
+
className: plugin_manager_module_css_default.panelName,
|
|
641
|
+
children: item.id
|
|
642
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
643
|
+
className: plugin_manager_module_css_default.restartRequiredLine,
|
|
644
|
+
children: t("updateRestartRequired", { version: item.version })
|
|
645
|
+
})]
|
|
646
|
+
}, item.id))
|
|
647
|
+
}),
|
|
612
648
|
rows.length === 0 && applied.length === 0 && error === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
613
649
|
className: plugin_manager_module_css_default.hint,
|
|
614
650
|
children: t("noUpdates")
|
|
@@ -784,6 +820,7 @@ window.__ModuleLoader__.load({
|
|
|
784
820
|
"updateAll": "全部更新({count})",
|
|
785
821
|
"updatingAll": "更新 {name}({index}/{total})",
|
|
786
822
|
"updateAllDone": "更新完成,重启后生效。",
|
|
823
|
+
"updateRestartRequired": "已更新到 {version},需重启 DSH 后生效",
|
|
787
824
|
"updatesPanelTitle": "插件更新",
|
|
788
825
|
"thirdPartyOnly": "只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。",
|
|
789
826
|
"restartNow": "立即重启",
|
|
@@ -824,6 +861,7 @@ window.__ModuleLoader__.load({
|
|
|
824
861
|
"updateAll": "Update all ({count})",
|
|
825
862
|
"updatingAll": "Updating {name} ({index}/{total})",
|
|
826
863
|
"updateAllDone": "Updated; restart to take effect.",
|
|
864
|
+
"updateRestartRequired": "Updated to {version}; restart DSH for it to take effect",
|
|
827
865
|
"updatesPanelTitle": "Plugin updates",
|
|
828
866
|
"thirdPartyOnly": "Third-party plugins only; @deepseek-ai/ packages upgrade with DSH itself.",
|
|
829
867
|
"restartNow": "Restart now",
|
|
@@ -906,6 +944,23 @@ window.__ModuleLoader__.load({
|
|
|
906
944
|
return parsePlugin(value.plugin, 0);
|
|
907
945
|
}
|
|
908
946
|
/**
|
|
947
|
+
* Read the restart-required list off one gateway job (or off anything else
|
|
948
|
+
* carrying it).
|
|
949
|
+
*
|
|
950
|
+
* Deliberately tolerant where the other parsers in this module throw: this list
|
|
951
|
+
* is a hint attached to an update that already landed, so an unreadable value
|
|
952
|
+
* must cost the user the hint only. Throwing would reject an applied update and
|
|
953
|
+
* stop a batch run — the exact outcome the fact exists to avoid.
|
|
954
|
+
* @param value - decoded but untrusted job value.
|
|
955
|
+
* @returns the bundle names, empty when the value is absent or unusable.
|
|
956
|
+
*/
|
|
957
|
+
function parseRestartRequired(value) {
|
|
958
|
+
if (!Array.isArray(value)) return [];
|
|
959
|
+
const names = [];
|
|
960
|
+
for (const item of value) if (typeof item === "string" && item !== "") names.push(item);
|
|
961
|
+
return names;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
909
964
|
* Validate and normalize a `status` response value.
|
|
910
965
|
* @param value - decoded but untrusted response value.
|
|
911
966
|
* @returns the typed progress state.
|
|
@@ -1003,7 +1058,7 @@ window.__ModuleLoader__.load({
|
|
|
1003
1058
|
/** The building package's version, when the bundle carries it. */
|
|
1004
1059
|
function bakedVersion() {
|
|
1005
1060
|
try {
|
|
1006
|
-
return "0.4.
|
|
1061
|
+
return "0.4.10";
|
|
1007
1062
|
} catch {
|
|
1008
1063
|
return;
|
|
1009
1064
|
}
|
|
@@ -1129,7 +1184,10 @@ window.__ModuleLoader__.load({
|
|
|
1129
1184
|
const official = {
|
|
1130
1185
|
list: async () => parsePluginList(await call(LIST_ENDPOINT, {})),
|
|
1131
1186
|
install: async (spec) => parseInstalledPlugin(await call(INSTALL_ENDPOINT, { spec })),
|
|
1132
|
-
update: async (id) =>
|
|
1187
|
+
update: async (id) => ({
|
|
1188
|
+
plugin: parseInstalledPlugin(await call(UPDATE_ENDPOINT, { id })),
|
|
1189
|
+
restartRequired: []
|
|
1190
|
+
}),
|
|
1133
1191
|
uninstall: async (id) => parsePluginList(await call(UNINSTALL_ENDPOINT, { id })),
|
|
1134
1192
|
setEnabled: async (id, enabled) => parseInstalledPlugin(await call(SET_ENABLED_ENDPOINT, {
|
|
1135
1193
|
id,
|
|
@@ -1193,7 +1251,11 @@ window.__ModuleLoader__.load({
|
|
|
1193
1251
|
body: JSON.stringify({ id })
|
|
1194
1252
|
});
|
|
1195
1253
|
if (started.jobId === void 0) throw new Error("plugin-manager: gateway update returned no job");
|
|
1196
|
-
|
|
1254
|
+
const job = await waitJob(started.jobId);
|
|
1255
|
+
return {
|
|
1256
|
+
plugin: parseInstalledPlugin({ plugin: job.plugin }),
|
|
1257
|
+
restartRequired: parseRestartRequired(job.restartRequired)
|
|
1258
|
+
};
|
|
1197
1259
|
} finally {
|
|
1198
1260
|
gatewayInflight = false;
|
|
1199
1261
|
}
|