@linxin666/dsh-client-ui-plugin-manager 0.4.5 → 0.4.6
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 +2 -2
- package/README.zh.md +2 -2
- package/lib/client.js +12 -3
- package/lib/client.js.map +1 -1
- package/lib/index.js +198 -17
- package/lib/types/client/locales.d.ts +3 -0
- package/lib/types/core/protocol.d.ts +6 -0
- package/lib/types/host/detached-work.d.ts +44 -0
- package/lib/types/host/gateway.d.ts +1 -1
- package/lib/types/host/profile.d.ts +28 -0
- package/lib/types/host/routes.d.ts +11 -1
- package/package.json +6 -3
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: 7caf841a6dc01ff9b7bec7f6ad40590b54c960d7
|
|
6
|
+
README.zh.md: 750fb0033e2ffea591880c09235fde65a662bb40
|
package/README.md
CHANGED
|
@@ -67,9 +67,9 @@ The contract source of truth is `src/core/service.ts` (`PluginManagerService`).
|
|
|
67
67
|
## Known limitations
|
|
68
68
|
|
|
69
69
|
- Loopback-only: on a LAN or remote browser the update block renders a local-only notice (the same boundary the official installer page enforces; the gateway refuses non-loopback requests with 403).
|
|
70
|
-
- On the npm-published web runtime, gateway writes go through the official CLI. The gateway resolves `dsh` from the host process PATH first, then from `node_modules/.bin` project roots above the running host entry,
|
|
70
|
+
- On the npm-published web runtime, gateway writes go through the official CLI. The gateway resolves `dsh` from the host process PATH first, then from `node_modules/.bin` project roots above the running host entry, then from the running host package's own `lib/bin.js`, and finally from the packaged Desktop install's own CLI launcher under the Electron resource directory (`runtime/cli/bin/dsh.cmd` on Windows, `runtime/cli/bin/dsh` elsewhere) — the last one covers a packaged Desktop, where the host runs from inside `app.asar`, the private host package ships no `lib/bin.js`, every `.bin` shim directory is stripped from the installer, and the launcher puts only the bundled `node` on the host's PATH. A Node-script CLI (an npm or homebrew shim, a `.bin` symlink, a `lib/bin.js`) runs under an interpreter resolved without PATH: the `node` installed beside the CLI when the installation ships one, otherwise the host's own interpreter. The CLI's own directory goes first on the child PATH, so the `dsh plugin` run finds the pnpm installed beside it. If no source contains the CLI, CLI-backed writes remain unavailable — an application-owned profile writes through the official in-process manager and needs no binary, so its install, update and removal routes never demand one. CLI output is decoded as bytes in one pass, so a Windows console's code page (CP936/GBK) renders as readable text instead of replacement characters. Installs of git sources can take minutes and run as background jobs. Gateway updates apply only to npm registry sources, resolve the latest version on the host, and succeed only after the same installed package reports that exact version.
|
|
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. Every other runtime keeps the CLI as the single writer of installs, updates and removals.
|
|
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.
|
|
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
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's own recovery dialog is the only restart it offers — so that confirmation says what its dialog does before running it: confirming stops the host, the shell shows its error-titled dialog, and the dialog's Restart finishes `app.relaunch()` (a crash report is written with it); the manual way out, quitting DeepSeek Harness and opening it again, is named beside it. 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).
|
package/README.zh.md
CHANGED
|
@@ -67,9 +67,9 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
|
|
|
67
67
|
## 已知限制
|
|
68
68
|
|
|
69
69
|
- 仅限本机:LAN 或远程浏览器只显示「仅限本机操作」提示(与官方安装器页同一边界;网关对非 loopback 请求返回 403)。
|
|
70
|
-
- npm 发布的官方 web 上,网关写入经官方 CLI 执行。网关先从 host 进程 PATH 解析 `dsh`,再从运行中 host 入口上层各项目根的 `node_modules/.bin`
|
|
70
|
+
- npm 发布的官方 web 上,网关写入经官方 CLI 执行。网关先从 host 进程 PATH 解析 `dsh`,再从运行中 host 入口上层各项目根的 `node_modules/.bin` 回退查找,然后回退到运行中 host 包自身的 `lib/bin.js`,最后回退到桌面安装包自带的 CLI 启动器(位于 Electron 资源目录下:Windows 为 `runtime/cli/bin/dsh.cmd`,其他平台为 `runtime/cli/bin/dsh`)——最后这条覆盖打包桌面端:host 从 `app.asar` 内运行、私有 host 包不带 `lib/bin.js`、安装包剥除所有 `.bin` shim 目录,且启动器只把自带的 `node` 放进 host 的 PATH;Node 脚本形式的 CLI(npm/homebrew shim、`.bin` 符号链接、`lib/bin.js`)由不依赖 PATH 的解释器执行——安装包里 CLI 旁有 `node` 时用它,否则用 host 自身的解释器;CLI 所在目录放在子进程 PATH 首位,使 `dsh plugin` 运行能找到同处安装的 pnpm。全部来源都没有 CLI 时,走 CLI 的写入才不可用——应用自有 profile 由官方进程内管理器写入,不需要任何二进制,其安装、更新与卸载路由也不要求它。CLI 输出按字节一次性解码,Windows 中文控制台(CP936/GBK)的报错文本可读而不再是替换字符。git 源安装可能耗时数分钟,以后台任务运行。网关更新只适用于 npm registry 源,由 host 解析最新版本,且仅当同一已装包报告该精确版本时才算成功。
|
|
71
71
|
- 应用自有 profile(打包桌面客户端)的安装、更新与卸载走宿主挂载的官方进程内插件管理器——即该 profile 官方插件页所用的同一个写入器:CLI 直接拒绝 `--profile desktop`,启动器则把自带的包管理器调用交给该管理器。任务、状态轮询与校验与 CLI 路径一致:安装必须新增一条此前没有的依赖、卸载必须删除一条依赖、更新必须报告路由解析出的版本;而 CLI 专属的守卫(重复挂载剥离、insert 行与启动预检)仍留在 CLI 写入器一侧,因为该路径下官方管理器会自行校验并应用 bundle。管理器返回的判定会先于 profile 被读取:被拒绝的运行以 `application: 'failed'` 解析而不是抛错,因此任务上报该运行的真实原因(pnpm 诊断文本,或 `incompatible-version` 拒绝点名的包),而不是在 profile 未变之后给出一句空转文案。其余运行时的安装、更新与卸载仍以 CLI 为唯一写入器。
|
|
72
|
-
- 兼容性门禁只在目标清单声明了最低 DSH 版本时生效;未声明 `dsh.engines.dsh` 的包更新不被检查,官方安装器运行时(DSHCode 与 checkout 版 web
|
|
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
74
|
- 重启是显式、需用户点击且有三种模式的动作,路由按方法区分:`GET /api/plugin-manager/restart` 只读「重启方案」(无副作用,因此浏览器预取或直接输入 URL 都不会停掉宿主),`POST` 才执行;其他方法一律 405 拒绝。工具条先读方案,确认面板说的后果与实际执行的一致。终端启动(`dsh web`)时宿主启动一个 detached helper:等旧进程退出后按原命令行重新拉起,端口先释放再被替换进程绑定,替换进程的输出写入 `$DSH_HOME/logs/plugin-manager-restart.log`。打包桌面应用下本插件无法重启任何东西——进程树归 Electron,detached 重拉只会与桌面外壳抢同一端口,而外壳只提供它自己的恢复对话框这一条重启路径——因此那里的确认面板会先写明该对话框会做什么:确认后宿主退出,外壳弹出错误样式的「应用无法启动或已意外停止」对话框,在对话框里点「重启」即完成 `app.relaunch()`(同时写一份崩溃报告);旁边给出替代路径——退出 DeepSeek Harness 后重新打开。无终端的启动(受监督进程、编辑器任务)保持不动,工具条提示手动重启。不重启时,更新后的插件代码在下次启动生效。
|
|
75
75
|
- npm 运行时上重复 insert id 认领在安装后即被检出并自动回滚新插件(共享 id 写 disabled 无法阻止 loader 的重复检查,只会误伤现有插件)。
|
package/lib/client.js
CHANGED
|
@@ -185,6 +185,7 @@ window.__ModuleLoader__.load({
|
|
|
185
185
|
});
|
|
186
186
|
const requiresDsh = found?.requiresDsh;
|
|
187
187
|
const blocked = found?.compatible === false;
|
|
188
|
+
const unverified = blocked && found?.hostVersion === void 0;
|
|
188
189
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
189
190
|
className: plugin_manager_module_css_default.section,
|
|
190
191
|
"data-update-patch": true,
|
|
@@ -216,7 +217,8 @@ window.__ModuleLoader__.load({
|
|
|
216
217
|
found !== void 0 && requiresDsh !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
217
218
|
className: blocked ? plugin_manager_module_css_default.compatBlocked : plugin_manager_module_css_default.compatHint,
|
|
218
219
|
"data-update-compat": blocked ? "blocked" : "ok",
|
|
219
|
-
|
|
220
|
+
"data-update-compat-reason": blocked ? unverified ? "unverified" : "below-minimum" : void 0,
|
|
221
|
+
children: !blocked ? t("updateRequiresDsh", { min: displayMinimumVersion(requiresDsh) }) : unverified ? t("updateUnverifiedDsh", { min: displayMinimumVersion(requiresDsh) }) : t("updateBlockedDsh", { min: displayMinimumVersion(requiresDsh) })
|
|
220
222
|
}),
|
|
221
223
|
found !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
222
224
|
type: "button",
|
|
@@ -619,7 +621,8 @@ window.__ModuleLoader__.load({
|
|
|
619
621
|
}),
|
|
620
622
|
row.compatible === false && row.requiresDsh !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
621
623
|
className: plugin_manager_module_css_default.compatBlocked,
|
|
622
|
-
|
|
624
|
+
"data-update-row-compat-reason": row.hostVersion === void 0 ? "unverified" : "below-minimum",
|
|
625
|
+
children: row.hostVersion === void 0 ? t("updateUnverifiedDsh", { min: displayMinimumVersion(row.requiresDsh) }) : t("updateBlockedDsh", { min: displayMinimumVersion(row.requiresDsh) })
|
|
623
626
|
})
|
|
624
627
|
]
|
|
625
628
|
}, row.id))
|
|
@@ -758,6 +761,7 @@ window.__ModuleLoader__.load({
|
|
|
758
761
|
"latest": "最新 {version}",
|
|
759
762
|
"updateRequiresDsh": "需要 DSH ≥ {min}",
|
|
760
763
|
"updateBlockedDsh": "需要 DSH ≥ {min},请先升级 DSH 再更新",
|
|
764
|
+
"updateUnverifiedDsh": "无法确认本机 DSH 版本(需要 DSH ≥ {min}),已暂停更新",
|
|
761
765
|
"restartHint": "插件变更将在重启应用后生效。",
|
|
762
766
|
"updatesAvailable": "{count} 个可更新",
|
|
763
767
|
"updateAll": "全部更新({count})",
|
|
@@ -796,6 +800,7 @@ window.__ModuleLoader__.load({
|
|
|
796
800
|
"latest": "Latest {version}",
|
|
797
801
|
"updateRequiresDsh": "Requires DSH >= {min}",
|
|
798
802
|
"updateBlockedDsh": "Requires DSH >= {min}; upgrade DSH before updating",
|
|
803
|
+
"updateUnverifiedDsh": "Cannot confirm the local DSH version (this update needs DSH >= {min}); update paused",
|
|
799
804
|
"restartHint": "Plugin changes take effect after restarting the application.",
|
|
800
805
|
"updatesAvailable": "{count} updates available",
|
|
801
806
|
"updateAll": "Update all ({count})",
|
|
@@ -925,6 +930,10 @@ window.__ModuleLoader__.load({
|
|
|
925
930
|
if (typeof update.compatible !== "boolean") throw new Error(`plugin-manager: update row ${String(index)} is invalid`);
|
|
926
931
|
row.compatible = update.compatible;
|
|
927
932
|
}
|
|
933
|
+
if (update.hostVersion !== void 0) {
|
|
934
|
+
if (!isString(update.hostVersion)) throw new Error(`plugin-manager: update row ${String(index)} is invalid`);
|
|
935
|
+
row.hostVersion = update.hostVersion;
|
|
936
|
+
}
|
|
928
937
|
return row;
|
|
929
938
|
});
|
|
930
939
|
}
|
|
@@ -974,7 +983,7 @@ window.__ModuleLoader__.load({
|
|
|
974
983
|
/** The building package's version, when the bundle carries it. */
|
|
975
984
|
function bakedVersion() {
|
|
976
985
|
try {
|
|
977
|
-
return "0.4.
|
|
986
|
+
return "0.4.6";
|
|
978
987
|
} catch {
|
|
979
988
|
return;
|
|
980
989
|
}
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["messageOf","css","css","css"],"sources":["../../../packages/dsh-plugin-manager/src/core/version.ts","../../../packages/dsh-plugin-manager/src/client/PluginUpdatePatch.tsx","../../../packages/dsh-plugin-manager/src/client/body-mutations.ts","../../../packages/dsh-plugin-manager/src/core/updates.ts","../../../packages/dsh-plugin-manager/src/client/PluginListToolbar.tsx","../../../packages/dsh-plugin-manager/src/client/plugin-toolbar-mount.tsx","../../../packages/dsh-plugin-manager/src/client/locales.ts","../../../packages/dsh-plugin-manager/src/core/protocol.ts","../../../packages/dsh-plugin-manager/src/core/service.ts","../../../packages/dsh-plugin-manager/src/client/telemetry.ts","../../../packages/dsh-plugin-manager/src/client/index.ts"],"sourcesContent":["/**\n * DSH host version parsing and comparison for the update compatibility\n * check. The declared minimum lives in the published package manifest under\n * `dsh.engines.dsh`, falling back to the top-level `engines.dsh`; the only\n * supported form is `>=X.Y.Z[-prerelease]`.\n *\n * Comparison deliberately uses plain semver ordering instead of\n * `semver.satisfies`: npm's prerelease rule only allows a prerelease version\n * to satisfy a comparator set carrying a prerelease on the same\n * major.minor.patch tuple, which would reject a newer host line (0.1.1-rc.2)\n * against a declared `>=0.1.0-rc.8` — exactly the cross-cohort upgrade path\n * this check must allow. Everything here is pure and tolerant of untrusted\n * input: a malformed value means \"cannot verify\", which the callers treat as\n * a fail-closed verdict when a requirement was declared (issue #754).\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\n/** One parsed DSH host or package version. */\nexport interface DshVersion {\n major: number\n minor: number\n patch: number\n /** Prerelease identifiers, numeric identifiers kept as numbers (semver order). */\n prerelease: readonly (number | string)[]\n}\n\nconst VERSION_PATTERN = /^v?(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z.-]+))?$/\n\n/**\n * Parse a DSH host or package version string.\n * @param value - e.g. `0.1.0-rc.8`, `v1.2.3`.\n * @returns the parsed version, or undefined when malformed.\n */\nexport function parseDshVersion(value: string): DshVersion | undefined {\n const match = VERSION_PATTERN.exec(value.trim())\n if (match === null) return undefined\n const prereleaseParts = match[4] === undefined ? [] : match[4].split('.')\n if (prereleaseParts.some(part => part === '')) return undefined\n return {\n major: Number(match[1]),\n minor: Number(match[2]),\n patch: Number(match[3]),\n prerelease: prereleaseParts.map(part => /^\\d+$/.test(part) ? Number(part) : part),\n }\n}\n\n/**\n * Compare two version strings by semver order (a release is newer than any\n * prerelease of the same tuple).\n * @returns -1 / 0 / 1, or undefined when either side is malformed.\n */\nexport function compareVersions(left: string, right: string): number | undefined {\n const a = parseDshVersion(left)\n const b = parseDshVersion(right)\n if (a === undefined || b === undefined) return undefined\n for (const key of ['major', 'minor', 'patch'] as const) {\n if (a[key] !== b[key]) return a[key] < b[key] ? -1 : 1\n }\n return comparePrerelease(a.prerelease, b.prerelease)\n}\n\n/**\n * Semver prerelease ordering: numeric identifiers compare numerically,\n * numeric identifiers rank below alphanumeric ones, alphanumeric identifiers\n * compare lexically, and a longer list wins when the shared prefix is equal.\n */\nfunction comparePrerelease(left: readonly (number | string)[], right: readonly (number | string)[]): number {\n if (left.length === 0 && right.length === 0) return 0\n if (left.length === 0) return 1\n if (right.length === 0) return -1\n const length = Math.max(left.length, right.length)\n for (let index = 0; index < length; index += 1) {\n const a = left[index]\n const b = right[index]\n if (a === undefined) return -1\n if (b === undefined) return 1\n if (typeof a === 'number' && typeof b === 'number') {\n if (a !== b) return a < b ? -1 : 1\n } else if (typeof a === 'number') {\n return -1\n } else if (typeof b === 'number') {\n return 1\n } else if (a !== b) {\n return a < b ? -1 : 1\n }\n }\n return 0\n}\n\nconst MINIMUM_RANGE_PATTERN = /^>=\\s*(v?\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?)$/\n\n/**\n * Whether a host version satisfies a declared `>=X.Y.Z[-prerelease]` minimum.\n * @param host - the running DSH host version.\n * @param minimum - the declared minimum; any form other than `>=<semver>`\n * (plain semver, `^`, `~`, multi-comparator ranges, empty) returns undefined.\n * @returns true / false, or undefined when the host version is malformed or\n * the minimum uses an unsupported form — callers treat undefined as\n * \"cannot verify\" and fail closed for declared requirements.\n */\nexport function meetsMinimumDsh(host: string, minimum: string): boolean | undefined {\n const match = MINIMUM_RANGE_PATTERN.exec(minimum.trim())\n if (match === null) return undefined\n const compared = compareVersions(host, match[1])\n if (compared === undefined) return undefined\n return compared >= 0\n}\n\n/**\n * The bare minimum version for display: strips the `>=` operator (and an\n * optional leading `v`) from a declared requirement so UI copy that already\n * contains the comparison operator renders `0.1.1-rc.1` instead of\n * `>= >=0.1.1-rc.1`. Unsupported range forms render unchanged.\n * @param minimum - the declared minimum range.\n * @returns the version portion for display.\n */\nexport function displayMinimumVersion(minimum: string): string {\n const match = MINIMUM_RANGE_PATTERN.exec(minimum.trim())\n return match === null ? minimum.trim() : match[1].replace(/^v/, '')\n}\n\n/**\n * Read the declared DSH minimum from a published registry manifest:\n * `dsh.engines.dsh` first, top-level `engines.dsh` next, and\n * `peerDependencies[\"@deepseek-ai/dsh\"]` last, which is where a package that\n * only declares the host as a peer still gets gated at boot.\n * Defensive against malformed or untrusted metadata: anything that is not a\n * non-empty string reads as absent.\n * @param manifest - the decoded registry version manifest.\n * @returns the declared minimum, or undefined when not declared.\n */\nexport function dshRequirementOf(manifest: { dsh?: unknown; engines?: unknown; peerDependencies?: unknown }): string | undefined {\n const dshEngines = (manifest.dsh as { engines?: unknown } | undefined)?.engines as { dsh?: unknown } | undefined\n const engines = (manifest.engines as { dsh?: unknown } | undefined)?.dsh\n const peers = (manifest.peerDependencies as Record<string, unknown> | undefined)?.['@deepseek-ai/dsh']\n // The host's own peer gate is the LAST word: a package that declares the\n // host only under peerDependencies still gets that row skipped at boot when\n // the floor is not met, so a requirement we display must come from the same\n // place the gate reads, or the user is told nothing and then loses the row.\n const value = dshEngines?.dsh ?? engines ?? peers\n return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined\n}\n","/**\n * The check-for-updates patch contributed to the official Plugins page.\n *\n * This package used to own a \"Plugin manager\" tab inside the Plugins settings\n * section (`settings.plugins.tab`). Installing, uninstalling, enabling and\n * disabling moved to the official plugin manager page long ago, and the tab's\n * remaining half (read-only inventory, install-conflict ledger, boot-failure\n * repair conversation, safe-mode banner) is UI no official page renders. It is\n * gone; the one capability the official page still lacks is comparing an\n * installed plugin against its registry source.\n *\n * So this package now contributes exactly that, into the seat the official\n * Plugins page declares for contributed sections (`plugins.detail.section`,\n * a root-scope list rendered on every bundle / row / official-plugin page with\n * the page's `subject`). The official page owns the page chrome; this entry\n * renders one compact block, only on an installed bundle's page, drawing only\n * a plain button and its own section so it carries no dependency on the\n * official primitives bundle.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\nimport { useEffect, useRef, useState } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { InstallProgressItem, PluginUpdateItem } from '../core/protocol.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport css from './plugin-manager.module.css'\n\n/** One loader row of a bundle, as the official page's subject carries it. */\nexport interface PluginPageRowRef {\n rowId: string\n moduleName: string\n enabled: boolean\n}\n\n/** One bundle, as the official page's subject carries it. */\nexport interface PluginPageBundleRef {\n name: string\n version?: string\n installed: boolean\n enabled: boolean\n rows: readonly PluginPageRowRef[]\n}\n\n/**\n * The subject the official Plugins page renders a contributed section with:\n * its bundle page, its row page, or an official plugin's page. This package\n * only speaks to the bundle case.\n */\nexport type PluginPageSubject =\n | { kind: 'bundle'; pkg: PluginPageBundleRef }\n | { kind: 'row'; pkg: PluginPageBundleRef; row: PluginPageRowRef }\n | { kind: 'item'; id: string }\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface SlotMap {\n /**\n * One section contributed under a Plugins page's own content. Declared at\n * runtime by the official plugin-manager page's `main` registration; the\n * type is re-declared here, identically, so this package can register into\n * it without importing the page (the same way family plugins re-declare\n * `plugins.bundle.config`).\n */\n 'plugins.detail.section': {\n kind: 'list'\n scope: 'root'\n owner: { subject: PluginPageSubject }\n }\n }\n}\n\n/** Registration-side wire face the patch consumes. */\nexport interface PluginUpdatePatchInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n isLoopback: boolean\n /** Compare every installed plugin against the version its source serves. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /** Re-install one plugin from its recorded source. */\n update: (id: string) => Promise<unknown>\n /** Read the current install/update progress. */\n status: () => Promise<InstallProgressItem>\n}\n\n/** Full component props assembled by the Plugins page's section renderer. */\nexport type PluginUpdatePatchProps =\n PropsRuntime<'plugins.detail.section'>\n & PropsLocale<'settings.pluginManager'>\n & InjectFace<PluginUpdatePatchInjected>\n\n/** Error text for a caught request or lifecycle failure. */\nfunction messageOf(error: unknown): string {\n if (error instanceof AggregateError) {\n const details = error.errors.map(messageOf).join('; ')\n return details === '' ? error.message : `${error.message}: ${details}`\n }\n return error instanceof Error ? error.message : String(error)\n}\n\n/** Localized label for one install phase, with percent when the download has one. */\nfunction progressLabel(progress: InstallProgressItem, t: PluginUpdatePatchProps['t']): string {\n if (progress.stage === 'write') return t('writing')\n return progress.percent === undefined ? t('downloading') : t('downloadingPercent', { percent: String(progress.percent) })\n}\n\n/**\n * The update block on one official Plugins page: one check action, the verdict\n * for this page's bundle, and the update action it unlocks. The check is\n * explicit rather than automatic because one check reads every installed\n * plugin's registry manifest; a page visit must not fan that out.\n */\nexport function PluginUpdatePatch(props: PluginUpdatePatchProps) {\n const { t, subject, isLoopback, checkUpdates, update, status } = props\n\n const [checked, setChecked] = useState(false)\n const [found, setFound] = useState<PluginUpdateItem | undefined>(undefined)\n const [busy, setBusy] = useState<'check' | 'update' | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [progress, setProgress] = useState<InstallProgressItem>({ kind: 'idle', stage: 'fetch' })\n const [dirty, setDirty] = useState(false)\n /** Synchronous in-flight mirror of `busy`: the render guard alone lets a click and an Enter land in the same frame and double-fire. */\n const busyRef = useRef(false)\n\n const name = subject.kind === 'bundle' ? subject.pkg.name : undefined\n const installed = subject.kind === 'bundle' && subject.pkg.installed\n\n /** Poll update progress while an update is in flight. */\n useEffect(() => {\n if (busy !== 'update') {\n setProgress({ kind: 'idle', stage: 'fetch' })\n return\n }\n let stopped = false\n let timer: ReturnType<typeof setTimeout> | undefined\n const tick = (delay: number): void => {\n timer = setTimeout(() => {\n void status().then(next => {\n if (!stopped && next !== undefined) {\n setProgress(next)\n tick(400)\n }\n }).catch(() => { /* polling fails silently; the update itself owns the error row */ })\n }, delay)\n }\n tick(100)\n return () => {\n stopped = true\n if (timer !== undefined) clearTimeout(timer)\n }\n }, [busy, status])\n\n if (name === undefined || !installed) return null\n\n const onCheck = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setBusy('check')\n setError(undefined)\n void checkUpdates().then(items => {\n setFound(items.find(item => item.id === name))\n setChecked(true)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n setBusy(undefined)\n })\n }\n\n const onUpdate = (): void => {\n if (busyRef.current || found === undefined) return\n busyRef.current = true\n setBusy('update')\n setError(undefined)\n void update(found.id).then(() => {\n setFound(undefined)\n setChecked(false)\n setDirty(true)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n setBusy(undefined)\n })\n }\n\n if (!isLoopback) {\n return (\n <section className={css.notice} data-update-patch data-state=\"local-only\">\n <strong>{t('localOnlyTitle')}</strong>\n <p>{t('localOnlyBody')}</p>\n </section>\n )\n }\n\n const requiresDsh = found?.requiresDsh\n const blocked = found?.compatible === false\n\n return (\n <section className={css.section} data-update-patch aria-busy={busy !== undefined}>\n <h3 className={css.title}>{t('updateSection')}</h3>\n <div className={css.actionRow}>\n <button\n type=\"button\"\n className={css.button}\n disabled={busy !== undefined}\n onClick={onCheck}\n >\n {busy === 'check' ? t('checking') : t('checkUpdates')}\n </button>\n {checked && found === undefined && busy === undefined && (\n <p className={css.ok}>{t('noUpdates')}</p>\n )}\n {found !== undefined && (\n <span className={css.latest} data-update-latest={found.latest}>{t('latest', { version: found.latest })}</span>\n )}\n {found !== undefined && requiresDsh !== undefined && (\n <span className={blocked ? css.compatBlocked : css.compatHint} data-update-compat={blocked ? 'blocked' : 'ok'}>\n {blocked\n ? t('updateBlockedDsh', { min: displayMinimumVersion(requiresDsh) })\n : t('updateRequiresDsh', { min: displayMinimumVersion(requiresDsh) })}\n </span>\n )}\n {found !== undefined && (\n <button\n type=\"button\"\n className={`${css.button} ${css.primary}`}\n disabled={busy !== undefined || blocked}\n onClick={onUpdate}\n >\n {busy === 'update' ? t('updating') : t('update')}\n </button>\n )}\n </div>\n\n {busy === 'update' && (\n <div className={css.progressRow} role=\"status\">\n <div className={css.progressTrack}>\n <div\n className={css.progressBar}\n style={progress.percent === undefined ? undefined : { width: `${String(progress.percent)}%` }}\n data-indeterminate={progress.percent === undefined ? 'true' : undefined}\n />\n </div>\n <p className={css.hint}>{progressLabel(progress, t)}</p>\n </div>\n )}\n\n {error !== undefined && (\n <p className={css.error} role=\"alert\" data-update-error>{error}</p>\n )}\n\n {dirty && (\n <div className={css.restartRow}>\n <p>{t('restartHint')}</p>\n </div>\n )}\n </section>\n )\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/body-mutations.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * One `document.body` MutationObserver per page, shared by every family\n * plugin bundle.\n *\n * Family plugins that inject at the DOM level must notice when the shell\n * re-renders around their injected node: the aggregate shell's column shims\n * and any plugin surface still extending the shell from outside the official\n * slot seats. Each consumer used to install its OWN `MutationObserver` on\n * `document.body` with\n * `{ childList: true, subtree: true }`, so a page carrying N family plugins\n * paid N native observers and N callback invocations for EVERY mutation batch\n * the app produced — chat token streaming alone produces many per second, and\n * the count grows with the number of installed plugins.\n *\n * This module keeps exactly ONE body observer per page. The registry lives on\n * `globalThis` under a `Symbol.for` key, so the per-package generated copies\n * of this file (scripts/sync-shared.mjs) and separately bundled plugins all\n * reach the same hub at runtime instead of one hub per module instance.\n * Record subscribers receive the mutations accumulated since the last flush.\n * Consumers that only re-check their DOM use subscribeBodyInvalidations:\n * when all subscribers use that path, the hub retains no mutation records\n * (or detached subtrees) while a background page's animation frames pause.\n * Both paths run at most once per frame. The last subscriber disconnects the\n * observer, cancels the pending frame and releases its records.\n *\n * Failure policy: without a DOM or `MutationObserver` the subscription is a\n * no-op disposer (the same silence the per-consumer observers had), and when\n * `requestAnimationFrame` is unavailable the flush runs synchronously so a\n * subscriber is never silently dropped. A throwing subscriber cannot stop the\n * others.\n */\n\n/** The page-wide hub: one observer plus its subscribers and pending records. */\ninterface BodyMutationHub {\n observer: MutationObserver\n subscribers: Set<(records: MutationRecord[]) => void>\n pending: MutationRecord[]\n scheduled: boolean\n frame?: number\n}\n\n/** Cross-bundle registry key; `Symbol.for` so every module copy agrees. */\nconst HUB_KEY = Symbol.for('dsh-web.body-mutation-hub')\nconst INVALIDATION_ONLY = Symbol.for('dsh-web.body-mutation-invalidation')\ntype Subscriber = ((records: MutationRecord[]) => void) & { [INVALIDATION_ONLY]?: true }\n\nfunction needsRecords(subscribers: Set<(records: MutationRecord[]) => void>): boolean {\n for (const listener of subscribers) {\n if (!(listener as Subscriber)[INVALIDATION_ONLY]) return true\n }\n return false\n}\n\n/**\n * Subscribe to a coalesced DOM re-check without retaining mutation records.\n * The marked wrapper also works with an older hub, which delivers records\n * that it simply ignores until a page reload picks up the updated hub.\n */\nexport function subscribeBodyInvalidations(subscriber: () => void): () => void {\n const listener: Subscriber = () => { subscriber() }\n listener[INVALIDATION_ONLY] = true\n return subscribeBodyMutations(listener)\n}\n\n/**\n * Subscribe to body-level childList mutations.\n * @param subscriber - called at most once per animation frame with the records\n * collected since the previous flush; must be safe to run repeatedly.\n * @returns the disposer removing this subscriber (and the observer when it was\n * the last one).\n */\nexport function subscribeBodyMutations(subscriber: (records: MutationRecord[]) => void): () => void {\n if (typeof globalThis === 'undefined' || typeof document === 'undefined') return () => {}\n if (typeof MutationObserver !== 'function') return () => {}\n const registry = globalThis as unknown as Record<symbol, unknown>\n let hub = registry[HUB_KEY] as BodyMutationHub | undefined\n if (hub === undefined) {\n const subscribers = new Set<(records: MutationRecord[]) => void>()\n const created: BodyMutationHub = {\n observer: undefined as unknown as MutationObserver,\n subscribers,\n pending: [],\n scheduled: false,\n }\n const flush = (): void => {\n created.frame = undefined\n created.scheduled = false\n const batch = created.pending\n created.pending = []\n for (const listener of [...subscribers]) {\n if (!subscribers.has(listener)) continue\n try {\n listener(batch)\n } catch {\n // One subscriber must never break the others; the next flush retries it.\n }\n }\n }\n const schedule = (): void => {\n if (created.scheduled) return\n created.scheduled = true\n if (typeof requestAnimationFrame === 'function') created.frame = requestAnimationFrame(flush)\n else flush()\n }\n created.observer = new MutationObserver((records) => {\n if (needsRecords(subscribers)) {\n for (const record of records) created.pending.push(record)\n }\n schedule()\n })\n created.observer.observe(document.body ?? document.documentElement, { childList: true, subtree: true })\n registry[HUB_KEY] = created\n hub = created\n }\n const active = hub\n active.subscribers.add(subscriber)\n let subscribed = true\n return () => {\n if (!subscribed) return\n subscribed = false\n active.subscribers.delete(subscriber)\n if (!needsRecords(active.subscribers)) active.pending = []\n if (active.subscribers.size === 0 && registry[HUB_KEY] === active) {\n active.observer.disconnect()\n if (active.frame !== undefined && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(active.frame)\n active.frame = undefined\n active.pending = []\n active.scheduled = false\n delete registry[HUB_KEY]\n }\n }\n}\n","/**\n * Which update rows the list-level toolbar may act on. Pure, shared by the\n * browser half (the toolbar) and its tests: the host answers with every\n * installed package whose registry source serves a newer release, and the\n * policy of what may be updated in bulk lives here rather than in the host,\n * so the same rows stay available to the per-page update block.\n *\n * Two filters:\n *\n * - **Third-party only.** A package published under the `@deepseek-ai/` scope\n * ships with DSH itself: its version is chosen by the running installation,\n * the official page says an upgrade arrives by upgrading DSH, and a\n * plugin-initiated `pnpm add` of such a package can pull a release the runtime was\n * never tested against. The bulk action therefore never touches it.\n * - **Compatibility gate.** An update whose manifest declares a DSH minimum the\n * running host does not satisfy is listed (the user may still upgrade DSH)\n * but cannot be applied: the host would refuse it with 412 anyway.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { PluginUpdateItem } from './protocol.ts'\n\n/** The npm scope DSH's own packages are published under. */\nexport const OFFICIAL_SCOPE = '@deepseek-ai/'\n\n/** Whether a package id is a third-party plugin rather than a DSH-shipped one. */\nexport function isThirdPartyPlugin(id: string): boolean {\n return !id.startsWith(OFFICIAL_SCOPE)\n}\n\n/** The third-party update rows, in host order. */\nexport function thirdPartyUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[] {\n return items.filter(item => isThirdPartyPlugin(item.id))\n}\n\n/** Whether the running DSH host satisfies the row's declared minimum. */\nexport function isUpdateApplicable(item: PluginUpdateItem): boolean {\n return item.compatible !== false\n}\n\n/** The third-party rows this runtime can actually apply. */\nexport function applicableUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[] {\n return thirdPartyUpdates(items).filter(isUpdateApplicable)\n}\n","/**\n * The list-level toolbar: check every installed third-party plugin for a newer\n * registry release, apply them in one run, then restart DSH to load them.\n *\n * It exists because the official Plugins page compares one package at a time\n * (its `plugins.detail.section` contributions render on a bundle's page), while\n * the answer a user wants when they open the page is \"is anything of mine out\n * of date, and can I just fix it\". It is mounted beside the page's \"Installed\"\n * heading (see plugin-toolbar-mount.tsx) because that heading is the page's own\n * chrome and the page declares no seat next to it.\n *\n * Policy lives in core/updates.ts (third-party only, compatibility-gated) and\n * the operations come from the injected face, so this component is pure\n * rendering plus the sequence of calls: nothing here touches the DOM beyond its\n * own subtree.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PluginUpdateItem, RestartMode } from '../core/protocol.ts'\nimport { applicableUpdates, isUpdateApplicable, thirdPartyUpdates } from '../core/updates.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport css from './plugin-manager.module.css'\n\n/** The operations the toolbar drives (the package's dual-channel face). */\nexport interface PluginListToolbarInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n isLoopback: boolean\n /** Compare every installed plugin against the version its source serves. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /** Re-install one plugin from its recorded source. */\n update: (id: string) => Promise<unknown>\n /**\n * Read how a restart would be carried out, without carrying it out: the\n * confirmation must name the same consequence the host will produce (an\n * in-place relaunch, the packaged Desktop shell's own recovery dialog, or a\n * manual restart), and a plan read has no side effects.\n */\n restartPlan: () => Promise<RestartMode>\n /** Restart the host so an applied update is loaded. */\n restart: () => Promise<RestartMode>\n}\n\n/** Full component props. */\nexport type PluginListToolbarProps =\n & PropsLocale<'settings.pluginManager'>\n & PluginListToolbarInjected\n\n/** Error text for a caught request or lifecycle failure. */\nfunction messageOf(error: unknown): string {\n if (error instanceof AggregateError) {\n const details = error.errors.map(messageOf).join('; ')\n return details === '' ? error.message : `${error.message}: ${details}`\n }\n return error instanceof Error ? error.message : String(error)\n}\n\n/** What the toolbar is currently doing. */\ntype Phase = 'idle' | 'checking' | 'updating'\n\n/** Which flyout is open under the buttons. */\ntype Panel = 'none' | 'list' | 'restart'\n\n/**\n * The toolbar itself. All state is local: the page around it owns the plugin\n * list, and a restart tears this component down anyway.\n */\nexport function PluginListToolbar(props: PluginListToolbarProps) {\n const { t, isLoopback, checkUpdates, update, restartPlan, restart } = props\n\n const [phase, setPhase] = useState<Phase>('idle')\n const [checked, setChecked] = useState(false)\n /** Every third-party row the last check reported, including the applied ones. */\n const [found, setFound] = useState(0)\n const [rows, setRows] = useState<PluginUpdateItem[]>([])\n const [applied, setApplied] = useState<string[]>([])\n const [cursor, setCursor] = useState<{ name: string; index: number; total: number } | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [panel, setPanel] = useState<Panel>('none')\n /** How the host says it would restart, read before the confirmation is shown. */\n const [plan, setPlan] = useState<RestartMode | undefined>(undefined)\n const [restartMode, setRestartMode] = useState<RestartMode | undefined>(undefined)\n /** Synchronous in-flight mirror of the phase: a click and a keypress can land in one frame. */\n const busyRef = useRef(false)\n\n const pending = applicableUpdates(rows)\n\n /** Close the flyout on Escape, the shell's own dismissal gesture. */\n useEffect(() => {\n if (panel === 'none') return\n const onKey = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') setPanel('none')\n }\n window.addEventListener('keydown', onKey)\n return () => { window.removeEventListener('keydown', onKey) }\n }, [panel])\n\n const onCheck = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setPhase('checking')\n setError(undefined)\n setRestartMode(undefined)\n void checkUpdates().then(items => {\n const thirdParty = thirdPartyUpdates(items)\n setRows(thirdParty)\n setFound(thirdParty.length)\n setApplied([])\n setChecked(true)\n setPanel('list')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setPanel('list')\n }).finally(() => {\n busyRef.current = false\n setPhase('idle')\n })\n }\n\n const onUpdateAll = (): void => {\n if (busyRef.current) return\n const queue = applicableUpdates(rows)\n if (queue.length === 0) return\n busyRef.current = true\n setPhase('updating')\n setError(undefined)\n void (async () => {\n const done: string[] = []\n for (const [index, row] of queue.entries()) {\n setCursor({ name: row.id, index: index + 1, total: queue.length })\n try {\n await update(row.id)\n } catch (reason) {\n // Stop at the first failure: the remaining rows stay listed with their\n // versions, so the user sees exactly what did not go through.\n setError(t('failed', { reason: messageOf(reason) }))\n break\n }\n done.push(row.id)\n setApplied([...done])\n setRows(current => current.filter(item => item.id !== row.id))\n }\n setCursor(undefined)\n })().finally(() => {\n busyRef.current = false\n setPhase('idle')\n })\n }\n\n /** Ask the host how it would restart, then show the confirmation that matches. */\n const onAskRestart = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setError(undefined)\n void restartPlan().then(mode => {\n setPlan(mode)\n setPanel('restart')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setPanel('list')\n }).finally(() => {\n busyRef.current = false\n })\n }\n\n const onRestart = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setError(undefined)\n void restart().then(mode => {\n setRestartMode(mode)\n setPlan(undefined)\n setPanel('none')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n })\n }\n\n const shellProps = {\n 'data-dsh-plugin': 'plugin-manager',\n 'data-dsh-part': 'update-toolbar',\n 'data-update-toolbar': true,\n } as const\n\n if (!isLoopback) {\n return (\n <div className={css.toolbar} {...shellProps} data-state=\"local-only\">\n <button type=\"button\" className={css.toolbarButton} disabled title={t('localOnlyBody')}>\n {t('checkUpdates')}\n </button>\n </div>\n )\n }\n\n const busy = phase !== 'idle'\n /** One alert line, rendered in whichever flyout is open when it appears. */\n const errorLine = error === undefined\n ? null\n : <p className={css.error} role=\"alert\" data-update-error>{error}</p>\n /** What is still pending after a partial run (the applied rows leave the list). */\n const remaining = found - applied.length\n const summary = cursor !== undefined\n ? t('updatingAll', { name: cursor.name, index: String(cursor.index), total: String(cursor.total) })\n : remaining > 0\n ? t('updatesAvailable', { count: String(remaining) })\n : applied.length > 0\n ? t('updateAllDone')\n : t('noUpdates')\n\n return (\n <div className={css.toolbar} {...shellProps} data-state={restartMode ?? phase} aria-busy={busy}>\n <button type=\"button\" className={css.toolbarButton} data-update-check disabled={busy} onClick={onCheck}>\n {phase === 'checking' ? t('checking') : t('checkUpdates')}\n </button>\n\n {checked && (\n <button\n type=\"button\"\n className={css.toolbarSummary}\n data-update-summary\n data-pending={pending.length}\n aria-expanded={panel === 'list'}\n onClick={() => { setPanel(panel === 'list' ? 'none' : 'list') }}\n >\n {summary}\n </button>\n )}\n\n <button\n type=\"button\"\n className={applied.length > 0 ? `${css.toolbarButton} ${css.primary}` : css.toolbarButton}\n data-update-restart\n data-restart-pending={applied.length}\n disabled={busy || restartMode === 'relaunch'}\n onClick={() => { if (panel === 'restart') { setPanel('none'); setPlan(undefined); return } onAskRestart() }}\n >\n {restartMode === 'relaunch' ? t('restarting') : t('restartNow')}\n </button>\n\n {restartMode !== undefined && panel !== 'restart' && (\n <span className={css.toolbarHint} role=\"status\" data-update-restart-hint={restartMode}>\n {restartMode === 'shell' ? t('restartDesktopHint') : restartMode === 'manual' ? t('restartManualHint') : t('restartRelaunchHint')}\n </span>\n )}\n\n {panel === 'list' && (\n <div className={css.panel} data-update-panel role=\"group\" aria-label={t('updatesPanelTitle')}>\n {errorLine}\n {applied.length > 0 && <p className={css.ok} data-update-applied>{t('updateAllDone')}</p>}\n {rows.length === 0 && applied.length === 0 && error === undefined && <p className={css.hint}>{t('noUpdates')}</p>}\n {rows.length > 0 && (\n <ul className={css.panelList}>\n {rows.map(row => (\n <li key={row.id} className={css.panelRow} data-update-row={row.id} data-compatible={isUpdateApplicable(row) ? 'yes' : 'no'}>\n <span className={css.panelName}>{row.id}</span>\n <span className={css.panelVersion}>{row.current} → {row.latest}</span>\n {row.compatible === false && row.requiresDsh !== undefined && (\n <span className={css.compatBlocked}>{t('updateBlockedDsh', { min: displayMinimumVersion(row.requiresDsh) })}</span>\n )}\n </li>\n ))}\n </ul>\n )}\n <div className={css.panelActions}>\n {pending.length > 0 && (\n <button type=\"button\" className={`${css.button} ${css.primary}`} data-update-all disabled={busy} onClick={onUpdateAll}>\n {phase === 'updating' ? t('updating') : t('updateAll', { count: String(pending.length) })}\n </button>\n )}\n {applied.length > 0 && (\n <button type=\"button\" className={`${css.button} ${css.primary}`} data-update-panel-restart disabled={busy} onClick={onAskRestart}>\n {t('restartNow')}\n </button>\n )}\n </div>\n <p className={css.hint}>{t('thirdPartyOnly')}</p>\n </div>\n )}\n\n {panel === 'restart' && (\n <div className={css.panel} data-update-restart-panel data-restart-plan={plan} role=\"group\" aria-label={t('restartNow')}>\n {errorLine}\n <p className={css.hint} data-restart-plan-hint={plan}>\n {plan === 'shell' ? t('restartPlanShell') : plan === 'manual' ? t('restartPlanManual') : t('restartPlanRelaunch')}\n </p>\n {plan === 'shell' && <p className={css.hint}>{t('restartShellWarning')}</p>}\n <div className={css.panelActions}>\n <button type=\"button\" className={css.button} data-restart-cancel onClick={() => { setPanel('none'); setPlan(undefined) }}>\n {t('cancel')}\n </button>\n {plan !== 'manual' && (\n <button\n type=\"button\"\n className={`${css.button} ${css.primary}`}\n data-restart-confirm\n onClick={onRestart}\n >\n {t('restartConfirm')}\n </button>\n )}\n </div>\n </div>\n )}\n </div>\n )\n}\n","/**\n * Mounting the update toolbar beside the official Plugins page's \"Installed\"\n * heading.\n *\n * The page renders that heading itself — `<section data-plugin-group=\"bundles\">\n * <div class=\"groupHead\"><h3>Installed</h3><span>7</span></div>…` — and declares\n * no seat next to it: its extension points are `plugins.detail.*` (per page),\n * `plugins.bundle.config` / `plugins.row.config` / `plugins.item` (configuration\n * entries) and `plugins.bundle.activation`. A list-level action therefore has\n * to be inserted into the page's own chrome, the same way the sidebar foot card\n * is inserted above the Settings row.\n *\n * The container is a plain element carrying its own React root, so it can never\n * disturb the page's reconciliation, and it re-seats itself through the\n * page-wide body-mutation hub: a re-render that relocates or drops the heading\n * is followed on the next frame, and a panel switch that unmounts the list\n * simply detaches the container until the list returns.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { createElement } from 'react'\nimport { createRoot, type Root } from 'react-dom/client'\nimport { subscribeBodyInvalidations } from './body-mutations.ts'\nimport { PluginListToolbar, type PluginListToolbarProps } from './PluginListToolbar.tsx'\nimport css from './plugin-manager.module.css'\n\n/** Stable attribute identifying the injected container (mount idempotency). */\nexport const TOOLBAR_MOUNT_SELECTOR = '[data-dsh-plugin-manager-toolbar]'\n\n/** Toolbar props without the translate function, which is rebuilt per render. */\nexport type PluginListToolbarMountInput = Omit<PluginListToolbarProps, 't'> & {\n /** Translate in the namespace, read on every render so a language switch lands. */\n t: PluginListToolbarProps['t']\n}\n\n/** The mount's inputs. */\nexport interface PluginToolbarMountOptions {\n /** Build the toolbar props; called on mount and on every locale change. */\n props: () => PluginListToolbarMountInput\n /** Locale change subscription (ctx.locale.subscribe); re-renders the toolbar. */\n subscribe?: (listener: () => void) => () => void\n}\n\n/**\n * The official page's \"Installed\" group heading, when it is mounted. Class\n * names are CSS-module hashes in the official bundle, so the seat is found\n * through the page's own data attributes plus DOM position.\n * @returns the heading element to append into, or undefined off the list view.\n */\nexport function toolbarSeat(): HTMLElement | undefined {\n const page = document.querySelector('[data-plugin-panel]')\n const group = page?.querySelector('[data-plugin-group=\"bundles\"]')\n const head = group?.firstElementChild\n return head instanceof HTMLElement ? head : undefined\n}\n\n/**\n * Mount the toolbar into the Installed heading.\n * @param options - props factory and the optional locale subscription.\n * @returns disposer removing the container, its observers and its React root.\n */\nexport function mountPluginListToolbar(options: PluginToolbarMountOptions): () => void {\n if (typeof document === 'undefined') return () => {}\n // DOM-level idempotency: whatever path mounted a toolbar before this call\n // (a duplicated apply, an HMR re-injection), never mount a second one.\n if (document.querySelector(TOOLBAR_MOUNT_SELECTOR) !== null) return () => {}\n\n const container = document.createElement('div')\n container.setAttribute('data-dsh-plugin-manager-toolbar', '')\n container.className = css.mount\n const root: Root = createRoot(container)\n const render = (): void => {\n root.render(createElement(PluginListToolbar, options.props()))\n }\n render()\n\n /** Keep the container inside the heading; detach while the list is away. */\n const place = (): void => {\n const seat = toolbarSeat()\n if (seat === undefined) {\n container.remove()\n return\n }\n if (container.parentElement !== seat) seat.append(container)\n }\n place()\n\n const unsubscribeBody = subscribeBodyInvalidations(place)\n const unsubscribeLocale = options.subscribe === undefined ? ((): void => {}) : options.subscribe(render)\n\n return () => {\n unsubscribeBody()\n unsubscribeLocale()\n root.unmount()\n container.remove()\n }\n}\n","/**\n * Locale dictionaries for the plugin-manager's official-page patch. The zh\n * dictionary is the key source; the en dictionary mirrors the exact key set.\n *\n * The key set covers only what this package renders: the check-for-updates\n * block on a bundle's page in the official Plugins panel, and the list-level\n * update toolbar mounted beside that panel's \"Installed\" heading.\n * The former tab's keys (inventory, conflicts, repair seeds, safe mode,\n * aggregate children) left with that tab.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n/** Simplified Chinese copy (the key-set source of truth). */\nconst STATIC_ZH = {\n 'updateSection': '更新',\n 'checkUpdates': '检查更新',\n 'checking': '检查中…',\n 'noUpdates': '已是最新版本。',\n 'update': '更新',\n 'updating': '更新中…',\n 'latest': '最新 {version}',\n 'updateRequiresDsh': '需要 DSH ≥ {min}',\n 'updateBlockedDsh': '需要 DSH ≥ {min},请先升级 DSH 再更新',\n 'restartHint': '插件变更将在重启应用后生效。',\n 'updatesAvailable': '{count} 个可更新',\n 'updateAll': '全部更新({count})',\n 'updatingAll': '更新 {name}({index}/{total})',\n 'updateAllDone': '更新完成,重启后生效。',\n 'updatesPanelTitle': '插件更新',\n 'thirdPartyOnly': '只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。',\n 'restartNow': '立即重启',\n 'restarting': '正在重启…',\n 'restartConfirm': '确认重启',\n 'restartPlanRelaunch': '会重启 DSH 服务,正在运行的任务会中断。',\n 'restartPlanShell': '桌面版通过系统对话框重启:确认后会弹出官方的「应用无法启动或已意外停止」对话框,请在对话框中点「重启」。',\n 'restartPlanManual': '当前进程无法自动重启,请手动重启 DSH。',\n 'restartShellWarning': '它同时会写一份崩溃报告;也可以手动重启:退出 DeepSeek Harness(⌘Q)后重新打开。',\n 'restartDesktopHint': '请在随后出现的系统对话框中选择「重启」。',\n 'restartRelaunchHint': '已请求重启;服务恢复后刷新页面即可。',\n 'restartManualHint': '当前进程无法自动重启,请手动重启 DSH。',\n 'cancel': '取消',\n 'failed': '操作失败:{reason}',\n 'fetching': '正在获取插件信息…',\n 'downloading': '正在下载…',\n 'downloadingPercent': '正在下载 {percent}%',\n 'extracting': '正在解压…',\n 'writing': '正在写入配置…',\n 'localOnlyTitle': '仅限本机操作',\n 'localOnlyBody': '为了保护主机配置,插件管理只能从本机打开。'\n} satisfies Record<string, string>\n\n/** English copy, checked complete against the zh key set. */\nconst STATIC_EN = {\n 'updateSection': 'Update',\n 'checkUpdates': 'Check for updates',\n 'checking': 'Checking…',\n 'noUpdates': 'The installed version is the latest.',\n 'update': 'Update',\n 'updating': 'Updating…',\n 'latest': 'Latest {version}',\n 'updateRequiresDsh': 'Requires DSH >= {min}',\n 'updateBlockedDsh': 'Requires DSH >= {min}; upgrade DSH before updating',\n 'restartHint': 'Plugin changes take effect after restarting the application.',\n 'updatesAvailable': '{count} updates available',\n 'updateAll': 'Update all ({count})',\n 'updatingAll': 'Updating {name} ({index}/{total})',\n 'updateAllDone': 'Updated; restart to take effect.',\n 'updatesPanelTitle': 'Plugin updates',\n 'thirdPartyOnly': 'Third-party plugins only; @deepseek-ai/ packages upgrade with DSH itself.',\n 'restartNow': 'Restart now',\n 'restarting': 'Restarting…',\n 'restartConfirm': 'Restart',\n 'restartPlanRelaunch': 'The DSH service restarts; running tasks are interrupted.',\n 'restartPlanShell': 'The desktop app restarts through its system dialog: confirming shows the official \"DeepSeek Harness is unavailable\" dialog; click Restart in it.',\n 'restartPlanManual': 'This process cannot restart itself; restart DSH yourself.',\n 'restartShellWarning': 'It also writes a crash report. You can instead restart manually: quit DeepSeek Harness (Cmd+Q) and open it again.',\n 'restartDesktopHint': 'Choose Restart in the system dialog that follows.',\n 'restartRelaunchHint': 'Restart requested; reload the page once the server is back.',\n 'restartManualHint': 'This process cannot restart itself; restart DSH yourself.',\n 'cancel': 'Cancel',\n 'failed': 'Operation failed: {reason}',\n 'fetching': 'Fetching plugin metadata…',\n 'downloading': 'Downloading…',\n 'downloadingPercent': 'Downloading {percent}%',\n 'extracting': 'Extracting…',\n 'writing': 'Writing configuration…',\n 'localOnlyTitle': 'Available on this computer only',\n 'localOnlyBody': 'To protect host configuration, plugin management is only available from a local browser.'\n} satisfies Record<keyof typeof STATIC_ZH, string>\n\nexport const zh = STATIC_ZH\nexport const en = STATIC_EN\nexport type PluginManagerKey = keyof typeof STATIC_ZH\n","/**\n * Wire parsing for the official plugin-installer / plugin-control RPC\n * channels. This package is a browser-side consumer of those channels: every\n * response is decoded but untrusted, so each parser validates the shape it\n * needs and throws a typed error on mismatch. Callers treat a parse failure\n * as \"channel unavailable or drifted\" and degrade to command hints.\n *\n * The shapes mirror the official web installer tab's wire protocol (see the\n * DSH checkout's packages/client/ui-settings-plugin-installer/src/client/\n * protocol.ts); they are a contract observation, not an import.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\n/** One loader entry row claimed by an installed bundle package (aggregate child). */\nexport interface InstalledPluginChild {\n /** The loader entry id, e.g. web-ui-pet. */\n id: string\n /** Display name: the real plugin package (shell config.plugin) when known. */\n name: string\n /** Effective next-start enablement of this row alone (bundle default plus user override). */\n enabled: boolean\n /** Rows the manager must never disable (the manager tab itself, the compat face). */\n locked?: boolean\n}\n\n/** One installed user-plugin row served by `/plugin-installer list`. */\nexport interface InstalledPluginItem {\n id: string\n name: string\n version: string\n source: { kind: 'npm' | 'git'; spec: string }\n installedAt: string\n /** Effective next-start enablement across the bundle's own rows and the managed profile patch row. */\n enabled: boolean\n commit?: string\n /**\n * Entry rows this package's bundle patch claims, present when the package\n * is an aggregate claiming more than one row (gateway mode only — the\n * official channel wire has no children). Child enablement is individually\n * switchable; uninstall stays whole-package (the code ships in one npm\n * package).\n */\n children?: InstalledPluginChild[]\n}\n\n/**\n * How the host carried out (or refused) a restart request:\n * `relaunch` — this host re-executes itself in place; `shell` — the packaged\n * Desktop shell owns the process tree and runs its own restart; `manual` —\n * neither is safe here, the user restarts DSH themselves.\n */\nexport type RestartMode = 'relaunch' | 'shell' | 'manual'\n\n/** Point-in-time install/update progress reported by the host. */\nexport interface InstallProgressItem {\n kind: 'idle' | 'install' | 'update'\n stage: 'fetch' | 'download' | 'extract' | 'write'\n percent?: number\n}\n\n/** Whether an update row is a normal same-name update or a legacy package migration. */\nexport type PluginUpdateKind = 'update' | 'migrate'\n\n/** One plugin with a newer version available. */\nexport interface PluginUpdateItem {\n id: string\n current: string\n latest: string\n /** Normal same-name update or legacy aggregate migration. Defaults to update. */\n kind?: PluginUpdateKind\n /** Target package name when kind is migrate. */\n target?: string\n /** Exact target package version when kind is migrate. */\n targetVersion?: string\n /** Declared DSH minimum the update needs (package manifest's `dsh.engines.dsh`). */\n requiresDsh?: string\n /** Whether the running DSH host satisfies requiresDsh; absent when unknown. */\n compatible?: boolean\n}\n\n/** One recorded plugin boot failure served by the host. */\nexport interface PluginFailureItem {\n /** Installed plugin id (package name); empty for unattributable failures. */\n pluginId: string\n kind: 'load-failure' | 'hang' | 'late-rejection'\n message: string\n stack: string\n installPath: string\n at: string\n}\n\n/** Recovery facts served by the host: the failure ring, the plugin root, and safe mode. */\nexport interface PluginFailuresSnapshot {\n items: PluginFailureItem[]\n /** Absolute plugin install root — the repair conversation's workspace. */\n pluginRoot: string\n /** Whether the host is running in safe mode (user plugins skipped). */\n safeMode: boolean\n}\n\n/** Whether a decoded value is a non-array object. */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Whether a decoded value is a string. */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string'\n}\n\n/** Validate one aggregate child row. */\nfunction parsePluginChild(value: unknown, rowIndex: number, childIndex: number): InstalledPluginChild {\n if (!isRecord(value) || !isString(value.id) || !isString(value.name) || typeof value.enabled !== 'boolean') {\n throw new Error(`plugin-manager: plugin row ${String(rowIndex)} child ${String(childIndex)} is invalid`)\n }\n return {\n id: value.id,\n name: value.name,\n enabled: value.enabled,\n ...typeof value.locked === 'boolean' ? { locked: value.locked } : {},\n }\n}\n\n/** Validate one installed-plugin row. */\nfunction parsePlugin(value: unknown, index: number): InstalledPluginItem {\n if (!isRecord(value) || !isString(value.id) || !isString(value.name)\n || !isString(value.version) || !isString(value.installedAt)\n || typeof value.enabled !== 'boolean'\n || !isRecord(value.source) || (value.source.kind !== 'npm' && value.source.kind !== 'git')\n || !isString(value.source.spec)) {\n throw new Error(`plugin-manager: plugin row ${String(index)} is invalid`)\n }\n if (value.children !== undefined && !Array.isArray(value.children)) {\n throw new Error(`plugin-manager: plugin row ${String(index)} children is invalid`)\n }\n const children = (value.children as unknown[] | undefined)?.map((child, childIndex) => parsePluginChild(child, index, childIndex))\n return {\n id: value.id,\n name: value.name,\n version: value.version,\n source: { kind: value.source.kind, spec: value.source.spec },\n installedAt: value.installedAt,\n enabled: value.enabled,\n ...isString(value.commit) ? { commit: value.commit } : {},\n ...children !== undefined ? { children } : {},\n }\n}\n\n/**\n * Validate and normalize a `list` / `uninstall` response value.\n * @param value - decoded but untrusted response value.\n * @returns typed installed-plugin rows.\n */\nexport function parsePluginList(value: unknown): InstalledPluginItem[] {\n if (!isRecord(value) || !Array.isArray(value.plugins)) {\n throw new Error('plugin-manager: response must contain a plugins array')\n }\n return value.plugins.map((plugin, index) => parsePlugin(plugin, index))\n}\n\n/**\n * Validate and normalize an `install` / `update` / `set-enabled` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed installed-plugin row.\n */\nexport function parseInstalledPlugin(value: unknown): InstalledPluginItem {\n if (!isRecord(value) || value.plugin === undefined) {\n throw new Error('plugin-manager: response must contain a plugin row')\n }\n return parsePlugin(value.plugin, 0)\n}\n\n/**\n * Validate and normalize a `status` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed progress state.\n */\nexport function parseInstallStatus(value: unknown): InstallProgressItem {\n if (!isRecord(value) || !isRecord(value.progress)\n || (value.progress.kind !== 'idle' && value.progress.kind !== 'install' && value.progress.kind !== 'update')\n || (value.progress.stage !== 'fetch' && value.progress.stage !== 'download'\n && value.progress.stage !== 'extract' && value.progress.stage !== 'write')\n || (value.progress.percent !== undefined\n && (typeof value.progress.percent !== 'number' || !Number.isFinite(value.progress.percent)))) {\n throw new Error('plugin-manager: response must contain a valid progress state')\n }\n return {\n kind: value.progress.kind,\n stage: value.progress.stage,\n ...typeof value.progress.percent === 'number' ? { percent: value.progress.percent } : {},\n }\n}\n\n/**\n * Validate and normalize a `check-updates` response value.\n * @param value - decoded but untrusted response value.\n * @returns typed update rows.\n */\nexport function parseUpdateList(value: unknown): PluginUpdateItem[] {\n if (!isRecord(value) || !Array.isArray(value.updates)) {\n throw new Error('plugin-manager: response must contain an updates array')\n }\n return value.updates.map((update, index) => {\n if (!isRecord(update) || !isString(update.id) || !isString(update.current) || !isString(update.latest)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n const kind = update.kind === undefined ? 'update' : update.kind\n if (kind !== 'update' && kind !== 'migrate') {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n const row: PluginUpdateItem = { id: update.id, current: update.current, latest: update.latest }\n if (kind === 'migrate') {\n if (!isString(update.target) || !isString(update.targetVersion)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.kind = 'migrate'\n row.target = update.target\n row.targetVersion = update.targetVersion\n }\n if (update.requiresDsh !== undefined) {\n if (!isString(update.requiresDsh)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.requiresDsh = update.requiresDsh\n }\n if (update.compatible !== undefined) {\n if (typeof update.compatible !== 'boolean') {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.compatible = update.compatible\n }\n return row\n })\n}\n\n/**\n * Validate and normalize a `restart` response value.\n * @param value - decoded but untrusted response value.\n * @returns the mode the host actually used.\n */\nexport function parseRestartMode(value: unknown): RestartMode {\n const restart = isRecord(value) ? value.restart : undefined\n const mode = isRecord(restart) ? restart.mode : undefined\n if (mode !== 'relaunch' && mode !== 'shell' && mode !== 'manual') {\n throw new Error('plugin-manager: response must contain a restart mode')\n }\n return mode\n}\n\n/**\n * Validate and normalize a `failures` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed failures snapshot.\n */\nexport function parseFailuresSnapshot(value: unknown): PluginFailuresSnapshot {\n if (!isRecord(value) || !Array.isArray(value.items)\n || !isString(value.pluginRoot) || typeof value.safeMode !== 'boolean') {\n throw new Error('plugin-manager: response must contain a failures snapshot')\n }\n return {\n items: value.items.map((item, index) => {\n if (!isRecord(item) || !isString(item.pluginId)\n || (item.kind !== 'load-failure' && item.kind !== 'hang' && item.kind !== 'late-rejection')\n || !isString(item.message) || !isString(item.stack)\n || !isString(item.installPath) || !isString(item.at)) {\n throw new Error(`plugin-manager: failure row ${String(index)} is invalid`)\n }\n return {\n pluginId: item.pluginId,\n kind: item.kind,\n message: item.message,\n stack: item.stack,\n installPath: item.installPath,\n at: item.at,\n }\n }),\n pluginRoot: value.pluginRoot,\n safeMode: value.safeMode,\n }\n}\n","/**\n * The cordis service contract this package exposes to sibling client plugins\n * under the name `'pluginManager'`. The browser half builds one dual-channel\n * face (official /plugin-installer + /plugin-control RPC channels when\n * available, else this package's loopback HTTP gateway) and provides it via\n * `ctx.provide('pluginManager', face)`; consumers resolve it with\n * `ctx.inject(['pluginManager'], cb)` and read `ctx.pluginManager`.\n *\n * The interface is intentionally narrower than the face the Plugin manager\n * tab receives (`PluginManagerFace` in the client half): it is the stable\n * cross-plugin surface, so it only carries the operations a sibling plugin\n * needs to observe and drive the installed-plugin set.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { InstallProgressItem, InstalledPluginItem, PluginFailuresSnapshot } from './protocol.ts'\n\n/** The cordis service name the browser half provides the face under. */\nexport const PLUGIN_MANAGER_SERVICE = 'pluginManager'\n\n/**\n * The dual-channel plugin-management face, shared between the Plugin manager\n * tab and sibling client plugins.\n */\nexport interface PluginManagerService {\n /** Whether this browser has loopback authority to use the host routes. */\n readonly isLoopback: boolean\n /** Read the installed snapshot. */\n list(): Promise<InstalledPluginItem[]>\n /** Install one plugin from an npm spec or git URL. */\n install(spec: string): Promise<InstalledPluginItem>\n /** Remove one plugin. */\n uninstall(id: string): Promise<InstalledPluginItem[]>\n /** Read the current install/update progress. */\n status(): Promise<InstallProgressItem>\n /**\n * Read the recorded plugin boot-failure ring (plugin id, message, stack,\n * install path). On runtimes without a failure ring the host answers an\n * empty snapshot.\n */\n failures(): Promise<PluginFailuresSnapshot>\n /**\n * Flip one plugin's next-start enablement through the active channel (the\n * official installer RPC when available, else the loopback gateway's patch\n * `disabled` override row). The change takes effect after the host restart;\n * a running plugin is not stopped.\n */\n setEnabled(id: string, enabled: boolean): Promise<InstalledPluginItem>\n /**\n * Subscribe to successful mutations: the callback runs after install(),\n * update(), uninstall(), or setEnabled() resolves. One listener throwing\n * never breaks the others. Returns the unsubscribe function.\n */\n onChange(cb: () => void): () => void\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n /** The plugin-manager face (provided by the dsh-plugin-manager client half). */\n pluginManager: PluginManagerService\n }\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/telemetry.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * Anonymous install telemetry shared by the DSH Web UI family plugins.\n *\n * Once per UTC day per browser, each wired plugin sends one heartbeat to\n * the dsh-market edge API listing its package name (and version when known).\n * The payload carries no conversation data and no identifiers beyond a random\n * UUID generated in localStorage; the server hashes it with a deployment salt\n * before storage and never persists IP addresses. Sends are fire-and-forget:\n * failures stay silent and simply retry on a later mount or day. The system\n * is documented in docs/telemetry.md.\n */\n\nexport type TelemetryChannel = 'market' | 'npm' | 'unknown'\n\nexport interface TelemetryItem {\n /** npm package name or asset id, e.g. \"@linxin666/dsh-pet\" or \"skin:harbor\". */\n name: string\n /** Installed version when known; omitted otherwise. */\n version?: string\n /** Install channel when determinable (market = Workshop install). */\n channel?: TelemetryChannel\n}\n\nconst VISITOR_KEY = 'dsh-web-ui-telemetry-visitor'\nconst DAY_KEY_PREFIX = 'dsh-web-ui-telemetry-day:'\nconst ENDPOINT = 'https://dsh-market.com/api/telemetry/event'\n\n// Baked into each client bundle by shared/tsdown.client.ts (the package's own\n// package.json version at build time). Undefined in dev/test builds.\ndeclare const __DSH_PKG_VERSION__: string | undefined\n\n/** The building package's version, when the bundle carries it. */\nfunction bakedVersion(): string | undefined {\n try {\n return typeof __DSH_PKG_VERSION__ === 'string' && __DSH_PKG_VERSION__ !== ''\n ? __DSH_PKG_VERSION__\n : undefined\n } catch {\n return undefined\n }\n}\n\n/** Read or lazily create the anonymous visitor id; null when storage is unavailable. */\nfunction visitorId(): string | null {\n try {\n const existing = localStorage.getItem(VISITOR_KEY)\n if (existing && /^[A-Za-z0-9_-]{16,64}$/.test(existing)) return existing\n const fresh = crypto.randomUUID().replaceAll('-', '')\n localStorage.setItem(VISITOR_KEY, fresh)\n return fresh\n } catch {\n // Storage unavailable (privacy mode, sandboxed frame): report nothing.\n return null\n }\n}\n\n/** Drop stale per-day dedup keys so localStorage does not grow forever. */\nfunction pruneDayKeys(today: string): void {\n try {\n for (let index = localStorage.length - 1; index >= 0; index -= 1) {\n const key = localStorage.key(index)\n if (key !== null && key.startsWith(DAY_KEY_PREFIX) && key !== DAY_KEY_PREFIX + today) {\n localStorage.removeItem(key)\n }\n }\n } catch { /* best effort */ }\n}\n\n/**\n * Fire the daily heartbeat for the given items at most once per UTC day per\n * browser. Never throws and never blocks the caller. Items without an explicit\n * version inherit the bundle's baked build version.\n */\nexport function reportDailyHeartbeat(items: readonly TelemetryItem[]): void {\n try {\n if (items.length === 0) return\n const today = new Date().toISOString().slice(0, 10)\n // Automation contexts (CDP-driven QA browsers, fresh isolated profiles)\n // mint a new visitor id per run and would inflate instance counts.\n if (navigator.webdriver) return\n if (localStorage.getItem(DAY_KEY_PREFIX + today) !== null) return\n const visitor = visitorId()\n if (visitor === null) return\n pruneDayKeys(today)\n const payloadItems = items.map((item) => {\n const out: Record<string, string> = { name: item.name }\n const version = item.version ?? bakedVersion()\n if (version !== undefined) out.version = version\n if (item.channel !== undefined) out.channel = item.channel\n return out\n })\n const body = JSON.stringify({ kind: 'heartbeat', visitor, items: payloadItems })\n void fetch(ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body,\n keepalive: true,\n }).then((response) => {\n // Mark the day only after an accepted send, so offline browsers retry\n // on a later mount instead of going dark until tomorrow.\n if (response.ok) localStorage.setItem(DAY_KEY_PREFIX + today, '1')\n }).catch(() => { /* unreachable endpoint: stay silent */ })\n } catch { /* never break the host UI over telemetry */ }\n}\n","/**\n * Plugin-manager browser half: contributes the package's one remaining\n * surface — the check-for-updates block on the official Plugins page — and\n * provides the dual-channel face as the `'pluginManager'` cordis service for\n * sibling client plugins.\n *\n * It is dual-channel: on runtimes with the official installer services\n * (DSHCode, the 1.0.4 checkout web) every operation rides the official\n * `/plugin-installer` and `/plugin-control` loopback RPC channels (the single\n * writer); on the npm-published web runtime those channels do not exist, so the\n * same face falls back to this package's own loopback HTTP gateway, which\n * spawns the official CLI for writes. Neither the patch nor service consumers\n * know which mode the face runs in.\n *\n * The package used to register its own \"Plugin manager\" tab into the official\n * Plugins settings section (`settings.plugins.tab`). Installing, uninstalling\n * and enabling moved to the official page long ago, and the tab's remaining\n * half was UI no official page renders; the tab is gone and its one genuinely\n * missing capability — comparing an installed plugin against its registry\n * source, with the DSH-runtime compatibility gate — now renders inside the\n * official page through the `plugins.detail.section` seat it declares.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the renderer plugin's Context merge (ctx.slots, the\n// registry this package registers its contribution into).\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\nimport { PluginUpdatePatch, type PluginUpdatePatchInjected } from './PluginUpdatePatch.tsx'\nimport { mountPluginListToolbar } from './plugin-toolbar-mount.tsx'\nimport { en, zh, type PluginManagerKey } from './locales.ts'\nimport {\n parseFailuresSnapshot,\n parseInstallStatus,\n parseInstalledPlugin,\n parsePluginList,\n parseRestartMode,\n parseUpdateList,\n type InstalledPluginItem,\n type InstallProgressItem,\n type PluginFailuresSnapshot,\n type PluginUpdateItem,\n type RestartMode,\n} from '../core/protocol.ts'\nimport { PLUGIN_MANAGER_SERVICE, type PluginManagerService } from '../core/service.ts'\nimport { reportDailyHeartbeat } from './telemetry.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Copy for the check-for-updates patch. */\n 'settings.pluginManager': PluginManagerKey\n }\n}\n\nconst NS = 'settings.pluginManager'\nconst CHANNEL = '/plugin-installer'\nconst LIST_ENDPOINT = 'list'\nconst INSTALL_ENDPOINT = 'install'\nconst UPDATE_ENDPOINT = 'update'\nconst UNINSTALL_ENDPOINT = 'uninstall'\nconst SET_ENABLED_ENDPOINT = 'set-enabled'\nconst CHECK_UPDATES_ENDPOINT = 'check-updates'\nconst RESTART_ENDPOINT = 'restart'\nconst STATUS_ENDPOINT = 'status'\nconst FAILURES_ENDPOINT = 'failures'\n\n// DOCUMENT-RELATIVE (issue #1707): the GUI is served with `<base href=\"./\">`,\n// so a sub-path deployment resolves the gateway prefix against its entry\n// directory rather than the origin root.\nconst GATEWAY_PREFIX = 'api/plugin-manager'\n/** Gateway job polling cadence. */\nconst JOB_POLL_MS = 500\n/** Gateway job wait ceiling (the host add deadline is six minutes). */\nconst JOB_WAIT_MS = 7 * 60_000\n\n/** Services required by the patch registration and both channels. */\nexport const inject = ['slots', 'locale', 'connection']\n\n/** The gateway job wire shape served by /status. */\ninterface GatewayJobWire {\n phase: 'running' | 'done' | 'error'\n plugin?: unknown\n error?: string\n}\n\n/**\n * The face the update patch and the `'pluginManager'` cordis service share:\n * the patch's wire surface plus the cross-plugin service contract. The gateway\n * host still records install conflicts and boot failures; no client surface\n * consumes either since the tab left, so neither is on this face.\n */\nexport type PluginManagerFace = PluginUpdatePatchInjected & PluginManagerService & {\n /**\n * Restart DSH so an applied plugin update is loaded. Always rides this\n * package's own loopback route: neither official channel\n * (`/plugin-installer`, `/plugin-control`) has a restart method, and the\n * route answers how the restart was carried out (in-place relaunch, or a\n * packaged Desktop shell that owns the process tree). See host/restart.ts.\n */\n restart: () => Promise<RestartMode>\n /**\n * Read how a restart would be carried out without triggering it (the same\n * route's plan read). The toolbar words its confirmation from this, so a\n * packaged Desktop host can say what its system dialog will do instead of\n * surprising the user with it.\n */\n restartPlan: () => Promise<RestartMode>\n}\n\n/**\n * Build the dual-channel face once: official-channel and gateway-channel\n * implementations, the mode detection that picks between them, and the\n * change-notification listener set. The returned face is both the update\n * patch's injected props and the value provided as the\n * `'pluginManager'` cordis service.\n * @param ctx - the client context (connection).\n * @returns the shared face.\n */\nexport function createPluginManagerFace(ctx: ClientContext): PluginManagerFace {\n const connection = ctx.get('connection') as ConnectionHandle\n\n // Official channel implementations.\n\n const call = async (endpoint: string, payload: unknown): Promise<unknown> => {\n const result = await connection.rpc.call(CHANNEL, endpoint, payload)\n if (!result.ok) {\n throw new Error(`plugin-installer ${endpoint} failed: ${result.error.code}: ${result.error.message}`)\n }\n return result.value\n }\n const official = {\n list: async (): Promise<InstalledPluginItem[]> => parsePluginList(await call(LIST_ENDPOINT, {})),\n install: async (spec: string): Promise<InstalledPluginItem> => parseInstalledPlugin(await call(INSTALL_ENDPOINT, { spec })),\n update: async (id: string): Promise<InstalledPluginItem> => parseInstalledPlugin(await call(UPDATE_ENDPOINT, { id })),\n uninstall: async (id: string): Promise<InstalledPluginItem[]> => parsePluginList(await call(UNINSTALL_ENDPOINT, { id })),\n setEnabled: async (id: string, enabled: boolean): Promise<InstalledPluginItem> =>\n parseInstalledPlugin(await call(SET_ENABLED_ENDPOINT, { id, enabled })),\n checkUpdates: async (): Promise<PluginUpdateItem[]> => parseUpdateList(await call(CHECK_UPDATES_ENDPOINT, {})),\n status: async (): Promise<InstallProgressItem> => parseInstallStatus(await call(STATUS_ENDPOINT, {})),\n failures: async (): Promise<PluginFailuresSnapshot> => parseFailuresSnapshot(await call(FAILURES_ENDPOINT, {})),\n }\n\n // Gateway channel implementations.\n\n const gatewayJson = async (path: string, init?: RequestInit): Promise<unknown> => {\n const response = await fetch(path, {\n ...init,\n headers: { 'content-type': 'application/json', ...init?.headers },\n })\n if (response.status === 403) {\n throw new Error('plugin-manager: plugin management is only available from a local browser')\n }\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string }\n throw new Error(body.error ?? `plugin-manager: gateway ${path} failed: HTTP ${String(response.status)}`)\n }\n return response.json()\n }\n\n /** Wait for one gateway job to settle, returning its wire state. */\n const waitJob = async (jobId: string): Promise<GatewayJobWire> => {\n const deadline = Date.now() + JOB_WAIT_MS\n for (;;) {\n const body = await gatewayJson(`${GATEWAY_PREFIX}/status?job=${encodeURIComponent(jobId)}`) as { job?: GatewayJobWire }\n const job = body.job\n if (job === undefined) throw new Error('plugin-manager: gateway job vanished')\n if (job.phase === 'done') return job\n if (job.phase === 'error') throw new Error(job.error ?? 'plugin-manager: gateway job failed')\n if (Date.now() > deadline) throw new Error('plugin-manager: gateway job timed out')\n await new Promise(resolve => { setTimeout(resolve, JOB_POLL_MS) })\n }\n }\n\n /** Whether a gateway install/remove is in flight (drives the progress row). */\n let gatewayInflight = false\n\n const gateway = {\n list: async (): Promise<InstalledPluginItem[]> =>\n parsePluginList(await gatewayJson(`${GATEWAY_PREFIX}/list`)),\n install: async (spec: string): Promise<InstalledPluginItem> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/install`, {\n method: 'POST',\n body: JSON.stringify({ spec }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway install returned no job')\n const job = await waitJob(started.jobId)\n return parseInstalledPlugin({ plugin: job.plugin })\n } finally {\n gatewayInflight = false\n }\n },\n update: async (id: string): Promise<InstalledPluginItem> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/update`, {\n method: 'POST',\n body: JSON.stringify({ id }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway update returned no job')\n const job = await waitJob(started.jobId)\n return parseInstalledPlugin({ plugin: job.plugin })\n } finally {\n gatewayInflight = false\n }\n },\n uninstall: async (id: string): Promise<InstalledPluginItem[]> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/remove`, {\n method: 'POST',\n body: JSON.stringify({ id }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway remove returned no job')\n await waitJob(started.jobId)\n return gateway.list()\n } finally {\n gatewayInflight = false\n }\n },\n setEnabled: async (id: string, enabled: boolean): Promise<InstalledPluginItem> =>\n parseInstalledPlugin(await gatewayJson(`${GATEWAY_PREFIX}/set-enabled`, {\n method: 'POST',\n body: JSON.stringify({ id, enabled }),\n })),\n checkUpdates: async (): Promise<PluginUpdateItem[]> =>\n parseUpdateList(await gatewayJson(`${GATEWAY_PREFIX}/check-updates`)),\n status: async (): Promise<InstallProgressItem> =>\n gatewayInflight ? { kind: 'install', stage: 'download' } : { kind: 'idle', stage: 'fetch' },\n failures: async (): Promise<PluginFailuresSnapshot> =>\n parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`)),\n // Restart has no official-channel counterpart, so this route is the one\n // call that is always the gateway's, whichever mode the face runs in. The\n // GET-shaped call is the plan read: no state changes, no process exits.\n restartPlan: async (): Promise<RestartMode> =>\n parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`)),\n restart: async (): Promise<RestartMode> =>\n parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`, { method: 'POST' })),\n }\n\n // Mode selection.\n\n let modePromise: Promise<'official' | 'gateway'> | undefined\n const ensureMode = (): Promise<'official' | 'gateway'> => {\n if (modePromise === undefined) {\n modePromise = (async () => {\n // Prefer the host verdict: the gateway's /mode route reports whether\n // the official installer channels exist, so the direct channel probe\n // below (which 405s into the browser console on the npm web runtime)\n // only runs when the host half is absent or explicitly returns null\n // for a desktop runtime whose services are registered in-process.\n try {\n const mode = await gatewayJson(`${GATEWAY_PREFIX}/mode`) as { official?: boolean | null }\n if (mode.official === true) return 'official' as const\n if (mode.official === false) return 'gateway' as const\n } catch {\n // Host half absent (an official runtime without a boot profile):\n // fall back to the direct channel probe.\n }\n try {\n const result = await connection.rpc.call(CHANNEL, LIST_ENDPOINT, {})\n return result.ok ? 'official' as const : 'gateway' as const\n } catch {\n return 'gateway' as const\n }\n })()\n }\n return modePromise\n }\n\n // Change notification.\n\n /** Listeners subscribed through onChange; fired after successful mutations. */\n const listeners = new Set<() => void>()\n /** Notify every listener; one listener throwing never breaks the others. */\n const notifyChange = (): void => {\n for (const listener of [...listeners]) {\n try {\n listener()\n } catch {\n // A consumer's listener failure is its own; keep notifying the rest.\n }\n }\n }\n\n // The shared face.\n\n return {\n isLoopback: connection.isLoopback,\n list: async () => (await ensureMode()) === 'official' ? official.list() : gateway.list(),\n install: async spec => {\n const item = await ((await ensureMode()) === 'official' ? official.install(spec) : gateway.install(spec))\n notifyChange()\n return item\n },\n update: async id => {\n const item = await ((await ensureMode()) === 'official' ? official.update(id) : gateway.update(id))\n notifyChange()\n return item\n },\n uninstall: async id => {\n const rows = await ((await ensureMode()) === 'official' ? official.uninstall(id) : gateway.uninstall(id))\n notifyChange()\n return rows\n },\n setEnabled: async (id, enabled) => {\n const item = await ((await ensureMode()) === 'official' ? official.setEnabled(id, enabled) : gateway.setEnabled(id, enabled))\n notifyChange()\n return item\n },\n checkUpdates: async () => (await ensureMode()) === 'official' ? official.checkUpdates() : gateway.checkUpdates(),\n restartPlan: () => gateway.restartPlan(),\n restart: () => gateway.restart(),\n status: async () => (await ensureMode()) === 'official' ? official.status() : gateway.status(),\n failures: async () => (await ensureMode()) === 'official' ? official.failures() : gateway.failures(),\n onChange: cb => {\n listeners.add(cb)\n return () => { listeners.delete(cb) }\n },\n }\n}\n\n/** Contribute the check-for-updates patch and provide the shared face. */\nexport function apply(ctx: ClientContext): void {\n // Anonymous install heartbeat (docs/telemetry.md): one beat per browser per\n // UTC day, package name only, silent failure.\n reportDailyHeartbeat([{ name: '@linxin666/dsh-client-ui-plugin-manager' }])\n\n ctx.effect(() => {\n try {\n return ctx.locale.register(NS, { zh, en })\n } catch {\n return () => {}\n }\n }, 'plugin-manager: dictionaries')\n\n // Built once: the patch and the 'pluginManager' cordis service share one\n // face, so consumers observe exactly the mutations the patch performs.\n const face = createPluginManagerFace(ctx)\n try {\n if (!ctx.get(PLUGIN_MANAGER_SERVICE)) {\n ctx.provide(PLUGIN_MANAGER_SERVICE, face)\n }\n } catch {\n // ignore duplicate provide\n }\n\n // The list-level toolbar rides the page's own \"Installed\" heading: the\n // official page declares no seat beside it, so the entry is inserted into\n // the heading element itself and tracks the page through the shared body\n // mutation hub. Its translate function is rebuilt on every render so a\n // language switch reaches copy that no slot outlet owns.\n ctx.effect(() => {\n try {\n return mountPluginListToolbar({\n props: () => ({\n isLoopback: face.isLoopback,\n checkUpdates: face.checkUpdates,\n update: face.update,\n restartPlan: face.restartPlan,\n restart: face.restart,\n t: ctx.locale.bind(NS),\n }),\n subscribe: listener => ctx.locale.subscribe(listener),\n })\n } catch {\n return () => {}\n }\n }, 'plugin-manager: update toolbar')\n\n // The official Plugins page declares this seat on its main-panel entry and\n // renders one section per contribution on each bundle / row / plugin page;\n // `inject` waits for that declaration, exactly like the family plugin cards\n // that register into `plugins.bundle.config`.\n ctx.slots.inject('plugins.detail.section', () => {\n try {\n return ctx.slots.register({\n name: 'plugins.detail.section',\n id: 'family-update-check',\n order: 30,\n locale: NS,\n inject: () => face,\n }, PluginUpdatePatch)\n } catch {\n return () => {}\n }\n })\n}\n"],"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":["messageOf","css","css","css"],"sources":["../../../packages/dsh-plugin-manager/src/core/version.ts","../../../packages/dsh-plugin-manager/src/client/PluginUpdatePatch.tsx","../../../packages/dsh-plugin-manager/src/client/body-mutations.ts","../../../packages/dsh-plugin-manager/src/core/updates.ts","../../../packages/dsh-plugin-manager/src/client/PluginListToolbar.tsx","../../../packages/dsh-plugin-manager/src/client/plugin-toolbar-mount.tsx","../../../packages/dsh-plugin-manager/src/client/locales.ts","../../../packages/dsh-plugin-manager/src/core/protocol.ts","../../../packages/dsh-plugin-manager/src/core/service.ts","../../../packages/dsh-plugin-manager/src/client/telemetry.ts","../../../packages/dsh-plugin-manager/src/client/index.ts"],"sourcesContent":["/**\n * DSH host version parsing and comparison for the update compatibility\n * check. The declared minimum lives in the published package manifest under\n * `dsh.engines.dsh`, falling back to the top-level `engines.dsh`; the only\n * supported form is `>=X.Y.Z[-prerelease]`.\n *\n * Comparison deliberately uses plain semver ordering instead of\n * `semver.satisfies`: npm's prerelease rule only allows a prerelease version\n * to satisfy a comparator set carrying a prerelease on the same\n * major.minor.patch tuple, which would reject a newer host line (0.1.1-rc.2)\n * against a declared `>=0.1.0-rc.8` — exactly the cross-cohort upgrade path\n * this check must allow. Everything here is pure and tolerant of untrusted\n * input: a malformed value means \"cannot verify\", which the callers treat as\n * a fail-closed verdict when a requirement was declared (issue #754).\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\n/** One parsed DSH host or package version. */\nexport interface DshVersion {\n major: number\n minor: number\n patch: number\n /** Prerelease identifiers, numeric identifiers kept as numbers (semver order). */\n prerelease: readonly (number | string)[]\n}\n\nconst VERSION_PATTERN = /^v?(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z.-]+))?$/\n\n/**\n * Parse a DSH host or package version string.\n * @param value - e.g. `0.1.0-rc.8`, `v1.2.3`.\n * @returns the parsed version, or undefined when malformed.\n */\nexport function parseDshVersion(value: string): DshVersion | undefined {\n const match = VERSION_PATTERN.exec(value.trim())\n if (match === null) return undefined\n const prereleaseParts = match[4] === undefined ? [] : match[4].split('.')\n if (prereleaseParts.some(part => part === '')) return undefined\n return {\n major: Number(match[1]),\n minor: Number(match[2]),\n patch: Number(match[3]),\n prerelease: prereleaseParts.map(part => /^\\d+$/.test(part) ? Number(part) : part),\n }\n}\n\n/**\n * Compare two version strings by semver order (a release is newer than any\n * prerelease of the same tuple).\n * @returns -1 / 0 / 1, or undefined when either side is malformed.\n */\nexport function compareVersions(left: string, right: string): number | undefined {\n const a = parseDshVersion(left)\n const b = parseDshVersion(right)\n if (a === undefined || b === undefined) return undefined\n for (const key of ['major', 'minor', 'patch'] as const) {\n if (a[key] !== b[key]) return a[key] < b[key] ? -1 : 1\n }\n return comparePrerelease(a.prerelease, b.prerelease)\n}\n\n/**\n * Semver prerelease ordering: numeric identifiers compare numerically,\n * numeric identifiers rank below alphanumeric ones, alphanumeric identifiers\n * compare lexically, and a longer list wins when the shared prefix is equal.\n */\nfunction comparePrerelease(left: readonly (number | string)[], right: readonly (number | string)[]): number {\n if (left.length === 0 && right.length === 0) return 0\n if (left.length === 0) return 1\n if (right.length === 0) return -1\n const length = Math.max(left.length, right.length)\n for (let index = 0; index < length; index += 1) {\n const a = left[index]\n const b = right[index]\n if (a === undefined) return -1\n if (b === undefined) return 1\n if (typeof a === 'number' && typeof b === 'number') {\n if (a !== b) return a < b ? -1 : 1\n } else if (typeof a === 'number') {\n return -1\n } else if (typeof b === 'number') {\n return 1\n } else if (a !== b) {\n return a < b ? -1 : 1\n }\n }\n return 0\n}\n\nconst MINIMUM_RANGE_PATTERN = /^>=\\s*(v?\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?)$/\n\n/**\n * Whether a host version satisfies a declared `>=X.Y.Z[-prerelease]` minimum.\n * @param host - the running DSH host version.\n * @param minimum - the declared minimum; any form other than `>=<semver>`\n * (plain semver, `^`, `~`, multi-comparator ranges, empty) returns undefined.\n * @returns true / false, or undefined when the host version is malformed or\n * the minimum uses an unsupported form — callers treat undefined as\n * \"cannot verify\" and fail closed for declared requirements.\n */\nexport function meetsMinimumDsh(host: string, minimum: string): boolean | undefined {\n const match = MINIMUM_RANGE_PATTERN.exec(minimum.trim())\n if (match === null) return undefined\n const compared = compareVersions(host, match[1])\n if (compared === undefined) return undefined\n return compared >= 0\n}\n\n/**\n * The bare minimum version for display: strips the `>=` operator (and an\n * optional leading `v`) from a declared requirement so UI copy that already\n * contains the comparison operator renders `0.1.1-rc.1` instead of\n * `>= >=0.1.1-rc.1`. Unsupported range forms render unchanged.\n * @param minimum - the declared minimum range.\n * @returns the version portion for display.\n */\nexport function displayMinimumVersion(minimum: string): string {\n const match = MINIMUM_RANGE_PATTERN.exec(minimum.trim())\n return match === null ? minimum.trim() : match[1].replace(/^v/, '')\n}\n\n/**\n * Read the declared DSH minimum from a published registry manifest:\n * `dsh.engines.dsh` first, top-level `engines.dsh` next, and\n * `peerDependencies[\"@deepseek-ai/dsh\"]` last, which is where a package that\n * only declares the host as a peer still gets gated at boot.\n * Defensive against malformed or untrusted metadata: anything that is not a\n * non-empty string reads as absent.\n * @param manifest - the decoded registry version manifest.\n * @returns the declared minimum, or undefined when not declared.\n */\nexport function dshRequirementOf(manifest: { dsh?: unknown; engines?: unknown; peerDependencies?: unknown }): string | undefined {\n const dshEngines = (manifest.dsh as { engines?: unknown } | undefined)?.engines as { dsh?: unknown } | undefined\n const engines = (manifest.engines as { dsh?: unknown } | undefined)?.dsh\n const peers = (manifest.peerDependencies as Record<string, unknown> | undefined)?.['@deepseek-ai/dsh']\n // The host's own peer gate is the LAST word: a package that declares the\n // host only under peerDependencies still gets that row skipped at boot when\n // the floor is not met, so a requirement we display must come from the same\n // place the gate reads, or the user is told nothing and then loses the row.\n const value = dshEngines?.dsh ?? engines ?? peers\n return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined\n}\n","/**\n * The check-for-updates patch contributed to the official Plugins page.\n *\n * This package used to own a \"Plugin manager\" tab inside the Plugins settings\n * section (`settings.plugins.tab`). Installing, uninstalling, enabling and\n * disabling moved to the official plugin manager page long ago, and the tab's\n * remaining half (read-only inventory, install-conflict ledger, boot-failure\n * repair conversation, safe-mode banner) is UI no official page renders. It is\n * gone; the one capability the official page still lacks is comparing an\n * installed plugin against its registry source.\n *\n * So this package now contributes exactly that, into the seat the official\n * Plugins page declares for contributed sections (`plugins.detail.section`,\n * a root-scope list rendered on every bundle / row / official-plugin page with\n * the page's `subject`). The official page owns the page chrome; this entry\n * renders one compact block, only on an installed bundle's page, drawing only\n * a plain button and its own section so it carries no dependency on the\n * official primitives bundle.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\nimport { useEffect, useRef, useState } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { InstallProgressItem, PluginUpdateItem } from '../core/protocol.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport css from './plugin-manager.module.css'\n\n/** One loader row of a bundle, as the official page's subject carries it. */\nexport interface PluginPageRowRef {\n rowId: string\n moduleName: string\n enabled: boolean\n}\n\n/** One bundle, as the official page's subject carries it. */\nexport interface PluginPageBundleRef {\n name: string\n version?: string\n installed: boolean\n enabled: boolean\n rows: readonly PluginPageRowRef[]\n}\n\n/**\n * The subject the official Plugins page renders a contributed section with:\n * its bundle page, its row page, or an official plugin's page. This package\n * only speaks to the bundle case.\n */\nexport type PluginPageSubject =\n | { kind: 'bundle'; pkg: PluginPageBundleRef }\n | { kind: 'row'; pkg: PluginPageBundleRef; row: PluginPageRowRef }\n | { kind: 'item'; id: string }\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface SlotMap {\n /**\n * One section contributed under a Plugins page's own content. Declared at\n * runtime by the official plugin-manager page's `main` registration; the\n * type is re-declared here, identically, so this package can register into\n * it without importing the page (the same way family plugins re-declare\n * `plugins.bundle.config`).\n */\n 'plugins.detail.section': {\n kind: 'list'\n scope: 'root'\n owner: { subject: PluginPageSubject }\n }\n }\n}\n\n/** Registration-side wire face the patch consumes. */\nexport interface PluginUpdatePatchInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n isLoopback: boolean\n /** Compare every installed plugin against the version its source serves. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /** Re-install one plugin from its recorded source. */\n update: (id: string) => Promise<unknown>\n /** Read the current install/update progress. */\n status: () => Promise<InstallProgressItem>\n}\n\n/** Full component props assembled by the Plugins page's section renderer. */\nexport type PluginUpdatePatchProps =\n PropsRuntime<'plugins.detail.section'>\n & PropsLocale<'settings.pluginManager'>\n & InjectFace<PluginUpdatePatchInjected>\n\n/** Error text for a caught request or lifecycle failure. */\nfunction messageOf(error: unknown): string {\n if (error instanceof AggregateError) {\n const details = error.errors.map(messageOf).join('; ')\n return details === '' ? error.message : `${error.message}: ${details}`\n }\n return error instanceof Error ? error.message : String(error)\n}\n\n/** Localized label for one install phase, with percent when the download has one. */\nfunction progressLabel(progress: InstallProgressItem, t: PluginUpdatePatchProps['t']): string {\n if (progress.stage === 'write') return t('writing')\n return progress.percent === undefined ? t('downloading') : t('downloadingPercent', { percent: String(progress.percent) })\n}\n\n/**\n * The update block on one official Plugins page: one check action, the verdict\n * for this page's bundle, and the update action it unlocks. The check is\n * explicit rather than automatic because one check reads every installed\n * plugin's registry manifest; a page visit must not fan that out.\n */\nexport function PluginUpdatePatch(props: PluginUpdatePatchProps) {\n const { t, subject, isLoopback, checkUpdates, update, status } = props\n\n const [checked, setChecked] = useState(false)\n const [found, setFound] = useState<PluginUpdateItem | undefined>(undefined)\n const [busy, setBusy] = useState<'check' | 'update' | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [progress, setProgress] = useState<InstallProgressItem>({ kind: 'idle', stage: 'fetch' })\n const [dirty, setDirty] = useState(false)\n /** Synchronous in-flight mirror of `busy`: the render guard alone lets a click and an Enter land in the same frame and double-fire. */\n const busyRef = useRef(false)\n\n const name = subject.kind === 'bundle' ? subject.pkg.name : undefined\n const installed = subject.kind === 'bundle' && subject.pkg.installed\n\n /** Poll update progress while an update is in flight. */\n useEffect(() => {\n if (busy !== 'update') {\n setProgress({ kind: 'idle', stage: 'fetch' })\n return\n }\n let stopped = false\n let timer: ReturnType<typeof setTimeout> | undefined\n const tick = (delay: number): void => {\n timer = setTimeout(() => {\n void status().then(next => {\n if (!stopped && next !== undefined) {\n setProgress(next)\n tick(400)\n }\n }).catch(() => { /* polling fails silently; the update itself owns the error row */ })\n }, delay)\n }\n tick(100)\n return () => {\n stopped = true\n if (timer !== undefined) clearTimeout(timer)\n }\n }, [busy, status])\n\n if (name === undefined || !installed) return null\n\n const onCheck = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setBusy('check')\n setError(undefined)\n void checkUpdates().then(items => {\n setFound(items.find(item => item.id === name))\n setChecked(true)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n setBusy(undefined)\n })\n }\n\n const onUpdate = (): void => {\n if (busyRef.current || found === undefined) return\n busyRef.current = true\n setBusy('update')\n setError(undefined)\n void update(found.id).then(() => {\n setFound(undefined)\n setChecked(false)\n setDirty(true)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n setBusy(undefined)\n })\n }\n\n if (!isLoopback) {\n return (\n <section className={css.notice} data-update-patch data-state=\"local-only\">\n <strong>{t('localOnlyTitle')}</strong>\n <p>{t('localOnlyBody')}</p>\n </section>\n )\n }\n\n const requiresDsh = found?.requiresDsh\n const blocked = found?.compatible === false\n // \"Blocked\" has two causes and they need different words. The host reports\n // hostVersion exactly when it managed to read the running DSH version, so a\n // blocked row WITHOUT one was never judged — telling that user to upgrade DSH\n // would send them after a fix the host could not even confirm was needed\n // (issue #1819).\n const unverified = blocked && found?.hostVersion === undefined\n\n return (\n <section className={css.section} data-update-patch aria-busy={busy !== undefined}>\n <h3 className={css.title}>{t('updateSection')}</h3>\n <div className={css.actionRow}>\n <button\n type=\"button\"\n className={css.button}\n disabled={busy !== undefined}\n onClick={onCheck}\n >\n {busy === 'check' ? t('checking') : t('checkUpdates')}\n </button>\n {checked && found === undefined && busy === undefined && (\n <p className={css.ok}>{t('noUpdates')}</p>\n )}\n {found !== undefined && (\n <span className={css.latest} data-update-latest={found.latest}>{t('latest', { version: found.latest })}</span>\n )}\n {found !== undefined && requiresDsh !== undefined && (\n <span\n className={blocked ? css.compatBlocked : css.compatHint}\n data-update-compat={blocked ? 'blocked' : 'ok'}\n data-update-compat-reason={blocked ? (unverified ? 'unverified' : 'below-minimum') : undefined}\n >\n {!blocked\n ? t('updateRequiresDsh', { min: displayMinimumVersion(requiresDsh) })\n : unverified\n ? t('updateUnverifiedDsh', { min: displayMinimumVersion(requiresDsh) })\n : t('updateBlockedDsh', { min: displayMinimumVersion(requiresDsh) })}\n </span>\n )}\n {found !== undefined && (\n <button\n type=\"button\"\n className={`${css.button} ${css.primary}`}\n disabled={busy !== undefined || blocked}\n onClick={onUpdate}\n >\n {busy === 'update' ? t('updating') : t('update')}\n </button>\n )}\n </div>\n\n {busy === 'update' && (\n <div className={css.progressRow} role=\"status\">\n <div className={css.progressTrack}>\n <div\n className={css.progressBar}\n style={progress.percent === undefined ? undefined : { width: `${String(progress.percent)}%` }}\n data-indeterminate={progress.percent === undefined ? 'true' : undefined}\n />\n </div>\n <p className={css.hint}>{progressLabel(progress, t)}</p>\n </div>\n )}\n\n {error !== undefined && (\n <p className={css.error} role=\"alert\" data-update-error>{error}</p>\n )}\n\n {dirty && (\n <div className={css.restartRow}>\n <p>{t('restartHint')}</p>\n </div>\n )}\n </section>\n )\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/body-mutations.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * One `document.body` MutationObserver per page, shared by every family\n * plugin bundle.\n *\n * Family plugins that inject at the DOM level must notice when the shell\n * re-renders around their injected node: the aggregate shell's column shims\n * and any plugin surface still extending the shell from outside the official\n * slot seats. Each consumer used to install its OWN `MutationObserver` on\n * `document.body` with\n * `{ childList: true, subtree: true }`, so a page carrying N family plugins\n * paid N native observers and N callback invocations for EVERY mutation batch\n * the app produced — chat token streaming alone produces many per second, and\n * the count grows with the number of installed plugins.\n *\n * This module keeps exactly ONE body observer per page. The registry lives on\n * `globalThis` under a `Symbol.for` key, so the per-package generated copies\n * of this file (scripts/sync-shared.mjs) and separately bundled plugins all\n * reach the same hub at runtime instead of one hub per module instance.\n * Record subscribers receive the mutations accumulated since the last flush.\n * Consumers that only re-check their DOM use subscribeBodyInvalidations:\n * when all subscribers use that path, the hub retains no mutation records\n * (or detached subtrees) while a background page's animation frames pause.\n * Both paths run at most once per frame. The last subscriber disconnects the\n * observer, cancels the pending frame and releases its records.\n *\n * Failure policy: without a DOM or `MutationObserver` the subscription is a\n * no-op disposer (the same silence the per-consumer observers had), and when\n * `requestAnimationFrame` is unavailable the flush runs synchronously so a\n * subscriber is never silently dropped. A throwing subscriber cannot stop the\n * others.\n */\n\n/** The page-wide hub: one observer plus its subscribers and pending records. */\ninterface BodyMutationHub {\n observer: MutationObserver\n subscribers: Set<(records: MutationRecord[]) => void>\n pending: MutationRecord[]\n scheduled: boolean\n frame?: number\n}\n\n/** Cross-bundle registry key; `Symbol.for` so every module copy agrees. */\nconst HUB_KEY = Symbol.for('dsh-web.body-mutation-hub')\nconst INVALIDATION_ONLY = Symbol.for('dsh-web.body-mutation-invalidation')\ntype Subscriber = ((records: MutationRecord[]) => void) & { [INVALIDATION_ONLY]?: true }\n\nfunction needsRecords(subscribers: Set<(records: MutationRecord[]) => void>): boolean {\n for (const listener of subscribers) {\n if (!(listener as Subscriber)[INVALIDATION_ONLY]) return true\n }\n return false\n}\n\n/**\n * Subscribe to a coalesced DOM re-check without retaining mutation records.\n * The marked wrapper also works with an older hub, which delivers records\n * that it simply ignores until a page reload picks up the updated hub.\n */\nexport function subscribeBodyInvalidations(subscriber: () => void): () => void {\n const listener: Subscriber = () => { subscriber() }\n listener[INVALIDATION_ONLY] = true\n return subscribeBodyMutations(listener)\n}\n\n/**\n * Subscribe to body-level childList mutations.\n * @param subscriber - called at most once per animation frame with the records\n * collected since the previous flush; must be safe to run repeatedly.\n * @returns the disposer removing this subscriber (and the observer when it was\n * the last one).\n */\nexport function subscribeBodyMutations(subscriber: (records: MutationRecord[]) => void): () => void {\n if (typeof globalThis === 'undefined' || typeof document === 'undefined') return () => {}\n if (typeof MutationObserver !== 'function') return () => {}\n const registry = globalThis as unknown as Record<symbol, unknown>\n let hub = registry[HUB_KEY] as BodyMutationHub | undefined\n if (hub === undefined) {\n const subscribers = new Set<(records: MutationRecord[]) => void>()\n const created: BodyMutationHub = {\n observer: undefined as unknown as MutationObserver,\n subscribers,\n pending: [],\n scheduled: false,\n }\n const flush = (): void => {\n created.frame = undefined\n created.scheduled = false\n const batch = created.pending\n created.pending = []\n for (const listener of [...subscribers]) {\n if (!subscribers.has(listener)) continue\n try {\n listener(batch)\n } catch {\n // One subscriber must never break the others; the next flush retries it.\n }\n }\n }\n const schedule = (): void => {\n if (created.scheduled) return\n created.scheduled = true\n if (typeof requestAnimationFrame === 'function') created.frame = requestAnimationFrame(flush)\n else flush()\n }\n created.observer = new MutationObserver((records) => {\n if (needsRecords(subscribers)) {\n for (const record of records) created.pending.push(record)\n }\n schedule()\n })\n created.observer.observe(document.body ?? document.documentElement, { childList: true, subtree: true })\n registry[HUB_KEY] = created\n hub = created\n }\n const active = hub\n active.subscribers.add(subscriber)\n let subscribed = true\n return () => {\n if (!subscribed) return\n subscribed = false\n active.subscribers.delete(subscriber)\n if (!needsRecords(active.subscribers)) active.pending = []\n if (active.subscribers.size === 0 && registry[HUB_KEY] === active) {\n active.observer.disconnect()\n if (active.frame !== undefined && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(active.frame)\n active.frame = undefined\n active.pending = []\n active.scheduled = false\n delete registry[HUB_KEY]\n }\n }\n}\n","/**\n * Which update rows the list-level toolbar may act on. Pure, shared by the\n * browser half (the toolbar) and its tests: the host answers with every\n * installed package whose registry source serves a newer release, and the\n * policy of what may be updated in bulk lives here rather than in the host,\n * so the same rows stay available to the per-page update block.\n *\n * Two filters:\n *\n * - **Third-party only.** A package published under the `@deepseek-ai/` scope\n * ships with DSH itself: its version is chosen by the running installation,\n * the official page says an upgrade arrives by upgrading DSH, and a\n * plugin-initiated `pnpm add` of such a package can pull a release the runtime was\n * never tested against. The bulk action therefore never touches it.\n * - **Compatibility gate.** An update whose manifest declares a DSH minimum the\n * running host does not satisfy is listed (the user may still upgrade DSH)\n * but cannot be applied: the host would refuse it with 412 anyway.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { PluginUpdateItem } from './protocol.ts'\n\n/** The npm scope DSH's own packages are published under. */\nexport const OFFICIAL_SCOPE = '@deepseek-ai/'\n\n/** Whether a package id is a third-party plugin rather than a DSH-shipped one. */\nexport function isThirdPartyPlugin(id: string): boolean {\n return !id.startsWith(OFFICIAL_SCOPE)\n}\n\n/** The third-party update rows, in host order. */\nexport function thirdPartyUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[] {\n return items.filter(item => isThirdPartyPlugin(item.id))\n}\n\n/** Whether the running DSH host satisfies the row's declared minimum. */\nexport function isUpdateApplicable(item: PluginUpdateItem): boolean {\n return item.compatible !== false\n}\n\n/** The third-party rows this runtime can actually apply. */\nexport function applicableUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[] {\n return thirdPartyUpdates(items).filter(isUpdateApplicable)\n}\n","/**\n * The list-level toolbar: check every installed third-party plugin for a newer\n * registry release, apply them in one run, then restart DSH to load them.\n *\n * It exists because the official Plugins page compares one package at a time\n * (its `plugins.detail.section` contributions render on a bundle's page), while\n * the answer a user wants when they open the page is \"is anything of mine out\n * of date, and can I just fix it\". It is mounted beside the page's \"Installed\"\n * heading (see plugin-toolbar-mount.tsx) because that heading is the page's own\n * chrome and the page declares no seat next to it.\n *\n * Policy lives in core/updates.ts (third-party only, compatibility-gated) and\n * the operations come from the injected face, so this component is pure\n * rendering plus the sequence of calls: nothing here touches the DOM beyond its\n * own subtree.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PluginUpdateItem, RestartMode } from '../core/protocol.ts'\nimport { applicableUpdates, isUpdateApplicable, thirdPartyUpdates } from '../core/updates.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport css from './plugin-manager.module.css'\n\n/** The operations the toolbar drives (the package's dual-channel face). */\nexport interface PluginListToolbarInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n isLoopback: boolean\n /** Compare every installed plugin against the version its source serves. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /** Re-install one plugin from its recorded source. */\n update: (id: string) => Promise<unknown>\n /**\n * Read how a restart would be carried out, without carrying it out: the\n * confirmation must name the same consequence the host will produce (an\n * in-place relaunch, the packaged Desktop shell's own recovery dialog, or a\n * manual restart), and a plan read has no side effects.\n */\n restartPlan: () => Promise<RestartMode>\n /** Restart the host so an applied update is loaded. */\n restart: () => Promise<RestartMode>\n}\n\n/** Full component props. */\nexport type PluginListToolbarProps =\n & PropsLocale<'settings.pluginManager'>\n & PluginListToolbarInjected\n\n/** Error text for a caught request or lifecycle failure. */\nfunction messageOf(error: unknown): string {\n if (error instanceof AggregateError) {\n const details = error.errors.map(messageOf).join('; ')\n return details === '' ? error.message : `${error.message}: ${details}`\n }\n return error instanceof Error ? error.message : String(error)\n}\n\n/** What the toolbar is currently doing. */\ntype Phase = 'idle' | 'checking' | 'updating'\n\n/** Which flyout is open under the buttons. */\ntype Panel = 'none' | 'list' | 'restart'\n\n/**\n * The toolbar itself. All state is local: the page around it owns the plugin\n * list, and a restart tears this component down anyway.\n */\nexport function PluginListToolbar(props: PluginListToolbarProps) {\n const { t, isLoopback, checkUpdates, update, restartPlan, restart } = props\n\n const [phase, setPhase] = useState<Phase>('idle')\n const [checked, setChecked] = useState(false)\n /** Every third-party row the last check reported, including the applied ones. */\n const [found, setFound] = useState(0)\n const [rows, setRows] = useState<PluginUpdateItem[]>([])\n const [applied, setApplied] = useState<string[]>([])\n const [cursor, setCursor] = useState<{ name: string; index: number; total: number } | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [panel, setPanel] = useState<Panel>('none')\n /** How the host says it would restart, read before the confirmation is shown. */\n const [plan, setPlan] = useState<RestartMode | undefined>(undefined)\n const [restartMode, setRestartMode] = useState<RestartMode | undefined>(undefined)\n /** Synchronous in-flight mirror of the phase: a click and a keypress can land in one frame. */\n const busyRef = useRef(false)\n\n const pending = applicableUpdates(rows)\n\n /** Close the flyout on Escape, the shell's own dismissal gesture. */\n useEffect(() => {\n if (panel === 'none') return\n const onKey = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') setPanel('none')\n }\n window.addEventListener('keydown', onKey)\n return () => { window.removeEventListener('keydown', onKey) }\n }, [panel])\n\n const onCheck = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setPhase('checking')\n setError(undefined)\n setRestartMode(undefined)\n void checkUpdates().then(items => {\n const thirdParty = thirdPartyUpdates(items)\n setRows(thirdParty)\n setFound(thirdParty.length)\n setApplied([])\n setChecked(true)\n setPanel('list')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setPanel('list')\n }).finally(() => {\n busyRef.current = false\n setPhase('idle')\n })\n }\n\n const onUpdateAll = (): void => {\n if (busyRef.current) return\n const queue = applicableUpdates(rows)\n if (queue.length === 0) return\n busyRef.current = true\n setPhase('updating')\n setError(undefined)\n void (async () => {\n const done: string[] = []\n for (const [index, row] of queue.entries()) {\n setCursor({ name: row.id, index: index + 1, total: queue.length })\n try {\n await update(row.id)\n } catch (reason) {\n // Stop at the first failure: the remaining rows stay listed with their\n // versions, so the user sees exactly what did not go through.\n setError(t('failed', { reason: messageOf(reason) }))\n break\n }\n done.push(row.id)\n setApplied([...done])\n setRows(current => current.filter(item => item.id !== row.id))\n }\n setCursor(undefined)\n })().finally(() => {\n busyRef.current = false\n setPhase('idle')\n })\n }\n\n /** Ask the host how it would restart, then show the confirmation that matches. */\n const onAskRestart = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setError(undefined)\n void restartPlan().then(mode => {\n setPlan(mode)\n setPanel('restart')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setPanel('list')\n }).finally(() => {\n busyRef.current = false\n })\n }\n\n const onRestart = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setError(undefined)\n void restart().then(mode => {\n setRestartMode(mode)\n setPlan(undefined)\n setPanel('none')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n })\n }\n\n const shellProps = {\n 'data-dsh-plugin': 'plugin-manager',\n 'data-dsh-part': 'update-toolbar',\n 'data-update-toolbar': true,\n } as const\n\n if (!isLoopback) {\n return (\n <div className={css.toolbar} {...shellProps} data-state=\"local-only\">\n <button type=\"button\" className={css.toolbarButton} disabled title={t('localOnlyBody')}>\n {t('checkUpdates')}\n </button>\n </div>\n )\n }\n\n const busy = phase !== 'idle'\n /** One alert line, rendered in whichever flyout is open when it appears. */\n const errorLine = error === undefined\n ? null\n : <p className={css.error} role=\"alert\" data-update-error>{error}</p>\n /** What is still pending after a partial run (the applied rows leave the list). */\n const remaining = found - applied.length\n const summary = cursor !== undefined\n ? t('updatingAll', { name: cursor.name, index: String(cursor.index), total: String(cursor.total) })\n : remaining > 0\n ? t('updatesAvailable', { count: String(remaining) })\n : applied.length > 0\n ? t('updateAllDone')\n : t('noUpdates')\n\n return (\n <div className={css.toolbar} {...shellProps} data-state={restartMode ?? phase} aria-busy={busy}>\n <button type=\"button\" className={css.toolbarButton} data-update-check disabled={busy} onClick={onCheck}>\n {phase === 'checking' ? t('checking') : t('checkUpdates')}\n </button>\n\n {checked && (\n <button\n type=\"button\"\n className={css.toolbarSummary}\n data-update-summary\n data-pending={pending.length}\n aria-expanded={panel === 'list'}\n onClick={() => { setPanel(panel === 'list' ? 'none' : 'list') }}\n >\n {summary}\n </button>\n )}\n\n <button\n type=\"button\"\n className={applied.length > 0 ? `${css.toolbarButton} ${css.primary}` : css.toolbarButton}\n data-update-restart\n data-restart-pending={applied.length}\n disabled={busy || restartMode === 'relaunch'}\n onClick={() => { if (panel === 'restart') { setPanel('none'); setPlan(undefined); return } onAskRestart() }}\n >\n {restartMode === 'relaunch' ? t('restarting') : t('restartNow')}\n </button>\n\n {restartMode !== undefined && panel !== 'restart' && (\n <span className={css.toolbarHint} role=\"status\" data-update-restart-hint={restartMode}>\n {restartMode === 'shell' ? t('restartDesktopHint') : restartMode === 'manual' ? t('restartManualHint') : t('restartRelaunchHint')}\n </span>\n )}\n\n {panel === 'list' && (\n <div className={css.panel} data-update-panel role=\"group\" aria-label={t('updatesPanelTitle')}>\n {errorLine}\n {applied.length > 0 && <p className={css.ok} data-update-applied>{t('updateAllDone')}</p>}\n {rows.length === 0 && applied.length === 0 && error === undefined && <p className={css.hint}>{t('noUpdates')}</p>}\n {rows.length > 0 && (\n <ul className={css.panelList}>\n {rows.map(row => (\n <li key={row.id} className={css.panelRow} data-update-row={row.id} data-compatible={isUpdateApplicable(row) ? 'yes' : 'no'}>\n <span className={css.panelName}>{row.id}</span>\n <span className={css.panelVersion}>{row.current} → {row.latest}</span>\n {row.compatible === false && row.requiresDsh !== undefined && (\n <span className={css.compatBlocked} data-update-row-compat-reason={row.hostVersion === undefined ? 'unverified' : 'below-minimum'}>\n {row.hostVersion === undefined\n ? t('updateUnverifiedDsh', { min: displayMinimumVersion(row.requiresDsh) })\n : t('updateBlockedDsh', { min: displayMinimumVersion(row.requiresDsh) })}\n </span>\n )}\n </li>\n ))}\n </ul>\n )}\n <div className={css.panelActions}>\n {pending.length > 0 && (\n <button type=\"button\" className={`${css.button} ${css.primary}`} data-update-all disabled={busy} onClick={onUpdateAll}>\n {phase === 'updating' ? t('updating') : t('updateAll', { count: String(pending.length) })}\n </button>\n )}\n {applied.length > 0 && (\n <button type=\"button\" className={`${css.button} ${css.primary}`} data-update-panel-restart disabled={busy} onClick={onAskRestart}>\n {t('restartNow')}\n </button>\n )}\n </div>\n <p className={css.hint}>{t('thirdPartyOnly')}</p>\n </div>\n )}\n\n {panel === 'restart' && (\n <div className={css.panel} data-update-restart-panel data-restart-plan={plan} role=\"group\" aria-label={t('restartNow')}>\n {errorLine}\n <p className={css.hint} data-restart-plan-hint={plan}>\n {plan === 'shell' ? t('restartPlanShell') : plan === 'manual' ? t('restartPlanManual') : t('restartPlanRelaunch')}\n </p>\n {plan === 'shell' && <p className={css.hint}>{t('restartShellWarning')}</p>}\n <div className={css.panelActions}>\n <button type=\"button\" className={css.button} data-restart-cancel onClick={() => { setPanel('none'); setPlan(undefined) }}>\n {t('cancel')}\n </button>\n {plan !== 'manual' && (\n <button\n type=\"button\"\n className={`${css.button} ${css.primary}`}\n data-restart-confirm\n onClick={onRestart}\n >\n {t('restartConfirm')}\n </button>\n )}\n </div>\n </div>\n )}\n </div>\n )\n}\n","/**\n * Mounting the update toolbar beside the official Plugins page's \"Installed\"\n * heading.\n *\n * The page renders that heading itself — `<section data-plugin-group=\"bundles\">\n * <div class=\"groupHead\"><h3>Installed</h3><span>7</span></div>…` — and declares\n * no seat next to it: its extension points are `plugins.detail.*` (per page),\n * `plugins.bundle.config` / `plugins.row.config` / `plugins.item` (configuration\n * entries) and `plugins.bundle.activation`. A list-level action therefore has\n * to be inserted into the page's own chrome, the same way the sidebar foot card\n * is inserted above the Settings row.\n *\n * The container is a plain element carrying its own React root, so it can never\n * disturb the page's reconciliation, and it re-seats itself through the\n * page-wide body-mutation hub: a re-render that relocates or drops the heading\n * is followed on the next frame, and a panel switch that unmounts the list\n * simply detaches the container until the list returns.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { createElement } from 'react'\nimport { createRoot, type Root } from 'react-dom/client'\nimport { subscribeBodyInvalidations } from './body-mutations.ts'\nimport { PluginListToolbar, type PluginListToolbarProps } from './PluginListToolbar.tsx'\nimport css from './plugin-manager.module.css'\n\n/** Stable attribute identifying the injected container (mount idempotency). */\nexport const TOOLBAR_MOUNT_SELECTOR = '[data-dsh-plugin-manager-toolbar]'\n\n/** Toolbar props without the translate function, which is rebuilt per render. */\nexport type PluginListToolbarMountInput = Omit<PluginListToolbarProps, 't'> & {\n /** Translate in the namespace, read on every render so a language switch lands. */\n t: PluginListToolbarProps['t']\n}\n\n/** The mount's inputs. */\nexport interface PluginToolbarMountOptions {\n /** Build the toolbar props; called on mount and on every locale change. */\n props: () => PluginListToolbarMountInput\n /** Locale change subscription (ctx.locale.subscribe); re-renders the toolbar. */\n subscribe?: (listener: () => void) => () => void\n}\n\n/**\n * The official page's \"Installed\" group heading, when it is mounted. Class\n * names are CSS-module hashes in the official bundle, so the seat is found\n * through the page's own data attributes plus DOM position.\n * @returns the heading element to append into, or undefined off the list view.\n */\nexport function toolbarSeat(): HTMLElement | undefined {\n const page = document.querySelector('[data-plugin-panel]')\n const group = page?.querySelector('[data-plugin-group=\"bundles\"]')\n const head = group?.firstElementChild\n return head instanceof HTMLElement ? head : undefined\n}\n\n/**\n * Mount the toolbar into the Installed heading.\n * @param options - props factory and the optional locale subscription.\n * @returns disposer removing the container, its observers and its React root.\n */\nexport function mountPluginListToolbar(options: PluginToolbarMountOptions): () => void {\n if (typeof document === 'undefined') return () => {}\n // DOM-level idempotency: whatever path mounted a toolbar before this call\n // (a duplicated apply, an HMR re-injection), never mount a second one.\n if (document.querySelector(TOOLBAR_MOUNT_SELECTOR) !== null) return () => {}\n\n const container = document.createElement('div')\n container.setAttribute('data-dsh-plugin-manager-toolbar', '')\n container.className = css.mount\n const root: Root = createRoot(container)\n const render = (): void => {\n root.render(createElement(PluginListToolbar, options.props()))\n }\n render()\n\n /** Keep the container inside the heading; detach while the list is away. */\n const place = (): void => {\n const seat = toolbarSeat()\n if (seat === undefined) {\n container.remove()\n return\n }\n if (container.parentElement !== seat) seat.append(container)\n }\n place()\n\n const unsubscribeBody = subscribeBodyInvalidations(place)\n const unsubscribeLocale = options.subscribe === undefined ? ((): void => {}) : options.subscribe(render)\n\n return () => {\n unsubscribeBody()\n unsubscribeLocale()\n root.unmount()\n container.remove()\n }\n}\n","/**\n * Locale dictionaries for the plugin-manager's official-page patch. The zh\n * dictionary is the key source; the en dictionary mirrors the exact key set.\n *\n * The key set covers only what this package renders: the check-for-updates\n * block on a bundle's page in the official Plugins panel, and the list-level\n * update toolbar mounted beside that panel's \"Installed\" heading.\n * The former tab's keys (inventory, conflicts, repair seeds, safe mode,\n * aggregate children) left with that tab.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n/** Simplified Chinese copy (the key-set source of truth). */\nconst STATIC_ZH = {\n 'updateSection': '更新',\n 'checkUpdates': '检查更新',\n 'checking': '检查中…',\n 'noUpdates': '已是最新版本。',\n 'update': '更新',\n 'updating': '更新中…',\n 'latest': '最新 {version}',\n 'updateRequiresDsh': '需要 DSH ≥ {min}',\n 'updateBlockedDsh': '需要 DSH ≥ {min},请先升级 DSH 再更新',\n 'updateUnverifiedDsh': '无法确认本机 DSH 版本(需要 DSH ≥ {min}),已暂停更新',\n 'restartHint': '插件变更将在重启应用后生效。',\n 'updatesAvailable': '{count} 个可更新',\n 'updateAll': '全部更新({count})',\n 'updatingAll': '更新 {name}({index}/{total})',\n 'updateAllDone': '更新完成,重启后生效。',\n 'updatesPanelTitle': '插件更新',\n 'thirdPartyOnly': '只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。',\n 'restartNow': '立即重启',\n 'restarting': '正在重启…',\n 'restartConfirm': '确认重启',\n 'restartPlanRelaunch': '会重启 DSH 服务,正在运行的任务会中断。',\n 'restartPlanShell': '桌面版通过系统对话框重启:确认后会弹出官方的「应用无法启动或已意外停止」对话框,请在对话框中点「重启」。',\n 'restartPlanManual': '当前进程无法自动重启,请手动重启 DSH。',\n 'restartShellWarning': '它同时会写一份崩溃报告;也可以手动重启:退出 DeepSeek Harness(⌘Q)后重新打开。',\n 'restartDesktopHint': '请在随后出现的系统对话框中选择「重启」。',\n 'restartRelaunchHint': '已请求重启;服务恢复后刷新页面即可。',\n 'restartManualHint': '当前进程无法自动重启,请手动重启 DSH。',\n 'cancel': '取消',\n 'failed': '操作失败:{reason}',\n 'fetching': '正在获取插件信息…',\n 'downloading': '正在下载…',\n 'downloadingPercent': '正在下载 {percent}%',\n 'extracting': '正在解压…',\n 'writing': '正在写入配置…',\n 'localOnlyTitle': '仅限本机操作',\n 'localOnlyBody': '为了保护主机配置,插件管理只能从本机打开。'\n} satisfies Record<string, string>\n\n/** English copy, checked complete against the zh key set. */\nconst STATIC_EN = {\n 'updateSection': 'Update',\n 'checkUpdates': 'Check for updates',\n 'checking': 'Checking…',\n 'noUpdates': 'The installed version is the latest.',\n 'update': 'Update',\n 'updating': 'Updating…',\n 'latest': 'Latest {version}',\n 'updateRequiresDsh': 'Requires DSH >= {min}',\n 'updateBlockedDsh': 'Requires DSH >= {min}; upgrade DSH before updating',\n 'updateUnverifiedDsh': 'Cannot confirm the local DSH version (this update needs DSH >= {min}); update paused',\n 'restartHint': 'Plugin changes take effect after restarting the application.',\n 'updatesAvailable': '{count} updates available',\n 'updateAll': 'Update all ({count})',\n 'updatingAll': 'Updating {name} ({index}/{total})',\n 'updateAllDone': 'Updated; restart to take effect.',\n 'updatesPanelTitle': 'Plugin updates',\n 'thirdPartyOnly': 'Third-party plugins only; @deepseek-ai/ packages upgrade with DSH itself.',\n 'restartNow': 'Restart now',\n 'restarting': 'Restarting…',\n 'restartConfirm': 'Restart',\n 'restartPlanRelaunch': 'The DSH service restarts; running tasks are interrupted.',\n 'restartPlanShell': 'The desktop app restarts through its system dialog: confirming shows the official \"DeepSeek Harness is unavailable\" dialog; click Restart in it.',\n 'restartPlanManual': 'This process cannot restart itself; restart DSH yourself.',\n 'restartShellWarning': 'It also writes a crash report. You can instead restart manually: quit DeepSeek Harness (Cmd+Q) and open it again.',\n 'restartDesktopHint': 'Choose Restart in the system dialog that follows.',\n 'restartRelaunchHint': 'Restart requested; reload the page once the server is back.',\n 'restartManualHint': 'This process cannot restart itself; restart DSH yourself.',\n 'cancel': 'Cancel',\n 'failed': 'Operation failed: {reason}',\n 'fetching': 'Fetching plugin metadata…',\n 'downloading': 'Downloading…',\n 'downloadingPercent': 'Downloading {percent}%',\n 'extracting': 'Extracting…',\n 'writing': 'Writing configuration…',\n 'localOnlyTitle': 'Available on this computer only',\n 'localOnlyBody': 'To protect host configuration, plugin management is only available from a local browser.'\n} satisfies Record<keyof typeof STATIC_ZH, string>\n\nexport const zh = STATIC_ZH\nexport const en = STATIC_EN\nexport type PluginManagerKey = keyof typeof STATIC_ZH\n","/**\n * Wire parsing for the official plugin-installer / plugin-control RPC\n * channels. This package is a browser-side consumer of those channels: every\n * response is decoded but untrusted, so each parser validates the shape it\n * needs and throws a typed error on mismatch. Callers treat a parse failure\n * as \"channel unavailable or drifted\" and degrade to command hints.\n *\n * The shapes mirror the official web installer tab's wire protocol (see the\n * DSH checkout's packages/client/ui-settings-plugin-installer/src/client/\n * protocol.ts); they are a contract observation, not an import.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\n/** One loader entry row claimed by an installed bundle package (aggregate child). */\nexport interface InstalledPluginChild {\n /** The loader entry id, e.g. web-ui-pet. */\n id: string\n /** Display name: the real plugin package (shell config.plugin) when known. */\n name: string\n /** Effective next-start enablement of this row alone (bundle default plus user override). */\n enabled: boolean\n /** Rows the manager must never disable (the manager tab itself, the compat face). */\n locked?: boolean\n}\n\n/** One installed user-plugin row served by `/plugin-installer list`. */\nexport interface InstalledPluginItem {\n id: string\n name: string\n version: string\n source: { kind: 'npm' | 'git'; spec: string }\n installedAt: string\n /** Effective next-start enablement across the bundle's own rows and the managed profile patch row. */\n enabled: boolean\n commit?: string\n /**\n * Entry rows this package's bundle patch claims, present when the package\n * is an aggregate claiming more than one row (gateway mode only — the\n * official channel wire has no children). Child enablement is individually\n * switchable; uninstall stays whole-package (the code ships in one npm\n * package).\n */\n children?: InstalledPluginChild[]\n}\n\n/**\n * How the host carried out (or refused) a restart request:\n * `relaunch` — this host re-executes itself in place; `shell` — the packaged\n * Desktop shell owns the process tree and runs its own restart; `manual` —\n * neither is safe here, the user restarts DSH themselves.\n */\nexport type RestartMode = 'relaunch' | 'shell' | 'manual'\n\n/** Point-in-time install/update progress reported by the host. */\nexport interface InstallProgressItem {\n kind: 'idle' | 'install' | 'update'\n stage: 'fetch' | 'download' | 'extract' | 'write'\n percent?: number\n}\n\n/** Whether an update row is a normal same-name update or a legacy package migration. */\nexport type PluginUpdateKind = 'update' | 'migrate'\n\n/** One plugin with a newer version available. */\nexport interface PluginUpdateItem {\n id: string\n current: string\n latest: string\n /** Normal same-name update or legacy aggregate migration. Defaults to update. */\n kind?: PluginUpdateKind\n /** Target package name when kind is migrate. */\n target?: string\n /** Exact target package version when kind is migrate. */\n targetVersion?: string\n /** Declared DSH minimum the update needs (package manifest's `dsh.engines.dsh`). */\n requiresDsh?: string\n /** Whether the running DSH host satisfies requiresDsh; absent when unknown. */\n compatible?: boolean\n /**\n * The running DSH version the verdict was made from, when the host could read\n * it. Its absence is what separates \"this host is too old\" from \"this host\n * could not be asked\" — different problems, with different copy (issue #1819).\n */\n hostVersion?: string\n}\n\n/** One recorded plugin boot failure served by the host. */\nexport interface PluginFailureItem {\n /** Installed plugin id (package name); empty for unattributable failures. */\n pluginId: string\n kind: 'load-failure' | 'hang' | 'late-rejection'\n message: string\n stack: string\n installPath: string\n at: string\n}\n\n/** Recovery facts served by the host: the failure ring, the plugin root, and safe mode. */\nexport interface PluginFailuresSnapshot {\n items: PluginFailureItem[]\n /** Absolute plugin install root — the repair conversation's workspace. */\n pluginRoot: string\n /** Whether the host is running in safe mode (user plugins skipped). */\n safeMode: boolean\n}\n\n/** Whether a decoded value is a non-array object. */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Whether a decoded value is a string. */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string'\n}\n\n/** Validate one aggregate child row. */\nfunction parsePluginChild(value: unknown, rowIndex: number, childIndex: number): InstalledPluginChild {\n if (!isRecord(value) || !isString(value.id) || !isString(value.name) || typeof value.enabled !== 'boolean') {\n throw new Error(`plugin-manager: plugin row ${String(rowIndex)} child ${String(childIndex)} is invalid`)\n }\n return {\n id: value.id,\n name: value.name,\n enabled: value.enabled,\n ...typeof value.locked === 'boolean' ? { locked: value.locked } : {},\n }\n}\n\n/** Validate one installed-plugin row. */\nfunction parsePlugin(value: unknown, index: number): InstalledPluginItem {\n if (!isRecord(value) || !isString(value.id) || !isString(value.name)\n || !isString(value.version) || !isString(value.installedAt)\n || typeof value.enabled !== 'boolean'\n || !isRecord(value.source) || (value.source.kind !== 'npm' && value.source.kind !== 'git')\n || !isString(value.source.spec)) {\n throw new Error(`plugin-manager: plugin row ${String(index)} is invalid`)\n }\n if (value.children !== undefined && !Array.isArray(value.children)) {\n throw new Error(`plugin-manager: plugin row ${String(index)} children is invalid`)\n }\n const children = (value.children as unknown[] | undefined)?.map((child, childIndex) => parsePluginChild(child, index, childIndex))\n return {\n id: value.id,\n name: value.name,\n version: value.version,\n source: { kind: value.source.kind, spec: value.source.spec },\n installedAt: value.installedAt,\n enabled: value.enabled,\n ...isString(value.commit) ? { commit: value.commit } : {},\n ...children !== undefined ? { children } : {},\n }\n}\n\n/**\n * Validate and normalize a `list` / `uninstall` response value.\n * @param value - decoded but untrusted response value.\n * @returns typed installed-plugin rows.\n */\nexport function parsePluginList(value: unknown): InstalledPluginItem[] {\n if (!isRecord(value) || !Array.isArray(value.plugins)) {\n throw new Error('plugin-manager: response must contain a plugins array')\n }\n return value.plugins.map((plugin, index) => parsePlugin(plugin, index))\n}\n\n/**\n * Validate and normalize an `install` / `update` / `set-enabled` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed installed-plugin row.\n */\nexport function parseInstalledPlugin(value: unknown): InstalledPluginItem {\n if (!isRecord(value) || value.plugin === undefined) {\n throw new Error('plugin-manager: response must contain a plugin row')\n }\n return parsePlugin(value.plugin, 0)\n}\n\n/**\n * Validate and normalize a `status` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed progress state.\n */\nexport function parseInstallStatus(value: unknown): InstallProgressItem {\n if (!isRecord(value) || !isRecord(value.progress)\n || (value.progress.kind !== 'idle' && value.progress.kind !== 'install' && value.progress.kind !== 'update')\n || (value.progress.stage !== 'fetch' && value.progress.stage !== 'download'\n && value.progress.stage !== 'extract' && value.progress.stage !== 'write')\n || (value.progress.percent !== undefined\n && (typeof value.progress.percent !== 'number' || !Number.isFinite(value.progress.percent)))) {\n throw new Error('plugin-manager: response must contain a valid progress state')\n }\n return {\n kind: value.progress.kind,\n stage: value.progress.stage,\n ...typeof value.progress.percent === 'number' ? { percent: value.progress.percent } : {},\n }\n}\n\n/**\n * Validate and normalize a `check-updates` response value.\n * @param value - decoded but untrusted response value.\n * @returns typed update rows.\n */\nexport function parseUpdateList(value: unknown): PluginUpdateItem[] {\n if (!isRecord(value) || !Array.isArray(value.updates)) {\n throw new Error('plugin-manager: response must contain an updates array')\n }\n return value.updates.map((update, index) => {\n if (!isRecord(update) || !isString(update.id) || !isString(update.current) || !isString(update.latest)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n const kind = update.kind === undefined ? 'update' : update.kind\n if (kind !== 'update' && kind !== 'migrate') {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n const row: PluginUpdateItem = { id: update.id, current: update.current, latest: update.latest }\n if (kind === 'migrate') {\n if (!isString(update.target) || !isString(update.targetVersion)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.kind = 'migrate'\n row.target = update.target\n row.targetVersion = update.targetVersion\n }\n if (update.requiresDsh !== undefined) {\n if (!isString(update.requiresDsh)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.requiresDsh = update.requiresDsh\n }\n if (update.compatible !== undefined) {\n if (typeof update.compatible !== 'boolean') {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.compatible = update.compatible\n }\n if (update.hostVersion !== undefined) {\n if (!isString(update.hostVersion)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.hostVersion = update.hostVersion\n }\n return row\n })\n}\n\n/**\n * Validate and normalize a `restart` response value.\n * @param value - decoded but untrusted response value.\n * @returns the mode the host actually used.\n */\nexport function parseRestartMode(value: unknown): RestartMode {\n const restart = isRecord(value) ? value.restart : undefined\n const mode = isRecord(restart) ? restart.mode : undefined\n if (mode !== 'relaunch' && mode !== 'shell' && mode !== 'manual') {\n throw new Error('plugin-manager: response must contain a restart mode')\n }\n return mode\n}\n\n/**\n * Validate and normalize a `failures` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed failures snapshot.\n */\nexport function parseFailuresSnapshot(value: unknown): PluginFailuresSnapshot {\n if (!isRecord(value) || !Array.isArray(value.items)\n || !isString(value.pluginRoot) || typeof value.safeMode !== 'boolean') {\n throw new Error('plugin-manager: response must contain a failures snapshot')\n }\n return {\n items: value.items.map((item, index) => {\n if (!isRecord(item) || !isString(item.pluginId)\n || (item.kind !== 'load-failure' && item.kind !== 'hang' && item.kind !== 'late-rejection')\n || !isString(item.message) || !isString(item.stack)\n || !isString(item.installPath) || !isString(item.at)) {\n throw new Error(`plugin-manager: failure row ${String(index)} is invalid`)\n }\n return {\n pluginId: item.pluginId,\n kind: item.kind,\n message: item.message,\n stack: item.stack,\n installPath: item.installPath,\n at: item.at,\n }\n }),\n pluginRoot: value.pluginRoot,\n safeMode: value.safeMode,\n }\n}\n","/**\n * The cordis service contract this package exposes to sibling client plugins\n * under the name `'pluginManager'`. The browser half builds one dual-channel\n * face (official /plugin-installer + /plugin-control RPC channels when\n * available, else this package's loopback HTTP gateway) and provides it via\n * `ctx.provide('pluginManager', face)`; consumers resolve it with\n * `ctx.inject(['pluginManager'], cb)` and read `ctx.pluginManager`.\n *\n * The interface is intentionally narrower than the face the Plugin manager\n * tab receives (`PluginManagerFace` in the client half): it is the stable\n * cross-plugin surface, so it only carries the operations a sibling plugin\n * needs to observe and drive the installed-plugin set.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { InstallProgressItem, InstalledPluginItem, PluginFailuresSnapshot } from './protocol.ts'\n\n/** The cordis service name the browser half provides the face under. */\nexport const PLUGIN_MANAGER_SERVICE = 'pluginManager'\n\n/**\n * The dual-channel plugin-management face, shared between the Plugin manager\n * tab and sibling client plugins.\n */\nexport interface PluginManagerService {\n /** Whether this browser has loopback authority to use the host routes. */\n readonly isLoopback: boolean\n /** Read the installed snapshot. */\n list(): Promise<InstalledPluginItem[]>\n /** Install one plugin from an npm spec or git URL. */\n install(spec: string): Promise<InstalledPluginItem>\n /** Remove one plugin. */\n uninstall(id: string): Promise<InstalledPluginItem[]>\n /** Read the current install/update progress. */\n status(): Promise<InstallProgressItem>\n /**\n * Read the recorded plugin boot-failure ring (plugin id, message, stack,\n * install path). On runtimes without a failure ring the host answers an\n * empty snapshot.\n */\n failures(): Promise<PluginFailuresSnapshot>\n /**\n * Flip one plugin's next-start enablement through the active channel (the\n * official installer RPC when available, else the loopback gateway's patch\n * `disabled` override row). The change takes effect after the host restart;\n * a running plugin is not stopped.\n */\n setEnabled(id: string, enabled: boolean): Promise<InstalledPluginItem>\n /**\n * Subscribe to successful mutations: the callback runs after install(),\n * update(), uninstall(), or setEnabled() resolves. One listener throwing\n * never breaks the others. Returns the unsubscribe function.\n */\n onChange(cb: () => void): () => void\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n /** The plugin-manager face (provided by the dsh-plugin-manager client half). */\n pluginManager: PluginManagerService\n }\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/telemetry.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * Anonymous install telemetry shared by the DSH Web UI family plugins.\n *\n * Once per UTC day per browser, each wired plugin sends one heartbeat to\n * the dsh-market edge API listing its package name (and version when known).\n * The payload carries no conversation data and no identifiers beyond a random\n * UUID generated in localStorage; the server hashes it with a deployment salt\n * before storage and never persists IP addresses. Sends are fire-and-forget:\n * failures stay silent and simply retry on a later mount or day. The system\n * is documented in docs/telemetry.md.\n */\n\nexport type TelemetryChannel = 'market' | 'npm' | 'unknown'\n\nexport interface TelemetryItem {\n /** npm package name or asset id, e.g. \"@linxin666/dsh-pet\" or \"skin:harbor\". */\n name: string\n /** Installed version when known; omitted otherwise. */\n version?: string\n /** Install channel when determinable (market = Workshop install). */\n channel?: TelemetryChannel\n}\n\nconst VISITOR_KEY = 'dsh-web-ui-telemetry-visitor'\nconst DAY_KEY_PREFIX = 'dsh-web-ui-telemetry-day:'\nconst ENDPOINT = 'https://dsh-market.com/api/telemetry/event'\n\n// Baked into each client bundle by shared/tsdown.client.ts (the package's own\n// package.json version at build time). Undefined in dev/test builds.\ndeclare const __DSH_PKG_VERSION__: string | undefined\n\n/** The building package's version, when the bundle carries it. */\nfunction bakedVersion(): string | undefined {\n try {\n return typeof __DSH_PKG_VERSION__ === 'string' && __DSH_PKG_VERSION__ !== ''\n ? __DSH_PKG_VERSION__\n : undefined\n } catch {\n return undefined\n }\n}\n\n/** Read or lazily create the anonymous visitor id; null when storage is unavailable. */\nfunction visitorId(): string | null {\n try {\n const existing = localStorage.getItem(VISITOR_KEY)\n if (existing && /^[A-Za-z0-9_-]{16,64}$/.test(existing)) return existing\n const fresh = crypto.randomUUID().replaceAll('-', '')\n localStorage.setItem(VISITOR_KEY, fresh)\n return fresh\n } catch {\n // Storage unavailable (privacy mode, sandboxed frame): report nothing.\n return null\n }\n}\n\n/** Drop stale per-day dedup keys so localStorage does not grow forever. */\nfunction pruneDayKeys(today: string): void {\n try {\n for (let index = localStorage.length - 1; index >= 0; index -= 1) {\n const key = localStorage.key(index)\n if (key !== null && key.startsWith(DAY_KEY_PREFIX) && key !== DAY_KEY_PREFIX + today) {\n localStorage.removeItem(key)\n }\n }\n } catch { /* best effort */ }\n}\n\n/**\n * Fire the daily heartbeat for the given items at most once per UTC day per\n * browser. Never throws and never blocks the caller. Items without an explicit\n * version inherit the bundle's baked build version.\n */\nexport function reportDailyHeartbeat(items: readonly TelemetryItem[]): void {\n try {\n if (items.length === 0) return\n const today = new Date().toISOString().slice(0, 10)\n // Automation contexts (CDP-driven QA browsers, fresh isolated profiles)\n // mint a new visitor id per run and would inflate instance counts.\n if (navigator.webdriver) return\n if (localStorage.getItem(DAY_KEY_PREFIX + today) !== null) return\n const visitor = visitorId()\n if (visitor === null) return\n pruneDayKeys(today)\n const payloadItems = items.map((item) => {\n const out: Record<string, string> = { name: item.name }\n const version = item.version ?? bakedVersion()\n if (version !== undefined) out.version = version\n if (item.channel !== undefined) out.channel = item.channel\n return out\n })\n const body = JSON.stringify({ kind: 'heartbeat', visitor, items: payloadItems })\n void fetch(ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body,\n keepalive: true,\n }).then((response) => {\n // Mark the day only after an accepted send, so offline browsers retry\n // on a later mount instead of going dark until tomorrow.\n if (response.ok) localStorage.setItem(DAY_KEY_PREFIX + today, '1')\n }).catch(() => { /* unreachable endpoint: stay silent */ })\n } catch { /* never break the host UI over telemetry */ }\n}\n","/**\n * Plugin-manager browser half: contributes the package's one remaining\n * surface — the check-for-updates block on the official Plugins page — and\n * provides the dual-channel face as the `'pluginManager'` cordis service for\n * sibling client plugins.\n *\n * It is dual-channel: on runtimes with the official installer services\n * (DSHCode, the 1.0.4 checkout web) every operation rides the official\n * `/plugin-installer` and `/plugin-control` loopback RPC channels (the single\n * writer); on the npm-published web runtime those channels do not exist, so the\n * same face falls back to this package's own loopback HTTP gateway, which\n * spawns the official CLI for writes. Neither the patch nor service consumers\n * know which mode the face runs in.\n *\n * The package used to register its own \"Plugin manager\" tab into the official\n * Plugins settings section (`settings.plugins.tab`). Installing, uninstalling\n * and enabling moved to the official page long ago, and the tab's remaining\n * half was UI no official page renders; the tab is gone and its one genuinely\n * missing capability — comparing an installed plugin against its registry\n * source, with the DSH-runtime compatibility gate — now renders inside the\n * official page through the `plugins.detail.section` seat it declares.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the renderer plugin's Context merge (ctx.slots, the\n// registry this package registers its contribution into).\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\nimport { PluginUpdatePatch, type PluginUpdatePatchInjected } from './PluginUpdatePatch.tsx'\nimport { mountPluginListToolbar } from './plugin-toolbar-mount.tsx'\nimport { en, zh, type PluginManagerKey } from './locales.ts'\nimport {\n parseFailuresSnapshot,\n parseInstallStatus,\n parseInstalledPlugin,\n parsePluginList,\n parseRestartMode,\n parseUpdateList,\n type InstalledPluginItem,\n type InstallProgressItem,\n type PluginFailuresSnapshot,\n type PluginUpdateItem,\n type RestartMode,\n} from '../core/protocol.ts'\nimport { PLUGIN_MANAGER_SERVICE, type PluginManagerService } from '../core/service.ts'\nimport { reportDailyHeartbeat } from './telemetry.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Copy for the check-for-updates patch. */\n 'settings.pluginManager': PluginManagerKey\n }\n}\n\nconst NS = 'settings.pluginManager'\nconst CHANNEL = '/plugin-installer'\nconst LIST_ENDPOINT = 'list'\nconst INSTALL_ENDPOINT = 'install'\nconst UPDATE_ENDPOINT = 'update'\nconst UNINSTALL_ENDPOINT = 'uninstall'\nconst SET_ENABLED_ENDPOINT = 'set-enabled'\nconst CHECK_UPDATES_ENDPOINT = 'check-updates'\nconst RESTART_ENDPOINT = 'restart'\nconst STATUS_ENDPOINT = 'status'\nconst FAILURES_ENDPOINT = 'failures'\n\n// DOCUMENT-RELATIVE (issue #1707): the GUI is served with `<base href=\"./\">`,\n// so a sub-path deployment resolves the gateway prefix against its entry\n// directory rather than the origin root.\nconst GATEWAY_PREFIX = 'api/plugin-manager'\n/** Gateway job polling cadence. */\nconst JOB_POLL_MS = 500\n/** Gateway job wait ceiling (the host add deadline is six minutes). */\nconst JOB_WAIT_MS = 7 * 60_000\n\n/** Services required by the patch registration and both channels. */\nexport const inject = ['slots', 'locale', 'connection']\n\n/** The gateway job wire shape served by /status. */\ninterface GatewayJobWire {\n phase: 'running' | 'done' | 'error'\n plugin?: unknown\n error?: string\n}\n\n/**\n * The face the update patch and the `'pluginManager'` cordis service share:\n * the patch's wire surface plus the cross-plugin service contract. The gateway\n * host still records install conflicts and boot failures; no client surface\n * consumes either since the tab left, so neither is on this face.\n */\nexport type PluginManagerFace = PluginUpdatePatchInjected & PluginManagerService & {\n /**\n * Restart DSH so an applied plugin update is loaded. Always rides this\n * package's own loopback route: neither official channel\n * (`/plugin-installer`, `/plugin-control`) has a restart method, and the\n * route answers how the restart was carried out (in-place relaunch, or a\n * packaged Desktop shell that owns the process tree). See host/restart.ts.\n */\n restart: () => Promise<RestartMode>\n /**\n * Read how a restart would be carried out without triggering it (the same\n * route's plan read). The toolbar words its confirmation from this, so a\n * packaged Desktop host can say what its system dialog will do instead of\n * surprising the user with it.\n */\n restartPlan: () => Promise<RestartMode>\n}\n\n/**\n * Build the dual-channel face once: official-channel and gateway-channel\n * implementations, the mode detection that picks between them, and the\n * change-notification listener set. The returned face is both the update\n * patch's injected props and the value provided as the\n * `'pluginManager'` cordis service.\n * @param ctx - the client context (connection).\n * @returns the shared face.\n */\nexport function createPluginManagerFace(ctx: ClientContext): PluginManagerFace {\n const connection = ctx.get('connection') as ConnectionHandle\n\n // Official channel implementations.\n\n const call = async (endpoint: string, payload: unknown): Promise<unknown> => {\n const result = await connection.rpc.call(CHANNEL, endpoint, payload)\n if (!result.ok) {\n throw new Error(`plugin-installer ${endpoint} failed: ${result.error.code}: ${result.error.message}`)\n }\n return result.value\n }\n const official = {\n list: async (): Promise<InstalledPluginItem[]> => parsePluginList(await call(LIST_ENDPOINT, {})),\n install: async (spec: string): Promise<InstalledPluginItem> => parseInstalledPlugin(await call(INSTALL_ENDPOINT, { spec })),\n update: async (id: string): Promise<InstalledPluginItem> => parseInstalledPlugin(await call(UPDATE_ENDPOINT, { id })),\n uninstall: async (id: string): Promise<InstalledPluginItem[]> => parsePluginList(await call(UNINSTALL_ENDPOINT, { id })),\n setEnabled: async (id: string, enabled: boolean): Promise<InstalledPluginItem> =>\n parseInstalledPlugin(await call(SET_ENABLED_ENDPOINT, { id, enabled })),\n checkUpdates: async (): Promise<PluginUpdateItem[]> => parseUpdateList(await call(CHECK_UPDATES_ENDPOINT, {})),\n status: async (): Promise<InstallProgressItem> => parseInstallStatus(await call(STATUS_ENDPOINT, {})),\n failures: async (): Promise<PluginFailuresSnapshot> => parseFailuresSnapshot(await call(FAILURES_ENDPOINT, {})),\n }\n\n // Gateway channel implementations.\n\n const gatewayJson = async (path: string, init?: RequestInit): Promise<unknown> => {\n const response = await fetch(path, {\n ...init,\n headers: { 'content-type': 'application/json', ...init?.headers },\n })\n if (response.status === 403) {\n throw new Error('plugin-manager: plugin management is only available from a local browser')\n }\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string }\n throw new Error(body.error ?? `plugin-manager: gateway ${path} failed: HTTP ${String(response.status)}`)\n }\n return response.json()\n }\n\n /** Wait for one gateway job to settle, returning its wire state. */\n const waitJob = async (jobId: string): Promise<GatewayJobWire> => {\n const deadline = Date.now() + JOB_WAIT_MS\n for (;;) {\n const body = await gatewayJson(`${GATEWAY_PREFIX}/status?job=${encodeURIComponent(jobId)}`) as { job?: GatewayJobWire }\n const job = body.job\n if (job === undefined) throw new Error('plugin-manager: gateway job vanished')\n if (job.phase === 'done') return job\n if (job.phase === 'error') throw new Error(job.error ?? 'plugin-manager: gateway job failed')\n if (Date.now() > deadline) throw new Error('plugin-manager: gateway job timed out')\n await new Promise(resolve => { setTimeout(resolve, JOB_POLL_MS) })\n }\n }\n\n /** Whether a gateway install/remove is in flight (drives the progress row). */\n let gatewayInflight = false\n\n const gateway = {\n list: async (): Promise<InstalledPluginItem[]> =>\n parsePluginList(await gatewayJson(`${GATEWAY_PREFIX}/list`)),\n install: async (spec: string): Promise<InstalledPluginItem> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/install`, {\n method: 'POST',\n body: JSON.stringify({ spec }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway install returned no job')\n const job = await waitJob(started.jobId)\n return parseInstalledPlugin({ plugin: job.plugin })\n } finally {\n gatewayInflight = false\n }\n },\n update: async (id: string): Promise<InstalledPluginItem> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/update`, {\n method: 'POST',\n body: JSON.stringify({ id }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway update returned no job')\n const job = await waitJob(started.jobId)\n return parseInstalledPlugin({ plugin: job.plugin })\n } finally {\n gatewayInflight = false\n }\n },\n uninstall: async (id: string): Promise<InstalledPluginItem[]> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/remove`, {\n method: 'POST',\n body: JSON.stringify({ id }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway remove returned no job')\n await waitJob(started.jobId)\n return gateway.list()\n } finally {\n gatewayInflight = false\n }\n },\n setEnabled: async (id: string, enabled: boolean): Promise<InstalledPluginItem> =>\n parseInstalledPlugin(await gatewayJson(`${GATEWAY_PREFIX}/set-enabled`, {\n method: 'POST',\n body: JSON.stringify({ id, enabled }),\n })),\n checkUpdates: async (): Promise<PluginUpdateItem[]> =>\n parseUpdateList(await gatewayJson(`${GATEWAY_PREFIX}/check-updates`)),\n status: async (): Promise<InstallProgressItem> =>\n gatewayInflight ? { kind: 'install', stage: 'download' } : { kind: 'idle', stage: 'fetch' },\n failures: async (): Promise<PluginFailuresSnapshot> =>\n parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`)),\n // Restart has no official-channel counterpart, so this route is the one\n // call that is always the gateway's, whichever mode the face runs in. The\n // GET-shaped call is the plan read: no state changes, no process exits.\n restartPlan: async (): Promise<RestartMode> =>\n parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`)),\n restart: async (): Promise<RestartMode> =>\n parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`, { method: 'POST' })),\n }\n\n // Mode selection.\n\n let modePromise: Promise<'official' | 'gateway'> | undefined\n const ensureMode = (): Promise<'official' | 'gateway'> => {\n if (modePromise === undefined) {\n modePromise = (async () => {\n // Prefer the host verdict: the gateway's /mode route reports whether\n // the official installer channels exist, so the direct channel probe\n // below (which 405s into the browser console on the npm web runtime)\n // only runs when the host half is absent or explicitly returns null\n // for a desktop runtime whose services are registered in-process.\n try {\n const mode = await gatewayJson(`${GATEWAY_PREFIX}/mode`) as { official?: boolean | null }\n if (mode.official === true) return 'official' as const\n if (mode.official === false) return 'gateway' as const\n } catch {\n // Host half absent (an official runtime without a boot profile):\n // fall back to the direct channel probe.\n }\n try {\n const result = await connection.rpc.call(CHANNEL, LIST_ENDPOINT, {})\n return result.ok ? 'official' as const : 'gateway' as const\n } catch {\n return 'gateway' as const\n }\n })()\n }\n return modePromise\n }\n\n // Change notification.\n\n /** Listeners subscribed through onChange; fired after successful mutations. */\n const listeners = new Set<() => void>()\n /** Notify every listener; one listener throwing never breaks the others. */\n const notifyChange = (): void => {\n for (const listener of [...listeners]) {\n try {\n listener()\n } catch {\n // A consumer's listener failure is its own; keep notifying the rest.\n }\n }\n }\n\n // The shared face.\n\n return {\n isLoopback: connection.isLoopback,\n list: async () => (await ensureMode()) === 'official' ? official.list() : gateway.list(),\n install: async spec => {\n const item = await ((await ensureMode()) === 'official' ? official.install(spec) : gateway.install(spec))\n notifyChange()\n return item\n },\n update: async id => {\n const item = await ((await ensureMode()) === 'official' ? official.update(id) : gateway.update(id))\n notifyChange()\n return item\n },\n uninstall: async id => {\n const rows = await ((await ensureMode()) === 'official' ? official.uninstall(id) : gateway.uninstall(id))\n notifyChange()\n return rows\n },\n setEnabled: async (id, enabled) => {\n const item = await ((await ensureMode()) === 'official' ? official.setEnabled(id, enabled) : gateway.setEnabled(id, enabled))\n notifyChange()\n return item\n },\n checkUpdates: async () => (await ensureMode()) === 'official' ? official.checkUpdates() : gateway.checkUpdates(),\n restartPlan: () => gateway.restartPlan(),\n restart: () => gateway.restart(),\n status: async () => (await ensureMode()) === 'official' ? official.status() : gateway.status(),\n failures: async () => (await ensureMode()) === 'official' ? official.failures() : gateway.failures(),\n onChange: cb => {\n listeners.add(cb)\n return () => { listeners.delete(cb) }\n },\n }\n}\n\n/** Contribute the check-for-updates patch and provide the shared face. */\nexport function apply(ctx: ClientContext): void {\n // Anonymous install heartbeat (docs/telemetry.md): one beat per browser per\n // UTC day, package name only, silent failure.\n reportDailyHeartbeat([{ name: '@linxin666/dsh-client-ui-plugin-manager' }])\n\n ctx.effect(() => {\n try {\n return ctx.locale.register(NS, { zh, en })\n } catch {\n return () => {}\n }\n }, 'plugin-manager: dictionaries')\n\n // Built once: the patch and the 'pluginManager' cordis service share one\n // face, so consumers observe exactly the mutations the patch performs.\n const face = createPluginManagerFace(ctx)\n try {\n if (!ctx.get(PLUGIN_MANAGER_SERVICE)) {\n ctx.provide(PLUGIN_MANAGER_SERVICE, face)\n }\n } catch {\n // ignore duplicate provide\n }\n\n // The list-level toolbar rides the page's own \"Installed\" heading: the\n // official page declares no seat beside it, so the entry is inserted into\n // the heading element itself and tracks the page through the shared body\n // mutation hub. Its translate function is rebuilt on every render so a\n // language switch reaches copy that no slot outlet owns.\n ctx.effect(() => {\n try {\n return mountPluginListToolbar({\n props: () => ({\n isLoopback: face.isLoopback,\n checkUpdates: face.checkUpdates,\n update: face.update,\n restartPlan: face.restartPlan,\n restart: face.restart,\n t: ctx.locale.bind(NS),\n }),\n subscribe: listener => ctx.locale.subscribe(listener),\n })\n } catch {\n return () => {}\n }\n }, 'plugin-manager: update toolbar')\n\n // The official Plugins page declares this seat on its main-panel entry and\n // renders one section per contribution on each bundle / row / plugin page;\n // `inject` waits for that declaration, exactly like the family plugin cards\n // that register into `plugins.bundle.config`.\n ctx.slots.inject('plugins.detail.section', () => {\n try {\n return ctx.slots.register({\n name: 'plugins.detail.section',\n id: 'family-update-check',\n order: 30,\n locale: NS,\n inject: () => face,\n }, PluginUpdatePatch)\n } catch {\n return () => {}\n }\n })\n}\n"],"mappings":";;;;;;;;;;EAyFA,MAAM,wBAAwB;;;;;;;;;EA2B9B,SAAgB,sBAAsB,SAAyB;GAC7D,MAAM,QAAQ,sBAAsB,KAAK,QAAQ,KAAK,CAAC;GACvD,OAAO,UAAU,OAAO,QAAQ,KAAK,IAAI,MAAM,EAAE,CAAC,QAAQ,MAAM,EAAE;EACpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EC/BA,SAASA,YAAU,OAAwB;GACzC,IAAI,iBAAiB,gBAAgB;IACnC,MAAM,UAAU,MAAM,OAAO,IAAIA,WAAS,CAAC,CAAC,KAAK,IAAI;IACrD,OAAO,YAAY,KAAK,MAAM,UAAU,GAAG,MAAM,QAAQ,IAAI;GAC/D;GACA,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC9D;;EAGA,SAAS,cAAc,UAA+B,GAAwC;GAC5F,IAAI,SAAS,UAAU,SAAS,OAAO,EAAE,SAAS;GAClD,OAAO,SAAS,YAAY,KAAA,IAAY,EAAE,aAAa,IAAI,EAAE,sBAAsB,EAAE,SAAS,OAAO,SAAS,OAAO,EAAE,CAAC;EAC1H;;;;;;;EAQA,SAAgB,kBAAkB,OAA+B;GAC/D,MAAM,EAAE,GAAG,SAAS,YAAY,cAAc,QAAQ,WAAW;GAEjE,MAAM,CAAC,SAAS,eAAA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AC,EAAE,MAAM,0CAA0C,CAAC,CAAC;GAE1E,IAAI,aAAa;IACf,IAAI;KACF,OAAO,IAAI,OAAO,SAAS,IAAI;MAAE;MAAI;KAAG,CAAC;IAC3C,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,GAAG,8BAA8B;GAIjC,MAAM,OAAO,wBAAwB,GAAG;GACxC,IAAI;IACF,IAAI,CAAC,IAAI,IAAA,eAA0B,GACjC,IAAI,QAAQ,wBAAwB,IAAI;GAE5C,QAAQ,CAER;GAOA,IAAI,aAAa;IACf,IAAI;KACF,OAAO,uBAAuB;MAC5B,cAAc;OACZ,YAAY,KAAK;OACjB,cAAc,KAAK;OACnB,QAAQ,KAAK;OACb,aAAa,KAAK;OAClB,SAAS,KAAK;OACd,GAAG,IAAI,OAAO,KAAK,EAAE;MACvB;MACA,YAAW,aAAY,IAAI,OAAO,UAAU,QAAQ;KACtD,CAAC;IACH,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,GAAG,gCAAgC;GAMnC,IAAI,MAAM,OAAO,gCAAgC;IAC/C,IAAI;KACF,OAAO,IAAI,MAAM,SAAS;MACxB,MAAM;MACN,IAAI;MACJ,OAAO;MACP,QAAQ;MACR,cAAc;KAChB,GAAG,iBAAiB;IACtB,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,CAAC;EACH"}
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { basename, dirname, isAbsolute, join, normalize, posix, sep, win32 } fro
|
|
|
5
5
|
import { isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import { isAbsolute as isAbsolute$1, join as join$1 } from "node:path/posix";
|
|
8
|
+
import { AsyncResource } from "node:async_hooks";
|
|
8
9
|
//#region src/mount-once.ts
|
|
9
10
|
/**
|
|
10
11
|
* Host single-instance guard shared by the plugin family. The family bundle
|
|
@@ -582,6 +583,38 @@ function desktopSelectedProfile(env = process.env) {
|
|
|
582
583
|
} catch {}
|
|
583
584
|
}
|
|
584
585
|
/**
|
|
586
|
+
* The running installation's own `@deepseek-ai/dsh` package.json, as the
|
|
587
|
+
* launcher published it on `profileContext`, or undefined when the host
|
|
588
|
+
* publishes none (or publishes something unusable). This is a READ-ONLY
|
|
589
|
+
* fact — unlike the profile directory and the patch path it is never a write
|
|
590
|
+
* target — but it still arrives from outside this package, so it must be an
|
|
591
|
+
* absolute, traversal-free path before anything reads a version out of it.
|
|
592
|
+
* @param launched - the profile facts the Host published, when available.
|
|
593
|
+
* @returns the validated anchor path, or undefined.
|
|
594
|
+
*/
|
|
595
|
+
function launchedInstallAnchor(launched) {
|
|
596
|
+
const anchor = launched === void 0 || typeof launched.installAnchor !== "string" ? "" : launched.installAnchor.trim();
|
|
597
|
+
if (anchor === "") return void 0;
|
|
598
|
+
if (!isAbsolute(anchor) || anchor.split(/[\/\\]/).includes("..")) return void 0;
|
|
599
|
+
return anchor;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Read the `version` field of one package manifest, tolerating every failure:
|
|
603
|
+
* a missing file, an unreadable one (a stripped asar entry), malformed JSON, or
|
|
604
|
+
* a non-string version all read as "no version". Callers fall back to their next
|
|
605
|
+
* source rather than reporting a version nobody declared.
|
|
606
|
+
* @param manifestPath - absolute path of a package.json.
|
|
607
|
+
* @returns the declared version, or undefined.
|
|
608
|
+
*/
|
|
609
|
+
function readManifestVersion(manifestPath) {
|
|
610
|
+
try {
|
|
611
|
+
const parsed = JSON.parse(stripBom(readFileSync(manifestPath, "utf8")));
|
|
612
|
+
return typeof parsed.version === "string" && parsed.version.trim() !== "" ? parsed.version.trim() : void 0;
|
|
613
|
+
} catch {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
585
618
|
* Whether the host argv names the packaged Desktop launcher, whose entry
|
|
586
619
|
* script is `@deepseek-ai/dsh-desktop-host`. The Desktop client boots the
|
|
587
620
|
* `desktop` profile through `runProfile()` WITHOUT a `--profile` flag and
|
|
@@ -1079,8 +1112,54 @@ const UNSAFE_SPEC_CHARS = /[&|<>"'`%!\n\r\0]/;
|
|
|
1079
1112
|
function unsafeSpecReason(spec) {
|
|
1080
1113
|
return UNSAFE_SPEC_CHARS.test(spec) ? "plugin-manager: spec 含有危险的 shell 元字符或控制字符,已拒绝" : void 0;
|
|
1081
1114
|
}
|
|
1115
|
+
/**
|
|
1116
|
+
* The Electron resource roots a packaged Desktop install may carry, as
|
|
1117
|
+
* absolute directories. Two independent launcher facts name them, and either
|
|
1118
|
+
* alone is enough:
|
|
1119
|
+
*
|
|
1120
|
+
* - `process.resourcesPath` is Electron's own answer for the directory holding
|
|
1121
|
+
* `app.asar` and the bundled runtime (the Desktop host runs as an Electron
|
|
1122
|
+
* Node-mode child, so it always has one);
|
|
1123
|
+
* - the running host entry script sits INSIDE that tree
|
|
1124
|
+
* (`<resources>/app.asar/dsh/node_modules/@deepseek-ai/dsh-desktop-host/lib/index.js`),
|
|
1125
|
+
* so the first ancestor directory named `resources` is the same location even
|
|
1126
|
+
* when the process is not Electron.
|
|
1127
|
+
*
|
|
1128
|
+
* A root is only ever used to build a candidate path that must then exist, so
|
|
1129
|
+
* an unrelated `resources` directory elsewhere in the tree resolves to nothing.
|
|
1130
|
+
* @param hostEntryPath - the running host's entry script.
|
|
1131
|
+
* @param resourcesPath - Electron's resource directory, when the host has one.
|
|
1132
|
+
* @param pathApi - platform path semantics.
|
|
1133
|
+
* @returns candidate resource roots, in probe order.
|
|
1134
|
+
*/
|
|
1135
|
+
function desktopResourceRoots(hostEntryPath, resourcesPath, pathApi) {
|
|
1136
|
+
const roots = [];
|
|
1137
|
+
if (resourcesPath !== void 0 && resourcesPath !== "") roots.push(resourcesPath);
|
|
1138
|
+
if (hostEntryPath !== void 0 && hostEntryPath !== "") {
|
|
1139
|
+
let current = pathApi.dirname(hostEntryPath);
|
|
1140
|
+
for (let depth = 0; depth < 12; depth += 1) {
|
|
1141
|
+
const parent = pathApi.dirname(current);
|
|
1142
|
+
if (parent === current) break;
|
|
1143
|
+
current = parent;
|
|
1144
|
+
if (pathApi.basename(current).toLowerCase() === "resources") {
|
|
1145
|
+
roots.push(current);
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return roots;
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Electron's resource directory when this process is an Electron child, read
|
|
1154
|
+
* defensively: the type is not in `@types/node`, and a plain Node host has no
|
|
1155
|
+
* such property at all.
|
|
1156
|
+
*/
|
|
1157
|
+
function processResourcesPath() {
|
|
1158
|
+
const value = process.resourcesPath;
|
|
1159
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
1160
|
+
}
|
|
1082
1161
|
/** The binary search roots for the dsh CLI. */
|
|
1083
|
-
function findDshBinary(env = process.env, platform = process.platform, exists = existsSync, hostEntryPath = process.argv[1]) {
|
|
1162
|
+
function findDshBinary(env = process.env, platform = process.platform, exists = existsSync, hostEntryPath = process.argv[1], resourcesPath = processResourcesPath()) {
|
|
1084
1163
|
const candidates = [];
|
|
1085
1164
|
const separator = platform === "win32" ? ";" : ":";
|
|
1086
1165
|
const pathApi = platform === "win32" ? win32 : posix;
|
|
@@ -1106,6 +1185,11 @@ function findDshBinary(env = process.env, platform = process.platform, exists =
|
|
|
1106
1185
|
const packageRoot = pathApi.dirname(entryDir);
|
|
1107
1186
|
candidates.push(pathApi.join(packageRoot, "lib", "bin.js"));
|
|
1108
1187
|
}
|
|
1188
|
+
for (const root of desktopResourceRoots(hostEntryPath, resourcesPath, pathApi)) {
|
|
1189
|
+
const cliBin = pathApi.join(root, "runtime", "cli", "bin");
|
|
1190
|
+
if (platform === "win32") candidates.push(pathApi.join(cliBin, "dsh.cmd"), pathApi.join(cliBin, "dsh.exe"));
|
|
1191
|
+
else candidates.push(pathApi.join(cliBin, "dsh"));
|
|
1192
|
+
}
|
|
1109
1193
|
for (const candidate of candidates) if (exists(candidate)) return candidate;
|
|
1110
1194
|
return null;
|
|
1111
1195
|
}
|
|
@@ -2488,6 +2572,61 @@ function targetSpecForLegacy(sourceSpec, familyVersion) {
|
|
|
2488
2572
|
if (familyVersion === "") return void 0;
|
|
2489
2573
|
return `${CURRENT_AGGREGATE}@${familyVersion}`;
|
|
2490
2574
|
}
|
|
2575
|
+
//#endregion
|
|
2576
|
+
//#region src/host/detached-work.ts
|
|
2577
|
+
/**
|
|
2578
|
+
* Run one piece of work outside the caller's async context.
|
|
2579
|
+
*
|
|
2580
|
+
* A Host mutation that runs inside `hmr.runExclusive` marks the running async
|
|
2581
|
+
* context with an AsyncLocalStorage store. Side effects on that path that write
|
|
2582
|
+
* a file the HMR config watcher refreshes from - `cordis.patch.yml` above all -
|
|
2583
|
+
* must not run under that mark, or the watcher's refresh re-enters the
|
|
2584
|
+
* exclusive transaction and is refused with "HMR transactions cannot be nested"
|
|
2585
|
+
* (#1751, #1754, #1816).
|
|
2586
|
+
*
|
|
2587
|
+
* Deferring is NOT enough, and the earlier belt that this one replaces was
|
|
2588
|
+
* built on a disproven premise: Node propagates an AsyncLocalStorage store into
|
|
2589
|
+
* `setImmediate`, into `node:timers`, into promise continuations, and into any
|
|
2590
|
+
* AsyncResource scoped to the current async id. Measured on Node 24:
|
|
2591
|
+
*
|
|
2592
|
+
* ```
|
|
2593
|
+
* als.run(true, () => setImmediate(() => als.getStore())) // -> true
|
|
2594
|
+
* ```
|
|
2595
|
+
*
|
|
2596
|
+
* What DOES start clean is an AsyncResource whose `triggerAsyncId` is not the
|
|
2597
|
+
* transaction. A resource created once at module scope - that is, before any
|
|
2598
|
+
* transaction existed - carries no store, and everything it schedules inherits
|
|
2599
|
+
* that emptiness rather than the caller's mark:
|
|
2600
|
+
*
|
|
2601
|
+
* ```
|
|
2602
|
+
* const detached = new AsyncResource('...') // module scope
|
|
2603
|
+
* als.run(true, () => detached.runInAsyncScope(() => setImmediate(() => als.getStore())))
|
|
2604
|
+
* // -> undefined
|
|
2605
|
+
* ```
|
|
2606
|
+
*
|
|
2607
|
+
* @module dsh-web-shared/host/detached-work
|
|
2608
|
+
*/
|
|
2609
|
+
/**
|
|
2610
|
+
* The escape hatch, created at module scope on purpose: a resource built while
|
|
2611
|
+
* a transaction is running would capture that transaction, so this single
|
|
2612
|
+
* instance is the only one the module ever needs. It carries no context of its
|
|
2613
|
+
* own, so every job run through it starts from the process's root context.
|
|
2614
|
+
*/
|
|
2615
|
+
const DETACHED = new AsyncResource("dsh-web:detached-work", { triggerAsyncId: 0 });
|
|
2616
|
+
/**
|
|
2617
|
+
* Run `work` outside the caller's AsyncLocalStorage context.
|
|
2618
|
+
*
|
|
2619
|
+
* The call itself is synchronous - this schedules, it does not defer. Work that
|
|
2620
|
+
* must not block the caller should schedule its own `setImmediate` inside
|
|
2621
|
+
* `work`, which then also starts clean because it inherits this resource's
|
|
2622
|
+
* empty context rather than the caller's.
|
|
2623
|
+
*
|
|
2624
|
+
* @param work - the side effect to detach from the caller's async context.
|
|
2625
|
+
* @returns whatever `work` returns.
|
|
2626
|
+
*/
|
|
2627
|
+
function runDetached(work) {
|
|
2628
|
+
return DETACHED.runInAsyncScope(work);
|
|
2629
|
+
}
|
|
2491
2630
|
/** How long the helper waits for this process to disappear before giving up on the wait. */
|
|
2492
2631
|
const RESTART_WAIT_MS = 3e4;
|
|
2493
2632
|
/** Exit/interpreter arguments a relaunch must not repeat (they re-bind fixed ports). */
|
|
@@ -2655,11 +2794,34 @@ async function fetchRegistryManifest(name) {
|
|
|
2655
2794
|
};
|
|
2656
2795
|
}
|
|
2657
2796
|
/**
|
|
2658
|
-
* Read the running DSH host version
|
|
2659
|
-
*
|
|
2660
|
-
*
|
|
2661
|
-
*
|
|
2662
|
-
*
|
|
2797
|
+
* Read the running DSH host version out of the installation's own manifest.
|
|
2798
|
+
*
|
|
2799
|
+
* The launcher publishes the `@deepseek-ai/dsh` package.json it booted from on
|
|
2800
|
+
* `profileContext.installAnchor`; that manifest's `version` is by construction
|
|
2801
|
+
* the version of the DSH this host is running. It is the primary source because
|
|
2802
|
+
* it is the only one a packaged Desktop install can answer: there the CLI is not
|
|
2803
|
+
* on PATH, every `.bin` shim is stripped from the installer, and the private
|
|
2804
|
+
* host package ships no `lib/bin.js` to run (issue #1819). A runtime that
|
|
2805
|
+
* publishes no anchor (or one whose manifest cannot be read) falls through to
|
|
2806
|
+
* {@link probeDshVersion}.
|
|
2807
|
+
* @param installAnchor - the published anchor path, when there is one.
|
|
2808
|
+
* @returns the running version, or undefined when it cannot be read.
|
|
2809
|
+
*/
|
|
2810
|
+
function readInstalledDshVersion(installAnchor) {
|
|
2811
|
+
if (installAnchor === void 0) return void 0;
|
|
2812
|
+
return readManifestVersion(installAnchor);
|
|
2813
|
+
}
|
|
2814
|
+
/**
|
|
2815
|
+
* Read the running DSH host version through `dsh --version`.
|
|
2816
|
+
*
|
|
2817
|
+
* This is the FALLBACK source, used only when the installation's own manifest
|
|
2818
|
+
* could not be read. It costs a subprocess and needs a CLI this host can reach,
|
|
2819
|
+
* which a packaged Desktop host cannot: the launcher puts only `node` on its
|
|
2820
|
+
* PATH, the installer strips every `node_modules/.bin`, and the private host
|
|
2821
|
+
* package ships no `lib/bin.js` (issue #1819). Returns undefined when the
|
|
2822
|
+
* binary is unavailable or the output is not a plain semver; callers treat an
|
|
2823
|
+
* unknown host version as a fail-closed verdict for declared requirements
|
|
2824
|
+
* (issue #754).
|
|
2663
2825
|
*/
|
|
2664
2826
|
async function probeDshVersion(cliAvailable) {
|
|
2665
2827
|
if (!cliAvailable()) return void 0;
|
|
@@ -2722,16 +2884,24 @@ function makeGatewayRoutes(deps) {
|
|
|
2722
2884
|
const { facts, gateway } = deps;
|
|
2723
2885
|
const fetchManifest = deps.fetchManifest ?? fetchRegistryManifest;
|
|
2724
2886
|
/**
|
|
2725
|
-
* Cached
|
|
2726
|
-
*
|
|
2727
|
-
*
|
|
2728
|
-
*
|
|
2887
|
+
* Cached host version: successful verdicts refresh after a TTL (the CLI update
|
|
2888
|
+
* path is the gateway itself, so a stale success is wrong long-term), failed
|
|
2889
|
+
* probes are retried after a cooldown instead of being cached forever, and
|
|
2890
|
+
* concurrent requests share one in-flight probe.
|
|
2891
|
+
*
|
|
2892
|
+
* The running installation's own manifest is read first. That is a local file
|
|
2893
|
+
* read with no process to spawn and nothing to fall out of date mid-run, so it
|
|
2894
|
+
* is re-read per resolution and never cached: a packaged Desktop host, where
|
|
2895
|
+
* the CLI fallback is unreachable, would otherwise spend its first request on
|
|
2896
|
+
* a probe that cannot succeed.
|
|
2729
2897
|
*/
|
|
2730
2898
|
let dshVersion;
|
|
2731
2899
|
let dshVersionAt = 0;
|
|
2732
2900
|
let dshVersionPending;
|
|
2733
2901
|
const resolveDshVersion = () => {
|
|
2734
2902
|
if (deps.dshVersion !== void 0) return deps.dshVersion();
|
|
2903
|
+
const installed = readInstalledDshVersion(deps.installAnchor);
|
|
2904
|
+
if (installed !== void 0) return Promise.resolve(installed);
|
|
2735
2905
|
const now = Date.now();
|
|
2736
2906
|
if (dshVersion !== void 0 && now - dshVersionAt < VERSION_PROBE_TTL_MS) return Promise.resolve(dshVersion);
|
|
2737
2907
|
if (dshVersionAt !== 0 && now - dshVersionAt < VERSION_PROBE_COOLDOWN_MS) return Promise.resolve(void 0);
|
|
@@ -2863,7 +3033,7 @@ function makeGatewayRoutes(deps) {
|
|
|
2863
3033
|
const { hostVersion, compatible } = await compatibleVerdict(requiresDsh);
|
|
2864
3034
|
if (!compatible) return {
|
|
2865
3035
|
status: 412,
|
|
2866
|
-
error: hostVersion === void 0 ? `plugin-manager: cannot verify the DSH version for ${migration.to}
|
|
3036
|
+
error: hostVersion === void 0 ? `plugin-manager: cannot verify the running DSH version for ${migration.to}; check the DSH runtime before migrating` : `plugin-manager: ${migration.to} requires DSH ${requiresDsh} (current DSH ${hostVersion}); upgrade DSH before migrating`
|
|
2867
3037
|
};
|
|
2868
3038
|
}
|
|
2869
3039
|
return {
|
|
@@ -2899,7 +3069,7 @@ function makeGatewayRoutes(deps) {
|
|
|
2899
3069
|
const { hostVersion, compatible } = await compatibleVerdict(requiresDsh);
|
|
2900
3070
|
if (!compatible) return {
|
|
2901
3071
|
status: 412,
|
|
2902
|
-
error: hostVersion === void 0 ? `plugin-manager: cannot verify the DSH version for ${target}
|
|
3072
|
+
error: hostVersion === void 0 ? `plugin-manager: cannot verify the running DSH version for ${target}; check the DSH runtime before updating` : `plugin-manager: ${target} requires DSH ${requiresDsh} (current DSH ${hostVersion}); upgrade DSH before updating`
|
|
2903
3073
|
};
|
|
2904
3074
|
}
|
|
2905
3075
|
return {
|
|
@@ -2981,7 +3151,11 @@ function makeGatewayRoutes(deps) {
|
|
|
2981
3151
|
const entryEnabled = enabled || LOCKED_ENTRY_IDS.has(entry.id);
|
|
2982
3152
|
next = setRowEnabled(next, facts.patchPath, entry.id, entry.name, entryEnabled, entry.baseEnabled);
|
|
2983
3153
|
}
|
|
2984
|
-
if (next !== patchText) await
|
|
3154
|
+
if (next !== patchText) await runDetached(() => new Promise((resolve, reject) => {
|
|
3155
|
+
setImmediate(() => {
|
|
3156
|
+
writePatchAtomic(facts.patchPath, next).then(resolve, reject);
|
|
3157
|
+
});
|
|
3158
|
+
}));
|
|
2985
3159
|
const plugin = (await snapshotGateway(facts, next)).plugins.find((item) => item.id === ownerName);
|
|
2986
3160
|
return plugin === void 0 ? { error: `plugin-manager: plugin ${ownerName} is not installed` } : { plugin };
|
|
2987
3161
|
});
|
|
@@ -3029,7 +3203,9 @@ function makeGatewayRoutes(deps) {
|
|
|
3029
3203
|
const requiresDsh = dshRequirementOf(targetManifest);
|
|
3030
3204
|
if (requiresDsh !== void 0) {
|
|
3031
3205
|
update.requiresDsh = requiresDsh;
|
|
3032
|
-
|
|
3206
|
+
const verdict = await compatibleVerdict(requiresDsh);
|
|
3207
|
+
update.compatible = verdict.compatible;
|
|
3208
|
+
if (verdict.hostVersion !== void 0) update.hostVersion = verdict.hostVersion;
|
|
3033
3209
|
}
|
|
3034
3210
|
updates.push(update);
|
|
3035
3211
|
continue;
|
|
@@ -3045,7 +3221,9 @@ function makeGatewayRoutes(deps) {
|
|
|
3045
3221
|
const requiresDsh = dshRequirementOf(manifest);
|
|
3046
3222
|
if (requiresDsh !== void 0) {
|
|
3047
3223
|
update.requiresDsh = requiresDsh;
|
|
3048
|
-
|
|
3224
|
+
const verdict = await compatibleVerdict(requiresDsh);
|
|
3225
|
+
update.compatible = verdict.compatible;
|
|
3226
|
+
if (verdict.hostVersion !== void 0) update.hostVersion = verdict.hostVersion;
|
|
3049
3227
|
}
|
|
3050
3228
|
updates.push(update);
|
|
3051
3229
|
}
|
|
@@ -3182,8 +3360,9 @@ function officialManager(ctx) {
|
|
|
3182
3360
|
}
|
|
3183
3361
|
function applyImpl(ctx) {
|
|
3184
3362
|
let facts;
|
|
3363
|
+
const launched = launchedProfile(ctx);
|
|
3185
3364
|
try {
|
|
3186
|
-
facts = resolveProfile(process.argv, process.env,
|
|
3365
|
+
facts = resolveProfile(process.argv, process.env, launched);
|
|
3187
3366
|
} catch (error) {
|
|
3188
3367
|
console.error("[plugin-manager]", error instanceof Error ? error.message : String(error));
|
|
3189
3368
|
return;
|
|
@@ -3191,11 +3370,13 @@ function applyImpl(ctx) {
|
|
|
3191
3370
|
if (!profileExists(facts.profileDir)) return;
|
|
3192
3371
|
const gateway = new CliGateway(facts, process.env, { nativeManager: () => officialManager(ctx) });
|
|
3193
3372
|
const cliAvailable = () => findDshBinary() !== null;
|
|
3373
|
+
const installAnchor = launchedInstallAnchor(launched);
|
|
3194
3374
|
ctx.effect(() => {
|
|
3195
3375
|
const disposers = makeGatewayRoutes({
|
|
3196
3376
|
facts,
|
|
3197
3377
|
gateway,
|
|
3198
|
-
cliAvailable
|
|
3378
|
+
cliAvailable,
|
|
3379
|
+
installAnchor
|
|
3199
3380
|
}).map((route) => ctx.webServer.register(route));
|
|
3200
3381
|
return () => {
|
|
3201
3382
|
for (const dispose of disposers) dispose();
|
|
@@ -20,6 +20,7 @@ declare const STATIC_ZH: {
|
|
|
20
20
|
latest: string;
|
|
21
21
|
updateRequiresDsh: string;
|
|
22
22
|
updateBlockedDsh: string;
|
|
23
|
+
updateUnverifiedDsh: string;
|
|
23
24
|
restartHint: string;
|
|
24
25
|
updatesAvailable: string;
|
|
25
26
|
updateAll: string;
|
|
@@ -57,6 +58,7 @@ export declare const zh: {
|
|
|
57
58
|
latest: string;
|
|
58
59
|
updateRequiresDsh: string;
|
|
59
60
|
updateBlockedDsh: string;
|
|
61
|
+
updateUnverifiedDsh: string;
|
|
60
62
|
restartHint: string;
|
|
61
63
|
updatesAvailable: string;
|
|
62
64
|
updateAll: string;
|
|
@@ -94,6 +96,7 @@ export declare const en: {
|
|
|
94
96
|
latest: string;
|
|
95
97
|
updateRequiresDsh: string;
|
|
96
98
|
updateBlockedDsh: string;
|
|
99
|
+
updateUnverifiedDsh: string;
|
|
97
100
|
restartHint: string;
|
|
98
101
|
updatesAvailable: string;
|
|
99
102
|
updateAll: string;
|
|
@@ -73,6 +73,12 @@ export interface PluginUpdateItem {
|
|
|
73
73
|
requiresDsh?: string;
|
|
74
74
|
/** Whether the running DSH host satisfies requiresDsh; absent when unknown. */
|
|
75
75
|
compatible?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The running DSH version the verdict was made from, when the host could read
|
|
78
|
+
* it. Its absence is what separates "this host is too old" from "this host
|
|
79
|
+
* could not be asked" — different problems, with different copy (issue #1819).
|
|
80
|
+
*/
|
|
81
|
+
hostVersion?: string;
|
|
76
82
|
}
|
|
77
83
|
/** One recorded plugin boot failure served by the host. */
|
|
78
84
|
export interface PluginFailureItem {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run one piece of work outside the caller's async context.
|
|
3
|
+
*
|
|
4
|
+
* A Host mutation that runs inside `hmr.runExclusive` marks the running async
|
|
5
|
+
* context with an AsyncLocalStorage store. Side effects on that path that write
|
|
6
|
+
* a file the HMR config watcher refreshes from - `cordis.patch.yml` above all -
|
|
7
|
+
* must not run under that mark, or the watcher's refresh re-enters the
|
|
8
|
+
* exclusive transaction and is refused with "HMR transactions cannot be nested"
|
|
9
|
+
* (#1751, #1754, #1816).
|
|
10
|
+
*
|
|
11
|
+
* Deferring is NOT enough, and the earlier belt that this one replaces was
|
|
12
|
+
* built on a disproven premise: Node propagates an AsyncLocalStorage store into
|
|
13
|
+
* `setImmediate`, into `node:timers`, into promise continuations, and into any
|
|
14
|
+
* AsyncResource scoped to the current async id. Measured on Node 24:
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* als.run(true, () => setImmediate(() => als.getStore())) // -> true
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* What DOES start clean is an AsyncResource whose `triggerAsyncId` is not the
|
|
21
|
+
* transaction. A resource created once at module scope - that is, before any
|
|
22
|
+
* transaction existed - carries no store, and everything it schedules inherits
|
|
23
|
+
* that emptiness rather than the caller's mark:
|
|
24
|
+
*
|
|
25
|
+
* ```
|
|
26
|
+
* const detached = new AsyncResource('...') // module scope
|
|
27
|
+
* als.run(true, () => detached.runInAsyncScope(() => setImmediate(() => als.getStore())))
|
|
28
|
+
* // -> undefined
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @module dsh-web-shared/host/detached-work
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Run `work` outside the caller's AsyncLocalStorage context.
|
|
35
|
+
*
|
|
36
|
+
* The call itself is synchronous - this schedules, it does not defer. Work that
|
|
37
|
+
* must not block the caller should schedule its own `setImmediate` inside
|
|
38
|
+
* `work`, which then also starts clean because it inherits this resource's
|
|
39
|
+
* empty context rather than the caller's.
|
|
40
|
+
*
|
|
41
|
+
* @param work - the side effect to detach from the caller's async context.
|
|
42
|
+
* @returns whatever `work` returns.
|
|
43
|
+
*/
|
|
44
|
+
export declare function runDetached<T>(work: () => T): T;
|
|
@@ -52,7 +52,7 @@ export interface GatewayJob {
|
|
|
52
52
|
error?: string;
|
|
53
53
|
}
|
|
54
54
|
/** The binary search roots for the dsh CLI. */
|
|
55
|
-
export declare function findDshBinary(env?: NodeJS.ProcessEnv, platform?: string, exists?: (path: string) => boolean, hostEntryPath?: string | undefined): string | null;
|
|
55
|
+
export declare function findDshBinary(env?: NodeJS.ProcessEnv, platform?: string, exists?: (path: string) => boolean, hostEntryPath?: string | undefined, resourcesPath?: string | undefined): string | null;
|
|
56
56
|
/**
|
|
57
57
|
* Read a file's leading bytes for the shebang probe. Every failure — a missing
|
|
58
58
|
* file, a directory, a permission error, an unreadable asar entry — reads as
|
|
@@ -22,6 +22,14 @@ export interface LaunchedProfile {
|
|
|
22
22
|
name?: unknown;
|
|
23
23
|
dir?: unknown;
|
|
24
24
|
patchPath?: unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Absolute path of the running installation's own `@deepseek-ai/dsh`
|
|
27
|
+
* package.json — the launcher's install anchor. Its `version` IS the version
|
|
28
|
+
* of the DSH this process booted, so it answers the compatibility question
|
|
29
|
+
* without spawning anything; on a packaged Desktop install it is the only
|
|
30
|
+
* source that does, because no `dsh` reaches that host's PATH (issue #1819).
|
|
31
|
+
*/
|
|
32
|
+
installAnchor?: unknown;
|
|
25
33
|
}
|
|
26
34
|
/** Resolved locations of one profile's writable surface. */
|
|
27
35
|
export interface ProfileFacts {
|
|
@@ -43,6 +51,26 @@ export interface ProfileFacts {
|
|
|
43
51
|
export declare function stripBom(text: string): string;
|
|
44
52
|
/** Read the packaged desktop app's persisted active profile, when present. */
|
|
45
53
|
export declare function desktopSelectedProfile(env?: NodeJS.ProcessEnv): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The running installation's own `@deepseek-ai/dsh` package.json, as the
|
|
56
|
+
* launcher published it on `profileContext`, or undefined when the host
|
|
57
|
+
* publishes none (or publishes something unusable). This is a READ-ONLY
|
|
58
|
+
* fact — unlike the profile directory and the patch path it is never a write
|
|
59
|
+
* target — but it still arrives from outside this package, so it must be an
|
|
60
|
+
* absolute, traversal-free path before anything reads a version out of it.
|
|
61
|
+
* @param launched - the profile facts the Host published, when available.
|
|
62
|
+
* @returns the validated anchor path, or undefined.
|
|
63
|
+
*/
|
|
64
|
+
export declare function launchedInstallAnchor(launched: LaunchedProfile | undefined): string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Read the `version` field of one package manifest, tolerating every failure:
|
|
67
|
+
* a missing file, an unreadable one (a stripped asar entry), malformed JSON, or
|
|
68
|
+
* a non-string version all read as "no version". Callers fall back to their next
|
|
69
|
+
* source rather than reporting a version nobody declared.
|
|
70
|
+
* @param manifestPath - absolute path of a package.json.
|
|
71
|
+
* @returns the declared version, or undefined.
|
|
72
|
+
*/
|
|
73
|
+
export declare function readManifestVersion(manifestPath: string): string | undefined;
|
|
46
74
|
/**
|
|
47
75
|
* Whether the host argv names the packaged Desktop launcher, whose entry
|
|
48
76
|
* script is `@deepseek-ai/dsh-desktop-host`. The Desktop client boots the
|
|
@@ -27,8 +27,18 @@ export interface GatewayRouteDeps {
|
|
|
27
27
|
/** Registry fetch seam for update checks (test seam); the default reads the
|
|
28
28
|
* `/<name>/latest` manifest including the `dsh` / `engines` metadata. */
|
|
29
29
|
fetchManifest?: (name: string) => Promise<RegistryVersionManifest | undefined>;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Running DSH host version seam (test seam). The default reads the version of
|
|
32
|
+
* the running installation in process, then falls back to `dsh --version`.
|
|
33
|
+
*/
|
|
31
34
|
dshVersion?: () => Promise<string | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* The running installation's own `@deepseek-ai/dsh` package.json, when the
|
|
37
|
+
* launcher published one. It is the primary version source: the file belongs
|
|
38
|
+
* to the runtime this process booted, so reading it needs no subprocess and no
|
|
39
|
+
* PATH — which a packaged Desktop host does not have (issue #1819).
|
|
40
|
+
*/
|
|
41
|
+
installAnchor?: string;
|
|
32
42
|
/** Official-channel detection seam (test seam); defaults to the boot dump probe. */
|
|
33
43
|
officialChannels?: () => Promise<boolean>;
|
|
34
44
|
/** Launch-fact seam for the restart route (test seam); defaults to this process. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-plugin-manager",
|
|
3
3
|
"description": "Update checking for the dsh web GUI's official Plugins page: compares installed plugins against the version their registry source serves, gates the update on the DSH runtime minimum the release declares, and drives the update through the official installer channel or this package's loopback CLI gateway.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.6",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -61,7 +61,10 @@
|
|
|
61
61
|
"vitest": "^4.1.1"
|
|
62
62
|
},
|
|
63
63
|
"files": [
|
|
64
|
-
"lib",
|
|
64
|
+
"lib/**/*.js",
|
|
65
|
+
"lib/**/*.js.map",
|
|
66
|
+
"lib/**/*.d.ts",
|
|
67
|
+
"lib/**/*.d.ts.map",
|
|
65
68
|
"cordis.patch.yml",
|
|
66
69
|
"README.md",
|
|
67
70
|
"README.zh.md",
|
|
@@ -73,7 +76,7 @@
|
|
|
73
76
|
"yaml": "^2.8.2"
|
|
74
77
|
},
|
|
75
78
|
"scripts": {
|
|
76
|
-
"build": "tsc -
|
|
79
|
+
"build": "tsc -b tsconfig.build.json && tsdown",
|
|
77
80
|
"watch": "tsdown --watch",
|
|
78
81
|
"test": "vitest run",
|
|
79
82
|
"typecheck": "tsc --noEmit"
|