@linxin666/dsh-client-ui-plugin-manager 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +3 -3
- package/README.zh.md +3 -3
- package/lib/client.js +69 -7
- package/lib/client.js.map +1 -1
- package/lib/index.js +80 -26
- package/lib/types/client/PluginListToolbar.d.ts +7 -3
- package/lib/types/client/PluginUpdatePatch.d.ts +7 -3
- package/lib/types/client/locales.d.ts +3 -0
- package/lib/types/core/protocol.d.ts +34 -0
- package/lib/types/host/gateway.d.ts +47 -12
- package/lib/types/host/loopback.d.ts +21 -0
- package/package.json +13 -13
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["messageOf","css","css","css"],"sources":["../../../packages/dsh-plugin-manager/src/core/version.ts","../../../packages/dsh-plugin-manager/src/client/PluginUpdatePatch.tsx","../../../packages/dsh-plugin-manager/src/client/body-mutations.ts","../../../packages/dsh-plugin-manager/src/core/updates.ts","../../../packages/dsh-plugin-manager/src/client/PluginListToolbar.tsx","../../../packages/dsh-plugin-manager/src/client/plugin-toolbar-mount.tsx","../../../packages/dsh-plugin-manager/src/client/locales.ts","../../../packages/dsh-plugin-manager/src/core/protocol.ts","../../../packages/dsh-plugin-manager/src/core/service.ts","../../../packages/dsh-plugin-manager/src/client/telemetry.ts","../../../packages/dsh-plugin-manager/src/client/index.ts"],"sourcesContent":["/**\n * Version parsing plus the requirement reader for the update compatibility\n * check. The declared minimum lives in the published package manifest under\n * `dsh.engines.dsh`, falling back to the top-level `engines.dsh` and then to\n * the `@deepseek-ai/dsh` peer; the range forms a manifest may use are the\n * full node-semver range grammar.\n *\n * This module is shared by both halves and therefore stays free of `semver`,\n * which is a node package: it parses and compares a single `X.Y.Z[-pre]`\n * version, which is all the browser half needs to render a declared range\n * (`displayMinimumVersion`) and all the host half needs to accept a probed\n * host version (`parseDshVersion`). The range verdict itself lives in the\n * host-only `../host/dsh-compat.ts`, which evaluates the declaration with\n * `semver.satisfies(host, range, { includePrerelease: true })` — the exact\n * call the official boot gate makes, so `||`, `^`, `~`, multi-comparator\n * and x-ranges all decide the same way here as they do at boot.\n *\n * Everything here is pure and tolerant of untrusted input: a malformed value\n * means \"cannot verify\", which the callers treat as a fail-closed verdict\n * when a requirement was declared (issue #754).\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\n/** One parsed DSH host or package version. */\nexport interface DshVersion {\n major: number\n minor: number\n patch: number\n /** Prerelease identifiers, numeric identifiers kept as numbers (semver order). */\n prerelease: readonly (number | string)[]\n}\n\nconst VERSION_PATTERN = /^v?(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z.-]+))?$/\n\n/**\n * Parse a DSH host or package version string.\n * @param value - e.g. `0.1.0-rc.8`, `v1.2.3`.\n * @returns the parsed version, or undefined when malformed.\n */\nexport function parseDshVersion(value: string): DshVersion | undefined {\n const match = VERSION_PATTERN.exec(value.trim())\n if (match === null) return undefined\n const prereleaseParts = match[4] === undefined ? [] : match[4].split('.')\n if (prereleaseParts.some(part => part === '')) return undefined\n return {\n major: Number(match[1]),\n minor: Number(match[2]),\n patch: Number(match[3]),\n prerelease: prereleaseParts.map(part => /^\\d+$/.test(part) ? Number(part) : part),\n }\n}\n\n/**\n * Compare two version strings by semver order (a release is newer than any\n * prerelease of the same tuple).\n * @returns -1 / 0 / 1, or undefined when either side is malformed.\n */\nexport function compareVersions(left: string, right: string): number | undefined {\n const a = parseDshVersion(left)\n const b = parseDshVersion(right)\n if (a === undefined || b === undefined) return undefined\n for (const key of ['major', 'minor', 'patch'] as const) {\n if (a[key] !== b[key]) return a[key] < b[key] ? -1 : 1\n }\n return comparePrerelease(a.prerelease, b.prerelease)\n}\n\n/**\n * Semver prerelease ordering: numeric identifiers compare numerically,\n * numeric identifiers rank below alphanumeric ones, alphanumeric identifiers\n * compare lexically, and a longer list wins when the shared prefix is equal.\n */\nfunction comparePrerelease(left: readonly (number | string)[], right: readonly (number | string)[]): number {\n if (left.length === 0 && right.length === 0) return 0\n if (left.length === 0) return 1\n if (right.length === 0) return -1\n const length = Math.max(left.length, right.length)\n for (let index = 0; index < length; index += 1) {\n const a = left[index]\n const b = right[index]\n if (a === undefined) return -1\n if (b === undefined) return 1\n if (typeof a === 'number' && typeof b === 'number') {\n if (a !== b) return a < b ? -1 : 1\n } else if (typeof a === 'number') {\n return -1\n } else if (typeof b === 'number') {\n return 1\n } else if (a !== b) {\n return a < b ? -1 : 1\n }\n }\n return 0\n}\n\nconst MINIMUM_RANGE_PATTERN = /^>=\\s*(v?\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?)$/\n\n/**\n * The bare minimum version for display: strips the `>=` operator (and an\n * optional leading `v`) from a declared requirement so UI copy that already\n * contains the comparison operator renders `0.1.1-rc.1` instead of\n * `>= >=0.1.1-rc.1`. Every other range form renders unchanged — the browser\n * half does not evaluate a range (the host does, in `../host/dsh-compat.ts`),\n * so it must not pull a range parser into the client bundle to shorten copy.\n * @param minimum - the declared minimum range.\n * @returns the version portion for display.\n */\nexport function displayMinimumVersion(minimum: string): string {\n const match = MINIMUM_RANGE_PATTERN.exec(minimum.trim())\n return match === null ? minimum.trim() : match[1].replace(/^v/, '')\n}\n\n/**\n * Read the declared DSH minimum from a published registry manifest:\n * `dsh.engines.dsh` first, top-level `engines.dsh` next, and\n * `peerDependencies[\"@deepseek-ai/dsh\"]` last, which is where a package that\n * only declares the host as a peer still gets gated at boot.\n * Defensive against malformed or untrusted metadata: anything that is not a\n * non-empty string reads as absent.\n * @param manifest - the decoded registry version manifest.\n * @returns the declared minimum, or undefined when not declared.\n */\nexport function dshRequirementOf(manifest: { dsh?: unknown; engines?: unknown; peerDependencies?: unknown }): string | undefined {\n const dshEngines = (manifest.dsh as { engines?: unknown } | undefined)?.engines as { dsh?: unknown } | undefined\n const engines = (manifest.engines as { dsh?: unknown } | undefined)?.dsh\n const peers = (manifest.peerDependencies as Record<string, unknown> | undefined)?.['@deepseek-ai/dsh']\n // The host's own peer gate is the LAST word: a package that declares the\n // host only under peerDependencies still gets that row skipped at boot when\n // the floor is not met, so a requirement we display must come from the same\n // place the gate reads, or the user is told nothing and then loses the row.\n const value = dshEngines?.dsh ?? engines ?? peers\n return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined\n}\n","/**\n * The check-for-updates patch contributed to the official Plugins page.\n *\n * This package used to own a \"Plugin manager\" tab inside the Plugins settings\n * section (`settings.plugins.tab`). Installing, uninstalling, enabling and\n * disabling moved to the official plugin manager page long ago, and the tab's\n * remaining half (read-only inventory, install-conflict ledger, boot-failure\n * repair conversation, safe-mode banner) is UI no official page renders. It is\n * gone; the one capability the official page still lacks is comparing an\n * installed plugin against its registry source.\n *\n * So this package now contributes exactly that, into the seat the official\n * Plugins page declares for contributed sections (`plugins.detail.section`,\n * a root-scope list rendered on every bundle / row / official-plugin page with\n * the page's `subject`). The official page owns the page chrome; this entry\n * renders one compact block, only on an installed bundle's page, drawing only\n * a plain button and its own section so it carries no dependency on the\n * official primitives bundle.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\nimport { useEffect, useRef, useState } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { InstallProgressItem, PluginUpdateItem } from '../core/protocol.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport css from './plugin-manager.module.css'\n\n/** One loader row of a bundle, as the official page's subject carries it. */\nexport interface PluginPageRowRef {\n rowId: string\n moduleName: string\n enabled: boolean\n}\n\n/** One bundle, as the official page's subject carries it. */\nexport interface PluginPageBundleRef {\n name: string\n version?: string\n installed: boolean\n enabled: boolean\n rows: readonly PluginPageRowRef[]\n}\n\n/**\n * The subject the official Plugins page renders a contributed section with:\n * its bundle page, its row page, or an official plugin's page. This package\n * only speaks to the bundle case.\n */\nexport type PluginPageSubject =\n | { kind: 'bundle'; pkg: PluginPageBundleRef }\n | { kind: 'row'; pkg: PluginPageBundleRef; row: PluginPageRowRef }\n | { kind: 'item'; id: string }\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface SlotMap {\n /**\n * One section contributed under a Plugins page's own content. Declared at\n * runtime by the official plugin-manager page's `main` registration; the\n * type is re-declared here, identically, so this package can register into\n * it without importing the page (the same way family plugins re-declare\n * `plugins.bundle.config`).\n */\n 'plugins.detail.section': {\n kind: 'list'\n scope: 'root'\n owner: { subject: PluginPageSubject }\n }\n }\n}\n\n/** Registration-side wire face the patch consumes. */\nexport interface PluginUpdatePatchInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n isLoopback: boolean\n /** Compare every installed plugin against the version its source serves. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /** Re-install one plugin from its recorded source. */\n update: (id: string) => Promise<unknown>\n /** Read the current install/update progress. */\n status: () => Promise<InstallProgressItem>\n}\n\n/** Full component props assembled by the Plugins page's section renderer. */\nexport type PluginUpdatePatchProps =\n PropsRuntime<'plugins.detail.section'>\n & PropsLocale<'settings.pluginManager'>\n & InjectFace<PluginUpdatePatchInjected>\n\n/** Error text for a caught request or lifecycle failure. */\nfunction messageOf(error: unknown): string {\n if (error instanceof AggregateError) {\n const details = error.errors.map(messageOf).join('; ')\n return details === '' ? error.message : `${error.message}: ${details}`\n }\n return error instanceof Error ? error.message : String(error)\n}\n\n/** Localized label for one install phase, with percent when the download has one. */\nfunction progressLabel(progress: InstallProgressItem, t: PluginUpdatePatchProps['t']): string {\n if (progress.stage === 'write') return t('writing')\n return progress.percent === undefined ? t('downloading') : t('downloadingPercent', { percent: String(progress.percent) })\n}\n\n/**\n * What the host's compatibility verdict amounts to for one update row.\n *\n * `compatible === false` on its own does not mean \"this DSH is too old\": the\n * host leaves `hostVersion` off a blocked row whenever it could not read its\n * own runtime version (issue #1819) and whenever it could not evaluate the\n * declared range at all — an empty declaration, a range node-semver rejects, a\n * host string that is not one version (issue #1899). Only a row that carries a\n * host version was actually compared against that version, so only that row\n * may send the user to upgrade DSH.\n *\n * The verdict is derived here once and shared by both surfaces that render it\n * (this section and the list-level toolbar) so the two cannot drift apart:\n * that drift is what left the \"cannot verify\" case telling users to upgrade a\n * DSH the host never checked.\n */\nexport type DshGate = 'open' | 'below-minimum' | 'unverified'\n\n/**\n * Read the gate state out of one wire row.\n * @param item - the update row, or undefined when no check has answered yet.\n * @returns `open` when nothing blocks the update, otherwise the reason it is\n * held back: `below-minimum` only when the host compared a version it read,\n * `unverified` when it could not make that comparison.\n */\nexport function dshGateOf(item: Pick<PluginUpdateItem, 'compatible' | 'hostVersion'> | undefined): DshGate {\n if (item?.compatible !== false) return 'open'\n return item.hostVersion === undefined ? 'unverified' : 'below-minimum'\n}\n\n/**\n * The update block on one official Plugins page: one check action, the verdict\n * for this page's bundle, and the update action it unlocks. The check is\n * explicit rather than automatic because one check reads every installed\n * plugin's registry manifest; a page visit must not fan that out.\n */\nexport function PluginUpdatePatch(props: PluginUpdatePatchProps) {\n const { t, subject, isLoopback, checkUpdates, update, status } = props\n\n const [checked, setChecked] = useState(false)\n const [found, setFound] = useState<PluginUpdateItem | undefined>(undefined)\n const [busy, setBusy] = useState<'check' | 'update' | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [progress, setProgress] = useState<InstallProgressItem>({ kind: 'idle', stage: 'fetch' })\n const [dirty, setDirty] = useState(false)\n /** Synchronous in-flight mirror of `busy`: the render guard alone lets a click and an Enter land in the same frame and double-fire. */\n const busyRef = useRef(false)\n\n const name = subject.kind === 'bundle' ? subject.pkg.name : undefined\n const installed = subject.kind === 'bundle' && subject.pkg.installed\n\n /** Poll update progress while an update is in flight. */\n useEffect(() => {\n if (busy !== 'update') {\n setProgress({ kind: 'idle', stage: 'fetch' })\n return\n }\n let stopped = false\n let timer: ReturnType<typeof setTimeout> | undefined\n const tick = (delay: number): void => {\n timer = setTimeout(() => {\n void status().then(next => {\n if (!stopped && next !== undefined) {\n setProgress(next)\n tick(400)\n }\n }).catch(() => { /* polling fails silently; the update itself owns the error row */ })\n }, delay)\n }\n tick(100)\n return () => {\n stopped = true\n if (timer !== undefined) clearTimeout(timer)\n }\n }, [busy, status])\n\n if (name === undefined || !installed) return null\n\n const onCheck = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setBusy('check')\n setError(undefined)\n void checkUpdates().then(items => {\n setFound(items.find(item => item.id === name))\n setChecked(true)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n setBusy(undefined)\n })\n }\n\n const onUpdate = (): void => {\n if (busyRef.current || found === undefined) return\n busyRef.current = true\n setBusy('update')\n setError(undefined)\n void update(found.id).then(() => {\n setFound(undefined)\n setChecked(false)\n setDirty(true)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n setBusy(undefined)\n })\n }\n\n if (!isLoopback) {\n return (\n <section className={css.notice} data-update-patch data-state=\"local-only\">\n <strong>{t('localOnlyTitle')}</strong>\n <p>{t('localOnlyBody')}</p>\n </section>\n )\n }\n\n const requiresDsh = found?.requiresDsh\n const gate = dshGateOf(found)\n const blocked = gate !== 'open'\n // A requirement the host could not verify has two causes — the running DSH\n // version could not be read, or the declared range could not be evaluated —\n // and neither is \"your DSH is too old\". The copy therefore names no cause and\n // sends nobody to upgrade DSH; see `dshGateOf`.\n\n return (\n <section className={css.section} data-update-patch aria-busy={busy !== undefined}>\n <h3 className={css.title}>{t('updateSection')}</h3>\n <div className={css.actionRow}>\n <button\n type=\"button\"\n className={css.button}\n disabled={busy !== undefined}\n onClick={onCheck}\n >\n {busy === 'check' ? t('checking') : t('checkUpdates')}\n </button>\n {checked && found === undefined && busy === undefined && (\n <p className={css.ok}>{t('noUpdates')}</p>\n )}\n {found !== undefined && (\n <span className={css.latest} data-update-latest={found.latest}>{t('latest', { version: found.latest })}</span>\n )}\n {found !== undefined && (requiresDsh !== undefined || blocked) && (\n <span\n className={blocked ? css.compatBlocked : css.compatHint}\n data-update-compat={blocked ? 'blocked' : 'ok'}\n data-update-compat-reason={blocked ? gate : undefined}\n >\n {requiresDsh !== undefined\n ? t(gate === 'open' ? 'updateRequiresDsh' : gate === 'unverified' ? 'updateUnverifiedDsh' : 'updateBlockedDsh', {\n min: displayMinimumVersion(requiresDsh),\n })\n : t('updateUnverifiedDshUnknownRange')}\n </span>\n )}\n {found !== undefined && (\n <button\n type=\"button\"\n className={`${css.button} ${css.primary}`}\n disabled={busy !== undefined || blocked}\n onClick={onUpdate}\n >\n {busy === 'update' ? t('updating') : t('update')}\n </button>\n )}\n </div>\n\n {busy === 'update' && (\n <div className={css.progressRow} role=\"status\">\n <div className={css.progressTrack}>\n <div\n className={css.progressBar}\n style={progress.percent === undefined ? undefined : { width: `${String(progress.percent)}%` }}\n data-indeterminate={progress.percent === undefined ? 'true' : undefined}\n />\n </div>\n <p className={css.hint}>{progressLabel(progress, t)}</p>\n </div>\n )}\n\n {error !== undefined && (\n <p className={css.error} role=\"alert\" data-update-error>{error}</p>\n )}\n\n {dirty && (\n <div className={css.restartRow}>\n <p>{t('restartHint')}</p>\n </div>\n )}\n </section>\n )\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/body-mutations.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * One `document.body` MutationObserver per page, shared by every family\n * plugin bundle.\n *\n * Family plugins that inject at the DOM level must notice when the shell\n * re-renders around their injected node: the aggregate shell's column shims\n * and any plugin surface still extending the shell from outside the official\n * slot seats. Each consumer used to install its OWN `MutationObserver` on\n * `document.body` with\n * `{ childList: true, subtree: true }`, so a page carrying N family plugins\n * paid N native observers and N callback invocations for EVERY mutation batch\n * the app produced — chat token streaming alone produces many per second, and\n * the count grows with the number of installed plugins.\n *\n * This module keeps exactly ONE body observer per page. The registry lives on\n * `globalThis` under a `Symbol.for` key, so the per-package generated copies\n * of this file (scripts/sync-shared.mjs) and separately bundled plugins all\n * reach the same hub at runtime instead of one hub per module instance.\n * Record subscribers receive the mutations accumulated since the last flush.\n * Consumers that only re-check their DOM use subscribeBodyInvalidations:\n * when all subscribers use that path, the hub retains no mutation records\n * (or detached subtrees) while a background page's animation frames pause.\n * Both paths run at most once per frame. The last subscriber disconnects the\n * observer, cancels the pending frame and releases its records.\n *\n * Failure policy: without a DOM or `MutationObserver` the subscription is a\n * no-op disposer (the same silence the per-consumer observers had), and when\n * `requestAnimationFrame` is unavailable the flush runs synchronously so a\n * subscriber is never silently dropped. A throwing subscriber cannot stop the\n * others.\n */\n\n/** The page-wide hub: one observer plus its subscribers and pending records. */\ninterface BodyMutationHub {\n observer: MutationObserver\n subscribers: Set<(records: MutationRecord[]) => void>\n pending: MutationRecord[]\n scheduled: boolean\n frame?: number\n}\n\n/** Cross-bundle registry key; `Symbol.for` so every module copy agrees. */\nconst HUB_KEY = Symbol.for('dsh-web.body-mutation-hub')\nconst INVALIDATION_ONLY = Symbol.for('dsh-web.body-mutation-invalidation')\ntype Subscriber = ((records: MutationRecord[]) => void) & { [INVALIDATION_ONLY]?: true }\n\nfunction needsRecords(subscribers: Set<(records: MutationRecord[]) => void>): boolean {\n for (const listener of subscribers) {\n if (!(listener as Subscriber)[INVALIDATION_ONLY]) return true\n }\n return false\n}\n\n/**\n * Subscribe to a coalesced DOM re-check without retaining mutation records.\n * The marked wrapper also works with an older hub, which delivers records\n * that it simply ignores until a page reload picks up the updated hub.\n */\nexport function subscribeBodyInvalidations(subscriber: () => void): () => void {\n const listener: Subscriber = () => { subscriber() }\n listener[INVALIDATION_ONLY] = true\n return subscribeBodyMutations(listener)\n}\n\n/**\n * Subscribe to body-level childList mutations.\n * @param subscriber - called at most once per animation frame with the records\n * collected since the previous flush; must be safe to run repeatedly.\n * @returns the disposer removing this subscriber (and the observer when it was\n * the last one).\n */\nexport function subscribeBodyMutations(subscriber: (records: MutationRecord[]) => void): () => void {\n if (typeof globalThis === 'undefined' || typeof document === 'undefined') return () => {}\n if (typeof MutationObserver !== 'function') return () => {}\n const registry = globalThis as unknown as Record<symbol, unknown>\n let hub = registry[HUB_KEY] as BodyMutationHub | undefined\n if (hub === undefined) {\n const subscribers = new Set<(records: MutationRecord[]) => void>()\n const created: BodyMutationHub = {\n observer: undefined as unknown as MutationObserver,\n subscribers,\n pending: [],\n scheduled: false,\n }\n const flush = (): void => {\n created.frame = undefined\n created.scheduled = false\n const batch = created.pending\n created.pending = []\n for (const listener of [...subscribers]) {\n if (!subscribers.has(listener)) continue\n try {\n listener(batch)\n } catch {\n // One subscriber must never break the others; the next flush retries it.\n }\n }\n }\n const schedule = (): void => {\n if (created.scheduled) return\n created.scheduled = true\n if (typeof requestAnimationFrame === 'function') created.frame = requestAnimationFrame(flush)\n else flush()\n }\n created.observer = new MutationObserver((records) => {\n if (needsRecords(subscribers)) {\n for (const record of records) created.pending.push(record)\n }\n schedule()\n })\n created.observer.observe(document.body ?? document.documentElement, { childList: true, subtree: true })\n registry[HUB_KEY] = created\n hub = created\n }\n const active = hub\n active.subscribers.add(subscriber)\n let subscribed = true\n return () => {\n if (!subscribed) return\n subscribed = false\n active.subscribers.delete(subscriber)\n if (!needsRecords(active.subscribers)) active.pending = []\n if (active.subscribers.size === 0 && registry[HUB_KEY] === active) {\n active.observer.disconnect()\n if (active.frame !== undefined && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(active.frame)\n active.frame = undefined\n active.pending = []\n active.scheduled = false\n delete registry[HUB_KEY]\n }\n }\n}\n","/**\n * Which update rows the list-level toolbar may act on. Pure, shared by the\n * browser half (the toolbar) and its tests: the host answers with every\n * installed package whose registry source serves a newer release, and the\n * policy of what may be updated in bulk lives here rather than in the host,\n * so the same rows stay available to the per-page update block.\n *\n * Two filters:\n *\n * - **Third-party only.** A package published under the `@deepseek-ai/` scope\n * ships with DSH itself: its version is chosen by the running installation,\n * the official page says an upgrade arrives by upgrading DSH, and a\n * plugin-initiated `pnpm add` of such a package can pull a release the runtime was\n * never tested against. The bulk action therefore never touches it.\n * - **Compatibility gate.** An update whose manifest declares a DSH minimum the\n * running host does not satisfy is listed (the user may still upgrade DSH)\n * but cannot be applied: the host would refuse it with 412 anyway.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { PluginUpdateItem } from './protocol.ts'\n\n/** The npm scope DSH's own packages are published under. */\nexport const OFFICIAL_SCOPE = '@deepseek-ai/'\n\n/** Whether a package id is a third-party plugin rather than a DSH-shipped one. */\nexport function isThirdPartyPlugin(id: string): boolean {\n return !id.startsWith(OFFICIAL_SCOPE)\n}\n\n/** The third-party update rows, in host order. */\nexport function thirdPartyUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[] {\n return items.filter(item => isThirdPartyPlugin(item.id))\n}\n\n/** Whether the running DSH host satisfies the row's declared minimum. */\nexport function isUpdateApplicable(item: PluginUpdateItem): boolean {\n return item.compatible !== false\n}\n\n/** The third-party rows this runtime can actually apply. */\nexport function applicableUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[] {\n return thirdPartyUpdates(items).filter(isUpdateApplicable)\n}\n","/**\n * The list-level toolbar: check every installed third-party plugin for a newer\n * registry release, apply them in one run, then restart DSH to load them.\n *\n * It exists because the official Plugins page compares one package at a time\n * (its `plugins.detail.section` contributions render on a bundle's page), while\n * the answer a user wants when they open the page is \"is anything of mine out\n * of date, and can I just fix it\". It is mounted beside the page's \"Installed\"\n * heading (see plugin-toolbar-mount.tsx) because that heading is the page's own\n * chrome and the page declares no seat next to it.\n *\n * Policy lives in core/updates.ts (third-party only, compatibility-gated) and\n * the operations come from the injected face, so this component is pure\n * rendering plus the sequence of calls: nothing here touches the DOM beyond its\n * own subtree.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PluginUpdateItem, RestartMode } from '../core/protocol.ts'\nimport { applicableUpdates, thirdPartyUpdates } from '../core/updates.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport { dshGateOf } from './PluginUpdatePatch.tsx'\nimport css from './plugin-manager.module.css'\n\n/** The operations the toolbar drives (the package's dual-channel face). */\nexport interface PluginListToolbarInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n isLoopback: boolean\n /** Compare every installed plugin against the version its source serves. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /** Re-install one plugin from its recorded source. */\n update: (id: string) => Promise<unknown>\n /**\n * Read how a restart would be carried out, without carrying it out: the\n * confirmation must name the same consequence the host will produce (an\n * in-place relaunch, the packaged Desktop shell's own recovery dialog, or a\n * manual restart), and a plan read has no side effects.\n */\n restartPlan: () => Promise<RestartMode>\n /** Restart the host so an applied update is loaded. */\n restart: () => Promise<RestartMode>\n}\n\n/** Full component props. */\nexport type PluginListToolbarProps =\n & PropsLocale<'settings.pluginManager'>\n & PluginListToolbarInjected\n\n/** Error text for a caught request or lifecycle failure. */\nfunction messageOf(error: unknown): string {\n if (error instanceof AggregateError) {\n const details = error.errors.map(messageOf).join('; ')\n return details === '' ? error.message : `${error.message}: ${details}`\n }\n return error instanceof Error ? error.message : String(error)\n}\n\n/** What the toolbar is currently doing. */\ntype Phase = 'idle' | 'checking' | 'updating'\n\n/** Which flyout is open under the buttons. */\ntype Panel = 'none' | 'list' | 'restart'\n\n/**\n * The toolbar itself. All state is local: the page around it owns the plugin\n * list, and a restart tears this component down anyway.\n */\nexport function PluginListToolbar(props: PluginListToolbarProps) {\n const { t, isLoopback, checkUpdates, update, restartPlan, restart } = props\n\n const [phase, setPhase] = useState<Phase>('idle')\n const [checked, setChecked] = useState(false)\n /** Every third-party row the last check reported, including the applied ones. */\n const [found, setFound] = useState(0)\n const [rows, setRows] = useState<PluginUpdateItem[]>([])\n const [applied, setApplied] = useState<string[]>([])\n const [cursor, setCursor] = useState<{ name: string; index: number; total: number } | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [panel, setPanel] = useState<Panel>('none')\n /** How the host says it would restart, read before the confirmation is shown. */\n const [plan, setPlan] = useState<RestartMode | undefined>(undefined)\n const [restartMode, setRestartMode] = useState<RestartMode | undefined>(undefined)\n /** Synchronous in-flight mirror of the phase: a click and a keypress can land in one frame. */\n const busyRef = useRef(false)\n\n const pending = applicableUpdates(rows)\n\n /** Close the flyout on Escape, the shell's own dismissal gesture. */\n useEffect(() => {\n if (panel === 'none') return\n const onKey = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') setPanel('none')\n }\n window.addEventListener('keydown', onKey)\n return () => { window.removeEventListener('keydown', onKey) }\n }, [panel])\n\n const onCheck = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setPhase('checking')\n setError(undefined)\n setRestartMode(undefined)\n void checkUpdates().then(items => {\n const thirdParty = thirdPartyUpdates(items)\n setRows(thirdParty)\n setFound(thirdParty.length)\n setApplied([])\n setChecked(true)\n setPanel('list')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setPanel('list')\n }).finally(() => {\n busyRef.current = false\n setPhase('idle')\n })\n }\n\n const onUpdateAll = (): void => {\n if (busyRef.current) return\n const queue = applicableUpdates(rows)\n if (queue.length === 0) return\n busyRef.current = true\n setPhase('updating')\n setError(undefined)\n void (async () => {\n const done: string[] = []\n for (const [index, row] of queue.entries()) {\n setCursor({ name: row.id, index: index + 1, total: queue.length })\n try {\n await update(row.id)\n } catch (reason) {\n // Stop at the first failure: the remaining rows stay listed with their\n // versions, so the user sees exactly what did not go through.\n setError(t('failed', { reason: messageOf(reason) }))\n break\n }\n done.push(row.id)\n setApplied([...done])\n setRows(current => current.filter(item => item.id !== row.id))\n }\n setCursor(undefined)\n })().finally(() => {\n busyRef.current = false\n setPhase('idle')\n })\n }\n\n /** Ask the host how it would restart, then show the confirmation that matches. */\n const onAskRestart = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setError(undefined)\n void restartPlan().then(mode => {\n setPlan(mode)\n setPanel('restart')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setPanel('list')\n }).finally(() => {\n busyRef.current = false\n })\n }\n\n const onRestart = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setError(undefined)\n void restart().then(mode => {\n setRestartMode(mode)\n setPlan(undefined)\n setPanel('none')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n })\n }\n\n const shellProps = {\n 'data-dsh-plugin': 'plugin-manager',\n 'data-dsh-part': 'update-toolbar',\n 'data-update-toolbar': true,\n } as const\n\n if (!isLoopback) {\n return (\n <div className={css.toolbar} {...shellProps} data-state=\"local-only\">\n <button type=\"button\" className={css.toolbarButton} disabled title={t('localOnlyBody')}>\n {t('checkUpdates')}\n </button>\n </div>\n )\n }\n\n const busy = phase !== 'idle'\n /** One alert line, rendered in whichever flyout is open when it appears. */\n const errorLine = error === undefined\n ? null\n : <p className={css.error} role=\"alert\" data-update-error>{error}</p>\n /** What is still pending after a partial run (the applied rows leave the list). */\n const remaining = found - applied.length\n const summary = cursor !== undefined\n ? t('updatingAll', { name: cursor.name, index: String(cursor.index), total: String(cursor.total) })\n : remaining > 0\n ? t('updatesAvailable', { count: String(remaining) })\n : applied.length > 0\n ? t('updateAllDone')\n : t('noUpdates')\n\n return (\n <div className={css.toolbar} {...shellProps} data-state={restartMode ?? phase} aria-busy={busy}>\n <button type=\"button\" className={css.toolbarButton} data-update-check disabled={busy} onClick={onCheck}>\n {phase === 'checking' ? t('checking') : t('checkUpdates')}\n </button>\n\n {checked && (\n <button\n type=\"button\"\n className={css.toolbarSummary}\n data-update-summary\n data-pending={pending.length}\n aria-expanded={panel === 'list'}\n onClick={() => { setPanel(panel === 'list' ? 'none' : 'list') }}\n >\n {summary}\n </button>\n )}\n\n <button\n type=\"button\"\n className={applied.length > 0 ? `${css.toolbarButton} ${css.primary}` : css.toolbarButton}\n data-update-restart\n data-restart-pending={applied.length}\n disabled={busy || restartMode === 'relaunch'}\n onClick={() => { if (panel === 'restart') { setPanel('none'); setPlan(undefined); return } onAskRestart() }}\n >\n {restartMode === 'relaunch' ? t('restarting') : t('restartNow')}\n </button>\n\n {restartMode !== undefined && panel !== 'restart' && (\n <span className={css.toolbarHint} role=\"status\" data-update-restart-hint={restartMode}>\n {restartMode === 'shell' ? t('restartDesktopHint') : restartMode === 'manual' ? t('restartManualHint') : t('restartRelaunchHint')}\n </span>\n )}\n\n {panel === 'list' && (\n <div className={css.panel} data-update-panel role=\"group\" aria-label={t('updatesPanelTitle')}>\n {errorLine}\n {applied.length > 0 && <p className={css.ok} data-update-applied>{t('updateAllDone')}</p>}\n {rows.length === 0 && applied.length === 0 && error === undefined && <p className={css.hint}>{t('noUpdates')}</p>}\n {rows.length > 0 && (\n <ul className={css.panelList}>\n {rows.map(row => {\n // One verdict per row, read once: the badge, its copy and the\n // bulk action's exclusion all come from the same answer.\n const gate = dshGateOf(row)\n return (\n <li key={row.id} className={css.panelRow} data-update-row={row.id} data-compatible={gate === 'open' ? 'yes' : 'no'}>\n <span className={css.panelName}>{row.id}</span>\n <span className={css.panelVersion}>{row.current} → {row.latest}</span>\n {gate === 'open' ? null : (\n <span className={css.compatBlocked} data-update-row-compat-reason={gate}>\n {row.requiresDsh !== undefined\n ? t(gate === 'unverified' ? 'updateUnverifiedDsh' : 'updateBlockedDsh', {\n min: displayMinimumVersion(row.requiresDsh),\n })\n : t('updateUnverifiedDshUnknownRange')}\n </span>\n )}\n </li>\n )\n })}\n </ul>\n )}\n <div className={css.panelActions}>\n {pending.length > 0 && (\n <button type=\"button\" className={`${css.button} ${css.primary}`} data-update-all disabled={busy} onClick={onUpdateAll}>\n {phase === 'updating' ? t('updating') : t('updateAll', { count: String(pending.length) })}\n </button>\n )}\n {applied.length > 0 && (\n <button type=\"button\" className={`${css.button} ${css.primary}`} data-update-panel-restart disabled={busy} onClick={onAskRestart}>\n {t('restartNow')}\n </button>\n )}\n </div>\n <p className={css.hint}>{t('thirdPartyOnly')}</p>\n </div>\n )}\n\n {panel === 'restart' && (\n <div className={css.panel} data-update-restart-panel data-restart-plan={plan} role=\"group\" aria-label={t('restartNow')}>\n {errorLine}\n <p className={css.hint} data-restart-plan-hint={plan}>\n {plan === 'shell' ? t('restartPlanShell') : plan === 'manual' ? t('restartPlanManual') : t('restartPlanRelaunch')}\n </p>\n {plan === 'shell' && <p className={css.hint}>{t('restartShellWarning')}</p>}\n <div className={css.panelActions}>\n <button type=\"button\" className={css.button} data-restart-cancel onClick={() => { setPanel('none'); setPlan(undefined) }}>\n {t('cancel')}\n </button>\n {plan !== 'manual' && (\n <button\n type=\"button\"\n className={`${css.button} ${css.primary}`}\n data-restart-confirm\n onClick={onRestart}\n >\n {t('restartConfirm')}\n </button>\n )}\n </div>\n </div>\n )}\n </div>\n )\n}\n","/**\n * Mounting the update toolbar beside the official Plugins page's \"Installed\"\n * heading.\n *\n * The page renders that heading itself — `<section data-plugin-group=\"bundles\">\n * <div class=\"groupHead\"><h3>Installed</h3><span>7</span></div>…` — and declares\n * no seat next to it: its extension points are `plugins.detail.*` (per page),\n * `plugins.bundle.config` / `plugins.row.config` / `plugins.item` (configuration\n * entries) and `plugins.bundle.activation`. A list-level action therefore has\n * to be inserted into the page's own chrome, the same way the sidebar foot card\n * is inserted above the Settings row.\n *\n * The container is a plain element carrying its own React root, so it can never\n * disturb the page's reconciliation, and it re-seats itself through the\n * page-wide body-mutation hub: a re-render that relocates or drops the heading\n * is followed on the next frame, and a panel switch that unmounts the list\n * simply detaches the container until the list returns.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { createElement } from 'react'\nimport { createRoot, type Root } from 'react-dom/client'\nimport { subscribeBodyInvalidations } from './body-mutations.ts'\nimport { PluginListToolbar, type PluginListToolbarProps } from './PluginListToolbar.tsx'\nimport css from './plugin-manager.module.css'\n\n/** Stable attribute identifying the injected container (mount idempotency). */\nexport const TOOLBAR_MOUNT_SELECTOR = '[data-dsh-plugin-manager-toolbar]'\n\n/** Toolbar props without the translate function, which is rebuilt per render. */\nexport type PluginListToolbarMountInput = Omit<PluginListToolbarProps, 't'> & {\n /** Translate in the namespace, read on every render so a language switch lands. */\n t: PluginListToolbarProps['t']\n}\n\n/** The mount's inputs. */\nexport interface PluginToolbarMountOptions {\n /** Build the toolbar props; called on mount and on every locale change. */\n props: () => PluginListToolbarMountInput\n /** Locale change subscription (ctx.locale.subscribe); re-renders the toolbar. */\n subscribe?: (listener: () => void) => () => void\n}\n\n/**\n * The official page's \"Installed\" group heading, when it is mounted. Class\n * names are CSS-module hashes in the official bundle, so the seat is found\n * through the page's own data attributes plus DOM position.\n * @returns the heading element to append into, or undefined off the list view.\n */\nexport function toolbarSeat(): HTMLElement | undefined {\n const page = document.querySelector('[data-plugin-panel]')\n const group = page?.querySelector('[data-plugin-group=\"bundles\"]')\n const head = group?.firstElementChild\n return head instanceof HTMLElement ? head : undefined\n}\n\n/**\n * Mount the toolbar into the Installed heading.\n * @param options - props factory and the optional locale subscription.\n * @returns disposer removing the container, its observers and its React root.\n */\nexport function mountPluginListToolbar(options: PluginToolbarMountOptions): () => void {\n if (typeof document === 'undefined') return () => {}\n // DOM-level idempotency: whatever path mounted a toolbar before this call\n // (a duplicated apply, an HMR re-injection), never mount a second one.\n if (document.querySelector(TOOLBAR_MOUNT_SELECTOR) !== null) return () => {}\n\n const container = document.createElement('div')\n container.setAttribute('data-dsh-plugin-manager-toolbar', '')\n container.className = css.mount\n const root: Root = createRoot(container)\n const render = (): void => {\n root.render(createElement(PluginListToolbar, options.props()))\n }\n render()\n\n /** Keep the container inside the heading; detach while the list is away. */\n const place = (): void => {\n const seat = toolbarSeat()\n if (seat === undefined) {\n container.remove()\n return\n }\n if (container.parentElement !== seat) seat.append(container)\n }\n place()\n\n const unsubscribeBody = subscribeBodyInvalidations(place)\n const unsubscribeLocale = options.subscribe === undefined ? ((): void => {}) : options.subscribe(render)\n\n return () => {\n unsubscribeBody()\n unsubscribeLocale()\n root.unmount()\n container.remove()\n }\n}\n","/**\n * Locale dictionaries for the plugin-manager's official-page patch. The zh\n * dictionary is the key source; the en dictionary mirrors the exact key set.\n *\n * The key set covers only what this package renders: the check-for-updates\n * block on a bundle's page in the official Plugins panel, and the list-level\n * update toolbar mounted beside that panel's \"Installed\" heading.\n * The former tab's keys (inventory, conflicts, repair seeds, safe mode,\n * aggregate children) left with that tab.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n/** Simplified Chinese copy (the key-set source of truth). */\nconst STATIC_ZH = {\n 'updateSection': '更新',\n 'checkUpdates': '检查更新',\n 'checking': '检查中…',\n 'noUpdates': '已是最新版本。',\n 'update': '更新',\n 'updating': '更新中…',\n 'latest': '最新 {version}',\n 'updateRequiresDsh': '需要 DSH ≥ {min}',\n 'updateBlockedDsh': '需要 DSH ≥ {min},请先升级 DSH 再更新',\n 'updateUnverifiedDsh': '无法核验本机 DSH 与该声明的兼容性(需要 DSH ≥ {min}),已暂停更新',\n 'updateUnverifiedDshUnknownRange': '无法核验该插件声明的 DSH 兼容范围,已暂停更新',\n 'restartHint': '插件变更将在重启应用后生效。',\n 'updatesAvailable': '{count} 个可更新',\n 'updateAll': '全部更新({count})',\n 'updatingAll': '更新 {name}({index}/{total})',\n 'updateAllDone': '更新完成,重启后生效。',\n 'updatesPanelTitle': '插件更新',\n 'thirdPartyOnly': '只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。',\n 'restartNow': '立即重启',\n 'restarting': '正在重启…',\n 'restartConfirm': '确认重启',\n 'restartPlanRelaunch': '会重启 DSH 服务,正在运行的任务会中断。',\n 'restartPlanShell': '桌面版重启由应用外壳执行:确认后宿主进程会退出,由外壳重新拉起。',\n 'restartPlanManual': '当前进程无法自动重启,请手动重启 DSH。',\n 'restartShellWarning': '它同时会写一份崩溃报告;也可以手动重启:退出 DeepSeek Harness(⌘Q)后重新打开。',\n 'restartDesktopHint': '请在随后出现的系统对话框中选择「重启」。',\n 'restartRelaunchHint': '已请求重启;服务恢复后刷新页面即可。',\n 'restartManualHint': '当前进程无法自动重启,请手动重启 DSH。',\n 'cancel': '取消',\n 'failed': '操作失败:{reason}',\n 'fetching': '正在获取插件信息…',\n 'downloading': '正在下载…',\n 'downloadingPercent': '正在下载 {percent}%',\n 'extracting': '正在解压…',\n 'writing': '正在写入配置…',\n 'localOnlyTitle': '仅限本机操作',\n 'localOnlyBody': '为了保护主机配置,插件管理只能从本机打开。'\n} satisfies Record<string, string>\n\n/** English copy, checked complete against the zh key set. */\nconst STATIC_EN = {\n 'updateSection': 'Update',\n 'checkUpdates': 'Check for updates',\n 'checking': 'Checking…',\n 'noUpdates': 'The installed version is the latest.',\n 'update': 'Update',\n 'updating': 'Updating…',\n 'latest': 'Latest {version}',\n 'updateRequiresDsh': 'Requires DSH >= {min}',\n 'updateBlockedDsh': 'Requires DSH >= {min}; upgrade DSH before updating',\n 'updateUnverifiedDsh': 'Cannot verify this host against the declared DSH range (this update needs DSH >= {min}); update paused',\n 'updateUnverifiedDshUnknownRange': 'Cannot verify the DSH range this plugin declares; update paused',\n 'restartHint': 'Plugin changes take effect after restarting the application.',\n 'updatesAvailable': '{count} updates available',\n 'updateAll': 'Update all ({count})',\n 'updatingAll': 'Updating {name} ({index}/{total})',\n 'updateAllDone': 'Updated; restart to take effect.',\n 'updatesPanelTitle': 'Plugin updates',\n 'thirdPartyOnly': 'Third-party plugins only; @deepseek-ai/ packages upgrade with DSH itself.',\n 'restartNow': 'Restart now',\n 'restarting': 'Restarting…',\n 'restartConfirm': 'Restart',\n 'restartPlanRelaunch': 'The DSH service restarts; running tasks are interrupted.',\n 'restartPlanShell': 'The desktop app performs the restart: confirming stops the host process and the shell brings a new one up.',\n 'restartPlanManual': 'This process cannot restart itself; restart DSH yourself.',\n 'restartShellWarning': 'It also writes a crash report. You can instead restart manually: quit DeepSeek Harness (Cmd+Q) and open it again.',\n 'restartDesktopHint': 'Choose Restart in the system dialog that follows.',\n 'restartRelaunchHint': 'Restart requested; reload the page once the server is back.',\n 'restartManualHint': 'This process cannot restart itself; restart DSH yourself.',\n 'cancel': 'Cancel',\n 'failed': 'Operation failed: {reason}',\n 'fetching': 'Fetching plugin metadata…',\n 'downloading': 'Downloading…',\n 'downloadingPercent': 'Downloading {percent}%',\n 'extracting': 'Extracting…',\n 'writing': 'Writing configuration…',\n 'localOnlyTitle': 'Available on this computer only',\n 'localOnlyBody': 'To protect host configuration, plugin management is only available from a local browser.'\n} satisfies Record<keyof typeof STATIC_ZH, string>\n\nexport const zh = STATIC_ZH\nexport const en = STATIC_EN\nexport type PluginManagerKey = keyof typeof STATIC_ZH\n","/**\n * Wire parsing for the official plugin-installer / plugin-control RPC\n * channels. This package is a browser-side consumer of those channels: every\n * response is decoded but untrusted, so each parser validates the shape it\n * needs and throws a typed error on mismatch. Callers treat a parse failure\n * as \"channel unavailable or drifted\" and degrade to command hints.\n *\n * The shapes mirror the official web installer tab's wire protocol (see the\n * DSH checkout's packages/client/ui-settings-plugin-installer/src/client/\n * protocol.ts); they are a contract observation, not an import.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\n/** One loader entry row claimed by an installed bundle package (aggregate child). */\nexport interface InstalledPluginChild {\n /** The loader entry id, e.g. web-ui-pet. */\n id: string\n /** Display name: the real plugin package (shell config.plugin) when known. */\n name: string\n /** Effective next-start enablement of this row alone (bundle default plus user override). */\n enabled: boolean\n /** Rows the manager must never disable (the manager tab itself, the compat face). */\n locked?: boolean\n}\n\n/** One installed user-plugin row served by `/plugin-installer list`. */\nexport interface InstalledPluginItem {\n id: string\n name: string\n version: string\n source: { kind: 'npm' | 'git'; spec: string }\n installedAt: string\n /** Effective next-start enablement across the bundle's own rows and the managed profile patch row. */\n enabled: boolean\n commit?: string\n /**\n * Entry rows this package's bundle patch claims, present when the package\n * is an aggregate claiming more than one row (gateway mode only — the\n * official channel wire has no children). Child enablement is individually\n * switchable; uninstall stays whole-package (the code ships in one npm\n * package).\n */\n children?: InstalledPluginChild[]\n}\n\n/**\n * How the host carried out (or refused) a restart request:\n * `relaunch` — this host re-executes itself in place; `shell` — the packaged\n * Desktop shell owns the process tree and runs its own restart; `manual` —\n * neither is safe here, the user restarts DSH themselves.\n */\nexport type RestartMode = 'relaunch' | 'shell' | 'manual'\n\n/** Point-in-time install/update progress reported by the host. */\nexport interface InstallProgressItem {\n kind: 'idle' | 'install' | 'update'\n stage: 'fetch' | 'download' | 'extract' | 'write'\n percent?: number\n}\n\n/** Whether an update row is a normal same-name update or a legacy package migration. */\nexport type PluginUpdateKind = 'update' | 'migrate'\n\n/** One plugin with a newer version available. */\nexport interface PluginUpdateItem {\n id: string\n current: string\n latest: string\n /** Normal same-name update or legacy aggregate migration. Defaults to update. */\n kind?: PluginUpdateKind\n /** Target package name when kind is migrate. */\n target?: string\n /** Exact target package version when kind is migrate. */\n targetVersion?: string\n /** Declared DSH minimum the update needs (package manifest's `dsh.engines.dsh`). */\n requiresDsh?: string\n /** Whether the running DSH host satisfies requiresDsh; absent when unknown. */\n compatible?: boolean\n /**\n * The running DSH version the verdict was made from, present only when the\n * host compared it and found it below the declaration. Its absence is what\n * separates \"this host is too old\" from \"we could not verify\" — a host that\n * could not be read, or a declaration that could not be parsed; different\n * problems, with different copy (issues #1819 and #1899).\n */\n hostVersion?: string\n}\n\n/** One recorded plugin boot failure served by the host. */\nexport interface PluginFailureItem {\n /** Installed plugin id (package name); empty for unattributable failures. */\n pluginId: string\n kind: 'load-failure' | 'hang' | 'late-rejection'\n message: string\n stack: string\n installPath: string\n at: string\n}\n\n/** Recovery facts served by the host: the failure ring, the plugin root, and safe mode. */\nexport interface PluginFailuresSnapshot {\n items: PluginFailureItem[]\n /** Absolute plugin install root — the repair conversation's workspace. */\n pluginRoot: string\n /** Whether the host is running in safe mode (user plugins skipped). */\n safeMode: boolean\n}\n\n/** Whether a decoded value is a non-array object. */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Whether a decoded value is a string. */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string'\n}\n\n/** Validate one aggregate child row. */\nfunction parsePluginChild(value: unknown, rowIndex: number, childIndex: number): InstalledPluginChild {\n if (!isRecord(value) || !isString(value.id) || !isString(value.name) || typeof value.enabled !== 'boolean') {\n throw new Error(`plugin-manager: plugin row ${String(rowIndex)} child ${String(childIndex)} is invalid`)\n }\n return {\n id: value.id,\n name: value.name,\n enabled: value.enabled,\n ...typeof value.locked === 'boolean' ? { locked: value.locked } : {},\n }\n}\n\n/** Validate one installed-plugin row. */\nfunction parsePlugin(value: unknown, index: number): InstalledPluginItem {\n if (!isRecord(value) || !isString(value.id) || !isString(value.name)\n || !isString(value.version) || !isString(value.installedAt)\n || typeof value.enabled !== 'boolean'\n || !isRecord(value.source) || (value.source.kind !== 'npm' && value.source.kind !== 'git')\n || !isString(value.source.spec)) {\n throw new Error(`plugin-manager: plugin row ${String(index)} is invalid`)\n }\n if (value.children !== undefined && !Array.isArray(value.children)) {\n throw new Error(`plugin-manager: plugin row ${String(index)} children is invalid`)\n }\n const children = (value.children as unknown[] | undefined)?.map((child, childIndex) => parsePluginChild(child, index, childIndex))\n return {\n id: value.id,\n name: value.name,\n version: value.version,\n source: { kind: value.source.kind, spec: value.source.spec },\n installedAt: value.installedAt,\n enabled: value.enabled,\n ...isString(value.commit) ? { commit: value.commit } : {},\n ...children !== undefined ? { children } : {},\n }\n}\n\n/**\n * Validate and normalize a `list` / `uninstall` response value.\n * @param value - decoded but untrusted response value.\n * @returns typed installed-plugin rows.\n */\nexport function parsePluginList(value: unknown): InstalledPluginItem[] {\n if (!isRecord(value) || !Array.isArray(value.plugins)) {\n throw new Error('plugin-manager: response must contain a plugins array')\n }\n return value.plugins.map((plugin, index) => parsePlugin(plugin, index))\n}\n\n/**\n * Validate and normalize an `install` / `update` / `set-enabled` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed installed-plugin row.\n */\nexport function parseInstalledPlugin(value: unknown): InstalledPluginItem {\n if (!isRecord(value) || value.plugin === undefined) {\n throw new Error('plugin-manager: response must contain a plugin row')\n }\n return parsePlugin(value.plugin, 0)\n}\n\n/**\n * Validate and normalize a `status` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed progress state.\n */\nexport function parseInstallStatus(value: unknown): InstallProgressItem {\n if (!isRecord(value) || !isRecord(value.progress)\n || (value.progress.kind !== 'idle' && value.progress.kind !== 'install' && value.progress.kind !== 'update')\n || (value.progress.stage !== 'fetch' && value.progress.stage !== 'download'\n && value.progress.stage !== 'extract' && value.progress.stage !== 'write')\n || (value.progress.percent !== undefined\n && (typeof value.progress.percent !== 'number' || !Number.isFinite(value.progress.percent)))) {\n throw new Error('plugin-manager: response must contain a valid progress state')\n }\n return {\n kind: value.progress.kind,\n stage: value.progress.stage,\n ...typeof value.progress.percent === 'number' ? { percent: value.progress.percent } : {},\n }\n}\n\n/**\n * Validate and normalize a `check-updates` response value.\n * @param value - decoded but untrusted response value.\n * @returns typed update rows.\n */\nexport function parseUpdateList(value: unknown): PluginUpdateItem[] {\n if (!isRecord(value) || !Array.isArray(value.updates)) {\n throw new Error('plugin-manager: response must contain an updates array')\n }\n return value.updates.map((update, index) => {\n if (!isRecord(update) || !isString(update.id) || !isString(update.current) || !isString(update.latest)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n const kind = update.kind === undefined ? 'update' : update.kind\n if (kind !== 'update' && kind !== 'migrate') {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n const row: PluginUpdateItem = { id: update.id, current: update.current, latest: update.latest }\n if (kind === 'migrate') {\n if (!isString(update.target) || !isString(update.targetVersion)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.kind = 'migrate'\n row.target = update.target\n row.targetVersion = update.targetVersion\n }\n if (update.requiresDsh !== undefined) {\n if (!isString(update.requiresDsh)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.requiresDsh = update.requiresDsh\n }\n if (update.compatible !== undefined) {\n if (typeof update.compatible !== 'boolean') {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.compatible = update.compatible\n }\n if (update.hostVersion !== undefined) {\n if (!isString(update.hostVersion)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.hostVersion = update.hostVersion\n }\n return row\n })\n}\n\n/**\n * Validate and normalize a `restart` response value.\n * @param value - decoded but untrusted response value.\n * @returns the mode the host actually used.\n */\nexport function parseRestartMode(value: unknown): RestartMode {\n const restart = isRecord(value) ? value.restart : undefined\n const mode = isRecord(restart) ? restart.mode : undefined\n if (mode !== 'relaunch' && mode !== 'shell' && mode !== 'manual') {\n throw new Error('plugin-manager: response must contain a restart mode')\n }\n return mode\n}\n\n/**\n * Validate and normalize a `failures` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed failures snapshot.\n */\nexport function parseFailuresSnapshot(value: unknown): PluginFailuresSnapshot {\n if (!isRecord(value) || !Array.isArray(value.items)\n || !isString(value.pluginRoot) || typeof value.safeMode !== 'boolean') {\n throw new Error('plugin-manager: response must contain a failures snapshot')\n }\n return {\n items: value.items.map((item, index) => {\n if (!isRecord(item) || !isString(item.pluginId)\n || (item.kind !== 'load-failure' && item.kind !== 'hang' && item.kind !== 'late-rejection')\n || !isString(item.message) || !isString(item.stack)\n || !isString(item.installPath) || !isString(item.at)) {\n throw new Error(`plugin-manager: failure row ${String(index)} is invalid`)\n }\n return {\n pluginId: item.pluginId,\n kind: item.kind,\n message: item.message,\n stack: item.stack,\n installPath: item.installPath,\n at: item.at,\n }\n }),\n pluginRoot: value.pluginRoot,\n safeMode: value.safeMode,\n }\n}\n","/**\n * The cordis service contract this package exposes to sibling client plugins\n * under the name `'pluginManager'`. The browser half builds one dual-channel\n * face (official /plugin-installer + /plugin-control RPC channels when\n * available, else this package's loopback HTTP gateway) and provides it via\n * `ctx.provide('pluginManager', face)`; consumers resolve it with\n * `ctx.inject(['pluginManager'], cb)` and read `ctx.pluginManager`.\n *\n * The interface is intentionally narrower than the face the Plugin manager\n * tab receives (`PluginManagerFace` in the client half): it is the stable\n * cross-plugin surface, so it only carries the operations a sibling plugin\n * needs to observe and drive the installed-plugin set.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { InstallProgressItem, InstalledPluginItem, PluginFailuresSnapshot } from './protocol.ts'\n\n/** The cordis service name the browser half provides the face under. */\nexport const PLUGIN_MANAGER_SERVICE = 'pluginManager'\n\n/**\n * The dual-channel plugin-management face, shared between the Plugin manager\n * tab and sibling client plugins.\n */\nexport interface PluginManagerService {\n /** Whether this browser has loopback authority to use the host routes. */\n readonly isLoopback: boolean\n /** Read the installed snapshot. */\n list(): Promise<InstalledPluginItem[]>\n /** Install one plugin from an npm spec or git URL. */\n install(spec: string): Promise<InstalledPluginItem>\n /** Remove one plugin. */\n uninstall(id: string): Promise<InstalledPluginItem[]>\n /** Read the current install/update progress. */\n status(): Promise<InstallProgressItem>\n /**\n * Read the recorded plugin boot-failure ring (plugin id, message, stack,\n * install path). On runtimes without a failure ring the host answers an\n * empty snapshot.\n */\n failures(): Promise<PluginFailuresSnapshot>\n /**\n * Flip one plugin's next-start enablement through the active channel (the\n * official installer RPC when available, else the loopback gateway's patch\n * `disabled` override row). The change takes effect after the host restart;\n * a running plugin is not stopped.\n */\n setEnabled(id: string, enabled: boolean): Promise<InstalledPluginItem>\n /**\n * Subscribe to successful mutations: the callback runs after install(),\n * update(), uninstall(), or setEnabled() resolves. One listener throwing\n * never breaks the others. Returns the unsubscribe function.\n */\n onChange(cb: () => void): () => void\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n /** The plugin-manager face (provided by the dsh-plugin-manager client half). */\n pluginManager: PluginManagerService\n }\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/telemetry.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * Anonymous install telemetry shared by the DSH Web UI family plugins.\n *\n * Once per UTC day per browser, each wired plugin sends one heartbeat to\n * the dsh-market edge API listing its package name (and version when known).\n * The payload carries no conversation data and no identifiers beyond a random\n * UUID generated in localStorage; the server hashes it with a deployment salt\n * before storage and never persists IP addresses. Sends are fire-and-forget:\n * failures stay silent and simply retry on a later mount or day. Frames where\n * storage is unavailable report nothing.\n *\n * The family-wide opt-out and the browser's Do Not Track signal both suppress\n * the heartbeat; the Web Plugins settings switch writes the same localStorage\n * key. The system is documented in docs/telemetry.md.\n */\n\nexport type TelemetryChannel = 'market' | 'npm' | 'unknown'\n\nexport interface TelemetryItem {\n /** npm package name or asset id, e.g. \"@linxin666/dsh-pet\" or \"skin:harbor\". */\n name: string\n /** Installed version when known; omitted otherwise. */\n version?: string\n /** Install channel when determinable (market = Workshop install). */\n channel?: TelemetryChannel\n}\n\n/** localStorage key carrying the family-wide telemetry opt-out ('1' = off). */\nexport const TELEMETRY_OPT_OUT_KEY = 'dsh-web-ui-telemetry-opt-out'\n\nconst VISITOR_KEY = 'dsh-web-ui-telemetry-visitor'\nconst DAY_KEY_PREFIX = 'dsh-web-ui-telemetry-day:'\nconst ENDPOINT = 'https://dsh-market.com/api/telemetry/event'\n\n// Baked into each client bundle by shared/tsdown.client.ts (the package's own\n// package.json version at build time). Undefined in dev/test builds.\ndeclare const __DSH_PKG_VERSION__: string | undefined\n\n/** The building package's version, when the bundle carries it. */\nfunction bakedVersion(): string | undefined {\n try {\n return typeof __DSH_PKG_VERSION__ === 'string' && __DSH_PKG_VERSION__ !== ''\n ? __DSH_PKG_VERSION__\n : undefined\n } catch {\n return undefined\n }\n}\n\n/** Whether the user switched the family-wide opt-out on (reads storage only). */\nexport function isTelemetryOptedOut(): boolean {\n try {\n return localStorage.getItem(TELEMETRY_OPT_OUT_KEY) === '1'\n } catch {\n // Storage unavailable: there is no stored opt-out to honour.\n return false\n }\n}\n\n/** Turn the family-wide opt-out on or off (writing '1' / removing the key); never throws. */\nexport function setTelemetryOptedOut(optedOut: boolean): void {\n try {\n if (optedOut) localStorage.setItem(TELEMETRY_OPT_OUT_KEY, '1')\n else localStorage.removeItem(TELEMETRY_OPT_OUT_KEY)\n } catch {\n // Storage unavailable: the preference cannot be persisted on this machine.\n }\n}\n\n/** Whether the browser itself asks not to be tracked; a failed read means no signal. */\nfunction doNotTrackRequested(): boolean {\n try {\n // '1' per the DNT header spec, 'yes' from older Firefox builds.\n return navigator.doNotTrack === '1' || navigator.doNotTrack === 'yes'\n } catch {\n return false\n }\n}\n\n/** Whether a heartbeat must be suppressed right now: opt-out stored, or the browser asks not to be tracked. */\nexport function isTelemetrySuppressed(): boolean {\n return isTelemetryOptedOut() || doNotTrackRequested()\n}\n\n/** Read or lazily create the anonymous visitor id; null when storage is unavailable. */\nfunction visitorId(): string | null {\n try {\n const existing = localStorage.getItem(VISITOR_KEY)\n if (existing && /^[A-Za-z0-9_-]{16,64}$/.test(existing)) return existing\n const fresh = crypto.randomUUID().replaceAll('-', '')\n localStorage.setItem(VISITOR_KEY, fresh)\n return fresh\n } catch {\n // Storage unavailable (privacy mode, sandboxed frame): report nothing.\n return null\n }\n}\n\n/** Drop stale per-day dedup keys so localStorage does not grow forever. */\nfunction pruneDayKeys(today: string): void {\n try {\n for (let index = localStorage.length - 1; index >= 0; index -= 1) {\n const key = localStorage.key(index)\n if (key !== null && key.startsWith(DAY_KEY_PREFIX) && key !== DAY_KEY_PREFIX + today) {\n localStorage.removeItem(key)\n }\n }\n } catch { /* best effort */ }\n}\n\n/**\n * Fire the daily heartbeat for the given items at most once per UTC day per\n * browser. Never throws and never blocks the caller. Items without an explicit\n * version inherit the bundle's baked build version.\n */\nexport function reportDailyHeartbeat(items: readonly TelemetryItem[]): void {\n try {\n // First guard: a stored opt-out or the browser's Do Not Track stops every\n // read below from minting an id, marking the day, or reaching the network.\n if (isTelemetrySuppressed()) return\n if (items.length === 0) return\n const today = new Date().toISOString().slice(0, 10)\n // Automation contexts (CDP-driven QA browsers, fresh isolated profiles)\n // mint a new visitor id per run and would inflate instance counts.\n if (navigator.webdriver) return\n if (localStorage.getItem(DAY_KEY_PREFIX + today) !== null) return\n const visitor = visitorId()\n if (visitor === null) return\n pruneDayKeys(today)\n const payloadItems = items.map((item) => {\n const out: Record<string, string> = { name: item.name }\n const version = item.version ?? bakedVersion()\n if (version !== undefined) out.version = version\n if (item.channel !== undefined) out.channel = item.channel\n return out\n })\n const body = JSON.stringify({ kind: 'heartbeat', visitor, items: payloadItems })\n void fetch(ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body,\n keepalive: true,\n }).then((response) => {\n // Mark the day only after an accepted send, so offline browsers retry\n // on a later mount instead of going dark until tomorrow.\n if (response.ok) localStorage.setItem(DAY_KEY_PREFIX + today, '1')\n }).catch(() => { /* unreachable endpoint: stay silent */ })\n } catch { /* never break the host UI over telemetry */ }\n}\n","/**\n * Plugin-manager browser half: contributes the package's one remaining\n * surface — the check-for-updates block on the official Plugins page — and\n * provides the dual-channel face as the `'pluginManager'` cordis service for\n * sibling client plugins.\n *\n * It is dual-channel: on runtimes with the official installer services\n * (DSHCode, the 1.0.4 checkout web) every operation rides the official\n * `/plugin-installer` and `/plugin-control` loopback RPC channels (the single\n * writer); on the npm-published web runtime those channels do not exist, so the\n * same face falls back to this package's own loopback HTTP gateway, which\n * spawns the official CLI for writes. Neither the patch nor service consumers\n * know which mode the face runs in.\n *\n * The package used to register its own \"Plugin manager\" tab into the official\n * Plugins settings section (`settings.plugins.tab`). Installing, uninstalling\n * and enabling moved to the official page long ago, and the tab's remaining\n * half was UI no official page renders; the tab is gone and its one genuinely\n * missing capability — comparing an installed plugin against its registry\n * source, with the DSH-runtime compatibility gate — now renders inside the\n * official page through the `plugins.detail.section` seat it declares.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the renderer plugin's Context merge (ctx.slots, the\n// registry this package registers its contribution into).\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\nimport { PluginUpdatePatch, type PluginUpdatePatchInjected } from './PluginUpdatePatch.tsx'\nimport { mountPluginListToolbar } from './plugin-toolbar-mount.tsx'\nimport { en, zh, type PluginManagerKey } from './locales.ts'\nimport {\n parseFailuresSnapshot,\n parseInstallStatus,\n parseInstalledPlugin,\n parsePluginList,\n parseRestartMode,\n parseUpdateList,\n type InstalledPluginItem,\n type InstallProgressItem,\n type PluginFailuresSnapshot,\n type PluginUpdateItem,\n type RestartMode,\n} from '../core/protocol.ts'\nimport { PLUGIN_MANAGER_SERVICE, type PluginManagerService } from '../core/service.ts'\nimport { reportDailyHeartbeat } from './telemetry.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Copy for the check-for-updates patch. */\n 'settings.pluginManager': PluginManagerKey\n }\n}\n\nconst NS = 'settings.pluginManager'\nconst CHANNEL = '/plugin-installer'\nconst LIST_ENDPOINT = 'list'\nconst INSTALL_ENDPOINT = 'install'\nconst UPDATE_ENDPOINT = 'update'\nconst UNINSTALL_ENDPOINT = 'uninstall'\nconst SET_ENABLED_ENDPOINT = 'set-enabled'\nconst CHECK_UPDATES_ENDPOINT = 'check-updates'\nconst RESTART_ENDPOINT = 'restart'\nconst STATUS_ENDPOINT = 'status'\nconst FAILURES_ENDPOINT = 'failures'\n\n// DOCUMENT-RELATIVE (issue #1707): the GUI is served with `<base href=\"./\">`,\n// so a sub-path deployment resolves the gateway prefix against its entry\n// directory rather than the origin root.\nconst GATEWAY_PREFIX = 'api/plugin-manager'\n/** Gateway job polling cadence. */\nconst JOB_POLL_MS = 500\n/** Gateway job wait ceiling (the host add deadline is six minutes). */\nconst JOB_WAIT_MS = 7 * 60_000\n\n/** Services required by the patch registration and both channels. */\nexport const inject = ['slots', 'locale', 'connection']\n\n/** The gateway job wire shape served by /status. */\ninterface GatewayJobWire {\n phase: 'running' | 'done' | 'error'\n plugin?: unknown\n error?: string\n}\n\n/**\n * The face the update patch and the `'pluginManager'` cordis service share:\n * the patch's wire surface plus the cross-plugin service contract. The gateway\n * host still records install conflicts and boot failures; no client surface\n * consumes either since the tab left, so neither is on this face.\n */\nexport type PluginManagerFace = PluginUpdatePatchInjected & PluginManagerService & {\n /**\n * Restart DSH so an applied plugin update is loaded. Always rides this\n * package's own loopback route: neither official channel\n * (`/plugin-installer`, `/plugin-control`) has a restart method, and the\n * route answers how the restart was carried out (in-place relaunch, or a\n * packaged Desktop shell that owns the process tree). See host/restart.ts.\n */\n restart: () => Promise<RestartMode>\n /**\n * Read how a restart would be carried out without triggering it (the same\n * route's plan read). The toolbar words its confirmation from this, so a\n * packaged Desktop host can say what its system dialog will do instead of\n * surprising the user with it.\n */\n restartPlan: () => Promise<RestartMode>\n}\n\n/**\n * Build the dual-channel face once: official-channel and gateway-channel\n * implementations, the mode detection that picks between them, and the\n * change-notification listener set. The returned face is both the update\n * patch's injected props and the value provided as the\n * `'pluginManager'` cordis service.\n * @param ctx - the client context (connection).\n * @returns the shared face.\n */\nexport function createPluginManagerFace(ctx: ClientContext): PluginManagerFace {\n const connection = ctx.get('connection') as ConnectionHandle\n\n // Official channel implementations.\n\n const call = async (endpoint: string, payload: unknown): Promise<unknown> => {\n const result = await connection.rpc.call(CHANNEL, endpoint, payload)\n if (!result.ok) {\n throw new Error(`plugin-installer ${endpoint} failed: ${result.error.code}: ${result.error.message}`)\n }\n return result.value\n }\n const official = {\n list: async (): Promise<InstalledPluginItem[]> => parsePluginList(await call(LIST_ENDPOINT, {})),\n install: async (spec: string): Promise<InstalledPluginItem> => parseInstalledPlugin(await call(INSTALL_ENDPOINT, { spec })),\n update: async (id: string): Promise<InstalledPluginItem> => parseInstalledPlugin(await call(UPDATE_ENDPOINT, { id })),\n uninstall: async (id: string): Promise<InstalledPluginItem[]> => parsePluginList(await call(UNINSTALL_ENDPOINT, { id })),\n setEnabled: async (id: string, enabled: boolean): Promise<InstalledPluginItem> =>\n parseInstalledPlugin(await call(SET_ENABLED_ENDPOINT, { id, enabled })),\n checkUpdates: async (): Promise<PluginUpdateItem[]> => parseUpdateList(await call(CHECK_UPDATES_ENDPOINT, {})),\n status: async (): Promise<InstallProgressItem> => parseInstallStatus(await call(STATUS_ENDPOINT, {})),\n failures: async (): Promise<PluginFailuresSnapshot> => parseFailuresSnapshot(await call(FAILURES_ENDPOINT, {})),\n }\n\n // Gateway channel implementations.\n\n const gatewayJson = async (path: string, init?: RequestInit): Promise<unknown> => {\n const response = await fetch(path, {\n ...init,\n headers: { 'content-type': 'application/json', ...init?.headers },\n })\n if (response.status === 403) {\n throw new Error('plugin-manager: plugin management is only available from a local browser')\n }\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string }\n throw new Error(body.error ?? `plugin-manager: gateway ${path} failed: HTTP ${String(response.status)}`)\n }\n return response.json()\n }\n\n /** Wait for one gateway job to settle, returning its wire state. */\n const waitJob = async (jobId: string): Promise<GatewayJobWire> => {\n const deadline = Date.now() + JOB_WAIT_MS\n for (;;) {\n const body = await gatewayJson(`${GATEWAY_PREFIX}/status?job=${encodeURIComponent(jobId)}`) as { job?: GatewayJobWire }\n const job = body.job\n if (job === undefined) throw new Error('plugin-manager: gateway job vanished')\n if (job.phase === 'done') return job\n if (job.phase === 'error') throw new Error(job.error ?? 'plugin-manager: gateway job failed')\n if (Date.now() > deadline) throw new Error('plugin-manager: gateway job timed out')\n await new Promise(resolve => { setTimeout(resolve, JOB_POLL_MS) })\n }\n }\n\n /** Whether a gateway install/remove is in flight (drives the progress row). */\n let gatewayInflight = false\n\n const gateway = {\n list: async (): Promise<InstalledPluginItem[]> =>\n parsePluginList(await gatewayJson(`${GATEWAY_PREFIX}/list`)),\n install: async (spec: string): Promise<InstalledPluginItem> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/install`, {\n method: 'POST',\n body: JSON.stringify({ spec }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway install returned no job')\n const job = await waitJob(started.jobId)\n return parseInstalledPlugin({ plugin: job.plugin })\n } finally {\n gatewayInflight = false\n }\n },\n update: async (id: string): Promise<InstalledPluginItem> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/update`, {\n method: 'POST',\n body: JSON.stringify({ id }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway update returned no job')\n const job = await waitJob(started.jobId)\n return parseInstalledPlugin({ plugin: job.plugin })\n } finally {\n gatewayInflight = false\n }\n },\n uninstall: async (id: string): Promise<InstalledPluginItem[]> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/remove`, {\n method: 'POST',\n body: JSON.stringify({ id }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway remove returned no job')\n await waitJob(started.jobId)\n return gateway.list()\n } finally {\n gatewayInflight = false\n }\n },\n setEnabled: async (id: string, enabled: boolean): Promise<InstalledPluginItem> =>\n parseInstalledPlugin(await gatewayJson(`${GATEWAY_PREFIX}/set-enabled`, {\n method: 'POST',\n body: JSON.stringify({ id, enabled }),\n })),\n checkUpdates: async (): Promise<PluginUpdateItem[]> =>\n parseUpdateList(await gatewayJson(`${GATEWAY_PREFIX}/check-updates`)),\n status: async (): Promise<InstallProgressItem> =>\n gatewayInflight ? { kind: 'install', stage: 'download' } : { kind: 'idle', stage: 'fetch' },\n failures: async (): Promise<PluginFailuresSnapshot> =>\n parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`)),\n // Restart has no official-channel counterpart, so this route is the one\n // call that is always the gateway's, whichever mode the face runs in. The\n // GET-shaped call is the plan read: no state changes, no process exits.\n restartPlan: async (): Promise<RestartMode> =>\n parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`)),\n restart: async (): Promise<RestartMode> =>\n parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`, { method: 'POST' })),\n }\n\n // Mode selection.\n\n let modePromise: Promise<'official' | 'gateway'> | undefined\n const ensureMode = (): Promise<'official' | 'gateway'> => {\n if (modePromise === undefined) {\n modePromise = (async () => {\n // Prefer the host verdict: the gateway's /mode route reports whether\n // the official installer channels exist, so the direct channel probe\n // below (which 405s into the browser console on the npm web runtime)\n // only runs when the host half is absent or explicitly returns null\n // for a desktop runtime whose services are registered in-process.\n try {\n const mode = await gatewayJson(`${GATEWAY_PREFIX}/mode`) as { official?: boolean | null }\n if (mode.official === true) return 'official' as const\n if (mode.official === false) return 'gateway' as const\n } catch {\n // Host half absent (an official runtime without a boot profile):\n // fall back to the direct channel probe.\n }\n try {\n const result = await connection.rpc.call(CHANNEL, LIST_ENDPOINT, {})\n return result.ok ? 'official' as const : 'gateway' as const\n } catch {\n return 'gateway' as const\n }\n })()\n }\n return modePromise\n }\n\n // Change notification.\n\n /** Listeners subscribed through onChange; fired after successful mutations. */\n const listeners = new Set<() => void>()\n /** Notify every listener; one listener throwing never breaks the others. */\n const notifyChange = (): void => {\n for (const listener of [...listeners]) {\n try {\n listener()\n } catch {\n // A consumer's listener failure is its own; keep notifying the rest.\n }\n }\n }\n\n // The shared face.\n\n return {\n isLoopback: connection.isLoopback,\n list: async () => (await ensureMode()) === 'official' ? official.list() : gateway.list(),\n install: async spec => {\n const item = await ((await ensureMode()) === 'official' ? official.install(spec) : gateway.install(spec))\n notifyChange()\n return item\n },\n update: async id => {\n const item = await ((await ensureMode()) === 'official' ? official.update(id) : gateway.update(id))\n notifyChange()\n return item\n },\n uninstall: async id => {\n const rows = await ((await ensureMode()) === 'official' ? official.uninstall(id) : gateway.uninstall(id))\n notifyChange()\n return rows\n },\n setEnabled: async (id, enabled) => {\n const item = await ((await ensureMode()) === 'official' ? official.setEnabled(id, enabled) : gateway.setEnabled(id, enabled))\n notifyChange()\n return item\n },\n checkUpdates: async () => (await ensureMode()) === 'official' ? official.checkUpdates() : gateway.checkUpdates(),\n restartPlan: () => gateway.restartPlan(),\n restart: () => gateway.restart(),\n status: async () => (await ensureMode()) === 'official' ? official.status() : gateway.status(),\n failures: async () => (await ensureMode()) === 'official' ? official.failures() : gateway.failures(),\n onChange: cb => {\n listeners.add(cb)\n return () => { listeners.delete(cb) }\n },\n }\n}\n\n/** Contribute the check-for-updates patch and provide the shared face. */\nexport function apply(ctx: ClientContext): void {\n // Anonymous install heartbeat (docs/telemetry.md): one beat per browser per\n // UTC day, package name only, silent failure.\n reportDailyHeartbeat([{ name: '@linxin666/dsh-client-ui-plugin-manager' }])\n\n ctx.effect(() => {\n try {\n return ctx.locale.register(NS, { zh, en })\n } catch {\n return () => {}\n }\n }, 'plugin-manager: dictionaries')\n\n // Built once: the patch and the 'pluginManager' cordis service share one\n // face, so consumers observe exactly the mutations the patch performs.\n const face = createPluginManagerFace(ctx)\n try {\n if (!ctx.get(PLUGIN_MANAGER_SERVICE)) {\n ctx.provide(PLUGIN_MANAGER_SERVICE, face)\n }\n } catch {\n // ignore duplicate provide\n }\n\n // The list-level toolbar rides the page's own \"Installed\" heading: the\n // official page declares no seat beside it, so the entry is inserted into\n // the heading element itself and tracks the page through the shared body\n // mutation hub. Its translate function is rebuilt on every render so a\n // language switch reaches copy that no slot outlet owns.\n ctx.effect(() => {\n try {\n return mountPluginListToolbar({\n props: () => ({\n isLoopback: face.isLoopback,\n checkUpdates: face.checkUpdates,\n update: face.update,\n restartPlan: face.restartPlan,\n restart: face.restart,\n t: ctx.locale.bind(NS),\n }),\n subscribe: listener => ctx.locale.subscribe(listener),\n })\n } catch {\n return () => {}\n }\n }, 'plugin-manager: update toolbar')\n\n // The official Plugins page declares this seat on its main-panel entry and\n // renders one section per contribution on each bundle / row / plugin page;\n // `inject` waits for that declaration, exactly like the family plugin cards\n // that register into `plugins.bundle.config`.\n ctx.slots.inject('plugins.detail.section', () => {\n try {\n return ctx.slots.register({\n name: 'plugins.detail.section',\n id: 'family-update-check',\n order: 30,\n locale: NS,\n inject: () => face,\n }, PluginUpdatePatch)\n } catch {\n return () => {}\n }\n })\n}\n"],"mapp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,EAAE,MAAM,0CAA0C,CAAC,CAAC;GAE1E,IAAI,aAAa;IACf,IAAI;KACF,OAAO,IAAI,OAAO,SAAS,IAAI;MAAE;MAAI;KAAG,CAAC;IAC3C,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,GAAG,8BAA8B;GAIjC,MAAM,OAAO,wBAAwB,GAAG;GACxC,IAAI;IACF,IAAI,CAAC,IAAI,IAAA,eAA0B,GACjC,IAAI,QAAQ,wBAAwB,IAAI;GAE5C,QAAQ,CAER;GAOA,IAAI,aAAa;IACf,IAAI;KACF,OAAO,uBAAuB;MAC5B,cAAc;OACZ,YAAY,KAAK;OACjB,cAAc,KAAK;OACnB,QAAQ,KAAK;OACb,aAAa,KAAK;OAClB,SAAS,KAAK;OACd,GAAG,IAAI,OAAO,KAAK,EAAE;MACvB;MACA,YAAW,aAAY,IAAI,OAAO,UAAU,QAAQ;KACtD,CAAC;IACH,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,GAAG,gCAAgC;GAMnC,IAAI,MAAM,OAAO,gCAAgC;IAC/C,IAAI;KACF,OAAO,IAAI,MAAM,SAAS;MACxB,MAAM;MACN,IAAI;MACJ,OAAO;MACP,QAAQ;MACR,cAAc;KAChB,GAAG,iBAAiB;IACtB,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,CAAC;EACH"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["messageOf","css","css","css"],"sources":["../../../packages/dsh-plugin-manager/src/core/version.ts","../../../packages/dsh-plugin-manager/src/client/PluginUpdatePatch.tsx","../../../packages/dsh-plugin-manager/src/client/body-mutations.ts","../../../packages/dsh-plugin-manager/src/core/updates.ts","../../../packages/dsh-plugin-manager/src/client/PluginListToolbar.tsx","../../../packages/dsh-plugin-manager/src/client/plugin-toolbar-mount.tsx","../../../packages/dsh-plugin-manager/src/client/locales.ts","../../../packages/dsh-plugin-manager/src/core/protocol.ts","../../../packages/dsh-plugin-manager/src/core/service.ts","../../../packages/dsh-plugin-manager/src/client/telemetry.ts","../../../packages/dsh-plugin-manager/src/client/index.ts"],"sourcesContent":["/**\n * Version parsing plus the requirement reader for the update compatibility\n * check. The declared minimum lives in the published package manifest under\n * `dsh.engines.dsh`, falling back to the top-level `engines.dsh` and then to\n * the `@deepseek-ai/dsh` peer; the range forms a manifest may use are the\n * full node-semver range grammar.\n *\n * This module is shared by both halves and therefore stays free of `semver`,\n * which is a node package: it parses and compares a single `X.Y.Z[-pre]`\n * version, which is all the browser half needs to render a declared range\n * (`displayMinimumVersion`) and all the host half needs to accept a probed\n * host version (`parseDshVersion`). The range verdict itself lives in the\n * host-only `../host/dsh-compat.ts`, which evaluates the declaration with\n * `semver.satisfies(host, range, { includePrerelease: true })` — the exact\n * call the official boot gate makes, so `||`, `^`, `~`, multi-comparator\n * and x-ranges all decide the same way here as they do at boot.\n *\n * Everything here is pure and tolerant of untrusted input: a malformed value\n * means \"cannot verify\", which the callers treat as a fail-closed verdict\n * when a requirement was declared (issue #754).\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\n/** One parsed DSH host or package version. */\nexport interface DshVersion {\n major: number\n minor: number\n patch: number\n /** Prerelease identifiers, numeric identifiers kept as numbers (semver order). */\n prerelease: readonly (number | string)[]\n}\n\nconst VERSION_PATTERN = /^v?(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z.-]+))?$/\n\n/**\n * Parse a DSH host or package version string.\n * @param value - e.g. `0.1.0-rc.8`, `v1.2.3`.\n * @returns the parsed version, or undefined when malformed.\n */\nexport function parseDshVersion(value: string): DshVersion | undefined {\n const match = VERSION_PATTERN.exec(value.trim())\n if (match === null) return undefined\n const prereleaseParts = match[4] === undefined ? [] : match[4].split('.')\n if (prereleaseParts.some(part => part === '')) return undefined\n return {\n major: Number(match[1]),\n minor: Number(match[2]),\n patch: Number(match[3]),\n prerelease: prereleaseParts.map(part => /^\\d+$/.test(part) ? Number(part) : part),\n }\n}\n\n/**\n * Compare two version strings by semver order (a release is newer than any\n * prerelease of the same tuple).\n * @returns -1 / 0 / 1, or undefined when either side is malformed.\n */\nexport function compareVersions(left: string, right: string): number | undefined {\n const a = parseDshVersion(left)\n const b = parseDshVersion(right)\n if (a === undefined || b === undefined) return undefined\n for (const key of ['major', 'minor', 'patch'] as const) {\n if (a[key] !== b[key]) return a[key] < b[key] ? -1 : 1\n }\n return comparePrerelease(a.prerelease, b.prerelease)\n}\n\n/**\n * Semver prerelease ordering: numeric identifiers compare numerically,\n * numeric identifiers rank below alphanumeric ones, alphanumeric identifiers\n * compare lexically, and a longer list wins when the shared prefix is equal.\n */\nfunction comparePrerelease(left: readonly (number | string)[], right: readonly (number | string)[]): number {\n if (left.length === 0 && right.length === 0) return 0\n if (left.length === 0) return 1\n if (right.length === 0) return -1\n const length = Math.max(left.length, right.length)\n for (let index = 0; index < length; index += 1) {\n const a = left[index]\n const b = right[index]\n if (a === undefined) return -1\n if (b === undefined) return 1\n if (typeof a === 'number' && typeof b === 'number') {\n if (a !== b) return a < b ? -1 : 1\n } else if (typeof a === 'number') {\n return -1\n } else if (typeof b === 'number') {\n return 1\n } else if (a !== b) {\n return a < b ? -1 : 1\n }\n }\n return 0\n}\n\nconst MINIMUM_RANGE_PATTERN = /^>=\\s*(v?\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?)$/\n\n/**\n * The bare minimum version for display: strips the `>=` operator (and an\n * optional leading `v`) from a declared requirement so UI copy that already\n * contains the comparison operator renders `0.1.1-rc.1` instead of\n * `>= >=0.1.1-rc.1`. Every other range form renders unchanged — the browser\n * half does not evaluate a range (the host does, in `../host/dsh-compat.ts`),\n * so it must not pull a range parser into the client bundle to shorten copy.\n * @param minimum - the declared minimum range.\n * @returns the version portion for display.\n */\nexport function displayMinimumVersion(minimum: string): string {\n const match = MINIMUM_RANGE_PATTERN.exec(minimum.trim())\n return match === null ? minimum.trim() : match[1].replace(/^v/, '')\n}\n\n/**\n * Read the declared DSH minimum from a published registry manifest:\n * `dsh.engines.dsh` first, top-level `engines.dsh` next, and\n * `peerDependencies[\"@deepseek-ai/dsh\"]` last, which is where a package that\n * only declares the host as a peer still gets gated at boot.\n * Defensive against malformed or untrusted metadata: anything that is not a\n * non-empty string reads as absent.\n * @param manifest - the decoded registry version manifest.\n * @returns the declared minimum, or undefined when not declared.\n */\nexport function dshRequirementOf(manifest: { dsh?: unknown; engines?: unknown; peerDependencies?: unknown }): string | undefined {\n const dshEngines = (manifest.dsh as { engines?: unknown } | undefined)?.engines as { dsh?: unknown } | undefined\n const engines = (manifest.engines as { dsh?: unknown } | undefined)?.dsh\n const peers = (manifest.peerDependencies as Record<string, unknown> | undefined)?.['@deepseek-ai/dsh']\n // The host's own peer gate is the LAST word: a package that declares the\n // host only under peerDependencies still gets that row skipped at boot when\n // the floor is not met, so a requirement we display must come from the same\n // place the gate reads, or the user is told nothing and then loses the row.\n const value = dshEngines?.dsh ?? engines ?? peers\n return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined\n}\n","/**\n * The check-for-updates patch contributed to the official Plugins page.\n *\n * This package used to own a \"Plugin manager\" tab inside the Plugins settings\n * section (`settings.plugins.tab`). Installing, uninstalling, enabling and\n * disabling moved to the official plugin manager page long ago, and the tab's\n * remaining half (read-only inventory, install-conflict ledger, boot-failure\n * repair conversation, safe-mode banner) is UI no official page renders. It is\n * gone; the one capability the official page still lacks is comparing an\n * installed plugin against its registry source.\n *\n * So this package now contributes exactly that, into the seat the official\n * Plugins page declares for contributed sections (`plugins.detail.section`,\n * a root-scope list rendered on every bundle / row / official-plugin page with\n * the page's `subject`). The official page owns the page chrome; this entry\n * renders one compact block, only on an installed bundle's page, drawing only\n * a plain button and its own section so it carries no dependency on the\n * official primitives bundle.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\nimport { useEffect, useRef, useState } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { InstallProgressItem, PluginUpdateItem, PluginUpdateResult } from '../core/protocol.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport css from './plugin-manager.module.css'\n\n/** One loader row of a bundle, as the official page's subject carries it. */\nexport interface PluginPageRowRef {\n rowId: string\n moduleName: string\n enabled: boolean\n}\n\n/** One bundle, as the official page's subject carries it. */\nexport interface PluginPageBundleRef {\n name: string\n version?: string\n installed: boolean\n enabled: boolean\n rows: readonly PluginPageRowRef[]\n}\n\n/**\n * The subject the official Plugins page renders a contributed section with:\n * its bundle page, its row page, or an official plugin's page. This package\n * only speaks to the bundle case.\n */\nexport type PluginPageSubject =\n | { kind: 'bundle'; pkg: PluginPageBundleRef }\n | { kind: 'row'; pkg: PluginPageBundleRef; row: PluginPageRowRef }\n | { kind: 'item'; id: string }\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface SlotMap {\n /**\n * One section contributed under a Plugins page's own content. Declared at\n * runtime by the official plugin-manager page's `main` registration; the\n * type is re-declared here, identically, so this package can register into\n * it without importing the page (the same way family plugins re-declare\n * `plugins.bundle.config`).\n */\n 'plugins.detail.section': {\n kind: 'list'\n scope: 'root'\n owner: { subject: PluginPageSubject }\n }\n }\n}\n\n/** Registration-side wire face the patch consumes. */\nexport interface PluginUpdatePatchInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n isLoopback: boolean\n /** Compare every installed plugin against the version its source serves. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /**\n * Re-install one plugin from its recorded source. Resolves with what landed:\n * the row at the new version, plus the bundles only a restart loads. A landed\n * update that needs a restart is not a failure and must not be reported as one.\n */\n update: (id: string) => Promise<PluginUpdateResult>\n /** Read the current install/update progress. */\n status: () => Promise<InstallProgressItem>\n}\n\n/** Full component props assembled by the Plugins page's section renderer. */\nexport type PluginUpdatePatchProps =\n PropsRuntime<'plugins.detail.section'>\n & PropsLocale<'settings.pluginManager'>\n & InjectFace<PluginUpdatePatchInjected>\n\n/** Error text for a caught request or lifecycle failure. */\nfunction messageOf(error: unknown): string {\n if (error instanceof AggregateError) {\n const details = error.errors.map(messageOf).join('; ')\n return details === '' ? error.message : `${error.message}: ${details}`\n }\n return error instanceof Error ? error.message : String(error)\n}\n\n/** Localized label for one install phase, with percent when the download has one. */\nfunction progressLabel(progress: InstallProgressItem, t: PluginUpdatePatchProps['t']): string {\n if (progress.stage === 'write') return t('writing')\n return progress.percent === undefined ? t('downloading') : t('downloadingPercent', { percent: String(progress.percent) })\n}\n\n/**\n * What the host's compatibility verdict amounts to for one update row.\n *\n * `compatible === false` on its own does not mean \"this DSH is too old\": the\n * host leaves `hostVersion` off a blocked row whenever it could not read its\n * own runtime version (issue #1819) and whenever it could not evaluate the\n * declared range at all — an empty declaration, a range node-semver rejects, a\n * host string that is not one version (issue #1899). Only a row that carries a\n * host version was actually compared against that version, so only that row\n * may send the user to upgrade DSH.\n *\n * The verdict is derived here once and shared by both surfaces that render it\n * (this section and the list-level toolbar) so the two cannot drift apart:\n * that drift is what left the \"cannot verify\" case telling users to upgrade a\n * DSH the host never checked.\n */\nexport type DshGate = 'open' | 'below-minimum' | 'unverified'\n\n/**\n * Read the gate state out of one wire row.\n * @param item - the update row, or undefined when no check has answered yet.\n * @returns `open` when nothing blocks the update, otherwise the reason it is\n * held back: `below-minimum` only when the host compared a version it read,\n * `unverified` when it could not make that comparison.\n */\nexport function dshGateOf(item: Pick<PluginUpdateItem, 'compatible' | 'hostVersion'> | undefined): DshGate {\n if (item?.compatible !== false) return 'open'\n return item.hostVersion === undefined ? 'unverified' : 'below-minimum'\n}\n\n/**\n * The update block on one official Plugins page: one check action, the verdict\n * for this page's bundle, and the update action it unlocks. The check is\n * explicit rather than automatic because one check reads every installed\n * plugin's registry manifest; a page visit must not fan that out.\n */\nexport function PluginUpdatePatch(props: PluginUpdatePatchProps) {\n const { t, subject, isLoopback, checkUpdates, update, status } = props\n\n const [checked, setChecked] = useState(false)\n const [found, setFound] = useState<PluginUpdateItem | undefined>(undefined)\n const [busy, setBusy] = useState<'check' | 'update' | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [progress, setProgress] = useState<InstallProgressItem>({ kind: 'idle', stage: 'fetch' })\n const [dirty, setDirty] = useState(false)\n /** Version the update landed on when this process cannot load it without a restart. */\n const [restartRequired, setRestartRequired] = useState<string | undefined>(undefined)\n /** Synchronous in-flight mirror of `busy`: the render guard alone lets a click and an Enter land in the same frame and double-fire. */\n const busyRef = useRef(false)\n\n const name = subject.kind === 'bundle' ? subject.pkg.name : undefined\n const installed = subject.kind === 'bundle' && subject.pkg.installed\n\n /** Poll update progress while an update is in flight. */\n useEffect(() => {\n if (busy !== 'update') {\n setProgress({ kind: 'idle', stage: 'fetch' })\n return\n }\n let stopped = false\n let timer: ReturnType<typeof setTimeout> | undefined\n const tick = (delay: number): void => {\n timer = setTimeout(() => {\n void status().then(next => {\n if (!stopped && next !== undefined) {\n setProgress(next)\n tick(400)\n }\n }).catch(() => { /* polling fails silently; the update itself owns the error row */ })\n }, delay)\n }\n tick(100)\n return () => {\n stopped = true\n if (timer !== undefined) clearTimeout(timer)\n }\n }, [busy, status])\n\n if (name === undefined || !installed) return null\n\n const onCheck = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setBusy('check')\n setError(undefined)\n void checkUpdates().then(items => {\n setFound(items.find(item => item.id === name))\n setChecked(true)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n setBusy(undefined)\n })\n }\n\n const onUpdate = (): void => {\n if (busyRef.current || found === undefined) return\n busyRef.current = true\n setBusy('update')\n setError(undefined)\n void update(found.id).then(result => {\n setFound(undefined)\n setChecked(false)\n setDirty(true)\n // A version that landed but is not loaded is stated as such: the update\n // succeeded, and the plugin's rows are not running until DSH restarts.\n setRestartRequired(result.restartRequired.length > 0 ? result.plugin.version : undefined)\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n setBusy(undefined)\n })\n }\n\n if (!isLoopback) {\n return (\n <section className={css.notice} data-update-patch data-state=\"local-only\">\n <strong>{t('localOnlyTitle')}</strong>\n <p>{t('localOnlyBody')}</p>\n </section>\n )\n }\n\n const requiresDsh = found?.requiresDsh\n const gate = dshGateOf(found)\n const blocked = gate !== 'open'\n // A requirement the host could not verify has two causes — the running DSH\n // version could not be read, or the declared range could not be evaluated —\n // and neither is \"your DSH is too old\". The copy therefore names no cause and\n // sends nobody to upgrade DSH; see `dshGateOf`.\n\n return (\n <section className={css.section} data-update-patch aria-busy={busy !== undefined}>\n <h3 className={css.title}>{t('updateSection')}</h3>\n <div className={css.actionRow}>\n <button\n type=\"button\"\n className={css.button}\n disabled={busy !== undefined}\n onClick={onCheck}\n >\n {busy === 'check' ? t('checking') : t('checkUpdates')}\n </button>\n {checked && found === undefined && busy === undefined && (\n <p className={css.ok}>{t('noUpdates')}</p>\n )}\n {found !== undefined && (\n <span className={css.latest} data-update-latest={found.latest}>{t('latest', { version: found.latest })}</span>\n )}\n {found !== undefined && (requiresDsh !== undefined || blocked) && (\n <span\n className={blocked ? css.compatBlocked : css.compatHint}\n data-update-compat={blocked ? 'blocked' : 'ok'}\n data-update-compat-reason={blocked ? gate : undefined}\n >\n {requiresDsh !== undefined\n ? t(gate === 'open' ? 'updateRequiresDsh' : gate === 'unverified' ? 'updateUnverifiedDsh' : 'updateBlockedDsh', {\n min: displayMinimumVersion(requiresDsh),\n })\n : t('updateUnverifiedDshUnknownRange')}\n </span>\n )}\n {found !== undefined && (\n <button\n type=\"button\"\n className={`${css.button} ${css.primary}`}\n disabled={busy !== undefined || blocked}\n onClick={onUpdate}\n >\n {busy === 'update' ? t('updating') : t('update')}\n </button>\n )}\n </div>\n\n {busy === 'update' && (\n <div className={css.progressRow} role=\"status\">\n <div className={css.progressTrack}>\n <div\n className={css.progressBar}\n style={progress.percent === undefined ? undefined : { width: `${String(progress.percent)}%` }}\n data-indeterminate={progress.percent === undefined ? 'true' : undefined}\n />\n </div>\n <p className={css.hint}>{progressLabel(progress, t)}</p>\n </div>\n )}\n\n {error !== undefined && (\n <p className={css.error} role=\"alert\" data-update-error>{error}</p>\n )}\n\n {restartRequired !== undefined ? (\n <div className={css.restartRow} data-update-restart-required=\"yes\">\n <p>{t('updateRestartRequired', { version: restartRequired })}</p>\n </div>\n ) : dirty && (\n <div className={css.restartRow}>\n <p>{t('restartHint')}</p>\n </div>\n )}\n </section>\n )\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/body-mutations.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * One `document.body` MutationObserver per page, shared by every family\n * plugin bundle.\n *\n * Family plugins that inject at the DOM level must notice when the shell\n * re-renders around their injected node: the aggregate shell's column shims\n * and any plugin surface still extending the shell from outside the official\n * slot seats. Each consumer used to install its OWN `MutationObserver` on\n * `document.body` with\n * `{ childList: true, subtree: true }`, so a page carrying N family plugins\n * paid N native observers and N callback invocations for EVERY mutation batch\n * the app produced — chat token streaming alone produces many per second, and\n * the count grows with the number of installed plugins.\n *\n * This module keeps exactly ONE body observer per page. The registry lives on\n * `globalThis` under a `Symbol.for` key, so the per-package generated copies\n * of this file (scripts/sync-shared.mjs) and separately bundled plugins all\n * reach the same hub at runtime instead of one hub per module instance.\n * Record subscribers receive the mutations accumulated since the last flush.\n * Consumers that only re-check their DOM use subscribeBodyInvalidations:\n * when all subscribers use that path, the hub retains no mutation records\n * (or detached subtrees) while a background page's animation frames pause.\n * Both paths run at most once per frame. The last subscriber disconnects the\n * observer, cancels the pending frame and releases its records.\n *\n * Failure policy: without a DOM or `MutationObserver` the subscription is a\n * no-op disposer (the same silence the per-consumer observers had), and when\n * `requestAnimationFrame` is unavailable the flush runs synchronously so a\n * subscriber is never silently dropped. A throwing subscriber cannot stop the\n * others.\n */\n\n/** The page-wide hub: one observer plus its subscribers and pending records. */\ninterface BodyMutationHub {\n observer: MutationObserver\n subscribers: Set<(records: MutationRecord[]) => void>\n pending: MutationRecord[]\n scheduled: boolean\n frame?: number\n}\n\n/** Cross-bundle registry key; `Symbol.for` so every module copy agrees. */\nconst HUB_KEY = Symbol.for('dsh-web.body-mutation-hub')\nconst INVALIDATION_ONLY = Symbol.for('dsh-web.body-mutation-invalidation')\ntype Subscriber = ((records: MutationRecord[]) => void) & { [INVALIDATION_ONLY]?: true }\n\nfunction needsRecords(subscribers: Set<(records: MutationRecord[]) => void>): boolean {\n for (const listener of subscribers) {\n if (!(listener as Subscriber)[INVALIDATION_ONLY]) return true\n }\n return false\n}\n\n/**\n * Subscribe to a coalesced DOM re-check without retaining mutation records.\n * The marked wrapper also works with an older hub, which delivers records\n * that it simply ignores until a page reload picks up the updated hub.\n */\nexport function subscribeBodyInvalidations(subscriber: () => void): () => void {\n const listener: Subscriber = () => { subscriber() }\n listener[INVALIDATION_ONLY] = true\n return subscribeBodyMutations(listener)\n}\n\n/**\n * Subscribe to body-level childList mutations.\n * @param subscriber - called at most once per animation frame with the records\n * collected since the previous flush; must be safe to run repeatedly.\n * @returns the disposer removing this subscriber (and the observer when it was\n * the last one).\n */\nexport function subscribeBodyMutations(subscriber: (records: MutationRecord[]) => void): () => void {\n if (typeof globalThis === 'undefined' || typeof document === 'undefined') return () => {}\n if (typeof MutationObserver !== 'function') return () => {}\n const registry = globalThis as unknown as Record<symbol, unknown>\n let hub = registry[HUB_KEY] as BodyMutationHub | undefined\n if (hub === undefined) {\n const subscribers = new Set<(records: MutationRecord[]) => void>()\n const created: BodyMutationHub = {\n observer: undefined as unknown as MutationObserver,\n subscribers,\n pending: [],\n scheduled: false,\n }\n const flush = (): void => {\n created.frame = undefined\n created.scheduled = false\n const batch = created.pending\n created.pending = []\n for (const listener of [...subscribers]) {\n if (!subscribers.has(listener)) continue\n try {\n listener(batch)\n } catch {\n // One subscriber must never break the others; the next flush retries it.\n }\n }\n }\n const schedule = (): void => {\n if (created.scheduled) return\n created.scheduled = true\n if (typeof requestAnimationFrame === 'function') created.frame = requestAnimationFrame(flush)\n else flush()\n }\n created.observer = new MutationObserver((records) => {\n if (needsRecords(subscribers)) {\n for (const record of records) created.pending.push(record)\n }\n schedule()\n })\n created.observer.observe(document.body ?? document.documentElement, { childList: true, subtree: true })\n registry[HUB_KEY] = created\n hub = created\n }\n const active = hub\n active.subscribers.add(subscriber)\n let subscribed = true\n return () => {\n if (!subscribed) return\n subscribed = false\n active.subscribers.delete(subscriber)\n if (!needsRecords(active.subscribers)) active.pending = []\n if (active.subscribers.size === 0 && registry[HUB_KEY] === active) {\n active.observer.disconnect()\n if (active.frame !== undefined && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(active.frame)\n active.frame = undefined\n active.pending = []\n active.scheduled = false\n delete registry[HUB_KEY]\n }\n }\n}\n","/**\n * Which update rows the list-level toolbar may act on. Pure, shared by the\n * browser half (the toolbar) and its tests: the host answers with every\n * installed package whose registry source serves a newer release, and the\n * policy of what may be updated in bulk lives here rather than in the host,\n * so the same rows stay available to the per-page update block.\n *\n * Two filters:\n *\n * - **Third-party only.** A package published under the `@deepseek-ai/` scope\n * ships with DSH itself: its version is chosen by the running installation,\n * the official page says an upgrade arrives by upgrading DSH, and a\n * plugin-initiated `pnpm add` of such a package can pull a release the runtime was\n * never tested against. The bulk action therefore never touches it.\n * - **Compatibility gate.** An update whose manifest declares a DSH minimum the\n * running host does not satisfy is listed (the user may still upgrade DSH)\n * but cannot be applied: the host would refuse it with 412 anyway.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { PluginUpdateItem } from './protocol.ts'\n\n/** The npm scope DSH's own packages are published under. */\nexport const OFFICIAL_SCOPE = '@deepseek-ai/'\n\n/** Whether a package id is a third-party plugin rather than a DSH-shipped one. */\nexport function isThirdPartyPlugin(id: string): boolean {\n return !id.startsWith(OFFICIAL_SCOPE)\n}\n\n/** The third-party update rows, in host order. */\nexport function thirdPartyUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[] {\n return items.filter(item => isThirdPartyPlugin(item.id))\n}\n\n/** Whether the running DSH host satisfies the row's declared minimum. */\nexport function isUpdateApplicable(item: PluginUpdateItem): boolean {\n return item.compatible !== false\n}\n\n/** The third-party rows this runtime can actually apply. */\nexport function applicableUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[] {\n return thirdPartyUpdates(items).filter(isUpdateApplicable)\n}\n","/**\n * The list-level toolbar: check every installed third-party plugin for a newer\n * registry release, apply them in one run, then restart DSH to load them.\n *\n * It exists because the official Plugins page compares one package at a time\n * (its `plugins.detail.section` contributions render on a bundle's page), while\n * the answer a user wants when they open the page is \"is anything of mine out\n * of date, and can I just fix it\". It is mounted beside the page's \"Installed\"\n * heading (see plugin-toolbar-mount.tsx) because that heading is the page's own\n * chrome and the page declares no seat next to it.\n *\n * Policy lives in core/updates.ts (third-party only, compatibility-gated) and\n * the operations come from the injected face, so this component is pure\n * rendering plus the sequence of calls: nothing here touches the DOM beyond its\n * own subtree.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PluginUpdateItem, PluginUpdateResult, RestartMode } from '../core/protocol.ts'\nimport { applicableUpdates, thirdPartyUpdates } from '../core/updates.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport { dshGateOf } from './PluginUpdatePatch.tsx'\nimport css from './plugin-manager.module.css'\n\n/** The operations the toolbar drives (the package's dual-channel face). */\nexport interface PluginListToolbarInjected {\n /** Whether this browser has loopback authority to use the host routes. */\n isLoopback: boolean\n /** Compare every installed plugin against the version its source serves. */\n checkUpdates: () => Promise<PluginUpdateItem[]>\n /**\n * Re-install one plugin from its recorded source. Resolves with what landed:\n * the row at the new version, plus the bundles only a restart loads. A landed\n * update that needs a restart keeps the batch running instead of failing it.\n */\n update: (id: string) => Promise<PluginUpdateResult>\n /**\n * Read how a restart would be carried out, without carrying it out: the\n * confirmation must name the same consequence the host will produce (an\n * in-place relaunch, the packaged Desktop shell's own recovery dialog, or a\n * manual restart), and a plan read has no side effects.\n */\n restartPlan: () => Promise<RestartMode>\n /** Restart the host so an applied update is loaded. */\n restart: () => Promise<RestartMode>\n}\n\n/** Full component props. */\nexport type PluginListToolbarProps =\n & PropsLocale<'settings.pluginManager'>\n & PluginListToolbarInjected\n\n/** Error text for a caught request or lifecycle failure. */\nfunction messageOf(error: unknown): string {\n if (error instanceof AggregateError) {\n const details = error.errors.map(messageOf).join('; ')\n return details === '' ? error.message : `${error.message}: ${details}`\n }\n return error instanceof Error ? error.message : String(error)\n}\n\n/** What the toolbar is currently doing. */\ntype Phase = 'idle' | 'checking' | 'updating'\n\n/** Which flyout is open under the buttons. */\ntype Panel = 'none' | 'list' | 'restart'\n\n/**\n * The toolbar itself. All state is local: the page around it owns the plugin\n * list, and a restart tears this component down anyway.\n */\nexport function PluginListToolbar(props: PluginListToolbarProps) {\n const { t, isLoopback, checkUpdates, update, restartPlan, restart } = props\n\n const [phase, setPhase] = useState<Phase>('idle')\n const [checked, setChecked] = useState(false)\n /** Every third-party row the last check reported, including the applied ones. */\n const [found, setFound] = useState(0)\n const [rows, setRows] = useState<PluginUpdateItem[]>([])\n const [applied, setApplied] = useState<string[]>([])\n /**\n * Updates this run applied whose new version the running host has not loaded,\n * with the version that landed. They stay in `applied` — the update did go\n * through — and are listed as needing a restart instead of leaving the panel\n * claiming a plain success.\n */\n const [restartRequired, setRestartRequired] = useState<{ id: string; version: string }[]>([])\n const [cursor, setCursor] = useState<{ name: string; index: number; total: number } | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [panel, setPanel] = useState<Panel>('none')\n /** How the host says it would restart, read before the confirmation is shown. */\n const [plan, setPlan] = useState<RestartMode | undefined>(undefined)\n const [restartMode, setRestartMode] = useState<RestartMode | undefined>(undefined)\n /** Synchronous in-flight mirror of the phase: a click and a keypress can land in one frame. */\n const busyRef = useRef(false)\n\n const pending = applicableUpdates(rows)\n\n /** Close the flyout on Escape, the shell's own dismissal gesture. */\n useEffect(() => {\n if (panel === 'none') return\n const onKey = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') setPanel('none')\n }\n window.addEventListener('keydown', onKey)\n return () => { window.removeEventListener('keydown', onKey) }\n }, [panel])\n\n const onCheck = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setPhase('checking')\n setError(undefined)\n setRestartMode(undefined)\n void checkUpdates().then(items => {\n const thirdParty = thirdPartyUpdates(items)\n setRows(thirdParty)\n setFound(thirdParty.length)\n setApplied([])\n setRestartRequired([])\n setChecked(true)\n setPanel('list')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setPanel('list')\n }).finally(() => {\n busyRef.current = false\n setPhase('idle')\n })\n }\n\n const onUpdateAll = (): void => {\n if (busyRef.current) return\n const queue = applicableUpdates(rows)\n if (queue.length === 0) return\n busyRef.current = true\n setPhase('updating')\n setError(undefined)\n void (async () => {\n const done: string[] = []\n for (const [index, row] of queue.entries()) {\n setCursor({ name: row.id, index: index + 1, total: queue.length })\n try {\n const result = await update(row.id)\n // The update landed; when this process cannot load it, the run still\n // counts as applied and continues, and the panel names the restart.\n if (result.restartRequired.length > 0) {\n setRestartRequired(current => [...current, { id: row.id, version: result.plugin.version }])\n }\n } catch (reason) {\n // Stop at the first failure: the remaining rows stay listed with their\n // versions, so the user sees exactly what did not go through.\n setError(t('failed', { reason: messageOf(reason) }))\n break\n }\n done.push(row.id)\n setApplied([...done])\n setRows(current => current.filter(item => item.id !== row.id))\n }\n setCursor(undefined)\n })().finally(() => {\n busyRef.current = false\n setPhase('idle')\n })\n }\n\n /** Ask the host how it would restart, then show the confirmation that matches. */\n const onAskRestart = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setError(undefined)\n void restartPlan().then(mode => {\n setPlan(mode)\n setPanel('restart')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n setPanel('list')\n }).finally(() => {\n busyRef.current = false\n })\n }\n\n const onRestart = (): void => {\n if (busyRef.current) return\n busyRef.current = true\n setError(undefined)\n void restart().then(mode => {\n setRestartMode(mode)\n setPlan(undefined)\n setPanel('none')\n }).catch(reason => {\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n busyRef.current = false\n })\n }\n\n const shellProps = {\n 'data-dsh-plugin': 'plugin-manager',\n 'data-dsh-part': 'update-toolbar',\n 'data-update-toolbar': true,\n } as const\n\n if (!isLoopback) {\n return (\n <div className={css.toolbar} {...shellProps} data-state=\"local-only\">\n <button type=\"button\" className={css.toolbarButton} disabled title={t('localOnlyBody')}>\n {t('checkUpdates')}\n </button>\n </div>\n )\n }\n\n const busy = phase !== 'idle'\n /** One alert line, rendered in whichever flyout is open when it appears. */\n const errorLine = error === undefined\n ? null\n : <p className={css.error} role=\"alert\" data-update-error>{error}</p>\n /** What is still pending after a partial run (the applied rows leave the list). */\n const remaining = found - applied.length\n const summary = cursor !== undefined\n ? t('updatingAll', { name: cursor.name, index: String(cursor.index), total: String(cursor.total) })\n : remaining > 0\n ? t('updatesAvailable', { count: String(remaining) })\n : applied.length > 0\n ? t('updateAllDone')\n : t('noUpdates')\n\n return (\n <div className={css.toolbar} {...shellProps} data-state={restartMode ?? phase} aria-busy={busy}>\n <button type=\"button\" className={css.toolbarButton} data-update-check disabled={busy} onClick={onCheck}>\n {phase === 'checking' ? t('checking') : t('checkUpdates')}\n </button>\n\n {checked && (\n <button\n type=\"button\"\n className={css.toolbarSummary}\n data-update-summary\n data-pending={pending.length}\n aria-expanded={panel === 'list'}\n onClick={() => { setPanel(panel === 'list' ? 'none' : 'list') }}\n >\n {summary}\n </button>\n )}\n\n <button\n type=\"button\"\n className={applied.length > 0 ? `${css.toolbarButton} ${css.primary}` : css.toolbarButton}\n data-update-restart\n data-restart-pending={applied.length}\n disabled={busy || restartMode === 'relaunch'}\n onClick={() => { if (panel === 'restart') { setPanel('none'); setPlan(undefined); return } onAskRestart() }}\n >\n {restartMode === 'relaunch' ? t('restarting') : t('restartNow')}\n </button>\n\n {restartMode !== undefined && panel !== 'restart' && (\n <span className={css.toolbarHint} role=\"status\" data-update-restart-hint={restartMode}>\n {restartMode === 'shell' ? t('restartDesktopHint') : restartMode === 'manual' ? t('restartManualHint') : t('restartRelaunchHint')}\n </span>\n )}\n\n {panel === 'list' && (\n <div className={css.panel} data-update-panel role=\"group\" aria-label={t('updatesPanelTitle')}>\n {errorLine}\n {applied.length > 0 && <p className={css.ok} data-update-applied>{t('updateAllDone')}</p>}\n {restartRequired.length > 0 && (\n <ul className={css.restartRequired} data-update-restart-required>\n {restartRequired.map(item => (\n <li key={item.id} className={css.panelRow} data-update-restart-row={item.id}>\n <span className={css.panelName}>{item.id}</span>\n <span className={css.restartRequiredLine}>{t('updateRestartRequired', { version: item.version })}</span>\n </li>\n ))}\n </ul>\n )}\n {rows.length === 0 && applied.length === 0 && error === undefined && <p className={css.hint}>{t('noUpdates')}</p>}\n {rows.length > 0 && (\n <ul className={css.panelList}>\n {rows.map(row => {\n // One verdict per row, read once: the badge, its copy and the\n // bulk action's exclusion all come from the same answer.\n const gate = dshGateOf(row)\n return (\n <li key={row.id} className={css.panelRow} data-update-row={row.id} data-compatible={gate === 'open' ? 'yes' : 'no'}>\n <span className={css.panelName}>{row.id}</span>\n <span className={css.panelVersion}>{row.current} → {row.latest}</span>\n {gate === 'open' ? null : (\n <span className={css.compatBlocked} data-update-row-compat-reason={gate}>\n {row.requiresDsh !== undefined\n ? t(gate === 'unverified' ? 'updateUnverifiedDsh' : 'updateBlockedDsh', {\n min: displayMinimumVersion(row.requiresDsh),\n })\n : t('updateUnverifiedDshUnknownRange')}\n </span>\n )}\n </li>\n )\n })}\n </ul>\n )}\n <div className={css.panelActions}>\n {pending.length > 0 && (\n <button type=\"button\" className={`${css.button} ${css.primary}`} data-update-all disabled={busy} onClick={onUpdateAll}>\n {phase === 'updating' ? t('updating') : t('updateAll', { count: String(pending.length) })}\n </button>\n )}\n {applied.length > 0 && (\n <button type=\"button\" className={`${css.button} ${css.primary}`} data-update-panel-restart disabled={busy} onClick={onAskRestart}>\n {t('restartNow')}\n </button>\n )}\n </div>\n <p className={css.hint}>{t('thirdPartyOnly')}</p>\n </div>\n )}\n\n {panel === 'restart' && (\n <div className={css.panel} data-update-restart-panel data-restart-plan={plan} role=\"group\" aria-label={t('restartNow')}>\n {errorLine}\n <p className={css.hint} data-restart-plan-hint={plan}>\n {plan === 'shell' ? t('restartPlanShell') : plan === 'manual' ? t('restartPlanManual') : t('restartPlanRelaunch')}\n </p>\n {plan === 'shell' && <p className={css.hint}>{t('restartShellWarning')}</p>}\n <div className={css.panelActions}>\n <button type=\"button\" className={css.button} data-restart-cancel onClick={() => { setPanel('none'); setPlan(undefined) }}>\n {t('cancel')}\n </button>\n {plan !== 'manual' && (\n <button\n type=\"button\"\n className={`${css.button} ${css.primary}`}\n data-restart-confirm\n onClick={onRestart}\n >\n {t('restartConfirm')}\n </button>\n )}\n </div>\n </div>\n )}\n </div>\n )\n}\n","/**\n * Mounting the update toolbar beside the official Plugins page's \"Installed\"\n * heading.\n *\n * The page renders that heading itself — `<section data-plugin-group=\"bundles\">\n * <div class=\"groupHead\"><h3>Installed</h3><span>7</span></div>…` — and declares\n * no seat next to it: its extension points are `plugins.detail.*` (per page),\n * `plugins.bundle.config` / `plugins.row.config` / `plugins.item` (configuration\n * entries) and `plugins.bundle.activation`. A list-level action therefore has\n * to be inserted into the page's own chrome, the same way the sidebar foot card\n * is inserted above the Settings row.\n *\n * The container is a plain element carrying its own React root, so it can never\n * disturb the page's reconciliation, and it re-seats itself through the\n * page-wide body-mutation hub: a re-render that relocates or drops the heading\n * is followed on the next frame, and a panel switch that unmounts the list\n * simply detaches the container until the list returns.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { createElement } from 'react'\nimport { createRoot, type Root } from 'react-dom/client'\nimport { subscribeBodyInvalidations } from './body-mutations.ts'\nimport { PluginListToolbar, type PluginListToolbarProps } from './PluginListToolbar.tsx'\nimport css from './plugin-manager.module.css'\n\n/** Stable attribute identifying the injected container (mount idempotency). */\nexport const TOOLBAR_MOUNT_SELECTOR = '[data-dsh-plugin-manager-toolbar]'\n\n/** Toolbar props without the translate function, which is rebuilt per render. */\nexport type PluginListToolbarMountInput = Omit<PluginListToolbarProps, 't'> & {\n /** Translate in the namespace, read on every render so a language switch lands. */\n t: PluginListToolbarProps['t']\n}\n\n/** The mount's inputs. */\nexport interface PluginToolbarMountOptions {\n /** Build the toolbar props; called on mount and on every locale change. */\n props: () => PluginListToolbarMountInput\n /** Locale change subscription (ctx.locale.subscribe); re-renders the toolbar. */\n subscribe?: (listener: () => void) => () => void\n}\n\n/**\n * The official page's \"Installed\" group heading, when it is mounted. Class\n * names are CSS-module hashes in the official bundle, so the seat is found\n * through the page's own data attributes plus DOM position.\n * @returns the heading element to append into, or undefined off the list view.\n */\nexport function toolbarSeat(): HTMLElement | undefined {\n const page = document.querySelector('[data-plugin-panel]')\n const group = page?.querySelector('[data-plugin-group=\"bundles\"]')\n const head = group?.firstElementChild\n return head instanceof HTMLElement ? head : undefined\n}\n\n/**\n * Mount the toolbar into the Installed heading.\n * @param options - props factory and the optional locale subscription.\n * @returns disposer removing the container, its observers and its React root.\n */\nexport function mountPluginListToolbar(options: PluginToolbarMountOptions): () => void {\n if (typeof document === 'undefined') return () => {}\n // DOM-level idempotency: whatever path mounted a toolbar before this call\n // (a duplicated apply, an HMR re-injection), never mount a second one.\n if (document.querySelector(TOOLBAR_MOUNT_SELECTOR) !== null) return () => {}\n\n const container = document.createElement('div')\n container.setAttribute('data-dsh-plugin-manager-toolbar', '')\n container.className = css.mount\n const root: Root = createRoot(container)\n const render = (): void => {\n root.render(createElement(PluginListToolbar, options.props()))\n }\n render()\n\n /** Keep the container inside the heading; detach while the list is away. */\n const place = (): void => {\n const seat = toolbarSeat()\n if (seat === undefined) {\n container.remove()\n return\n }\n if (container.parentElement !== seat) seat.append(container)\n }\n place()\n\n const unsubscribeBody = subscribeBodyInvalidations(place)\n const unsubscribeLocale = options.subscribe === undefined ? ((): void => {}) : options.subscribe(render)\n\n return () => {\n unsubscribeBody()\n unsubscribeLocale()\n root.unmount()\n container.remove()\n }\n}\n","/**\n * Locale dictionaries for the plugin-manager's official-page patch. The zh\n * dictionary is the key source; the en dictionary mirrors the exact key set.\n *\n * The key set covers only what this package renders: the check-for-updates\n * block on a bundle's page in the official Plugins panel, and the list-level\n * update toolbar mounted beside that panel's \"Installed\" heading.\n * The former tab's keys (inventory, conflicts, repair seeds, safe mode,\n * aggregate children) left with that tab.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n/** Simplified Chinese copy (the key-set source of truth). */\nconst STATIC_ZH = {\n 'updateSection': '更新',\n 'checkUpdates': '检查更新',\n 'checking': '检查中…',\n 'noUpdates': '已是最新版本。',\n 'update': '更新',\n 'updating': '更新中…',\n 'latest': '最新 {version}',\n 'updateRequiresDsh': '需要 DSH ≥ {min}',\n 'updateBlockedDsh': '需要 DSH ≥ {min},请先升级 DSH 再更新',\n 'updateUnverifiedDsh': '无法核验本机 DSH 与该声明的兼容性(需要 DSH ≥ {min}),已暂停更新',\n 'updateUnverifiedDshUnknownRange': '无法核验该插件声明的 DSH 兼容范围,已暂停更新',\n 'restartHint': '插件变更将在重启应用后生效。',\n 'updatesAvailable': '{count} 个可更新',\n 'updateAll': '全部更新({count})',\n 'updatingAll': '更新 {name}({index}/{total})',\n 'updateAllDone': '更新完成,重启后生效。',\n 'updateRestartRequired': '已更新到 {version},需重启 DSH 后生效',\n 'updatesPanelTitle': '插件更新',\n 'thirdPartyOnly': '只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。',\n 'restartNow': '立即重启',\n 'restarting': '正在重启…',\n 'restartConfirm': '确认重启',\n 'restartPlanRelaunch': '会重启 DSH 服务,正在运行的任务会中断。',\n 'restartPlanShell': '桌面版重启由应用外壳执行:确认后宿主进程会退出,由外壳重新拉起。',\n 'restartPlanManual': '当前进程无法自动重启,请手动重启 DSH。',\n 'restartShellWarning': '它同时会写一份崩溃报告;也可以手动重启:退出 DeepSeek Harness(⌘Q)后重新打开。',\n 'restartDesktopHint': '请在随后出现的系统对话框中选择「重启」。',\n 'restartRelaunchHint': '已请求重启;服务恢复后刷新页面即可。',\n 'restartManualHint': '当前进程无法自动重启,请手动重启 DSH。',\n 'cancel': '取消',\n 'failed': '操作失败:{reason}',\n 'fetching': '正在获取插件信息…',\n 'downloading': '正在下载…',\n 'downloadingPercent': '正在下载 {percent}%',\n 'extracting': '正在解压…',\n 'writing': '正在写入配置…',\n 'localOnlyTitle': '仅限本机操作',\n 'localOnlyBody': '为了保护主机配置,插件管理只能从本机打开。'\n} satisfies Record<string, string>\n\n/** English copy, checked complete against the zh key set. */\nconst STATIC_EN = {\n 'updateSection': 'Update',\n 'checkUpdates': 'Check for updates',\n 'checking': 'Checking…',\n 'noUpdates': 'The installed version is the latest.',\n 'update': 'Update',\n 'updating': 'Updating…',\n 'latest': 'Latest {version}',\n 'updateRequiresDsh': 'Requires DSH >= {min}',\n 'updateBlockedDsh': 'Requires DSH >= {min}; upgrade DSH before updating',\n 'updateUnverifiedDsh': 'Cannot verify this host against the declared DSH range (this update needs DSH >= {min}); update paused',\n 'updateUnverifiedDshUnknownRange': 'Cannot verify the DSH range this plugin declares; update paused',\n 'restartHint': 'Plugin changes take effect after restarting the application.',\n 'updatesAvailable': '{count} updates available',\n 'updateAll': 'Update all ({count})',\n 'updatingAll': 'Updating {name} ({index}/{total})',\n 'updateAllDone': 'Updated; restart to take effect.',\n 'updateRestartRequired': 'Updated to {version}; restart DSH for it to take effect',\n 'updatesPanelTitle': 'Plugin updates',\n 'thirdPartyOnly': 'Third-party plugins only; @deepseek-ai/ packages upgrade with DSH itself.',\n 'restartNow': 'Restart now',\n 'restarting': 'Restarting…',\n 'restartConfirm': 'Restart',\n 'restartPlanRelaunch': 'The DSH service restarts; running tasks are interrupted.',\n 'restartPlanShell': 'The desktop app performs the restart: confirming stops the host process and the shell brings a new one up.',\n 'restartPlanManual': 'This process cannot restart itself; restart DSH yourself.',\n 'restartShellWarning': 'It also writes a crash report. You can instead restart manually: quit DeepSeek Harness (Cmd+Q) and open it again.',\n 'restartDesktopHint': 'Choose Restart in the system dialog that follows.',\n 'restartRelaunchHint': 'Restart requested; reload the page once the server is back.',\n 'restartManualHint': 'This process cannot restart itself; restart DSH yourself.',\n 'cancel': 'Cancel',\n 'failed': 'Operation failed: {reason}',\n 'fetching': 'Fetching plugin metadata…',\n 'downloading': 'Downloading…',\n 'downloadingPercent': 'Downloading {percent}%',\n 'extracting': 'Extracting…',\n 'writing': 'Writing configuration…',\n 'localOnlyTitle': 'Available on this computer only',\n 'localOnlyBody': 'To protect host configuration, plugin management is only available from a local browser.'\n} satisfies Record<keyof typeof STATIC_ZH, string>\n\nexport const zh = STATIC_ZH\nexport const en = STATIC_EN\nexport type PluginManagerKey = keyof typeof STATIC_ZH\n","/**\n * Wire parsing for the official plugin-installer / plugin-control RPC\n * channels. This package is a browser-side consumer of those channels: every\n * response is decoded but untrusted, so each parser validates the shape it\n * needs and throws a typed error on mismatch. Callers treat a parse failure\n * as \"channel unavailable or drifted\" and degrade to command hints.\n *\n * The shapes mirror the official web installer tab's wire protocol (see the\n * DSH checkout's packages/client/ui-settings-plugin-installer/src/client/\n * protocol.ts); they are a contract observation, not an import.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\n/** One loader entry row claimed by an installed bundle package (aggregate child). */\nexport interface InstalledPluginChild {\n /** The loader entry id, e.g. web-ui-pet. */\n id: string\n /** Display name: the real plugin package (shell config.plugin) when known. */\n name: string\n /** Effective next-start enablement of this row alone (bundle default plus user override). */\n enabled: boolean\n /** Rows the manager must never disable (the manager tab itself, the compat face). */\n locked?: boolean\n}\n\n/** One installed user-plugin row served by `/plugin-installer list`. */\nexport interface InstalledPluginItem {\n id: string\n name: string\n version: string\n source: { kind: 'npm' | 'git'; spec: string }\n installedAt: string\n /** Effective next-start enablement across the bundle's own rows and the managed profile patch row. */\n enabled: boolean\n commit?: string\n /**\n * Entry rows this package's bundle patch claims, present when the package\n * is an aggregate claiming more than one row (gateway mode only — the\n * official channel wire has no children). Child enablement is individually\n * switchable; uninstall stays whole-package (the code ships in one npm\n * package).\n */\n children?: InstalledPluginChild[]\n}\n\n/**\n * How the host carried out (or refused) a restart request:\n * `relaunch` — this host re-executes itself in place; `shell` — the packaged\n * Desktop shell owns the process tree and runs its own restart; `manual` —\n * neither is safe here, the user restarts DSH themselves.\n */\nexport type RestartMode = 'relaunch' | 'shell' | 'manual'\n\n/**\n * The result of one applied update: the installed row, plus the host's verdict\n * on whether this process can serve it without a restart.\n *\n * The two facts are separate because they answer different questions and must\n * not be folded into one: the version landed (the row carries it), and the\n * running host may still not have loaded it. Reporting the second as an error\n * would be wrong twice over — the update did apply, and a batch update stops on\n * the first error it sees — so it travels as an accompanying fact instead.\n */\nexport interface PluginUpdateResult {\n /** The installed row, at the version the update landed on. */\n plugin: InstalledPluginItem\n /**\n * Bundles whose new version is on disk but which the running host has not\n * loaded, empty when the update took effect in place. The official manager\n * reports this as `application: 'restart-required'` (issue #1905); the\n * official installer channel carries no such fact, so it answers an empty\n * list.\n */\n restartRequired: 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/** Whether an update row is a normal same-name update or a legacy package migration. */\nexport type PluginUpdateKind = 'update' | 'migrate'\n\n/** One plugin with a newer version available. */\nexport interface PluginUpdateItem {\n id: string\n current: string\n latest: string\n /** Normal same-name update or legacy aggregate migration. Defaults to update. */\n kind?: PluginUpdateKind\n /** Target package name when kind is migrate. */\n target?: string\n /** Exact target package version when kind is migrate. */\n targetVersion?: string\n /** Declared DSH minimum the update needs (package manifest's `dsh.engines.dsh`). */\n requiresDsh?: string\n /** Whether the running DSH host satisfies requiresDsh; absent when unknown. */\n compatible?: boolean\n /**\n * The running DSH version the verdict was made from, present only when the\n * host compared it and found it below the declaration. Its absence is what\n * separates \"this host is too old\" from \"we could not verify\" — a host that\n * could not be read, or a declaration that could not be parsed; different\n * problems, with different copy (issues #1819 and #1899).\n */\n hostVersion?: string\n}\n\n/** One recorded plugin boot failure served by the host. */\nexport interface PluginFailureItem {\n /** Installed plugin id (package name); empty for unattributable failures. */\n pluginId: string\n kind: 'load-failure' | 'hang' | 'late-rejection'\n message: string\n stack: string\n installPath: string\n at: string\n}\n\n/** Recovery facts served by the host: the failure ring, the plugin root, and safe mode. */\nexport interface PluginFailuresSnapshot {\n items: PluginFailureItem[]\n /** Absolute plugin install root — the repair conversation's workspace. */\n pluginRoot: string\n /** Whether the host is running in safe mode (user plugins skipped). */\n safeMode: boolean\n}\n\n/** Whether a decoded value is a non-array object. */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Whether a decoded value is a string. */\nfunction isString(value: unknown): value is string {\n return typeof value === 'string'\n}\n\n/** Validate one aggregate child row. */\nfunction parsePluginChild(value: unknown, rowIndex: number, childIndex: number): InstalledPluginChild {\n if (!isRecord(value) || !isString(value.id) || !isString(value.name) || typeof value.enabled !== 'boolean') {\n throw new Error(`plugin-manager: plugin row ${String(rowIndex)} child ${String(childIndex)} is invalid`)\n }\n return {\n id: value.id,\n name: value.name,\n enabled: value.enabled,\n ...typeof value.locked === 'boolean' ? { locked: value.locked } : {},\n }\n}\n\n/** Validate one installed-plugin row. */\nfunction parsePlugin(value: unknown, index: number): InstalledPluginItem {\n if (!isRecord(value) || !isString(value.id) || !isString(value.name)\n || !isString(value.version) || !isString(value.installedAt)\n || typeof value.enabled !== 'boolean'\n || !isRecord(value.source) || (value.source.kind !== 'npm' && value.source.kind !== 'git')\n || !isString(value.source.spec)) {\n throw new Error(`plugin-manager: plugin row ${String(index)} is invalid`)\n }\n if (value.children !== undefined && !Array.isArray(value.children)) {\n throw new Error(`plugin-manager: plugin row ${String(index)} children is invalid`)\n }\n const children = (value.children as unknown[] | undefined)?.map((child, childIndex) => parsePluginChild(child, index, childIndex))\n return {\n id: value.id,\n name: value.name,\n version: value.version,\n source: { kind: value.source.kind, spec: value.source.spec },\n installedAt: value.installedAt,\n enabled: value.enabled,\n ...isString(value.commit) ? { commit: value.commit } : {},\n ...children !== undefined ? { children } : {},\n }\n}\n\n/**\n * Validate and normalize a `list` / `uninstall` response value.\n * @param value - decoded but untrusted response value.\n * @returns typed installed-plugin rows.\n */\nexport function parsePluginList(value: unknown): InstalledPluginItem[] {\n if (!isRecord(value) || !Array.isArray(value.plugins)) {\n throw new Error('plugin-manager: response must contain a plugins array')\n }\n return value.plugins.map((plugin, index) => parsePlugin(plugin, index))\n}\n\n/**\n * Validate and normalize an `install` / `update` / `set-enabled` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed installed-plugin row.\n */\nexport function parseInstalledPlugin(value: unknown): InstalledPluginItem {\n if (!isRecord(value) || value.plugin === undefined) {\n throw new Error('plugin-manager: response must contain a plugin row')\n }\n return parsePlugin(value.plugin, 0)\n}\n\n/**\n * Read the restart-required list off one gateway job (or off anything else\n * carrying it).\n *\n * Deliberately tolerant where the other parsers in this module throw: this list\n * is a hint attached to an update that already landed, so an unreadable value\n * must cost the user the hint only. Throwing would reject an applied update and\n * stop a batch run — the exact outcome the fact exists to avoid.\n * @param value - decoded but untrusted job value.\n * @returns the bundle names, empty when the value is absent or unusable.\n */\nexport function parseRestartRequired(value: unknown): string[] {\n if (!Array.isArray(value)) return []\n const names: string[] = []\n for (const item of value) {\n if (typeof item === 'string' && item !== '') names.push(item)\n }\n return names\n}\n\n/**\n * Validate and normalize a `status` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed progress state.\n */\nexport function parseInstallStatus(value: unknown): InstallProgressItem {\n if (!isRecord(value) || !isRecord(value.progress)\n || (value.progress.kind !== 'idle' && value.progress.kind !== 'install' && value.progress.kind !== 'update')\n || (value.progress.stage !== 'fetch' && value.progress.stage !== 'download'\n && value.progress.stage !== 'extract' && value.progress.stage !== 'write')\n || (value.progress.percent !== undefined\n && (typeof value.progress.percent !== 'number' || !Number.isFinite(value.progress.percent)))) {\n throw new Error('plugin-manager: response must contain a valid progress state')\n }\n return {\n kind: value.progress.kind,\n stage: value.progress.stage,\n ...typeof value.progress.percent === 'number' ? { percent: value.progress.percent } : {},\n }\n}\n\n/**\n * Validate and normalize a `check-updates` response value.\n * @param value - decoded but untrusted response value.\n * @returns typed update rows.\n */\nexport function parseUpdateList(value: unknown): PluginUpdateItem[] {\n if (!isRecord(value) || !Array.isArray(value.updates)) {\n throw new Error('plugin-manager: response must contain an updates array')\n }\n return value.updates.map((update, index) => {\n if (!isRecord(update) || !isString(update.id) || !isString(update.current) || !isString(update.latest)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n const kind = update.kind === undefined ? 'update' : update.kind\n if (kind !== 'update' && kind !== 'migrate') {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n const row: PluginUpdateItem = { id: update.id, current: update.current, latest: update.latest }\n if (kind === 'migrate') {\n if (!isString(update.target) || !isString(update.targetVersion)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.kind = 'migrate'\n row.target = update.target\n row.targetVersion = update.targetVersion\n }\n if (update.requiresDsh !== undefined) {\n if (!isString(update.requiresDsh)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.requiresDsh = update.requiresDsh\n }\n if (update.compatible !== undefined) {\n if (typeof update.compatible !== 'boolean') {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.compatible = update.compatible\n }\n if (update.hostVersion !== undefined) {\n if (!isString(update.hostVersion)) {\n throw new Error(`plugin-manager: update row ${String(index)} is invalid`)\n }\n row.hostVersion = update.hostVersion\n }\n return row\n })\n}\n\n/**\n * Validate and normalize a `restart` response value.\n * @param value - decoded but untrusted response value.\n * @returns the mode the host actually used.\n */\nexport function parseRestartMode(value: unknown): RestartMode {\n const restart = isRecord(value) ? value.restart : undefined\n const mode = isRecord(restart) ? restart.mode : undefined\n if (mode !== 'relaunch' && mode !== 'shell' && mode !== 'manual') {\n throw new Error('plugin-manager: response must contain a restart mode')\n }\n return mode\n}\n\n/**\n * Validate and normalize a `failures` response value.\n * @param value - decoded but untrusted response value.\n * @returns the typed failures snapshot.\n */\nexport function parseFailuresSnapshot(value: unknown): PluginFailuresSnapshot {\n if (!isRecord(value) || !Array.isArray(value.items)\n || !isString(value.pluginRoot) || typeof value.safeMode !== 'boolean') {\n throw new Error('plugin-manager: response must contain a failures snapshot')\n }\n return {\n items: value.items.map((item, index) => {\n if (!isRecord(item) || !isString(item.pluginId)\n || (item.kind !== 'load-failure' && item.kind !== 'hang' && item.kind !== 'late-rejection')\n || !isString(item.message) || !isString(item.stack)\n || !isString(item.installPath) || !isString(item.at)) {\n throw new Error(`plugin-manager: failure row ${String(index)} is invalid`)\n }\n return {\n pluginId: item.pluginId,\n kind: item.kind,\n message: item.message,\n stack: item.stack,\n installPath: item.installPath,\n at: item.at,\n }\n }),\n pluginRoot: value.pluginRoot,\n safeMode: value.safeMode,\n }\n}\n","/**\n * The cordis service contract this package exposes to sibling client plugins\n * under the name `'pluginManager'`. The browser half builds one dual-channel\n * face (official /plugin-installer + /plugin-control RPC channels when\n * available, else this package's loopback HTTP gateway) and provides it via\n * `ctx.provide('pluginManager', face)`; consumers resolve it with\n * `ctx.inject(['pluginManager'], cb)` and read `ctx.pluginManager`.\n *\n * The interface is intentionally narrower than the face the Plugin manager\n * tab receives (`PluginManagerFace` in the client half): it is the stable\n * cross-plugin surface, so it only carries the operations a sibling plugin\n * needs to observe and drive the installed-plugin set.\n * @module @linxin666/dsh-client-ui-plugin-manager/core\n */\n\nimport type { InstallProgressItem, InstalledPluginItem, PluginFailuresSnapshot } from './protocol.ts'\n\n/** The cordis service name the browser half provides the face under. */\nexport const PLUGIN_MANAGER_SERVICE = 'pluginManager'\n\n/**\n * The dual-channel plugin-management face, shared between the Plugin manager\n * tab and sibling client plugins.\n */\nexport interface PluginManagerService {\n /** Whether this browser has loopback authority to use the host routes. */\n readonly isLoopback: boolean\n /** Read the installed snapshot. */\n list(): Promise<InstalledPluginItem[]>\n /** Install one plugin from an npm spec or git URL. */\n install(spec: string): Promise<InstalledPluginItem>\n /** Remove one plugin. */\n uninstall(id: string): Promise<InstalledPluginItem[]>\n /** Read the current install/update progress. */\n status(): Promise<InstallProgressItem>\n /**\n * Read the recorded plugin boot-failure ring (plugin id, message, stack,\n * install path). On runtimes without a failure ring the host answers an\n * empty snapshot.\n */\n failures(): Promise<PluginFailuresSnapshot>\n /**\n * Flip one plugin's next-start enablement through the active channel (the\n * official installer RPC when available, else the loopback gateway's patch\n * `disabled` override row). The change takes effect after the host restart;\n * a running plugin is not stopped.\n */\n setEnabled(id: string, enabled: boolean): Promise<InstalledPluginItem>\n /**\n * Subscribe to successful mutations: the callback runs after install(),\n * update(), uninstall(), or setEnabled() resolves. One listener throwing\n * never breaks the others. Returns the unsubscribe function.\n */\n onChange(cb: () => void): () => void\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n /** The plugin-manager face (provided by the dsh-plugin-manager client half). */\n pluginManager: PluginManagerService\n }\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/telemetry.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * Anonymous install telemetry shared by the DSH Web UI family plugins.\n *\n * Once per UTC day per browser, each wired plugin sends one heartbeat to\n * the dsh-market edge API listing its package name (and version when known).\n * The payload carries no conversation data and no identifiers beyond a random\n * UUID generated in localStorage; the server hashes it with a deployment salt\n * before storage and never persists IP addresses. Sends are fire-and-forget:\n * failures stay silent and simply retry on a later mount or day. Frames where\n * storage is unavailable report nothing.\n *\n * The family-wide opt-out and the browser's Do Not Track signal both suppress\n * the heartbeat; the Web Plugins settings switch writes the same localStorage\n * key. The system is documented in docs/telemetry.md.\n */\n\nexport type TelemetryChannel = 'market' | 'npm' | 'unknown'\n\nexport interface TelemetryItem {\n /** npm package name or asset id, e.g. \"@linxin666/dsh-pet\" or \"skin:harbor\". */\n name: string\n /** Installed version when known; omitted otherwise. */\n version?: string\n /** Install channel when determinable (market = Workshop install). */\n channel?: TelemetryChannel\n}\n\n/** localStorage key carrying the family-wide telemetry opt-out ('1' = off). */\nexport const TELEMETRY_OPT_OUT_KEY = 'dsh-web-ui-telemetry-opt-out'\n\nconst VISITOR_KEY = 'dsh-web-ui-telemetry-visitor'\nconst DAY_KEY_PREFIX = 'dsh-web-ui-telemetry-day:'\nconst ENDPOINT = 'https://dsh-market.com/api/telemetry/event'\n\n// Baked into each client bundle by shared/tsdown.client.ts (the package's own\n// package.json version at build time). Undefined in dev/test builds.\ndeclare const __DSH_PKG_VERSION__: string | undefined\n\n/** The building package's version, when the bundle carries it. */\nfunction bakedVersion(): string | undefined {\n try {\n return typeof __DSH_PKG_VERSION__ === 'string' && __DSH_PKG_VERSION__ !== ''\n ? __DSH_PKG_VERSION__\n : undefined\n } catch {\n return undefined\n }\n}\n\n/** Whether the user switched the family-wide opt-out on (reads storage only). */\nexport function isTelemetryOptedOut(): boolean {\n try {\n return localStorage.getItem(TELEMETRY_OPT_OUT_KEY) === '1'\n } catch {\n // Storage unavailable: there is no stored opt-out to honour.\n return false\n }\n}\n\n/** Turn the family-wide opt-out on or off (writing '1' / removing the key); never throws. */\nexport function setTelemetryOptedOut(optedOut: boolean): void {\n try {\n if (optedOut) localStorage.setItem(TELEMETRY_OPT_OUT_KEY, '1')\n else localStorage.removeItem(TELEMETRY_OPT_OUT_KEY)\n } catch {\n // Storage unavailable: the preference cannot be persisted on this machine.\n }\n}\n\n/** Whether the browser itself asks not to be tracked; a failed read means no signal. */\nfunction doNotTrackRequested(): boolean {\n try {\n // '1' per the DNT header spec, 'yes' from older Firefox builds.\n return navigator.doNotTrack === '1' || navigator.doNotTrack === 'yes'\n } catch {\n return false\n }\n}\n\n/** Whether a heartbeat must be suppressed right now: opt-out stored, or the browser asks not to be tracked. */\nexport function isTelemetrySuppressed(): boolean {\n return isTelemetryOptedOut() || doNotTrackRequested()\n}\n\n/** Read or lazily create the anonymous visitor id; null when storage is unavailable. */\nfunction visitorId(): string | null {\n try {\n const existing = localStorage.getItem(VISITOR_KEY)\n if (existing && /^[A-Za-z0-9_-]{16,64}$/.test(existing)) return existing\n const fresh = crypto.randomUUID().replaceAll('-', '')\n localStorage.setItem(VISITOR_KEY, fresh)\n return fresh\n } catch {\n // Storage unavailable (privacy mode, sandboxed frame): report nothing.\n return null\n }\n}\n\n/** Drop stale per-day dedup keys so localStorage does not grow forever. */\nfunction pruneDayKeys(today: string): void {\n try {\n for (let index = localStorage.length - 1; index >= 0; index -= 1) {\n const key = localStorage.key(index)\n if (key !== null && key.startsWith(DAY_KEY_PREFIX) && key !== DAY_KEY_PREFIX + today) {\n localStorage.removeItem(key)\n }\n }\n } catch { /* best effort */ }\n}\n\n/**\n * Fire the daily heartbeat for the given items at most once per UTC day per\n * browser. Never throws and never blocks the caller. Items without an explicit\n * version inherit the bundle's baked build version.\n */\nexport function reportDailyHeartbeat(items: readonly TelemetryItem[]): void {\n try {\n // First guard: a stored opt-out or the browser's Do Not Track stops every\n // read below from minting an id, marking the day, or reaching the network.\n if (isTelemetrySuppressed()) return\n if (items.length === 0) return\n const today = new Date().toISOString().slice(0, 10)\n // Automation contexts (CDP-driven QA browsers, fresh isolated profiles)\n // mint a new visitor id per run and would inflate instance counts.\n if (navigator.webdriver) return\n if (localStorage.getItem(DAY_KEY_PREFIX + today) !== null) return\n const visitor = visitorId()\n if (visitor === null) return\n pruneDayKeys(today)\n const payloadItems = items.map((item) => {\n const out: Record<string, string> = { name: item.name }\n const version = item.version ?? bakedVersion()\n if (version !== undefined) out.version = version\n if (item.channel !== undefined) out.channel = item.channel\n return out\n })\n const body = JSON.stringify({ kind: 'heartbeat', visitor, items: payloadItems })\n void fetch(ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body,\n keepalive: true,\n }).then((response) => {\n // Mark the day only after an accepted send, so offline browsers retry\n // on a later mount instead of going dark until tomorrow.\n if (response.ok) localStorage.setItem(DAY_KEY_PREFIX + today, '1')\n }).catch(() => { /* unreachable endpoint: stay silent */ })\n } catch { /* never break the host UI over telemetry */ }\n}\n","/**\n * Plugin-manager browser half: contributes the package's one remaining\n * surface — the check-for-updates block on the official Plugins page — and\n * provides the dual-channel face as the `'pluginManager'` cordis service for\n * sibling client plugins.\n *\n * It is dual-channel: on runtimes with the official installer services\n * (DSHCode, the 1.0.4 checkout web) every operation rides the official\n * `/plugin-installer` and `/plugin-control` loopback RPC channels (the single\n * writer); on the npm-published web runtime those channels do not exist, so the\n * same face falls back to this package's own loopback HTTP gateway, which\n * spawns the official CLI for writes. Neither the patch nor service consumers\n * know which mode the face runs in.\n *\n * The package used to register its own \"Plugin manager\" tab into the official\n * Plugins settings section (`settings.plugins.tab`). Installing, uninstalling\n * and enabling moved to the official page long ago, and the tab's remaining\n * half was UI no official page renders; the tab is gone and its one genuinely\n * missing capability — comparing an installed plugin against its registry\n * source, with the DSH-runtime compatibility gate — now renders inside the\n * official page through the `plugins.detail.section` seat it declares.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the renderer plugin's Context merge (ctx.slots, the\n// registry this package registers its contribution into).\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\nimport { PluginUpdatePatch, type PluginUpdatePatchInjected } from './PluginUpdatePatch.tsx'\nimport { mountPluginListToolbar } from './plugin-toolbar-mount.tsx'\nimport { en, zh, type PluginManagerKey } from './locales.ts'\nimport {\n parseFailuresSnapshot,\n parseInstallStatus,\n parseInstalledPlugin,\n parsePluginList,\n parseRestartMode,\n parseRestartRequired,\n parseUpdateList,\n type InstalledPluginItem,\n type InstallProgressItem,\n type PluginFailuresSnapshot,\n type PluginUpdateItem,\n type PluginUpdateResult,\n type RestartMode,\n} from '../core/protocol.ts'\nimport { PLUGIN_MANAGER_SERVICE, type PluginManagerService } from '../core/service.ts'\nimport { reportDailyHeartbeat } from './telemetry.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Copy for the check-for-updates patch. */\n 'settings.pluginManager': PluginManagerKey\n }\n}\n\nconst NS = 'settings.pluginManager'\nconst CHANNEL = '/plugin-installer'\nconst LIST_ENDPOINT = 'list'\nconst INSTALL_ENDPOINT = 'install'\nconst UPDATE_ENDPOINT = 'update'\nconst UNINSTALL_ENDPOINT = 'uninstall'\nconst SET_ENABLED_ENDPOINT = 'set-enabled'\nconst CHECK_UPDATES_ENDPOINT = 'check-updates'\nconst RESTART_ENDPOINT = 'restart'\nconst STATUS_ENDPOINT = 'status'\nconst FAILURES_ENDPOINT = 'failures'\n\n// DOCUMENT-RELATIVE (issue #1707): the GUI is served with `<base href=\"./\">`,\n// so a sub-path deployment resolves the gateway prefix against its entry\n// directory rather than the origin root.\nconst GATEWAY_PREFIX = 'api/plugin-manager'\n/** Gateway job polling cadence. */\nconst JOB_POLL_MS = 500\n/** Gateway job wait ceiling (the host add deadline is six minutes). */\nconst JOB_WAIT_MS = 7 * 60_000\n\n/** Services required by the patch registration and both channels. */\nexport const inject = ['slots', 'locale', 'connection']\n\n/** The gateway job wire shape served by /status. */\ninterface GatewayJobWire {\n phase: 'running' | 'done' | 'error'\n plugin?: unknown\n error?: string\n /**\n * Bundles the job applied but this process has not loaded (the host read\n * `application: 'restart-required'` from the official manager). Optional and\n * untyped here: it is read through {@link parseRestartRequired}, which\n * degrades an unusable value to \"no restart needed\" instead of rejecting an\n * update that already landed.\n */\n restartRequired?: unknown\n}\n\n/**\n * The face the update patch and the `'pluginManager'` cordis service share:\n * the patch's wire surface plus the cross-plugin service contract. The gateway\n * host still records install conflicts and boot failures; no client surface\n * consumes either since the tab left, so neither is on this face.\n */\nexport type PluginManagerFace = PluginUpdatePatchInjected & PluginManagerService & {\n /**\n * Restart DSH so an applied plugin update is loaded. Always rides this\n * package's own loopback route: neither official channel\n * (`/plugin-installer`, `/plugin-control`) has a restart method, and the\n * route answers how the restart was carried out (in-place relaunch, or a\n * packaged Desktop shell that owns the process tree). See host/restart.ts.\n */\n restart: () => Promise<RestartMode>\n /**\n * Read how a restart would be carried out without triggering it (the same\n * route's plan read). The toolbar words its confirmation from this, so a\n * packaged Desktop host can say what its system dialog will do instead of\n * surprising the user with it.\n */\n restartPlan: () => Promise<RestartMode>\n}\n\n/**\n * Build the dual-channel face once: official-channel and gateway-channel\n * implementations, the mode detection that picks between them, and the\n * change-notification listener set. The returned face is both the update\n * patch's injected props and the value provided as the\n * `'pluginManager'` cordis service.\n * @param ctx - the client context (connection).\n * @returns the shared face.\n */\nexport function createPluginManagerFace(ctx: ClientContext): PluginManagerFace {\n const connection = ctx.get('connection') as ConnectionHandle\n\n // Official channel implementations.\n\n const call = async (endpoint: string, payload: unknown): Promise<unknown> => {\n const result = await connection.rpc.call(CHANNEL, endpoint, payload)\n if (!result.ok) {\n throw new Error(`plugin-installer ${endpoint} failed: ${result.error.code}: ${result.error.message}`)\n }\n return result.value\n }\n const official = {\n list: async (): Promise<InstalledPluginItem[]> => parsePluginList(await call(LIST_ENDPOINT, {})),\n install: async (spec: string): Promise<InstalledPluginItem> => parseInstalledPlugin(await call(INSTALL_ENDPOINT, { spec })),\n update: async (id: string): Promise<PluginUpdateResult> => ({\n plugin: parseInstalledPlugin(await call(UPDATE_ENDPOINT, { id })),\n // The official installer channel reports no restart fact: it owns the\n // load itself, so an applied update there is one this process serves.\n restartRequired: [],\n }),\n uninstall: async (id: string): Promise<InstalledPluginItem[]> => parsePluginList(await call(UNINSTALL_ENDPOINT, { id })),\n setEnabled: async (id: string, enabled: boolean): Promise<InstalledPluginItem> =>\n parseInstalledPlugin(await call(SET_ENABLED_ENDPOINT, { id, enabled })),\n checkUpdates: async (): Promise<PluginUpdateItem[]> => parseUpdateList(await call(CHECK_UPDATES_ENDPOINT, {})),\n status: async (): Promise<InstallProgressItem> => parseInstallStatus(await call(STATUS_ENDPOINT, {})),\n failures: async (): Promise<PluginFailuresSnapshot> => parseFailuresSnapshot(await call(FAILURES_ENDPOINT, {})),\n }\n\n // Gateway channel implementations.\n\n const gatewayJson = async (path: string, init?: RequestInit): Promise<unknown> => {\n const response = await fetch(path, {\n ...init,\n headers: { 'content-type': 'application/json', ...init?.headers },\n })\n if (response.status === 403) {\n throw new Error('plugin-manager: plugin management is only available from a local browser')\n }\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string }\n throw new Error(body.error ?? `plugin-manager: gateway ${path} failed: HTTP ${String(response.status)}`)\n }\n return response.json()\n }\n\n /** Wait for one gateway job to settle, returning its wire state. */\n const waitJob = async (jobId: string): Promise<GatewayJobWire> => {\n const deadline = Date.now() + JOB_WAIT_MS\n for (;;) {\n const body = await gatewayJson(`${GATEWAY_PREFIX}/status?job=${encodeURIComponent(jobId)}`) as { job?: GatewayJobWire }\n const job = body.job\n if (job === undefined) throw new Error('plugin-manager: gateway job vanished')\n if (job.phase === 'done') return job\n if (job.phase === 'error') throw new Error(job.error ?? 'plugin-manager: gateway job failed')\n if (Date.now() > deadline) throw new Error('plugin-manager: gateway job timed out')\n await new Promise(resolve => { setTimeout(resolve, JOB_POLL_MS) })\n }\n }\n\n /** Whether a gateway install/remove is in flight (drives the progress row). */\n let gatewayInflight = false\n\n const gateway = {\n list: async (): Promise<InstalledPluginItem[]> =>\n parsePluginList(await gatewayJson(`${GATEWAY_PREFIX}/list`)),\n install: async (spec: string): Promise<InstalledPluginItem> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/install`, {\n method: 'POST',\n body: JSON.stringify({ spec }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway install returned no job')\n const job = await waitJob(started.jobId)\n return parseInstalledPlugin({ plugin: job.plugin })\n } finally {\n gatewayInflight = false\n }\n },\n update: async (id: string): Promise<PluginUpdateResult> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/update`, {\n method: 'POST',\n body: JSON.stringify({ id }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway update returned no job')\n const job = await waitJob(started.jobId)\n return {\n plugin: parseInstalledPlugin({ plugin: job.plugin }),\n // The job is done either way; this is the difference between an\n // update this process serves and one only a restart loads.\n restartRequired: parseRestartRequired(job.restartRequired),\n }\n } finally {\n gatewayInflight = false\n }\n },\n uninstall: async (id: string): Promise<InstalledPluginItem[]> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/remove`, {\n method: 'POST',\n body: JSON.stringify({ id }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway remove returned no job')\n await waitJob(started.jobId)\n return gateway.list()\n } finally {\n gatewayInflight = false\n }\n },\n setEnabled: async (id: string, enabled: boolean): Promise<InstalledPluginItem> =>\n parseInstalledPlugin(await gatewayJson(`${GATEWAY_PREFIX}/set-enabled`, {\n method: 'POST',\n body: JSON.stringify({ id, enabled }),\n })),\n checkUpdates: async (): Promise<PluginUpdateItem[]> =>\n parseUpdateList(await gatewayJson(`${GATEWAY_PREFIX}/check-updates`)),\n status: async (): Promise<InstallProgressItem> =>\n gatewayInflight ? { kind: 'install', stage: 'download' } : { kind: 'idle', stage: 'fetch' },\n failures: async (): Promise<PluginFailuresSnapshot> =>\n parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`)),\n // Restart has no official-channel counterpart, so this route is the one\n // call that is always the gateway's, whichever mode the face runs in. The\n // GET-shaped call is the plan read: no state changes, no process exits.\n restartPlan: async (): Promise<RestartMode> =>\n parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`)),\n restart: async (): Promise<RestartMode> =>\n parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`, { method: 'POST' })),\n }\n\n // Mode selection.\n\n let modePromise: Promise<'official' | 'gateway'> | undefined\n const ensureMode = (): Promise<'official' | 'gateway'> => {\n if (modePromise === undefined) {\n modePromise = (async () => {\n // Prefer the host verdict: the gateway's /mode route reports whether\n // the official installer channels exist, so the direct channel probe\n // below (which 405s into the browser console on the npm web runtime)\n // only runs when the host half is absent or explicitly returns null\n // for a desktop runtime whose services are registered in-process.\n try {\n const mode = await gatewayJson(`${GATEWAY_PREFIX}/mode`) as { official?: boolean | null }\n if (mode.official === true) return 'official' as const\n if (mode.official === false) return 'gateway' as const\n } catch {\n // Host half absent (an official runtime without a boot profile):\n // fall back to the direct channel probe.\n }\n try {\n const result = await connection.rpc.call(CHANNEL, LIST_ENDPOINT, {})\n return result.ok ? 'official' as const : 'gateway' as const\n } catch {\n return 'gateway' as const\n }\n })()\n }\n return modePromise\n }\n\n // Change notification.\n\n /** Listeners subscribed through onChange; fired after successful mutations. */\n const listeners = new Set<() => void>()\n /** Notify every listener; one listener throwing never breaks the others. */\n const notifyChange = (): void => {\n for (const listener of [...listeners]) {\n try {\n listener()\n } catch {\n // A consumer's listener failure is its own; keep notifying the rest.\n }\n }\n }\n\n // The shared face.\n\n return {\n isLoopback: connection.isLoopback,\n list: async () => (await ensureMode()) === 'official' ? official.list() : gateway.list(),\n install: async spec => {\n const item = await ((await ensureMode()) === 'official' ? official.install(spec) : gateway.install(spec))\n notifyChange()\n return item\n },\n update: async id => {\n const item = await ((await ensureMode()) === 'official' ? official.update(id) : gateway.update(id))\n notifyChange()\n return item\n },\n uninstall: async id => {\n const rows = await ((await ensureMode()) === 'official' ? official.uninstall(id) : gateway.uninstall(id))\n notifyChange()\n return rows\n },\n setEnabled: async (id, enabled) => {\n const item = await ((await ensureMode()) === 'official' ? official.setEnabled(id, enabled) : gateway.setEnabled(id, enabled))\n notifyChange()\n return item\n },\n checkUpdates: async () => (await ensureMode()) === 'official' ? official.checkUpdates() : gateway.checkUpdates(),\n restartPlan: () => gateway.restartPlan(),\n restart: () => gateway.restart(),\n status: async () => (await ensureMode()) === 'official' ? official.status() : gateway.status(),\n failures: async () => (await ensureMode()) === 'official' ? official.failures() : gateway.failures(),\n onChange: cb => {\n listeners.add(cb)\n return () => { listeners.delete(cb) }\n },\n }\n}\n\n/** Contribute the check-for-updates patch and provide the shared face. */\nexport function apply(ctx: ClientContext): void {\n // Anonymous install heartbeat (docs/telemetry.md): one beat per browser per\n // UTC day, package name only, silent failure.\n reportDailyHeartbeat([{ name: '@linxin666/dsh-client-ui-plugin-manager' }])\n\n ctx.effect(() => {\n try {\n return ctx.locale.register(NS, { zh, en })\n } catch {\n return () => {}\n }\n }, 'plugin-manager: dictionaries')\n\n // Built once: the patch and the 'pluginManager' cordis service share one\n // face, so consumers observe exactly the mutations the patch performs.\n const face = createPluginManagerFace(ctx)\n try {\n if (!ctx.get(PLUGIN_MANAGER_SERVICE)) {\n ctx.provide(PLUGIN_MANAGER_SERVICE, face)\n }\n } catch {\n // ignore duplicate provide\n }\n\n // The list-level toolbar rides the page's own \"Installed\" heading: the\n // official page declares no seat beside it, so the entry is inserted into\n // the heading element itself and tracks the page through the shared body\n // mutation hub. Its translate function is rebuilt on every render so a\n // language switch reaches copy that no slot outlet owns.\n ctx.effect(() => {\n try {\n return mountPluginListToolbar({\n props: () => ({\n isLoopback: face.isLoopback,\n checkUpdates: face.checkUpdates,\n update: face.update,\n restartPlan: face.restartPlan,\n restart: face.restart,\n t: ctx.locale.bind(NS),\n }),\n subscribe: listener => ctx.locale.subscribe(listener),\n })\n } catch {\n return () => {}\n }\n }, 'plugin-manager: update toolbar')\n\n // The official Plugins page declares this seat on its main-panel entry and\n // renders one section per contribution on each bundle / row / plugin page;\n // `inject` waits for that declaration, exactly like the family plugin cards\n // that register into `plugins.bundle.config`.\n ctx.slots.inject('plugins.detail.section', () => {\n try {\n return ctx.slots.register({\n name: 'plugins.detail.section',\n id: 'family-update-check',\n order: 30,\n locale: NS,\n inject: () => face,\n }, PluginUpdatePatch)\n } catch {\n return () => {}\n }\n })\n}\n"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