@linxin666/dsh-client-ui-plugin-manager 0.2.5 → 0.2.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 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: b13f2e5952d50659cd099b70e6d13750eafb6315
6
- README.zh.md: d9534ef2b8d5c632b4494ea468216e7d29ee2fd9
5
+ README.md: b73785fe9b13fafc4801b8d008aaed9b892c69d9
6
+ README.zh.md: 35ecee296030f97e49abe3a55520ac7db132a21d
package/README.md CHANGED
@@ -9,7 +9,7 @@ Plugin manager tab for the dsh web GUI Plugins settings section: installs plugin
9
9
  - Registers a `Plugin manager` tab in the official Plugins settings section (the `settings.plugins.tab` slot, order 20), next to the official installer tab.
10
10
  - Dual-channel transport: on runtimes with the official installer services (DSHCode and the 1.0.4 checkout web), every operation rides the official `/plugin-installer` and `/plugin-control` loopback RPC channels; on the npm-published web runtime those channels do not exist, so the package's host half mounts a loopback-fenced HTTP gateway that spawns the official `dsh plugin` CLI for installs/removals (the single writer) and writes `disabled` override rows for enablement.
11
11
  - Installs plugins from an npm package name or a git repository URL, with progress.
12
- - Lists installed user plugins with next-start enable switches, update checks (registry, npm sources), updates, and uninstall.
12
+ - Lists installed user plugins with next-start enable switches, update checks (registry, npm sources), verified npm updates, and uninstall.
13
13
  - Shows the built-in product switches when the official plugin-control surface exists.
14
14
  - Surfaces install-time conflict actions: the product-snapshot diff around each install (official mode) or the profile layer diff around each CLI run (gateway mode), with undo for reversible actions and an `Ask the agent to fix` handoff on every conflict row.
15
15
  - Protects the next boot on the npm runtime: after each install the gateway verifies the dependency actually landed, rejects duplicate entry-id claims and insert rows naming unresolvable packages, and composes the profile with the CLI's `--dump-config` preflight; a conflicting or failing install is rolled back through the official remove path (the existing plugins are never touched), with the error and repair handoff on the error row.
@@ -55,7 +55,7 @@ The contract source of truth is `src/core/service.ts` (`PluginManagerService`).
55
55
  ## Known limitations
56
56
 
57
57
  - Loopback-only: on a LAN or remote browser the tab renders a local-only notice (the same boundary the official installer tab enforces; the gateway refuses non-loopback requests with 403).
58
- - On the npm-published web runtime, gateway writes go through the official CLI, so the `dsh` binary must be on the host process PATH; installs of git sources can take minutes and run as background jobs.
58
+ - On the npm-published web runtime, gateway writes go through the official CLI, so the `dsh` binary must be on the host process PATH; 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.
59
59
  - On the npm-published web runtime there is no boot-failure ring and no safe mode: those surfaces degrade to empty, and only install errors offer the repair handoff.
60
60
  - Enablement on the npm runtime writes bare `disabled` override rows into the profile's cordis.patch.yml; the runtime's loader honors them at the next start, but this path is less exercised than the official desktop writer's.
61
61
  - The web build has no in-place restart: changes apply at the next manual restart.
@@ -68,7 +68,7 @@ The contract source of truth is `src/core/service.ts` (`PluginManagerService`).
68
68
  ## Security model
69
69
 
70
70
  - Trust boundary is the loopback fence: every gateway route requires a loopback socket address, a loopback Host header, and a non-cross-site origin (socket + Host + Origin + `sec-fetch-site`), the same authority the official installer channels enforce. There is no browser-reachable path from a remote origin.
71
- - Mutation routes (install / remove / set-enabled) carry no token: the loopback authority *is* the local user, matching the official channels. Any local process can therefore drive plugin installs and removals, and npm installs run package install scripts — treat the gateway as local code execution by design and never expose it beyond loopback.
71
+ - Mutation routes (install / update / remove / set-enabled) carry no token: the loopback authority *is* the local user, matching the official channels. Any local process can therefore drive plugin installs and removals, and npm installs run package install scripts — treat the gateway as local code execution by design and never expose it beyond loopback.
72
72
  - Install specs and package ids are rejected when they contain shell metacharacters (`& | < >`, quotes, backtick, control characters). The gateway always spawns the official CLI without a shell; on Windows it resolves the npm-generated `dsh.cmd` to `node.exe` + the package `bin.js` so paths with spaces survive and `cmd.exe` never re-parses arguments. Residual upstream note: the official CLI itself forwards to pnpm with a `cmd.exe` shell on Windows, which this package cannot change — the metachar validation is the mitigation inside this repository.
73
73
  - Mutations are serialized through one queue, so concurrent jobs never interleave their before/after profile captures. An install is only `done` when the new dependency actually landed in the profile (and a removal only when it is gone); a success exit code alone is never trusted.
74
74
  - Conflict handling is owner-aware: a duplicate entry id or an insert row naming an unresolvable package rolls the *new* package back through the official remove path. The gateway never writes `disabled` rows for a shared id (such rows cannot stop the loader's duplicate check and would flag the existing owner).
package/README.zh.md CHANGED
@@ -9,7 +9,7 @@
9
9
  - 在官方「插件」设置分区注册「插件管理」Tab(`settings.plugins.tab` 槽位,order 20,与官方安装器 Tab 并列)。
10
10
  - 双通道传输:带官方安装器服务的运行时(DSHCode 与 1.0.4 checkout 版 web)走官方 `/plugin-installer`、`/plugin-control` loopback RPC 通道;npm 发布的官方 web 没有这些通道,本包的 host 半区挂载 loopback 门禁的 HTTP 网关——安装/卸载 spawn 官方 `dsh plugin` CLI(唯一写入器),启停写入 `disabled` 覆盖行。
11
11
  - 从 npm 包名或 git 仓库 URL 安装插件,带进度。
12
- - 列出已装用户插件:下次启动生效的启用开关、更新检查(npm 源走 registry)、更新与卸载。
12
+ - 列出已装用户插件:下次启动生效的启用开关、更新检查(npm 源走 registry)、已核验的 npm 更新与卸载。
13
13
  - 官方 plugin-control 面存在时展示内置产品开关。
14
14
  - 安装时冲突对账:官方模式对产品快照前后 diff;网关模式对每次 CLI 运行前后的 profile 层 diff,可撤销的动作给一键撤销,每条冲突都给「让 Agent 修复」转交。
15
15
  - 按插件渲染启动失败环:「让 Agent 修复」(以插件安装根为工作区的修复会话)与「复制错误」;npm web 运行时没有失败环,只有安装错误提供修复转交。
@@ -55,7 +55,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
55
55
  ## 已知限制
56
56
 
57
57
  - 仅限本机:LAN 或远程浏览器只显示「仅限本机操作」提示(与官方安装器 Tab 同一边界;网关对非 loopback 请求返回 403)。
58
- - npm 发布的官方 web 上,网关写入经官方 CLI 执行,因此 host 进程 PATH 里必须有 `dsh`;git 源安装可能耗时数分钟,以后台任务运行。
58
+ - npm 发布的官方 web 上,网关写入经官方 CLI 执行,因此 host 进程 PATH 里必须有 `dsh`;git 源安装可能耗时数分钟,以后台任务运行。网关更新只适用于 npm registry 源,由 host 解析最新版本,且仅当同一已装包报告该精确版本时才算成功。
59
59
  - npm 发布的官方 web 没有启动失败环与安全模式:这两处界面降级为空,只有安装错误提供修复转交。
60
60
  - npm 运行时上的启停会在 profile 的 cordis.patch.yml 写入裸 `disabled` 覆盖行;该运行时 loader 在下次启动时认读这些行,但这条路径不如官方桌面写入器经过充分锻炼。
61
61
  - web 端无壳内重启:变更在下次手动重启后生效。
@@ -68,7 +68,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
68
68
  ## 安全模型
69
69
 
70
70
  - 信任边界是 loopback 门禁:每条网关路由都要求 loopback socket 地址、loopback Host 头与非跨站来源(socket + Host + Origin + `sec-fetch-site` 四重),与官方安装器通道同一权威。远程来源的浏览器没有可达路径。
71
- - 变更类路由(install / remove / set-enabled)不带 token:loopback 权威即本机用户,与官方通道同模型。因此任何本机进程都能驱动插件安装与卸载,且 npm 安装会执行包的 install 脚本——请将本网关视为「设计上即本机代码执行」,绝不暴露到 loopback 之外。
71
+ - 变更类路由(install / update / remove / set-enabled)不带 token:loopback 权威即本机用户,与官方通道同模型。因此任何本机进程都能驱动插件安装与卸载,且 npm 安装会执行包的 install 脚本——请将本网关视为「设计上即本机代码执行」,绝不暴露到 loopback 之外。
72
72
  - 安装 spec 与包 id 含 shell 元字符(`& | < >`、引号、反引号、控制字符)时一律拒绝。网关在所有平台无 shell spawn 官方 CLI;Windows 下把 npm 生成的 `dsh.cmd` 解析为 `node.exe` + 包内 `bin.js`,含空格路径不被截断、`cmd.exe` 不再二次解析参数。上游残留说明:官方 CLI 内部向 pnpm 转发时在 Windows 上仍走 `cmd.exe` shell,本仓库无法改变——元字符校验即本仓库内的缓解。
73
73
  - 变更经同一队列串行,并发任务的 before/after profile 快照绝不交错。安装只有在依赖真实落入 profile 后才判 done(卸载以依赖消失为准),绝不轻信成功退出码。
74
74
  - 冲突处置是 owner-aware 的:重复入口 id 或引用不可解析包的 insert 行会经官方 remove 路径回滚**新**包;网关绝不对共享 id 写 `disabled` 行(那既阻止不了 loader 的重复检查,又会误伤现有插件)。
package/lib/client.js CHANGED
@@ -1308,9 +1308,19 @@ window.__ModuleLoader__.load({
1308
1308
  }
1309
1309
  },
1310
1310
  update: async (id) => {
1311
- const row = (await gateway.list()).find((item) => item.id === id);
1312
- if (row === void 0) throw new Error(`plugin-manager: plugin ${id} is not installed`);
1313
- return gateway.install(row.source.spec);
1311
+ gatewayInflight = true;
1312
+ try {
1313
+ const started = await gatewayJson(`${GATEWAY_PREFIX}/update`, {
1314
+ method: "POST",
1315
+ body: JSON.stringify({ id })
1316
+ });
1317
+ if (started.jobId === void 0) throw new Error("plugin-manager: gateway update returned no job");
1318
+ const job = await waitJob(started.jobId);
1319
+ lastInstallConflicts = Array.isArray(job.conflicts) ? job.conflicts : [];
1320
+ return parseInstalledPlugin({ plugin: job.plugin });
1321
+ } finally {
1322
+ gatewayInflight = false;
1323
+ }
1314
1324
  },
1315
1325
  uninstall: async (id) => {
1316
1326
  gatewayInflight = true;
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["css","Button","Modal"],"sources":["../../../packages/dsh-plugin-manager/src/core/conflict.ts","../../../packages/dsh-plugin-manager/src/core/repair.ts","../../../packages/dsh-plugin-manager/src/client/PluginManagerTab.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/index.ts"],"sourcesContent":["/**\n * Conflict-ledger diffing. The official host applies structural conflict\n * rules at install time (disableControlsOnInstall: installing the dsh-web-ui\n * family disables the built-in web-ui product rows so the two never\n * double-mount), but no UI surfaces what the rules just did. This module\n * diffs the plugin-control snapshots taken before and after an install and\n * classifies every state change so the tab can render it as a reversible,\n * attributable conflict notice.\n *\n * The install-time authority ends here: duplicate insert-id claims between\n * two user plugins carry no at-install signal through the RPC channels (the\n * Loader only re-reads the composition at the next start), so that failure\n * shape is left to the boot-failure ring — the real start is the authoritative\n * conflict detector.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { PluginControlItem } from './protocol.ts'\n\n/** One observed product-control state change between two snapshots. */\nexport interface ControlChange {\n id: string\n name: string\n from: PluginControlItem['state']\n to: PluginControlItem['state']\n}\n\n/** Meaningful change kinds a conflict notice distinguishes. */\nexport type ControlChangeKind = 'rule-disabled' | 'rule-enabled' | 'state-change'\n\n/**\n * Diff two plugin-control snapshots by id. Only entries present in both\n * snapshots with a changed state are reported; entries appearing or\n * disappearing are ordinary install/uninstall outcomes, not conflicts.\n * @param before - snapshot taken before the install.\n * @param after - snapshot taken after the install.\n * @returns one change per id whose state moved, in id order.\n */\nexport function diffControls(before: readonly PluginControlItem[], after: readonly PluginControlItem[]): ControlChange[] {\n const afterById = new Map(after.map(item => [item.id, item]))\n const changes: ControlChange[] = []\n for (const item of before) {\n const current = afterById.get(item.id)\n if (current === undefined || current.state === item.state) continue\n changes.push({ id: item.id, name: item.name, from: item.state, to: current.state })\n }\n return changes\n}\n\n/**\n * Classify one control-state change for messaging. A change into `disabled`\n * is the conflict rule's action (reversible by re-enabling); a change out of\n * `disabled` is a manual undo; anything else is reported neutrally.\n * @param change - one diff entry.\n * @returns the message kind.\n */\nexport function classifyChange(change: ControlChange): ControlChangeKind {\n if (change.to === 'disabled') return 'rule-disabled'\n if (change.from === 'disabled') return 'rule-enabled'\n return 'state-change'\n}\n","/**\n * Repair-conversation seed text. Two failure surfaces hand off to the agent\n * through the same shape: a failed install (target spec + install error) and\n * a recorded boot failure (the failure-ring row). The seeded message must be\n * self-contained — the repair session's workspace is the plugin install root,\n * so the agent's file tools reach the plugin code without leaving the\n * workspace boundary.\n *\n * Secret discipline: the seed carries only the spec, the host's truncated\n * failure message/stack, and paths. Callers must never append credentials,\n * tokens, or environment contents; the failure ring is the host's bounded,\n * pruned record and nothing else is added.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { PluginFailureItem } from './protocol.ts'\nimport type { LayerState } from './patch-diff.ts'\n\n/** Localized fragments the builders assemble. */\nexport interface RepairCopy {\n installTitle: string\n installSpecLabel: string\n installErrorLabel: string\n installAsk: string\n failureTitle: string\n failurePluginLabel: string\n failureKindLabel: string\n failureAtLabel: string\n failureMessageLabel: string\n failureStackLabel: string\n failurePathLabel: string\n failureAsk: string\n conflictTitle: string\n conflictPluginLabel: string\n conflictChangeLabel: string\n conflictAsk: string\n /** Localized names of the failure kinds. */\n kindNames: Record<PluginFailureItem['kind'], string>\n /** Localized names of the layer states a conflict change traverses. */\n stateNames: Record<LayerState, string>\n}\n\n/** Default copy (zh): the package's zh dictionary keys map onto these strings. */\nexport const DEFAULT_REPAIR_COPY: RepairCopy = {\n installTitle: '正在修复插件安装失败',\n installSpecLabel: '安装目标',\n installErrorLabel: '安装错误',\n installAsk: '请在插件安装根目录内检查插件包或依赖并修复,然后重试安装。',\n failureTitle: '正在修复插件启动失败',\n failurePluginLabel: '插件',\n failureKindLabel: '失败类型',\n failureAtLabel: '时间',\n failureMessageLabel: '错误信息',\n failureStackLabel: '堆栈',\n failurePathLabel: '安装路径',\n failureAsk: '请修复插件后重新启用并重启 dsh web。',\n conflictTitle: '正在处理插件安装冲突',\n conflictPluginLabel: '冲突条目',\n conflictChangeLabel: '状态变化',\n conflictAsk: '请检查冲突双方的入口行 id 与挂载方式,消除重复挂载后告诉我如何重新启用。',\n kindNames: {\n 'load-failure': '加载失败',\n hang: '启动挂起',\n 'late-rejection': '迟到拒绝',\n },\n stateNames: {\n enabled: '已开启',\n disabled: '已关闭',\n uninstalled: '已卸载',\n },\n}\n\n/**\n * Seed text for a failed install: the target and the rendered error,\n * self-contained for the agent.\n * @param spec - the install target (npm spec or git URL) that failed.\n * @param error - the rendered install error text.\n * @param copy - localized fragments.\n * @returns the repair prompt text.\n */\nexport function installRepairMessage(spec: string, error: string, copy: RepairCopy = DEFAULT_REPAIR_COPY): string {\n return [\n copy.installTitle,\n `${copy.installSpecLabel}: ${spec}`,\n `${copy.installErrorLabel}:\\n${error}`,\n copy.installAsk,\n ].join('\\n\\n')\n}\n\n/**\n * Seed text for one boot-failure ring row: the failure record, so the agent\n * can attribute and fix it in place.\n * @param failure - the recorded failure row.\n * @param copy - localized fragments.\n * @returns the repair prompt text.\n */\nexport function failureRepairMessage(failure: PluginFailureItem, copy: RepairCopy = DEFAULT_REPAIR_COPY): string {\n const parts = [\n copy.failureTitle,\n `${copy.failurePluginLabel}: ${failure.pluginId || '-'}`,\n `${copy.failureKindLabel}: ${copy.kindNames[failure.kind] ?? failure.kind}`,\n `${copy.failureAtLabel}: ${failure.at}`,\n `${copy.failureMessageLabel}:\\n${failure.message}`,\n ]\n if (failure.stack !== '') parts.push(`${copy.failureStackLabel}:\\n${failure.stack}`)\n if (failure.installPath !== '') parts.push(`${copy.failurePathLabel}: ${failure.installPath}`)\n parts.push(copy.failureAsk)\n return parts.join('\\n\\n')\n}\n\n/**\n * Seed text for one install-conflict notice: the entry and its state change,\n * so the agent can attribute the conflict and resolve the double mount.\n * @param change - the conflict change (id, display name, from/to states).\n * @param copy - localized fragments.\n * @returns the repair prompt text.\n */\nexport function conflictRepairMessage(\n change: { id: string; name: string; from: LayerState; to: LayerState },\n copy: RepairCopy = DEFAULT_REPAIR_COPY,\n): string {\n return [\n copy.conflictTitle,\n `${copy.conflictPluginLabel}: ${change.name} (${change.id})`,\n `${copy.conflictChangeLabel}: ${copy.stateNames[change.from] ?? change.from} -> ${copy.stateNames[change.to] ?? change.to}`,\n copy.conflictAsk,\n ].join('\\n\\n')\n}\n","/**\n * The plugin-manager tab: an install box, one row per installed user plugin\n * (next-start enablement switch, source badge, update availability, update and\n * uninstall actions, per-plugin boot-failure block), the built-in product\n * switches, an install-conflict notice (the diff of the plugin-control\n * snapshot around each install, reversible through the product switch), and\n * the failure-repair affordances. Enablement switches and installs persist\n * through the official host channels and apply at the next restart; the web\n * build shows a restart hint instead of an in-place restart.\n *\n * This tab registers into the official Plugins settings section\n * (`settings.plugins.tab` slot) next to the official installer tab; its added\n * value over that tab is the conflict ledger, the bilingual repair seeds, and\n * the family card vocabulary.\n */\nimport { useEffect, useRef, useState } from 'react'\nimport { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport { classifyChange, diffControls, type ControlChange } from '../core/conflict.ts'\nimport type {\n InstallProgressItem,\n InstalledPluginItem,\n PluginControlItem,\n PluginFailureItem,\n PluginFailuresSnapshot,\n PluginUpdateItem,\n} from '../core/protocol.ts'\nimport { conflictRepairMessage, failureRepairMessage, installRepairMessage, type RepairCopy } from '../core/repair.ts'\nimport type { PluginManagerKey } from './locales.ts'\nimport css from './plugin-manager.module.css'\n\n/** Registration-side wire face used by the tab. */\nexport interface PluginManagerTabInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n 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 /** Re-install one plugin from its recorded source. */\n update: (id: string) => Promise<InstalledPluginItem>\n /** Remove one plugin. */\n uninstall: (id: string) => Promise<InstalledPluginItem[]>\n /** Persist one user plugin's next-start enablement. */\n setEnabled: (id: string, enabled: boolean) => Promise<InstalledPluginItem>\n /** Compare installed versions against their sources. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /** Read the current install/update progress. */\n status: () => Promise<InstallProgressItem>\n /** Read the recorded boot failures, plugin root, and safe-mode state. */\n failures: () => Promise<PluginFailuresSnapshot>\n /** Persist the safe-mode marker (web: applied at the next manual restart). */\n setSafeMode: (enabled: boolean) => Promise<void>\n /** Start a repair conversation over the plugin install root. */\n repairPlugin: (pluginRoot: string, message: string) => Promise<void>\n /** Read the deployment-configured built-in product switches. */\n controlsList: () => Promise<PluginControlItem[]>\n /** Persist one product's next-start enablement. */\n controlsSetEnabled: (pluginId: string, enabled: boolean) => Promise<PluginControlItem[]>\n /** Conflicts the gateway host computed around the last install (gateway mode only). */\n lastInstallConflicts?: () => readonly ControlChange[]\n}\n\n/** Full component props assembled by the Settings slot renderer. */\nexport type PluginManagerTabProps =\n PropsRuntime<'settings.plugins.tab'>\n & PropsLocale<'settings.pluginManager'>\n & InjectFace<PluginManagerTabInjected>\n\ntype ViewState =\n | { readonly status: 'loading' }\n | { readonly status: 'error' }\n | {\n readonly status: 'ready'\n readonly plugins: readonly InstalledPluginItem[]\n readonly controls: readonly PluginControlItem[]\n readonly failures: PluginFailuresSnapshot\n }\n\n/** One row operation in flight. */\ntype BusyAction = { readonly kind: 'install' | 'update' | 'uninstall' | 'check'; readonly id?: string }\n\n/** One enablement switch in flight: a user plugin or a built-in product. */\ntype ToggleBusy = { readonly kind: 'user' | 'product'; readonly id: string }\n\n/** One uninstall target awaiting confirmation. */\ninterface UninstallTarget {\n readonly id: string\n readonly name: string\n}\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 fragments for the repair seed builders, read from the tab's dictionaries. */\nfunction repairCopy(t: PluginManagerTabProps['t']): RepairCopy {\n return {\n installTitle: t('repairInstallTitle'),\n installSpecLabel: t('repairInstallSpecLabel'),\n installErrorLabel: t('repairInstallErrorLabel'),\n installAsk: t('repairInstallAsk'),\n failureTitle: t('repairFailureTitle'),\n failurePluginLabel: t('repairFailurePluginLabel'),\n failureKindLabel: t('repairFailureKindLabel'),\n failureAtLabel: t('repairFailureAtLabel'),\n failureMessageLabel: t('repairFailureMessageLabel'),\n failureStackLabel: t('repairFailureStackLabel'),\n failurePathLabel: t('repairFailurePathLabel'),\n failureAsk: t('repairFailureAsk'),\n kindNames: {\n 'load-failure': t('repairKindLoad'),\n hang: t('repairKindHang'),\n 'late-rejection': t('repairKindLate'),\n },\n conflictTitle: t('repairConflictTitle'),\n conflictPluginLabel: t('repairConflictPluginLabel'),\n conflictChangeLabel: t('repairConflictChangeLabel'),\n conflictAsk: t('repairConflictAsk'),\n stateNames: {\n enabled: t('repairStateEnabled'),\n disabled: t('repairStateDisabled'),\n uninstalled: t('repairStateUninstalled'),\n },\n }\n}\n\n/** Localized label for one install phase, with percent when the download has one. */\nfunction progressLabel(progress: InstallProgressItem, t: PluginManagerTabProps['t']): string {\n if (progress.stage === 'fetch') return t('fetching')\n if (progress.stage === 'extract') return t('extracting')\n if (progress.stage === 'write') return t('writing')\n return progress.percent === undefined ? t('downloading') : t('downloadingPercent', { percent: String(progress.percent) })\n}\n\n/** The plugin-manager settings tab. */\nexport function PluginManagerTab(props: PluginManagerTabProps) {\n const {\n t,\n isLoopback,\n list,\n install,\n update,\n uninstall,\n setEnabled,\n checkUpdates,\n status,\n failures,\n setSafeMode,\n repairPlugin,\n controlsList,\n controlsSetEnabled,\n lastInstallConflicts,\n } = props\n\n const [view, setView] = useState<ViewState>({ status: 'loading' })\n const [busy, setBusy] = useState<BusyAction | undefined>(undefined)\n const [toggleBusy, setToggleBusy] = useState<ToggleBusy | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [failedSpec, setFailedSpec] = useState<string | undefined>(undefined)\n const [installError, setInstallError] = useState<string | undefined>(undefined)\n const [spec, setSpec] = useState('')\n const [dirty, setDirty] = useState(false)\n const [repairing, setRepairing] = useState<string | undefined>(undefined)\n const [copied, setCopied] = useState<string | undefined>(undefined)\n const [updates, setUpdates] = useState<ReadonlyMap<string, string>>(new Map())\n const [uninstallTarget, setUninstallTarget] = useState<UninstallTarget | undefined>(undefined)\n const [conflicts, setConflicts] = useState<readonly ControlChange[]>([])\n const [progress, setProgress] = useState<InstallProgressItem>({ kind: 'idle', stage: 'fetch' })\n /** Synchronous in-flight mirror of `busy`: the render-time guard alone lets a\n * click and an Enter land in the same frame and double-fire. */\n const busyRef = useRef(false)\n\n /** Reload every snapshot into the ready view. */\n const reload = async (): Promise<void> => {\n const [plugins, controls, failureSnapshot] = await Promise.all([list(), controlsList(), failures()])\n setView({ status: 'ready', plugins, controls, failures: failureSnapshot })\n }\n\n useEffect(() => {\n let cancelled = false\n void reload().catch(() => {\n if (!cancelled) setView({ status: 'error' })\n })\n return () => { cancelled = true }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n /** One row/form operation: busy state, error row, dirty flag on success. */\n const run = async (action: BusyAction, body: () => Promise<void>): Promise<void> => {\n if (busyRef.current) return\n busyRef.current = true\n setBusy(action)\n setError(undefined)\n try {\n await body()\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 /** Install one spec, then diff the product snapshot into a conflict notice. */\n const onInstall = (): void => {\n const target = spec.trim()\n if (target === '' || busy !== undefined || busyRef.current) return\n void (async () => {\n busyRef.current = true\n const before = view.status === 'ready' ? view.controls : await controlsList().catch(() => [])\n setBusy({ kind: 'install' })\n setError(undefined)\n setFailedSpec(undefined)\n setInstallError(undefined)\n try {\n await install(target)\n setSpec('')\n setDirty(true)\n const after = await controlsList().catch(() => [] as readonly PluginControlItem[])\n setConflicts(lastInstallConflicts !== undefined ? lastInstallConflicts() : diffControls(before, after))\n await reload()\n } catch (reason) {\n const reasonText = messageOf(reason)\n setFailedSpec(target)\n setInstallError(reasonText)\n setError(t('failed', { reason: reasonText }))\n } finally {\n busyRef.current = false\n setBusy(undefined)\n }\n })()\n }\n\n /** Poll install/update progress while such an operation is in flight. */\n useEffect(() => {\n if (busy === undefined || (busy.kind !== 'install' && busy.kind !== '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(() => { /* status polling fails silently; the operation 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 const toggleDisabled = busy !== undefined || toggleBusy !== undefined\n || (view.status === 'ready' && view.failures.safeMode)\n\n const onUserToggle = (id: string, enabled: boolean): void => {\n setToggleBusy({ kind: 'user', id })\n setError(undefined)\n void setEnabled(id, enabled).then(plugin => {\n setView(current => current.status === 'ready'\n ? { ...current, plugins: current.plugins.map(item => item.id === id ? plugin : item) }\n : current)\n setDirty(true)\n setToggleBusy(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setToggleBusy(undefined)\n })\n }\n\n const onProductToggle = (id: string, enabled: boolean): void => {\n setToggleBusy({ kind: 'product', id })\n setError(undefined)\n void controlsSetEnabled(id, enabled).then(controls => {\n setView(current => current.status === 'ready' ? { ...current, controls } : current)\n setConflicts(previous => previous.filter(change => change.id !== id))\n setDirty(true)\n setToggleBusy(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setToggleBusy(undefined)\n })\n }\n\n const onCheck = (): void => {\n void run({ kind: 'check' }, async () => {\n const found = await checkUpdates()\n setUpdates(new Map(found.map(item => [item.id, item.latest])))\n })\n }\n\n const onUpdate = (id: string): void => {\n void run({ kind: 'update', id }, async () => {\n await update(id)\n setUpdates(previous => {\n const next = new Map(previous)\n next.delete(id)\n return next\n })\n await reload()\n })\n }\n\n const onUninstall = (): void => {\n const target = uninstallTarget\n if (target === undefined) return\n void run({ kind: 'uninstall', id: target.id }, async () => {\n await uninstall(target.id)\n setUninstallTarget(undefined)\n await reload()\n })\n }\n\n /** Open a repair conversation seeded with one boot-failure record. `token`\n * identifies the row for the in-flight label (plugin id, or a row key for\n * unattributable failures). */\n const onRepair = (failure: PluginFailureItem, token: string): void => {\n if (view.status !== 'ready' || busy !== undefined || repairing !== undefined) return\n setError(undefined)\n setRepairing(token)\n void repairPlugin(view.failures.pluginRoot, failureRepairMessage(failure, repairCopy(t))).then(() => {\n setRepairing(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setRepairing(undefined)\n })\n }\n\n /** Hand the latest failed install off to a repair conversation over the\n * install root. The seed carries the install's own error (installError), not\n * whatever error the row currently shows. */\n const onRepairInstall = (): void => {\n if (view.status !== 'ready' || repairing !== undefined) return\n setError(undefined)\n setRepairing('install')\n void repairPlugin(view.failures.pluginRoot, installRepairMessage(failedSpec ?? '', installError ?? '', repairCopy(t))).then(() => {\n setError(undefined)\n setFailedSpec(undefined)\n setInstallError(undefined)\n setRepairing(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setRepairing(undefined)\n })\n }\n\n /** Copy a boot failure's message and stack for a manual repair conversation. */\n const onCopy = (failure: PluginFailureItem, token: string): void => {\n void navigator.clipboard.writeText(`${failure.message}\\n\\n${failure.stack}`).then(() => {\n setCopied(token)\n }).catch(() => {\n setError(t('failed', { reason: 'clipboard unavailable' }))\n })\n }\n\n const onExitSafeMode = (): void => {\n if (busy !== undefined) return\n setError(undefined)\n void setSafeMode(false).then(() => {\n setDirty(true)\n void reload().catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n })\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n })\n }\n\n /** Undo one conflict action by flipping the product switch back. */\n const onUndoConflict = (change: ControlChange): void => {\n if (change.to !== 'disabled') return\n onProductToggle(change.id, true)\n }\n\n /** Hand one conflict notice off to a repair conversation over the plugin root. */\n const onRepairConflict = (change: ControlChange): void => {\n if (view.status !== 'ready' || busy !== undefined || repairing !== undefined) return\n setError(undefined)\n const token = `conflict:${change.id}`\n setRepairing(token)\n void repairPlugin(view.failures.pluginRoot, conflictRepairMessage({\n id: change.id,\n name: change.name,\n from: change.from === 'enabled' || change.from === 'disabled' ? change.from : 'uninstalled',\n to: change.to === 'enabled' || change.to === 'disabled' ? change.to : 'uninstalled',\n }, repairCopy(t))).then(() => {\n setRepairing(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setRepairing(undefined)\n })\n }\n\n if (!isLoopback) {\n return (\n <div className={css.notice}>\n <strong>{t('localOnlyTitle')}</strong>\n <p>{t('localOnlyBody')}</p>\n </div>\n )\n }\n if (view.status === 'loading') return <div className={css.state}>{t('loading')}</div>\n if (view.status === 'error') return <div className={css.state}>{t('failed', { reason: 'load' })}</div>\n\n const attributable = new Map(view.failures.items.filter(item => item.pluginId !== '').map(item => [item.pluginId, item]))\n const unattributable = view.failures.items.filter(item => item.pluginId === '')\n\n return (\n <div className={css.section} aria-busy={busy !== undefined || toggleBusy !== undefined}>\n {view.failures.safeMode && (\n <div className={css.safeModeBanner} data-safe-mode>\n <p>{t('safeModeBanner')}</p>\n <Button variant=\"primary\" disabled={busy !== undefined} onClick={onExitSafeMode}>\n {t('exitSafeMode')}\n </Button>\n </div>\n )}\n\n <div className={css.installRow}>\n <input\n className={css.spec}\n type=\"text\"\n value={spec}\n placeholder={t('installPlaceholder')}\n disabled={busy !== undefined}\n onChange={event => { setSpec(event.target.value) }}\n onKeyDown={event => {\n if (event.key === 'Enter' && spec.trim() !== '' && busy === undefined) onInstall()\n }}\n />\n <Button\n variant=\"primary\"\n disabled={spec.trim() === '' || busy !== undefined}\n onClick={onInstall}\n >\n {busy !== undefined && busy.kind === 'install' ? t('installing') : t('install')}\n </Button>\n </div>\n <p className={css.hint}>{t('installHint')}</p>\n\n {(busy?.kind === 'install' || busy?.kind === '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: `${progress.percent}%` }}\n data-indeterminate={progress.percent === undefined ? 'true' : undefined}\n />\n </div>\n <p className={css.progressLabel}>{progressLabel(progress, t)}</p>\n </div>\n )}\n\n {error !== undefined && (\n <div className={css.errorRow}>\n <span className={css.error}>{error}</span>\n {failedSpec !== undefined && (\n <Button variant=\"outline\" disabled={repairing !== undefined} onClick={onRepairInstall}>\n {repairing === 'install' ? t('repairing') : t('repair')}\n </Button>\n )}\n </div>\n )}\n\n {conflicts.length > 0 && (\n <div className={css.conflicts}>\n <h3 className={css.sectionTitle}>{t('conflictTitle')}</h3>\n <ul className={css.list}>\n {conflicts.map(change => (\n <li key={change.id} className={css.row} data-conflict={change.id}>\n <div className={css.meta}>\n <span className={css.name}>{change.name}</span>\n <span className={css.sub}>\n {classifyChange(change) === 'rule-disabled'\n ? t('conflictDisabled', { name: change.name })\n : classifyChange(change) === 'rule-enabled'\n ? t('conflictEnabled', { name: change.name })\n : t('conflictChanged', { name: change.name })}\n </span>\n </div>\n <div className={css.actions}>\n {change.to === 'disabled' && (\n <Button\n variant=\"outline\"\n disabled={toggleDisabled}\n onClick={() => { onUndoConflict(change) }}\n >\n {t('undoConflict')}\n </Button>\n )}\n <Button\n variant=\"outline\"\n disabled={busy !== undefined || repairing !== undefined}\n onClick={() => { onRepairConflict(change) }}\n >\n {repairing === `conflict:${change.id}` ? t('repairing') : t('repair')}\n </Button>\n </div>\n </li>\n ))}\n </ul>\n <p className={css.hint}>{t('conflictHint')}</p>\n </div>\n )}\n\n <div className={css.group}>\n <h3 className={css.sectionTitle}>{t('userPlugins')}</h3>\n {view.plugins.length === 0\n ? <p className={css.empty}>{t('empty')}</p>\n : (\n <ul className={css.list}>\n {view.plugins.map(plugin => {\n const latest = updates.get(plugin.id)\n const failure = attributable.get(plugin.id)\n return (\n <li key={plugin.id} className={css.row} data-plugin-id={plugin.id}>\n <div className={css.meta}>\n <span className={css.name}>{plugin.name}</span>\n <span className={css.sub}>\n <span className={css.version}>{t('version', { version: plugin.version })}</span>\n <span className={css.sourceBadge} data-source={plugin.source.kind}>\n {plugin.source.kind === 'npm' ? t('npmSource') : t('gitSource')}\n </span>\n <span className={css.specText} title={plugin.source.spec}>{plugin.source.spec}</span>\n </span>\n {latest !== undefined && <span className={css.latest}>{t('latest', { version: latest })}</span>}\n {failure !== undefined && (\n <div className={css.failure} data-plugin-failure={plugin.id}>\n <span className={css.badge}>{t('failureBadge')}</span>\n <span className={css.failureMessage} title={failure.message}>{failure.message}</span>\n <div className={css.failureActions}>\n <Button\n variant=\"primary\"\n disabled={busy !== undefined || repairing !== undefined}\n onClick={() => { onRepair(failure, plugin.id) }}\n >\n {repairing === plugin.id ? t('repairing') : t('repair')}\n </Button>\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={() => { onCopy(failure, plugin.id) }}>\n {copied === plugin.id ? t('copied') : t('copyError')}\n </Button>\n </div>\n </div>\n )}\n </div>\n <div className={css.actions}>\n <span className={css.stateLabel} data-state={plugin.enabled ? 'enabled' : 'disabled'}>\n {plugin.enabled ? t('enabled') : t('disabled')}\n </span>\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={plugin.enabled}\n aria-label={plugin.enabled ? t('disableSwitch', { name: plugin.name }) : t('enableSwitch', { name: plugin.name })}\n className={css.switch}\n disabled={toggleDisabled}\n onClick={() => { onUserToggle(plugin.id, !plugin.enabled) }}\n />\n {latest !== undefined && (\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={() => { onUpdate(plugin.id) }}>\n {busy?.kind === 'update' && busy.id === plugin.id ? t('updating') : t('update')}\n </Button>\n )}\n <Button\n variant=\"outline\"\n disabled={busy !== undefined}\n onClick={() => { setUninstallTarget({ id: plugin.id, name: plugin.name }) }}\n >\n {t('uninstall')}\n </Button>\n </div>\n </li>\n )\n })}\n </ul>\n )}\n </div>\n\n {view.controls.length > 0 && (\n <div className={css.group}>\n <h3 className={css.sectionTitle}>{t('products')}</h3>\n <ul className={css.list}>\n {view.controls.map(control => (\n <li key={control.id} className={css.row} data-product-id={control.id}>\n <div className={css.meta}>\n <span className={css.name}>{control.name}</span>\n <span className={css.sub}>\n <a className={css.link} href={control.repository} target=\"_blank\" rel=\"noreferrer\">{t('source')}</a>\n </span>\n </div>\n <div className={css.actions}>\n <span className={css.stateLabel} data-state={control.state}>\n {t(control.state)}\n </span>\n {control.state === 'enabled' || control.state === 'disabled'\n ? (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={control.state === 'enabled'}\n aria-label={control.state === 'enabled'\n ? t('disableSwitch', { name: control.name })\n : t('enableSwitch', { name: control.name })}\n className={css.switch}\n disabled={toggleDisabled}\n onClick={() => { onProductToggle(control.id, control.state !== 'enabled') }}\n />\n )\n : null}\n </div>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {unattributable.length > 0 && (\n <div className={css.group}>\n <h3 className={css.sectionTitle}>{t('failureGroupTitle')}</h3>\n <ul className={css.list}>\n {unattributable.map((failure, index) => {\n const token = `other:${index}`\n return (\n <li key={`${failure.at}-${index}`} className={css.row} data-plugin-failure=\"other\">\n <div className={css.meta}>\n <span className={css.badge}>{t('failureBadge')}</span>\n <span className={css.failureMessage} title={failure.message}>{failure.message}</span>\n <div className={css.failureActions}>\n <Button\n variant=\"primary\"\n disabled={busy !== undefined || repairing !== undefined}\n onClick={() => { onRepair(failure, token) }}\n >\n {repairing === token ? t('repairing') : t('repair')}\n </Button>\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={() => { onCopy(failure, token) }}>\n {copied === token ? t('copied') : t('copyError')}\n </Button>\n </div>\n </div>\n </li>\n )\n })}\n </ul>\n </div>\n )}\n\n <div className={css.actionsRow}>\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={onCheck}>\n {busy?.kind === 'check' ? t('checking') : t('checkUpdates')}\n </Button>\n {updates.size === 0 && busy === undefined && view.plugins.length > 0 && (\n <p className={css.ok}>{t('noUpdates')}</p>\n )}\n </div>\n\n {toggleBusy !== undefined && <p className={css.applying} aria-live=\"polite\">{t('applying')}</p>}\n\n {dirty && (\n <div className={css.restartRow}>\n <p>{t('restartHint')}</p>\n </div>\n )}\n\n <Modal\n title={t('uninstallConfirmTitle')}\n open={uninstallTarget !== undefined}\n onClose={() => { setUninstallTarget(undefined) }}\n >\n <p className={css.confirmBody}>{t('uninstallConfirmBody', { name: uninstallTarget?.name ?? '' })}</p>\n <div className={css.modalActions}>\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={() => { setUninstallTarget(undefined) }}>\n {t('cancel')}\n </Button>\n <Button variant=\"primary\" className={css.dangerButton} disabled={busy !== undefined} onClick={onUninstall}>\n {t('confirm')}\n </Button>\n </div>\n </Modal>\n </div>\n )\n}\n","/**\n * Locale dictionaries for the plugin-manager tab. The zh dictionary is the\n * key source; the en dictionary mirrors the exact key set.\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 tab: '插件管理',\n loading: '正在读取插件…',\n empty: '尚未安装任何用户插件。',\n userPlugins: '用户插件',\n products: '内置产品',\n conflictTitle: '安装冲突',\n conflictDisabled: '已自动禁用 {name},避免重复挂载。',\n conflictEnabled: '已重新启用 {name}。',\n conflictChanged: '{name} 的状态已变更。',\n undoConflict: '撤销',\n conflictHint: '冲突动作在安装时自动执行,撤销会写回开关并在重启后生效。',\n installPlaceholder: 'npm 包名(如 @scope/name)或 git 仓库 URL',\n install: '安装',\n installing: '安装中…',\n installHint: '在 GitHub 或 npm 找到插件后,粘贴其 npm 包名或仓库地址安装;应用重启后插件生效。',\n version: '已安装 {version}',\n latest: '最新 {version}',\n update: '更新',\n updating: '更新中…',\n checkUpdates: '检查更新',\n checking: '检查中…',\n noUpdates: '所有插件都是最新版本。',\n uninstall: '卸载',\n uninstallConfirmTitle: '卸载插件',\n uninstallConfirmBody: '将删除 {name} 的安装目录与配置行,并在重启后生效。',\n confirm: '确认卸载',\n cancel: '取消',\n restartHint: '插件变更将在重启应用后生效。',\n failed: '操作失败:{reason}',\n enabled: '已开启',\n disabled: '已关闭',\n mixed: '部分开启',\n unavailable: '不可用',\n uninstalled: '已卸载',\n source: '查看源码',\n applying: '正在应用更改…',\n fetching: '正在获取插件信息…',\n downloading: '正在下载…',\n downloadingPercent: '正在下载 {percent}%',\n extracting: '正在解压…',\n writing: '正在写入配置…',\n localOnlyTitle: '仅限本机操作',\n localOnlyBody: '为了保护主机配置,插件管理只能从本机打开。',\n failureBadge: '启动失败',\n failureGroupTitle: '其他启动失败',\n repair: '让 Agent 修复',\n repairing: '正在创建修复对话…',\n copyError: '复制错误',\n copied: '已复制',\n safeModeBanner: '安全模式:用户插件配置已跳过,插件开关不可用。',\n exitSafeMode: '恢复正常模式并重启',\n npmSource: 'npm',\n gitSource: 'git',\n enableSwitch: '开启 {name}',\n disableSwitch: '关闭 {name}',\n repairInstallTitle: '插件安装失败,请帮我诊断并修复。',\n repairInstallSpecLabel: '安装目标',\n repairInstallErrorLabel: '错误信息',\n repairInstallAsk: '请检查该插件并重新安装;完成后告诉我结果。',\n repairFailureTitle: '插件上次启动失败。请修复它。',\n repairFailurePluginLabel: '插件',\n repairFailureKindLabel: '失败类型',\n repairFailureAtLabel: '时间',\n repairFailureMessageLabel: '失败详情',\n repairFailureStackLabel: '原始堆栈',\n repairFailurePathLabel: '插件安装目录',\n repairFailureAsk: '请检查并修复该插件;修复完成后告诉我如何重新启用。',\n repairKindLoad: '加载失败',\n repairKindHang: '启动挂起',\n repairKindLate: '迟到拒绝',\n repairConflictTitle: '正在处理插件安装冲突',\n repairConflictPluginLabel: '冲突条目',\n repairConflictChangeLabel: '状态变化',\n repairConflictAsk: '请检查冲突双方的入口行 id 与挂载方式,消除重复挂载后告诉我如何重新启用。',\n repairStateEnabled: '已开启',\n repairStateDisabled: '已关闭',\n repairStateUninstalled: '已卸载',\n} satisfies Record<string, string>\n\n/** English copy, checked complete against the zh key set. */\nconst STATIC_EN = {\n tab: 'Plugin manager',\n loading: 'Reading plugins…',\n empty: 'No user plugins installed yet.',\n userPlugins: 'User plugins',\n products: 'Built-in products',\n conflictTitle: 'Install conflicts',\n conflictDisabled: 'Automatically disabled {name} to avoid double mounting.',\n conflictEnabled: 'Re-enabled {name}.',\n conflictChanged: 'The state of {name} changed.',\n undoConflict: 'Undo',\n conflictHint: 'Conflict actions run automatically at install time; undoing writes the switch back and applies after a restart.',\n installPlaceholder: 'npm package (e.g. @scope/name) or git repository URL',\n install: 'Install',\n installing: 'Installing…',\n installHint: 'Find a plugin on GitHub or npm, then paste its npm package name or repository URL; plugins load after a restart.',\n version: 'Installed {version}',\n latest: 'Latest {version}',\n update: 'Update',\n updating: 'Updating…',\n checkUpdates: 'Check for updates',\n checking: 'Checking…',\n noUpdates: 'All plugins are up to date.',\n uninstall: 'Uninstall',\n uninstallConfirmTitle: 'Uninstall plugin',\n uninstallConfirmBody: '{name} and its configuration row will be removed; the change applies after a restart.',\n confirm: 'Uninstall',\n cancel: 'Cancel',\n restartHint: 'Plugin changes take effect after restarting the application.',\n failed: 'Operation failed: {reason}',\n enabled: 'On',\n disabled: 'Off',\n mixed: 'Partially on',\n unavailable: 'Unavailable',\n uninstalled: 'Uninstalled',\n source: 'View source',\n applying: 'Applying change…',\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 failureBadge: 'Startup failure',\n failureGroupTitle: 'Other startup failures',\n repair: 'Ask the agent to fix',\n repairing: 'Opening repair conversation…',\n copyError: 'Copy error',\n copied: 'Copied',\n safeModeBanner: 'Safe mode: user plugin configuration is skipped; plugin switches are disabled.',\n exitSafeMode: 'Restore normal mode and restart',\n npmSource: 'npm',\n gitSource: 'git',\n enableSwitch: 'Turn on {name}',\n disableSwitch: 'Turn off {name}',\n repairInstallTitle: 'The plugin installation failed. Please diagnose and fix it.',\n repairInstallSpecLabel: 'Install target',\n repairInstallErrorLabel: 'Error message',\n repairInstallAsk: 'Please inspect the plugin and reinstall it; tell me when it is done.',\n repairFailureTitle: 'A plugin failed to start last time. Please fix it.',\n repairFailurePluginLabel: 'Plugin',\n repairFailureKindLabel: 'Failure kind',\n repairFailureAtLabel: 'At',\n repairFailureMessageLabel: 'Failure details',\n repairFailureStackLabel: 'Original stack',\n repairFailurePathLabel: 'Plugin install directory',\n repairFailureAsk: 'Please inspect and fix the plugin; tell me how to re-enable it afterwards.',\n repairKindLoad: 'Load failure',\n repairKindHang: 'Startup hang',\n repairKindLate: 'Late rejection',\n repairConflictTitle: 'Handling a plugin install conflict',\n repairConflictPluginLabel: 'Conflicting entry',\n repairConflictChangeLabel: 'State change',\n repairConflictAsk: 'Inspect the entry ids and mounting of both sides, resolve the double mount, and tell me how to re-enable.',\n repairStateEnabled: 'On',\n repairStateDisabled: 'Off',\n repairStateUninstalled: 'Uninstalled',\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 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 /** Saved next-start enablement from the managed profile patch row. */\n enabled: boolean\n commit?: string\n}\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/** One plugin with a newer version available. */\nexport interface PluginUpdateItem {\n id: string\n current: string\n latest: 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/** One deployment-configured logical product switch. */\nexport interface PluginControlItem {\n id: string\n name: string\n repository: string\n state: 'enabled' | 'disabled' | 'mixed' | 'unavailable' | 'uninstalled'\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 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 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 }\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 plugin-control `list` / `set-enabled` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed control items.\n */\nexport function parsePluginControlSnapshot(value: unknown): PluginControlItem[] {\n if (!isRecord(value) || !Array.isArray(value.controls)) {\n throw new Error('plugin-manager: response must contain a controls array')\n }\n return value.controls.map((control, index) => {\n if (!isRecord(control) || !isString(control.id) || !isString(control.name)\n || !isString(control.repository)\n || (control.state !== 'enabled' && control.state !== 'disabled'\n && control.state !== 'mixed' && control.state !== 'unavailable'\n && control.state !== 'uninstalled')) {\n throw new Error(`plugin-manager: control row ${String(index)} is invalid`)\n }\n return {\n id: control.id,\n name: control.name,\n repository: control.repository,\n state: control.state,\n }\n })\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 return { id: update.id, current: update.current, latest: update.latest }\n })\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 } 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 * 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","/**\n * Plugin-manager browser half: contributes the family plugin-manager tab to\n * the official Plugins settings section (`settings.plugins.tab` slot) and\n * provides the same dual-channel face as the `'pluginManager'` cordis\n * service for sibling client plugins. It is dual-channel: on runtimes with\n * the official installer services (DSHCode, the 1.0.4 checkout web) every\n * operation rides the official `/plugin-installer` and `/plugin-control`\n * loopback RPC channels (the single writer); on the npm-published web runtime\n * those channels do not exist, so the same face falls back to this package's\n * own loopback HTTP gateway, which spawns the official CLI for writes.\n * Neither the tab nor service consumers know which mode the face runs in.\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 settings surface's slot contracts (settings.plugins.tab).\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n// Type-only: pulls the client runtime Context merge (ctx.workspaces, ctx.sessions).\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\nimport { PluginManagerTab, type PluginManagerTabInjected } from './PluginManagerTab.tsx'\nimport { en, zh, type PluginManagerKey } from './locales.ts'\nimport {\n parseFailuresSnapshot,\n parseInstallStatus,\n parseInstalledPlugin,\n parsePluginControlSnapshot,\n parsePluginList,\n parseUpdateList,\n type InstalledPluginItem,\n type InstallProgressItem,\n type PluginControlItem,\n type PluginFailuresSnapshot,\n type PluginUpdateItem,\n} from '../core/protocol.ts'\nimport { PLUGIN_MANAGER_SERVICE, type PluginManagerService } from '../core/service.ts'\nimport type { ControlChange } from '../core/conflict.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Copy for the family plugin-manager tab. */\n 'settings.pluginManager': PluginManagerKey\n }\n}\n\nconst NS = 'settings.pluginManager'\nconst CHANNEL = '/plugin-installer'\nconst CONTROL_CHANNEL = '/plugin-control'\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 STATUS_ENDPOINT = 'status'\nconst FAILURES_ENDPOINT = 'failures'\nconst SET_SAFE_MODE_ENDPOINT = 'set-safe-mode'\n\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 slot registration and both channels. */\nexport const inject = ['slots', 'locale', 'connection', 'workspaces', 'sessions']\n\n/** The gateway job wire shape served by /status. */\ninterface GatewayJobWire {\n phase: 'running' | 'done' | 'error'\n plugin?: unknown\n conflicts?: unknown\n error?: string\n}\n\n/**\n * The face the Plugin manager tab and the `'pluginManager'` cordis service\n * share: the full tab surface plus the cross-plugin service contract.\n */\nexport type PluginManagerFace = PluginManagerTabInjected & PluginManagerService\n\n/**\n * Build the dual-channel face once: official-channel and gateway-channel\n * implementations, the mode detection that picks between them, the repair\n * handoff, and the change-notification listener set. The returned face is\n * both the tab's injected props and the value provided as the\n * `'pluginManager'` cordis service.\n * @param ctx - the client context (connection, workspaces, sessions).\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 setSafeMode: async (enabled: boolean): Promise<void> => {\n await call(SET_SAFE_MODE_ENDPOINT, { enabled })\n },\n controlsList: async (): Promise<PluginControlItem[]> =>\n parsePluginControlSnapshot(await connection.rpc.call(CONTROL_CHANNEL, 'list', {}).then(result => {\n if (!result.ok) throw new Error(`plugin-control list failed: ${result.error.code}: ${result.error.message}`)\n return result.value\n })),\n controlsSetEnabled: async (pluginId: string, enabled: boolean): Promise<PluginControlItem[]> =>\n parsePluginControlSnapshot(await connection.rpc.call(CONTROL_CHANNEL, 'set-enabled', { pluginId, enabled }).then(result => {\n if (!result.ok) throw new Error(`plugin-control set-enabled failed: ${result.error.code}: ${result.error.message}`)\n return result.value\n })),\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 /** The conflict ledger of the last settled gateway install. */\n let lastInstallConflicts: ControlChange[] = []\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 lastInstallConflicts = Array.isArray(job.conflicts) ? job.conflicts as ControlChange[] : []\n return parseInstalledPlugin({ plugin: job.plugin })\n } finally {\n gatewayInflight = false\n }\n },\n update: async (id: string): Promise<InstalledPluginItem> => {\n const rows = await gateway.list()\n const row = rows.find(item => item.id === id)\n if (row === undefined) throw new Error(`plugin-manager: plugin ${id} is not installed`)\n return gateway.install(row.source.spec)\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 setSafeMode: async (): Promise<void> => {\n throw new Error('plugin-manager: safe mode is unavailable in this runtime')\n },\n controlsList: async (): Promise<PluginControlItem[]> => [],\n controlsSetEnabled: async (pluginId: string, enabled: boolean): Promise<PluginControlItem[]> => {\n await gateway.setEnabled(pluginId, enabled)\n return []\n },\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.\n try {\n const mode = await gatewayJson(`${GATEWAY_PREFIX}/mode`) as { official?: boolean }\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 /**\n * Start a repair conversation for a failed plugin: resolve a workspace over\n * the plugin install root (created once, reused after), open a fresh\n * session there, and seed its first prompt with the failure details. The\n * session's workspace is the plugin home so the agent's file tools reach\n * the plugin code without leaving the workspace boundary.\n * @param pluginRoot - absolute plugin install root.\n * @param message - the seeded first user message.\n * @returns resolution after the prompt is accepted and the session opens.\n */\n const repairPlugin = async (pluginRoot: string, message: string): Promise<void> => {\n const workspace = await ctx.workspaces.create({ path: pluginRoot })\n const sessionId = await ctx.workspaces.connectWorkspace(workspace.workspaceId)\n const binding = ctx.sessions.binding(sessionId)\n if (binding === undefined) throw new Error(`plugin-manager: repair session ${sessionId} is unavailable`)\n const result = await binding.session.prompt([{ type: 'text', text: message }], 'queue')\n if (!result.ok) throw new Error(`plugin-manager: repair prompt failed: ${result.error.code}: ${result.error.message}`)\n ctx.sessions.open(sessionId)\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 status: async () => (await ensureMode()) === 'official' ? official.status() : gateway.status(),\n failures: async () => (await ensureMode()) === 'official' ? official.failures() : gateway.failures(),\n setSafeMode: async enabled => (await ensureMode()) === 'official' ? official.setSafeMode(enabled) : gateway.setSafeMode(),\n repairPlugin,\n controlsList: async () => (await ensureMode()) === 'official' ? official.controlsList() : gateway.controlsList(),\n controlsSetEnabled: async (id, enabled) => (await ensureMode()) === 'official' ? official.controlsSetEnabled(id, enabled) : gateway.controlsSetEnabled(id, enabled),\n lastInstallConflicts: () => lastInstallConflicts,\n onChange: cb => {\n listeners.add(cb)\n return () => { listeners.delete(cb) }\n },\n }\n}\n\n/** Contribute the family plugin-manager tab and provide the shared face. */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'plugin-manager: dictionaries')\n\n // Built once: the tab and the 'pluginManager' cordis service share one\n // face, so consumers observe exactly the mutations the tab performs.\n const face = createPluginManagerFace(ctx)\n ctx.provide(PLUGIN_MANAGER_SERVICE, face)\n\n ctx.slots.inject('settings.plugins.tab', () => ctx.slots.register({\n name: 'settings.plugins.tab',\n id: 'family-plugins',\n order: 20,\n label: () => ctx.locale.bind(NS)('tab'),\n locale: NS,\n inject: () => face,\n }, PluginManagerTab))\n}\n"],"mappings":";;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cAAc;GAChB,GAAG,gBAAgB,CAAC;EACtB"}
1
+ {"version":3,"file":"client.js","names":["css","Button","Modal"],"sources":["../../../packages/dsh-plugin-manager/src/core/conflict.ts","../../../packages/dsh-plugin-manager/src/core/repair.ts","../../../packages/dsh-plugin-manager/src/client/PluginManagerTab.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/index.ts"],"sourcesContent":["/**\n * Conflict-ledger diffing. The official host applies structural conflict\n * rules at install time (disableControlsOnInstall: installing the dsh-web-ui\n * family disables the built-in web-ui product rows so the two never\n * double-mount), but no UI surfaces what the rules just did. This module\n * diffs the plugin-control snapshots taken before and after an install and\n * classifies every state change so the tab can render it as a reversible,\n * attributable conflict notice.\n *\n * The install-time authority ends here: duplicate insert-id claims between\n * two user plugins carry no at-install signal through the RPC channels (the\n * Loader only re-reads the composition at the next start), so that failure\n * shape is left to the boot-failure ring — the real start is the authoritative\n * conflict detector.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { PluginControlItem } from './protocol.ts'\n\n/** One observed product-control state change between two snapshots. */\nexport interface ControlChange {\n id: string\n name: string\n from: PluginControlItem['state']\n to: PluginControlItem['state']\n}\n\n/** Meaningful change kinds a conflict notice distinguishes. */\nexport type ControlChangeKind = 'rule-disabled' | 'rule-enabled' | 'state-change'\n\n/**\n * Diff two plugin-control snapshots by id. Only entries present in both\n * snapshots with a changed state are reported; entries appearing or\n * disappearing are ordinary install/uninstall outcomes, not conflicts.\n * @param before - snapshot taken before the install.\n * @param after - snapshot taken after the install.\n * @returns one change per id whose state moved, in id order.\n */\nexport function diffControls(before: readonly PluginControlItem[], after: readonly PluginControlItem[]): ControlChange[] {\n const afterById = new Map(after.map(item => [item.id, item]))\n const changes: ControlChange[] = []\n for (const item of before) {\n const current = afterById.get(item.id)\n if (current === undefined || current.state === item.state) continue\n changes.push({ id: item.id, name: item.name, from: item.state, to: current.state })\n }\n return changes\n}\n\n/**\n * Classify one control-state change for messaging. A change into `disabled`\n * is the conflict rule's action (reversible by re-enabling); a change out of\n * `disabled` is a manual undo; anything else is reported neutrally.\n * @param change - one diff entry.\n * @returns the message kind.\n */\nexport function classifyChange(change: ControlChange): ControlChangeKind {\n if (change.to === 'disabled') return 'rule-disabled'\n if (change.from === 'disabled') return 'rule-enabled'\n return 'state-change'\n}\n","/**\n * Repair-conversation seed text. Two failure surfaces hand off to the agent\n * through the same shape: a failed install (target spec + install error) and\n * a recorded boot failure (the failure-ring row). The seeded message must be\n * self-contained — the repair session's workspace is the plugin install root,\n * so the agent's file tools reach the plugin code without leaving the\n * workspace boundary.\n *\n * Secret discipline: the seed carries only the spec, the host's truncated\n * failure message/stack, and paths. Callers must never append credentials,\n * tokens, or environment contents; the failure ring is the host's bounded,\n * pruned record and nothing else is added.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { PluginFailureItem } from './protocol.ts'\nimport type { LayerState } from './patch-diff.ts'\n\n/** Localized fragments the builders assemble. */\nexport interface RepairCopy {\n installTitle: string\n installSpecLabel: string\n installErrorLabel: string\n installAsk: string\n failureTitle: string\n failurePluginLabel: string\n failureKindLabel: string\n failureAtLabel: string\n failureMessageLabel: string\n failureStackLabel: string\n failurePathLabel: string\n failureAsk: string\n conflictTitle: string\n conflictPluginLabel: string\n conflictChangeLabel: string\n conflictAsk: string\n /** Localized names of the failure kinds. */\n kindNames: Record<PluginFailureItem['kind'], string>\n /** Localized names of the layer states a conflict change traverses. */\n stateNames: Record<LayerState, string>\n}\n\n/** Default copy (zh): the package's zh dictionary keys map onto these strings. */\nexport const DEFAULT_REPAIR_COPY: RepairCopy = {\n installTitle: '正在修复插件安装失败',\n installSpecLabel: '安装目标',\n installErrorLabel: '安装错误',\n installAsk: '请在插件安装根目录内检查插件包或依赖并修复,然后重试安装。',\n failureTitle: '正在修复插件启动失败',\n failurePluginLabel: '插件',\n failureKindLabel: '失败类型',\n failureAtLabel: '时间',\n failureMessageLabel: '错误信息',\n failureStackLabel: '堆栈',\n failurePathLabel: '安装路径',\n failureAsk: '请修复插件后重新启用并重启 dsh web。',\n conflictTitle: '正在处理插件安装冲突',\n conflictPluginLabel: '冲突条目',\n conflictChangeLabel: '状态变化',\n conflictAsk: '请检查冲突双方的入口行 id 与挂载方式,消除重复挂载后告诉我如何重新启用。',\n kindNames: {\n 'load-failure': '加载失败',\n hang: '启动挂起',\n 'late-rejection': '迟到拒绝',\n },\n stateNames: {\n enabled: '已开启',\n disabled: '已关闭',\n uninstalled: '已卸载',\n },\n}\n\n/**\n * Seed text for a failed install: the target and the rendered error,\n * self-contained for the agent.\n * @param spec - the install target (npm spec or git URL) that failed.\n * @param error - the rendered install error text.\n * @param copy - localized fragments.\n * @returns the repair prompt text.\n */\nexport function installRepairMessage(spec: string, error: string, copy: RepairCopy = DEFAULT_REPAIR_COPY): string {\n return [\n copy.installTitle,\n `${copy.installSpecLabel}: ${spec}`,\n `${copy.installErrorLabel}:\\n${error}`,\n copy.installAsk,\n ].join('\\n\\n')\n}\n\n/**\n * Seed text for one boot-failure ring row: the failure record, so the agent\n * can attribute and fix it in place.\n * @param failure - the recorded failure row.\n * @param copy - localized fragments.\n * @returns the repair prompt text.\n */\nexport function failureRepairMessage(failure: PluginFailureItem, copy: RepairCopy = DEFAULT_REPAIR_COPY): string {\n const parts = [\n copy.failureTitle,\n `${copy.failurePluginLabel}: ${failure.pluginId || '-'}`,\n `${copy.failureKindLabel}: ${copy.kindNames[failure.kind] ?? failure.kind}`,\n `${copy.failureAtLabel}: ${failure.at}`,\n `${copy.failureMessageLabel}:\\n${failure.message}`,\n ]\n if (failure.stack !== '') parts.push(`${copy.failureStackLabel}:\\n${failure.stack}`)\n if (failure.installPath !== '') parts.push(`${copy.failurePathLabel}: ${failure.installPath}`)\n parts.push(copy.failureAsk)\n return parts.join('\\n\\n')\n}\n\n/**\n * Seed text for one install-conflict notice: the entry and its state change,\n * so the agent can attribute the conflict and resolve the double mount.\n * @param change - the conflict change (id, display name, from/to states).\n * @param copy - localized fragments.\n * @returns the repair prompt text.\n */\nexport function conflictRepairMessage(\n change: { id: string; name: string; from: LayerState; to: LayerState },\n copy: RepairCopy = DEFAULT_REPAIR_COPY,\n): string {\n return [\n copy.conflictTitle,\n `${copy.conflictPluginLabel}: ${change.name} (${change.id})`,\n `${copy.conflictChangeLabel}: ${copy.stateNames[change.from] ?? change.from} -> ${copy.stateNames[change.to] ?? change.to}`,\n copy.conflictAsk,\n ].join('\\n\\n')\n}\n","/**\n * The plugin-manager tab: an install box, one row per installed user plugin\n * (next-start enablement switch, source badge, update availability, update and\n * uninstall actions, per-plugin boot-failure block), the built-in product\n * switches, an install-conflict notice (the diff of the plugin-control\n * snapshot around each install, reversible through the product switch), and\n * the failure-repair affordances. Enablement switches and installs persist\n * through the official host channels and apply at the next restart; the web\n * build shows a restart hint instead of an in-place restart.\n *\n * This tab registers into the official Plugins settings section\n * (`settings.plugins.tab` slot) next to the official installer tab; its added\n * value over that tab is the conflict ledger, the bilingual repair seeds, and\n * the family card vocabulary.\n */\nimport { useEffect, useRef, useState } from 'react'\nimport { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport { classifyChange, diffControls, type ControlChange } from '../core/conflict.ts'\nimport type {\n InstallProgressItem,\n InstalledPluginItem,\n PluginControlItem,\n PluginFailureItem,\n PluginFailuresSnapshot,\n PluginUpdateItem,\n} from '../core/protocol.ts'\nimport { conflictRepairMessage, failureRepairMessage, installRepairMessage, type RepairCopy } from '../core/repair.ts'\nimport type { PluginManagerKey } from './locales.ts'\nimport css from './plugin-manager.module.css'\n\n/** Registration-side wire face used by the tab. */\nexport interface PluginManagerTabInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n 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 /** Re-install one plugin from its recorded source. */\n update: (id: string) => Promise<InstalledPluginItem>\n /** Remove one plugin. */\n uninstall: (id: string) => Promise<InstalledPluginItem[]>\n /** Persist one user plugin's next-start enablement. */\n setEnabled: (id: string, enabled: boolean) => Promise<InstalledPluginItem>\n /** Compare installed versions against their sources. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /** Read the current install/update progress. */\n status: () => Promise<InstallProgressItem>\n /** Read the recorded boot failures, plugin root, and safe-mode state. */\n failures: () => Promise<PluginFailuresSnapshot>\n /** Persist the safe-mode marker (web: applied at the next manual restart). */\n setSafeMode: (enabled: boolean) => Promise<void>\n /** Start a repair conversation over the plugin install root. */\n repairPlugin: (pluginRoot: string, message: string) => Promise<void>\n /** Read the deployment-configured built-in product switches. */\n controlsList: () => Promise<PluginControlItem[]>\n /** Persist one product's next-start enablement. */\n controlsSetEnabled: (pluginId: string, enabled: boolean) => Promise<PluginControlItem[]>\n /** Conflicts the gateway host computed around the last install (gateway mode only). */\n lastInstallConflicts?: () => readonly ControlChange[]\n}\n\n/** Full component props assembled by the Settings slot renderer. */\nexport type PluginManagerTabProps =\n PropsRuntime<'settings.plugins.tab'>\n & PropsLocale<'settings.pluginManager'>\n & InjectFace<PluginManagerTabInjected>\n\ntype ViewState =\n | { readonly status: 'loading' }\n | { readonly status: 'error' }\n | {\n readonly status: 'ready'\n readonly plugins: readonly InstalledPluginItem[]\n readonly controls: readonly PluginControlItem[]\n readonly failures: PluginFailuresSnapshot\n }\n\n/** One row operation in flight. */\ntype BusyAction = { readonly kind: 'install' | 'update' | 'uninstall' | 'check'; readonly id?: string }\n\n/** One enablement switch in flight: a user plugin or a built-in product. */\ntype ToggleBusy = { readonly kind: 'user' | 'product'; readonly id: string }\n\n/** One uninstall target awaiting confirmation. */\ninterface UninstallTarget {\n readonly id: string\n readonly name: string\n}\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 fragments for the repair seed builders, read from the tab's dictionaries. */\nfunction repairCopy(t: PluginManagerTabProps['t']): RepairCopy {\n return {\n installTitle: t('repairInstallTitle'),\n installSpecLabel: t('repairInstallSpecLabel'),\n installErrorLabel: t('repairInstallErrorLabel'),\n installAsk: t('repairInstallAsk'),\n failureTitle: t('repairFailureTitle'),\n failurePluginLabel: t('repairFailurePluginLabel'),\n failureKindLabel: t('repairFailureKindLabel'),\n failureAtLabel: t('repairFailureAtLabel'),\n failureMessageLabel: t('repairFailureMessageLabel'),\n failureStackLabel: t('repairFailureStackLabel'),\n failurePathLabel: t('repairFailurePathLabel'),\n failureAsk: t('repairFailureAsk'),\n kindNames: {\n 'load-failure': t('repairKindLoad'),\n hang: t('repairKindHang'),\n 'late-rejection': t('repairKindLate'),\n },\n conflictTitle: t('repairConflictTitle'),\n conflictPluginLabel: t('repairConflictPluginLabel'),\n conflictChangeLabel: t('repairConflictChangeLabel'),\n conflictAsk: t('repairConflictAsk'),\n stateNames: {\n enabled: t('repairStateEnabled'),\n disabled: t('repairStateDisabled'),\n uninstalled: t('repairStateUninstalled'),\n },\n }\n}\n\n/** Localized label for one install phase, with percent when the download has one. */\nfunction progressLabel(progress: InstallProgressItem, t: PluginManagerTabProps['t']): string {\n if (progress.stage === 'fetch') return t('fetching')\n if (progress.stage === 'extract') return t('extracting')\n if (progress.stage === 'write') return t('writing')\n return progress.percent === undefined ? t('downloading') : t('downloadingPercent', { percent: String(progress.percent) })\n}\n\n/** The plugin-manager settings tab. */\nexport function PluginManagerTab(props: PluginManagerTabProps) {\n const {\n t,\n isLoopback,\n list,\n install,\n update,\n uninstall,\n setEnabled,\n checkUpdates,\n status,\n failures,\n setSafeMode,\n repairPlugin,\n controlsList,\n controlsSetEnabled,\n lastInstallConflicts,\n } = props\n\n const [view, setView] = useState<ViewState>({ status: 'loading' })\n const [busy, setBusy] = useState<BusyAction | undefined>(undefined)\n const [toggleBusy, setToggleBusy] = useState<ToggleBusy | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [failedSpec, setFailedSpec] = useState<string | undefined>(undefined)\n const [installError, setInstallError] = useState<string | undefined>(undefined)\n const [spec, setSpec] = useState('')\n const [dirty, setDirty] = useState(false)\n const [repairing, setRepairing] = useState<string | undefined>(undefined)\n const [copied, setCopied] = useState<string | undefined>(undefined)\n const [updates, setUpdates] = useState<ReadonlyMap<string, string>>(new Map())\n const [uninstallTarget, setUninstallTarget] = useState<UninstallTarget | undefined>(undefined)\n const [conflicts, setConflicts] = useState<readonly ControlChange[]>([])\n const [progress, setProgress] = useState<InstallProgressItem>({ kind: 'idle', stage: 'fetch' })\n /** Synchronous in-flight mirror of `busy`: the render-time guard alone lets a\n * click and an Enter land in the same frame and double-fire. */\n const busyRef = useRef(false)\n\n /** Reload every snapshot into the ready view. */\n const reload = async (): Promise<void> => {\n const [plugins, controls, failureSnapshot] = await Promise.all([list(), controlsList(), failures()])\n setView({ status: 'ready', plugins, controls, failures: failureSnapshot })\n }\n\n useEffect(() => {\n let cancelled = false\n void reload().catch(() => {\n if (!cancelled) setView({ status: 'error' })\n })\n return () => { cancelled = true }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n /** One row/form operation: busy state, error row, dirty flag on success. */\n const run = async (action: BusyAction, body: () => Promise<void>): Promise<void> => {\n if (busyRef.current) return\n busyRef.current = true\n setBusy(action)\n setError(undefined)\n try {\n await body()\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 /** Install one spec, then diff the product snapshot into a conflict notice. */\n const onInstall = (): void => {\n const target = spec.trim()\n if (target === '' || busy !== undefined || busyRef.current) return\n void (async () => {\n busyRef.current = true\n const before = view.status === 'ready' ? view.controls : await controlsList().catch(() => [])\n setBusy({ kind: 'install' })\n setError(undefined)\n setFailedSpec(undefined)\n setInstallError(undefined)\n try {\n await install(target)\n setSpec('')\n setDirty(true)\n const after = await controlsList().catch(() => [] as readonly PluginControlItem[])\n setConflicts(lastInstallConflicts !== undefined ? lastInstallConflicts() : diffControls(before, after))\n await reload()\n } catch (reason) {\n const reasonText = messageOf(reason)\n setFailedSpec(target)\n setInstallError(reasonText)\n setError(t('failed', { reason: reasonText }))\n } finally {\n busyRef.current = false\n setBusy(undefined)\n }\n })()\n }\n\n /** Poll install/update progress while such an operation is in flight. */\n useEffect(() => {\n if (busy === undefined || (busy.kind !== 'install' && busy.kind !== '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(() => { /* status polling fails silently; the operation 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 const toggleDisabled = busy !== undefined || toggleBusy !== undefined\n || (view.status === 'ready' && view.failures.safeMode)\n\n const onUserToggle = (id: string, enabled: boolean): void => {\n setToggleBusy({ kind: 'user', id })\n setError(undefined)\n void setEnabled(id, enabled).then(plugin => {\n setView(current => current.status === 'ready'\n ? { ...current, plugins: current.plugins.map(item => item.id === id ? plugin : item) }\n : current)\n setDirty(true)\n setToggleBusy(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setToggleBusy(undefined)\n })\n }\n\n const onProductToggle = (id: string, enabled: boolean): void => {\n setToggleBusy({ kind: 'product', id })\n setError(undefined)\n void controlsSetEnabled(id, enabled).then(controls => {\n setView(current => current.status === 'ready' ? { ...current, controls } : current)\n setConflicts(previous => previous.filter(change => change.id !== id))\n setDirty(true)\n setToggleBusy(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setToggleBusy(undefined)\n })\n }\n\n const onCheck = (): void => {\n void run({ kind: 'check' }, async () => {\n const found = await checkUpdates()\n setUpdates(new Map(found.map(item => [item.id, item.latest])))\n })\n }\n\n const onUpdate = (id: string): void => {\n void run({ kind: 'update', id }, async () => {\n await update(id)\n setUpdates(previous => {\n const next = new Map(previous)\n next.delete(id)\n return next\n })\n await reload()\n })\n }\n\n const onUninstall = (): void => {\n const target = uninstallTarget\n if (target === undefined) return\n void run({ kind: 'uninstall', id: target.id }, async () => {\n await uninstall(target.id)\n setUninstallTarget(undefined)\n await reload()\n })\n }\n\n /** Open a repair conversation seeded with one boot-failure record. `token`\n * identifies the row for the in-flight label (plugin id, or a row key for\n * unattributable failures). */\n const onRepair = (failure: PluginFailureItem, token: string): void => {\n if (view.status !== 'ready' || busy !== undefined || repairing !== undefined) return\n setError(undefined)\n setRepairing(token)\n void repairPlugin(view.failures.pluginRoot, failureRepairMessage(failure, repairCopy(t))).then(() => {\n setRepairing(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setRepairing(undefined)\n })\n }\n\n /** Hand the latest failed install off to a repair conversation over the\n * install root. The seed carries the install's own error (installError), not\n * whatever error the row currently shows. */\n const onRepairInstall = (): void => {\n if (view.status !== 'ready' || repairing !== undefined) return\n setError(undefined)\n setRepairing('install')\n void repairPlugin(view.failures.pluginRoot, installRepairMessage(failedSpec ?? '', installError ?? '', repairCopy(t))).then(() => {\n setError(undefined)\n setFailedSpec(undefined)\n setInstallError(undefined)\n setRepairing(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setRepairing(undefined)\n })\n }\n\n /** Copy a boot failure's message and stack for a manual repair conversation. */\n const onCopy = (failure: PluginFailureItem, token: string): void => {\n void navigator.clipboard.writeText(`${failure.message}\\n\\n${failure.stack}`).then(() => {\n setCopied(token)\n }).catch(() => {\n setError(t('failed', { reason: 'clipboard unavailable' }))\n })\n }\n\n const onExitSafeMode = (): void => {\n if (busy !== undefined) return\n setError(undefined)\n void setSafeMode(false).then(() => {\n setDirty(true)\n void reload().catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n })\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n })\n }\n\n /** Undo one conflict action by flipping the product switch back. */\n const onUndoConflict = (change: ControlChange): void => {\n if (change.to !== 'disabled') return\n onProductToggle(change.id, true)\n }\n\n /** Hand one conflict notice off to a repair conversation over the plugin root. */\n const onRepairConflict = (change: ControlChange): void => {\n if (view.status !== 'ready' || busy !== undefined || repairing !== undefined) return\n setError(undefined)\n const token = `conflict:${change.id}`\n setRepairing(token)\n void repairPlugin(view.failures.pluginRoot, conflictRepairMessage({\n id: change.id,\n name: change.name,\n from: change.from === 'enabled' || change.from === 'disabled' ? change.from : 'uninstalled',\n to: change.to === 'enabled' || change.to === 'disabled' ? change.to : 'uninstalled',\n }, repairCopy(t))).then(() => {\n setRepairing(undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setRepairing(undefined)\n })\n }\n\n if (!isLoopback) {\n return (\n <div className={css.notice}>\n <strong>{t('localOnlyTitle')}</strong>\n <p>{t('localOnlyBody')}</p>\n </div>\n )\n }\n if (view.status === 'loading') return <div className={css.state}>{t('loading')}</div>\n if (view.status === 'error') return <div className={css.state}>{t('failed', { reason: 'load' })}</div>\n\n const attributable = new Map(view.failures.items.filter(item => item.pluginId !== '').map(item => [item.pluginId, item]))\n const unattributable = view.failures.items.filter(item => item.pluginId === '')\n\n return (\n <div className={css.section} aria-busy={busy !== undefined || toggleBusy !== undefined}>\n {view.failures.safeMode && (\n <div className={css.safeModeBanner} data-safe-mode>\n <p>{t('safeModeBanner')}</p>\n <Button variant=\"primary\" disabled={busy !== undefined} onClick={onExitSafeMode}>\n {t('exitSafeMode')}\n </Button>\n </div>\n )}\n\n <div className={css.installRow}>\n <input\n className={css.spec}\n type=\"text\"\n value={spec}\n placeholder={t('installPlaceholder')}\n disabled={busy !== undefined}\n onChange={event => { setSpec(event.target.value) }}\n onKeyDown={event => {\n if (event.key === 'Enter' && spec.trim() !== '' && busy === undefined) onInstall()\n }}\n />\n <Button\n variant=\"primary\"\n disabled={spec.trim() === '' || busy !== undefined}\n onClick={onInstall}\n >\n {busy !== undefined && busy.kind === 'install' ? t('installing') : t('install')}\n </Button>\n </div>\n <p className={css.hint}>{t('installHint')}</p>\n\n {(busy?.kind === 'install' || busy?.kind === '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: `${progress.percent}%` }}\n data-indeterminate={progress.percent === undefined ? 'true' : undefined}\n />\n </div>\n <p className={css.progressLabel}>{progressLabel(progress, t)}</p>\n </div>\n )}\n\n {error !== undefined && (\n <div className={css.errorRow}>\n <span className={css.error}>{error}</span>\n {failedSpec !== undefined && (\n <Button variant=\"outline\" disabled={repairing !== undefined} onClick={onRepairInstall}>\n {repairing === 'install' ? t('repairing') : t('repair')}\n </Button>\n )}\n </div>\n )}\n\n {conflicts.length > 0 && (\n <div className={css.conflicts}>\n <h3 className={css.sectionTitle}>{t('conflictTitle')}</h3>\n <ul className={css.list}>\n {conflicts.map(change => (\n <li key={change.id} className={css.row} data-conflict={change.id}>\n <div className={css.meta}>\n <span className={css.name}>{change.name}</span>\n <span className={css.sub}>\n {classifyChange(change) === 'rule-disabled'\n ? t('conflictDisabled', { name: change.name })\n : classifyChange(change) === 'rule-enabled'\n ? t('conflictEnabled', { name: change.name })\n : t('conflictChanged', { name: change.name })}\n </span>\n </div>\n <div className={css.actions}>\n {change.to === 'disabled' && (\n <Button\n variant=\"outline\"\n disabled={toggleDisabled}\n onClick={() => { onUndoConflict(change) }}\n >\n {t('undoConflict')}\n </Button>\n )}\n <Button\n variant=\"outline\"\n disabled={busy !== undefined || repairing !== undefined}\n onClick={() => { onRepairConflict(change) }}\n >\n {repairing === `conflict:${change.id}` ? t('repairing') : t('repair')}\n </Button>\n </div>\n </li>\n ))}\n </ul>\n <p className={css.hint}>{t('conflictHint')}</p>\n </div>\n )}\n\n <div className={css.group}>\n <h3 className={css.sectionTitle}>{t('userPlugins')}</h3>\n {view.plugins.length === 0\n ? <p className={css.empty}>{t('empty')}</p>\n : (\n <ul className={css.list}>\n {view.plugins.map(plugin => {\n const latest = updates.get(plugin.id)\n const failure = attributable.get(plugin.id)\n return (\n <li key={plugin.id} className={css.row} data-plugin-id={plugin.id}>\n <div className={css.meta}>\n <span className={css.name}>{plugin.name}</span>\n <span className={css.sub}>\n <span className={css.version}>{t('version', { version: plugin.version })}</span>\n <span className={css.sourceBadge} data-source={plugin.source.kind}>\n {plugin.source.kind === 'npm' ? t('npmSource') : t('gitSource')}\n </span>\n <span className={css.specText} title={plugin.source.spec}>{plugin.source.spec}</span>\n </span>\n {latest !== undefined && <span className={css.latest}>{t('latest', { version: latest })}</span>}\n {failure !== undefined && (\n <div className={css.failure} data-plugin-failure={plugin.id}>\n <span className={css.badge}>{t('failureBadge')}</span>\n <span className={css.failureMessage} title={failure.message}>{failure.message}</span>\n <div className={css.failureActions}>\n <Button\n variant=\"primary\"\n disabled={busy !== undefined || repairing !== undefined}\n onClick={() => { onRepair(failure, plugin.id) }}\n >\n {repairing === plugin.id ? t('repairing') : t('repair')}\n </Button>\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={() => { onCopy(failure, plugin.id) }}>\n {copied === plugin.id ? t('copied') : t('copyError')}\n </Button>\n </div>\n </div>\n )}\n </div>\n <div className={css.actions}>\n <span className={css.stateLabel} data-state={plugin.enabled ? 'enabled' : 'disabled'}>\n {plugin.enabled ? t('enabled') : t('disabled')}\n </span>\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={plugin.enabled}\n aria-label={plugin.enabled ? t('disableSwitch', { name: plugin.name }) : t('enableSwitch', { name: plugin.name })}\n className={css.switch}\n disabled={toggleDisabled}\n onClick={() => { onUserToggle(plugin.id, !plugin.enabled) }}\n />\n {latest !== undefined && (\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={() => { onUpdate(plugin.id) }}>\n {busy?.kind === 'update' && busy.id === plugin.id ? t('updating') : t('update')}\n </Button>\n )}\n <Button\n variant=\"outline\"\n disabled={busy !== undefined}\n onClick={() => { setUninstallTarget({ id: plugin.id, name: plugin.name }) }}\n >\n {t('uninstall')}\n </Button>\n </div>\n </li>\n )\n })}\n </ul>\n )}\n </div>\n\n {view.controls.length > 0 && (\n <div className={css.group}>\n <h3 className={css.sectionTitle}>{t('products')}</h3>\n <ul className={css.list}>\n {view.controls.map(control => (\n <li key={control.id} className={css.row} data-product-id={control.id}>\n <div className={css.meta}>\n <span className={css.name}>{control.name}</span>\n <span className={css.sub}>\n <a className={css.link} href={control.repository} target=\"_blank\" rel=\"noreferrer\">{t('source')}</a>\n </span>\n </div>\n <div className={css.actions}>\n <span className={css.stateLabel} data-state={control.state}>\n {t(control.state)}\n </span>\n {control.state === 'enabled' || control.state === 'disabled'\n ? (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={control.state === 'enabled'}\n aria-label={control.state === 'enabled'\n ? t('disableSwitch', { name: control.name })\n : t('enableSwitch', { name: control.name })}\n className={css.switch}\n disabled={toggleDisabled}\n onClick={() => { onProductToggle(control.id, control.state !== 'enabled') }}\n />\n )\n : null}\n </div>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {unattributable.length > 0 && (\n <div className={css.group}>\n <h3 className={css.sectionTitle}>{t('failureGroupTitle')}</h3>\n <ul className={css.list}>\n {unattributable.map((failure, index) => {\n const token = `other:${index}`\n return (\n <li key={`${failure.at}-${index}`} className={css.row} data-plugin-failure=\"other\">\n <div className={css.meta}>\n <span className={css.badge}>{t('failureBadge')}</span>\n <span className={css.failureMessage} title={failure.message}>{failure.message}</span>\n <div className={css.failureActions}>\n <Button\n variant=\"primary\"\n disabled={busy !== undefined || repairing !== undefined}\n onClick={() => { onRepair(failure, token) }}\n >\n {repairing === token ? t('repairing') : t('repair')}\n </Button>\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={() => { onCopy(failure, token) }}>\n {copied === token ? t('copied') : t('copyError')}\n </Button>\n </div>\n </div>\n </li>\n )\n })}\n </ul>\n </div>\n )}\n\n <div className={css.actionsRow}>\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={onCheck}>\n {busy?.kind === 'check' ? t('checking') : t('checkUpdates')}\n </Button>\n {updates.size === 0 && busy === undefined && view.plugins.length > 0 && (\n <p className={css.ok}>{t('noUpdates')}</p>\n )}\n </div>\n\n {toggleBusy !== undefined && <p className={css.applying} aria-live=\"polite\">{t('applying')}</p>}\n\n {dirty && (\n <div className={css.restartRow}>\n <p>{t('restartHint')}</p>\n </div>\n )}\n\n <Modal\n title={t('uninstallConfirmTitle')}\n open={uninstallTarget !== undefined}\n onClose={() => { setUninstallTarget(undefined) }}\n >\n <p className={css.confirmBody}>{t('uninstallConfirmBody', { name: uninstallTarget?.name ?? '' })}</p>\n <div className={css.modalActions}>\n <Button variant=\"outline\" disabled={busy !== undefined} onClick={() => { setUninstallTarget(undefined) }}>\n {t('cancel')}\n </Button>\n <Button variant=\"primary\" className={css.dangerButton} disabled={busy !== undefined} onClick={onUninstall}>\n {t('confirm')}\n </Button>\n </div>\n </Modal>\n </div>\n )\n}\n","/**\n * Locale dictionaries for the plugin-manager tab. The zh dictionary is the\n * key source; the en dictionary mirrors the exact key set.\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 tab: '插件管理',\n loading: '正在读取插件…',\n empty: '尚未安装任何用户插件。',\n userPlugins: '用户插件',\n products: '内置产品',\n conflictTitle: '安装冲突',\n conflictDisabled: '已自动禁用 {name},避免重复挂载。',\n conflictEnabled: '已重新启用 {name}。',\n conflictChanged: '{name} 的状态已变更。',\n undoConflict: '撤销',\n conflictHint: '冲突动作在安装时自动执行,撤销会写回开关并在重启后生效。',\n installPlaceholder: 'npm 包名(如 @scope/name)或 git 仓库 URL',\n install: '安装',\n installing: '安装中…',\n installHint: '在 GitHub 或 npm 找到插件后,粘贴其 npm 包名或仓库地址安装;应用重启后插件生效。',\n version: '已安装 {version}',\n latest: '最新 {version}',\n update: '更新',\n updating: '更新中…',\n checkUpdates: '检查更新',\n checking: '检查中…',\n noUpdates: '所有插件都是最新版本。',\n uninstall: '卸载',\n uninstallConfirmTitle: '卸载插件',\n uninstallConfirmBody: '将删除 {name} 的安装目录与配置行,并在重启后生效。',\n confirm: '确认卸载',\n cancel: '取消',\n restartHint: '插件变更将在重启应用后生效。',\n failed: '操作失败:{reason}',\n enabled: '已开启',\n disabled: '已关闭',\n mixed: '部分开启',\n unavailable: '不可用',\n uninstalled: '已卸载',\n source: '查看源码',\n applying: '正在应用更改…',\n fetching: '正在获取插件信息…',\n downloading: '正在下载…',\n downloadingPercent: '正在下载 {percent}%',\n extracting: '正在解压…',\n writing: '正在写入配置…',\n localOnlyTitle: '仅限本机操作',\n localOnlyBody: '为了保护主机配置,插件管理只能从本机打开。',\n failureBadge: '启动失败',\n failureGroupTitle: '其他启动失败',\n repair: '让 Agent 修复',\n repairing: '正在创建修复对话…',\n copyError: '复制错误',\n copied: '已复制',\n safeModeBanner: '安全模式:用户插件配置已跳过,插件开关不可用。',\n exitSafeMode: '恢复正常模式并重启',\n npmSource: 'npm',\n gitSource: 'git',\n enableSwitch: '开启 {name}',\n disableSwitch: '关闭 {name}',\n repairInstallTitle: '插件安装失败,请帮我诊断并修复。',\n repairInstallSpecLabel: '安装目标',\n repairInstallErrorLabel: '错误信息',\n repairInstallAsk: '请检查该插件并重新安装;完成后告诉我结果。',\n repairFailureTitle: '插件上次启动失败。请修复它。',\n repairFailurePluginLabel: '插件',\n repairFailureKindLabel: '失败类型',\n repairFailureAtLabel: '时间',\n repairFailureMessageLabel: '失败详情',\n repairFailureStackLabel: '原始堆栈',\n repairFailurePathLabel: '插件安装目录',\n repairFailureAsk: '请检查并修复该插件;修复完成后告诉我如何重新启用。',\n repairKindLoad: '加载失败',\n repairKindHang: '启动挂起',\n repairKindLate: '迟到拒绝',\n repairConflictTitle: '正在处理插件安装冲突',\n repairConflictPluginLabel: '冲突条目',\n repairConflictChangeLabel: '状态变化',\n repairConflictAsk: '请检查冲突双方的入口行 id 与挂载方式,消除重复挂载后告诉我如何重新启用。',\n repairStateEnabled: '已开启',\n repairStateDisabled: '已关闭',\n repairStateUninstalled: '已卸载',\n} satisfies Record<string, string>\n\n/** English copy, checked complete against the zh key set. */\nconst STATIC_EN = {\n tab: 'Plugin manager',\n loading: 'Reading plugins…',\n empty: 'No user plugins installed yet.',\n userPlugins: 'User plugins',\n products: 'Built-in products',\n conflictTitle: 'Install conflicts',\n conflictDisabled: 'Automatically disabled {name} to avoid double mounting.',\n conflictEnabled: 'Re-enabled {name}.',\n conflictChanged: 'The state of {name} changed.',\n undoConflict: 'Undo',\n conflictHint: 'Conflict actions run automatically at install time; undoing writes the switch back and applies after a restart.',\n installPlaceholder: 'npm package (e.g. @scope/name) or git repository URL',\n install: 'Install',\n installing: 'Installing…',\n installHint: 'Find a plugin on GitHub or npm, then paste its npm package name or repository URL; plugins load after a restart.',\n version: 'Installed {version}',\n latest: 'Latest {version}',\n update: 'Update',\n updating: 'Updating…',\n checkUpdates: 'Check for updates',\n checking: 'Checking…',\n noUpdates: 'All plugins are up to date.',\n uninstall: 'Uninstall',\n uninstallConfirmTitle: 'Uninstall plugin',\n uninstallConfirmBody: '{name} and its configuration row will be removed; the change applies after a restart.',\n confirm: 'Uninstall',\n cancel: 'Cancel',\n restartHint: 'Plugin changes take effect after restarting the application.',\n failed: 'Operation failed: {reason}',\n enabled: 'On',\n disabled: 'Off',\n mixed: 'Partially on',\n unavailable: 'Unavailable',\n uninstalled: 'Uninstalled',\n source: 'View source',\n applying: 'Applying change…',\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 failureBadge: 'Startup failure',\n failureGroupTitle: 'Other startup failures',\n repair: 'Ask the agent to fix',\n repairing: 'Opening repair conversation…',\n copyError: 'Copy error',\n copied: 'Copied',\n safeModeBanner: 'Safe mode: user plugin configuration is skipped; plugin switches are disabled.',\n exitSafeMode: 'Restore normal mode and restart',\n npmSource: 'npm',\n gitSource: 'git',\n enableSwitch: 'Turn on {name}',\n disableSwitch: 'Turn off {name}',\n repairInstallTitle: 'The plugin installation failed. Please diagnose and fix it.',\n repairInstallSpecLabel: 'Install target',\n repairInstallErrorLabel: 'Error message',\n repairInstallAsk: 'Please inspect the plugin and reinstall it; tell me when it is done.',\n repairFailureTitle: 'A plugin failed to start last time. Please fix it.',\n repairFailurePluginLabel: 'Plugin',\n repairFailureKindLabel: 'Failure kind',\n repairFailureAtLabel: 'At',\n repairFailureMessageLabel: 'Failure details',\n repairFailureStackLabel: 'Original stack',\n repairFailurePathLabel: 'Plugin install directory',\n repairFailureAsk: 'Please inspect and fix the plugin; tell me how to re-enable it afterwards.',\n repairKindLoad: 'Load failure',\n repairKindHang: 'Startup hang',\n repairKindLate: 'Late rejection',\n repairConflictTitle: 'Handling a plugin install conflict',\n repairConflictPluginLabel: 'Conflicting entry',\n repairConflictChangeLabel: 'State change',\n repairConflictAsk: 'Inspect the entry ids and mounting of both sides, resolve the double mount, and tell me how to re-enable.',\n repairStateEnabled: 'On',\n repairStateDisabled: 'Off',\n repairStateUninstalled: 'Uninstalled',\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 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 /** Saved next-start enablement from the managed profile patch row. */\n enabled: boolean\n commit?: string\n}\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/** One plugin with a newer version available. */\nexport interface PluginUpdateItem {\n id: string\n current: string\n latest: 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/** One deployment-configured logical product switch. */\nexport interface PluginControlItem {\n id: string\n name: string\n repository: string\n state: 'enabled' | 'disabled' | 'mixed' | 'unavailable' | 'uninstalled'\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 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 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 }\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 plugin-control `list` / `set-enabled` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed control items.\n */\nexport function parsePluginControlSnapshot(value: unknown): PluginControlItem[] {\n if (!isRecord(value) || !Array.isArray(value.controls)) {\n throw new Error('plugin-manager: response must contain a controls array')\n }\n return value.controls.map((control, index) => {\n if (!isRecord(control) || !isString(control.id) || !isString(control.name)\n || !isString(control.repository)\n || (control.state !== 'enabled' && control.state !== 'disabled'\n && control.state !== 'mixed' && control.state !== 'unavailable'\n && control.state !== 'uninstalled')) {\n throw new Error(`plugin-manager: control row ${String(index)} is invalid`)\n }\n return {\n id: control.id,\n name: control.name,\n repository: control.repository,\n state: control.state,\n }\n })\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 return { id: update.id, current: update.current, latest: update.latest }\n })\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 } 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 * 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","/**\n * Plugin-manager browser half: contributes the family plugin-manager tab to\n * the official Plugins settings section (`settings.plugins.tab` slot) and\n * provides the same dual-channel face as the `'pluginManager'` cordis\n * service for sibling client plugins. It is dual-channel: on runtimes with\n * the official installer services (DSHCode, the 1.0.4 checkout web) every\n * operation rides the official `/plugin-installer` and `/plugin-control`\n * loopback RPC channels (the single writer); on the npm-published web runtime\n * those channels do not exist, so the same face falls back to this package's\n * own loopback HTTP gateway, which spawns the official CLI for writes.\n * Neither the tab nor service consumers know which mode the face runs in.\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 settings surface's slot contracts (settings.plugins.tab).\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n// Type-only: pulls the client runtime Context merge (ctx.workspaces, ctx.sessions).\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\nimport { PluginManagerTab, type PluginManagerTabInjected } from './PluginManagerTab.tsx'\nimport { en, zh, type PluginManagerKey } from './locales.ts'\nimport {\n parseFailuresSnapshot,\n parseInstallStatus,\n parseInstalledPlugin,\n parsePluginControlSnapshot,\n parsePluginList,\n parseUpdateList,\n type InstalledPluginItem,\n type InstallProgressItem,\n type PluginControlItem,\n type PluginFailuresSnapshot,\n type PluginUpdateItem,\n} from '../core/protocol.ts'\nimport { PLUGIN_MANAGER_SERVICE, type PluginManagerService } from '../core/service.ts'\nimport type { ControlChange } from '../core/conflict.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Copy for the family plugin-manager tab. */\n 'settings.pluginManager': PluginManagerKey\n }\n}\n\nconst NS = 'settings.pluginManager'\nconst CHANNEL = '/plugin-installer'\nconst CONTROL_CHANNEL = '/plugin-control'\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 STATUS_ENDPOINT = 'status'\nconst FAILURES_ENDPOINT = 'failures'\nconst SET_SAFE_MODE_ENDPOINT = 'set-safe-mode'\n\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 slot registration and both channels. */\nexport const inject = ['slots', 'locale', 'connection', 'workspaces', 'sessions']\n\n/** The gateway job wire shape served by /status. */\ninterface GatewayJobWire {\n phase: 'running' | 'done' | 'error'\n plugin?: unknown\n conflicts?: unknown\n error?: string\n}\n\n/**\n * The face the Plugin manager tab and the `'pluginManager'` cordis service\n * share: the full tab surface plus the cross-plugin service contract.\n */\nexport type PluginManagerFace = PluginManagerTabInjected & PluginManagerService\n\n/**\n * Build the dual-channel face once: official-channel and gateway-channel\n * implementations, the mode detection that picks between them, the repair\n * handoff, and the change-notification listener set. The returned face is\n * both the tab's injected props and the value provided as the\n * `'pluginManager'` cordis service.\n * @param ctx - the client context (connection, workspaces, sessions).\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 setSafeMode: async (enabled: boolean): Promise<void> => {\n await call(SET_SAFE_MODE_ENDPOINT, { enabled })\n },\n controlsList: async (): Promise<PluginControlItem[]> =>\n parsePluginControlSnapshot(await connection.rpc.call(CONTROL_CHANNEL, 'list', {}).then(result => {\n if (!result.ok) throw new Error(`plugin-control list failed: ${result.error.code}: ${result.error.message}`)\n return result.value\n })),\n controlsSetEnabled: async (pluginId: string, enabled: boolean): Promise<PluginControlItem[]> =>\n parsePluginControlSnapshot(await connection.rpc.call(CONTROL_CHANNEL, 'set-enabled', { pluginId, enabled }).then(result => {\n if (!result.ok) throw new Error(`plugin-control set-enabled failed: ${result.error.code}: ${result.error.message}`)\n return result.value\n })),\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 /** The conflict ledger of the last settled gateway install. */\n let lastInstallConflicts: ControlChange[] = []\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 lastInstallConflicts = Array.isArray(job.conflicts) ? job.conflicts as ControlChange[] : []\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 lastInstallConflicts = Array.isArray(job.conflicts) ? job.conflicts as ControlChange[] : []\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 setSafeMode: async (): Promise<void> => {\n throw new Error('plugin-manager: safe mode is unavailable in this runtime')\n },\n controlsList: async (): Promise<PluginControlItem[]> => [],\n controlsSetEnabled: async (pluginId: string, enabled: boolean): Promise<PluginControlItem[]> => {\n await gateway.setEnabled(pluginId, enabled)\n return []\n },\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.\n try {\n const mode = await gatewayJson(`${GATEWAY_PREFIX}/mode`) as { official?: boolean }\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 /**\n * Start a repair conversation for a failed plugin: resolve a workspace over\n * the plugin install root (created once, reused after), open a fresh\n * session there, and seed its first prompt with the failure details. The\n * session's workspace is the plugin home so the agent's file tools reach\n * the plugin code without leaving the workspace boundary.\n * @param pluginRoot - absolute plugin install root.\n * @param message - the seeded first user message.\n * @returns resolution after the prompt is accepted and the session opens.\n */\n const repairPlugin = async (pluginRoot: string, message: string): Promise<void> => {\n const workspace = await ctx.workspaces.create({ path: pluginRoot })\n const sessionId = await ctx.workspaces.connectWorkspace(workspace.workspaceId)\n const binding = ctx.sessions.binding(sessionId)\n if (binding === undefined) throw new Error(`plugin-manager: repair session ${sessionId} is unavailable`)\n const result = await binding.session.prompt([{ type: 'text', text: message }], 'queue')\n if (!result.ok) throw new Error(`plugin-manager: repair prompt failed: ${result.error.code}: ${result.error.message}`)\n ctx.sessions.open(sessionId)\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 status: async () => (await ensureMode()) === 'official' ? official.status() : gateway.status(),\n failures: async () => (await ensureMode()) === 'official' ? official.failures() : gateway.failures(),\n setSafeMode: async enabled => (await ensureMode()) === 'official' ? official.setSafeMode(enabled) : gateway.setSafeMode(),\n repairPlugin,\n controlsList: async () => (await ensureMode()) === 'official' ? official.controlsList() : gateway.controlsList(),\n controlsSetEnabled: async (id, enabled) => (await ensureMode()) === 'official' ? official.controlsSetEnabled(id, enabled) : gateway.controlsSetEnabled(id, enabled),\n lastInstallConflicts: () => lastInstallConflicts,\n onChange: cb => {\n listeners.add(cb)\n return () => { listeners.delete(cb) }\n },\n }\n}\n\n/** Contribute the family plugin-manager tab and provide the shared face. */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'plugin-manager: dictionaries')\n\n // Built once: the tab and the 'pluginManager' cordis service share one\n // face, so consumers observe exactly the mutations the tab performs.\n const face = createPluginManagerFace(ctx)\n ctx.provide(PLUGIN_MANAGER_SERVICE, face)\n\n ctx.slots.inject('settings.plugins.tab', () => ctx.slots.register({\n name: 'settings.plugins.tab',\n id: 'family-plugins',\n order: 20,\n label: () => ctx.locale.bind(NS)('tab'),\n locale: NS,\n inject: () => face,\n }, PluginManagerTab))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;EAsCA,SAAgB,aAAa,QAAsC,OAAsD;GACvH,MAAM,YAAY,IAAI,IAAI,MAAM,KAAI,SAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;GAC5D,MAAM,UAA2B,CAAC;GAClC,KAAK,MAAM,QAAQ,QAAQ;IACzB,MAAM,UAAU,UAAU,IAAI,KAAK,EAAE;IACrC,IAAI,YAAY,KAAA,KAAa,QAAQ,UAAU,KAAK,OAAO;IAC3D,QAAQ,KAAK;KAAE,IAAI,KAAK;KAAI,MAAM,KAAK;KAAM,MAAM,KAAK;KAAO,IAAI,QAAQ;IAAM,CAAC;GACpF;GACA,OAAO;EACT;;;;;;;;EASA,SAAgB,eAAe,QAA0C;GACvE,IAAI,OAAO,OAAO,YAAY,OAAO;GACrC,IAAI,OAAO,SAAS,YAAY,OAAO;GACvC,OAAO;EACT;;;;ECjBA,MAAa,sBAAkC;GAC7C,cAAc;GACd,kBAAkB;GAClB,mBAAmB;GACnB,YAAY;GACZ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;IAC7F,UAAU,YAAa,MAAM,WAAW,MAAO,aAAa,SAAS,SAAS,IAAI,QAAQ,SAAS;IACnG,aAAa,OAAM,YAAY,MAAM,WAAW,MAAO,aAAa,SAAS,YAAY,OAAO,IAAI,QAAQ,YAAY;IACxH;IACA,cAAc,YAAa,MAAM,WAAW,MAAO,aAAa,SAAS,aAAa,IAAI,QAAQ,aAAa;IAC/G,oBAAoB,OAAO,IAAI,YAAa,MAAM,WAAW,MAAO,aAAa,SAAS,mBAAmB,IAAI,OAAO,IAAI,QAAQ,mBAAmB,IAAI,OAAO;IAClK,4BAA4B;IAC5B,WAAU,OAAM;KACd,UAAU,IAAI,EAAE;KAChB,aAAa;MAAE,UAAU,OAAO,EAAE;KAAE;IACtC;GACF;EACF;;EAGA,SAAgB,MAAM,KAA0B;GAC9C,IAAI,aAAa,IAAI,OAAO,SAAS,IAAI;IAAE;IAAI;GAAG,CAAC,GAAG,8BAA8B;GAIpF,MAAM,OAAO,wBAAwB,GAAG;GACxC,IAAI,QAAQ,wBAAwB,IAAI;GAExC,IAAI,MAAM,OAAO,8BAA8B,IAAI,MAAM,SAAS;IAChE,MAAM;IACN,IAAI;IACJ,OAAO;IACP,aAAa,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,KAAK;IACtC,QAAQ;IACR,cAAc;GAChB,GAAG,gBAAgB,CAAC;EACtB"}
package/lib/index.js CHANGED
@@ -800,6 +800,33 @@ var CliGateway = class {
800
800
  ], ADD_TIMEOUT_MS));
801
801
  return { jobId: job.id };
802
802
  }
803
+ /** Start an in-place npm update; the caller polls {@link status}. */
804
+ update(id, version) {
805
+ const spec = `${id}@${version}`;
806
+ const job = {
807
+ id: `job-${++this.counter}`,
808
+ action: "update",
809
+ spec,
810
+ targetId: id,
811
+ targetVersion: version,
812
+ phase: "running"
813
+ };
814
+ this.jobs.set(job.id, job);
815
+ const unsafe = unsafeSpecReason(spec);
816
+ if (unsafe !== void 0) {
817
+ job.phase = "error";
818
+ job.error = unsafe;
819
+ return { jobId: job.id };
820
+ }
821
+ this.enqueue(() => this.run(job, [
822
+ "plugin",
823
+ "--profile",
824
+ this.facts.profileName,
825
+ "add",
826
+ spec
827
+ ], ADD_TIMEOUT_MS));
828
+ return { jobId: job.id };
829
+ }
803
830
  /** Start a removal; the caller polls {@link status}. */
804
831
  remove(id) {
805
832
  const job = {
@@ -949,6 +976,24 @@ var CliGateway = class {
949
976
  }
950
977
  await this.verifyBoot(job, before, after, conflicts);
951
978
  if (job.phase === "error") return;
979
+ } else if (job.action === "update") {
980
+ const targetId = job.targetId;
981
+ const targetVersion = job.targetVersion;
982
+ if (targetId === void 0 || targetVersion === void 0 || !after.dependencies.includes(targetId)) {
983
+ job.phase = "error";
984
+ job.error = "plugin-manager: dsh plugin add 报告成功,但目标插件未保留在 profile 中(更新未生效)";
985
+ return;
986
+ }
987
+ const manifest = await readProfileManifest(this.facts.packageJsonPath);
988
+ const updated = await buildPluginRow(this.facts, targetId, manifest.dependencies[targetId] ?? job.spec, after.layer.rows);
989
+ if (updated.version !== targetVersion) {
990
+ job.phase = "error";
991
+ job.error = `plugin-manager: dsh plugin add 报告成功,但 ${targetId} 仍为 ${updated.version},预期 ${targetVersion}(更新未生效)`;
992
+ return;
993
+ }
994
+ job.plugin = updated;
995
+ await this.verifyBoot(job, before, after, conflicts);
996
+ if (job.phase === "error") return;
952
997
  } else if (before.dependencies.find((candidate) => !after.dependencies.includes(candidate)) === void 0) {
953
998
  job.phase = "error";
954
999
  job.error = "plugin-manager: dsh plugin remove 报告成功,但依赖仍在 profile 中(卸载未生效)";
@@ -960,7 +1005,7 @@ var CliGateway = class {
960
1005
  from: change.from,
961
1006
  to: change.to
962
1007
  }));
963
- job.plugin = await this.rowFor(job.action, job.spec, before, after);
1008
+ if (job.action !== "update") job.plugin = await this.rowFor(job.action, job.spec, before, after);
964
1009
  job.phase = "done";
965
1010
  }
966
1011
  /**
@@ -1224,6 +1269,10 @@ async function fetchLatestFromRegistry(name) {
1224
1269
  const body = await response.json();
1225
1270
  return typeof body.version === "string" ? body.version : void 0;
1226
1271
  }
1272
+ /** Whether a dependency spec is a direct npm-registry selector, not an alias or external source. */
1273
+ function isDirectRegistrySpec(spec) {
1274
+ return !/^(?:link:|file:|git:|github:|git\+|https?:\/\/|npm:|workspace:|catalog:)/.test(spec);
1275
+ }
1227
1276
  /**
1228
1277
  * Build the gateway routes.
1229
1278
  * @param deps - profile facts, the CLI gateway, and seams.
@@ -1266,6 +1315,58 @@ function makeGatewayRoutes(deps) {
1266
1315
  }
1267
1316
  sendJson(res, 200, gateway.install(spec.trim()));
1268
1317
  };
1318
+ const updateHandler = async (req, res) => {
1319
+ const id = (await readJsonBody(req))["id"];
1320
+ if (typeof id !== "string" || id.trim() === "") {
1321
+ sendJson(res, 400, { error: "plugin-manager: update needs an id" });
1322
+ return;
1323
+ }
1324
+ const target = id.trim();
1325
+ const unsafe = unsafeSpecReason(target);
1326
+ if (unsafe !== void 0) {
1327
+ sendJson(res, 400, { error: unsafe });
1328
+ return;
1329
+ }
1330
+ if (!deps.cliAvailable()) {
1331
+ sendJson(res, 500, { error: "plugin-manager: dsh CLI not found on PATH" });
1332
+ return;
1333
+ }
1334
+ const outcome = await gateway.withMutationLock(async () => {
1335
+ const patchText = await readPatchText(facts.patchPath);
1336
+ const row = (await snapshotGateway(facts, patchText)).plugins.find((plugin) => plugin.id === target);
1337
+ if (row === void 0) return {
1338
+ status: 404,
1339
+ error: `plugin-manager: plugin ${target} is not installed`
1340
+ };
1341
+ if (row.source.kind !== "npm" || !isDirectRegistrySpec(row.source.spec)) return {
1342
+ status: 400,
1343
+ error: `plugin-manager: ${target} is not a direct npm registry plugin`
1344
+ };
1345
+ const latest = await fetchLatest(target).catch(() => void 0);
1346
+ if (latest === void 0 || latest === "") return {
1347
+ status: 502,
1348
+ error: `plugin-manager: cannot resolve the latest version for ${target}`
1349
+ };
1350
+ const unsafeLatest = unsafeSpecReason(`${target}@${latest}`);
1351
+ if (unsafeLatest !== void 0) return {
1352
+ status: 502,
1353
+ error: unsafeLatest
1354
+ };
1355
+ if (row.version === latest) return {
1356
+ status: 409,
1357
+ error: `plugin-manager: ${target} is already at ${latest}`
1358
+ };
1359
+ return {
1360
+ status: 200,
1361
+ job: gateway.update(target, latest)
1362
+ };
1363
+ });
1364
+ if ("error" in outcome) {
1365
+ sendJson(res, outcome.status, { error: outcome.error });
1366
+ return;
1367
+ }
1368
+ sendJson(res, outcome.status, outcome.job);
1369
+ };
1269
1370
  const removeHandler = async (req, res) => {
1270
1371
  const id = (await readJsonBody(req))["id"];
1271
1372
  if (typeof id !== "string" || id.trim() === "") {
@@ -1354,7 +1455,7 @@ function makeGatewayRoutes(deps) {
1354
1455
  const snapshot = await snapshotGateway(facts, patchText);
1355
1456
  const updates = [];
1356
1457
  for (const plugin of snapshot.plugins) {
1357
- if (plugin.source.kind !== "npm") continue;
1458
+ if (plugin.source.kind !== "npm" || !isDirectRegistrySpec(plugin.source.spec)) continue;
1358
1459
  const latest = await fetchLatest(plugin.id).catch(() => void 0);
1359
1460
  if (latest !== void 0 && latest !== plugin.version) updates.push({
1360
1461
  id: plugin.id,
@@ -1375,6 +1476,11 @@ function makeGatewayRoutes(deps) {
1375
1476
  path: `${GATEWAY_PREFIX}/install`,
1376
1477
  handler: guard(installHandler)
1377
1478
  },
1479
+ {
1480
+ kind: "exact",
1481
+ path: `${GATEWAY_PREFIX}/update`,
1482
+ handler: guard(updateHandler)
1483
+ },
1378
1484
  {
1379
1485
  kind: "exact",
1380
1486
  path: `${GATEWAY_PREFIX}/remove`,
@@ -20,8 +20,12 @@ export declare function unsafeSpecReason(spec: string): string | undefined;
20
20
  /** One CLI-backed operation in flight or settled. */
21
21
  export interface GatewayJob {
22
22
  id: string;
23
- action: 'install' | 'remove';
23
+ action: 'install' | 'update' | 'remove';
24
24
  spec: string;
25
+ /** Installed package ID for an in-place npm update. */
26
+ targetId?: string;
27
+ /** Exact registry version the update must land on. */
28
+ targetVersion?: string;
25
29
  phase: 'running' | 'done' | 'error';
26
30
  /** The installed row on success (install) or the removed row (remove). */
27
31
  plugin?: InstalledPluginItem;
@@ -106,6 +110,10 @@ export declare class CliGateway {
106
110
  install(spec: string): {
107
111
  jobId: string;
108
112
  };
113
+ /** Start an in-place npm update; the caller polls {@link status}. */
114
+ update(id: string, version: string): {
115
+ jobId: string;
116
+ };
109
117
  /** Start a removal; the caller polls {@link status}. */
110
118
  remove(id: string): {
111
119
  jobId: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-client-ui-plugin-manager",
3
3
  "description": "Plugin manager tab for the dsh web GUI Plugins settings section: installs plugins from npm or git through the official host channels, lists installed plugins with next-start enablement switches, surfaces install-time conflict actions with undo, and hands failures off to repair conversations.",
4
- "version": "0.2.5",
4
+ "version": "0.2.6",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",