@linxin666/dsh-client-ui-plugin-manager 0.4.21 → 0.4.22

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/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["messageOf","css","css","Switch","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/builtin.ts","../../../packages/dsh-plugin-manager/src/client/BuiltinPlugins.tsx","../../../packages/dsh-plugin-manager/src/client/builtin-plugins-mount.tsx","../../../packages/dsh-plugin-manager/src/client/native-faces.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, type CSSProperties } 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/**\n * The custom property carrying the determinate fraction (0 to 1). The bar is a\n * full-width element the stylesheet scales along its own axis, so a progress\n * tick repaints one compositor property instead of re-laying-out the row.\n */\nconst PROGRESS_VARIABLE = '--plugin-manager-progress'\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(snapshot => {\n if (!stopped && snapshot !== undefined) {\n setProgress(snapshot)\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\n ? undefined\n : { [PROGRESS_VARIABLE]: String(progress.percent / 100) } as CSSProperties}\n data-indeterminate={progress.percent === undefined ? 'true' : undefined}\n data-update-progress={progress.percent === undefined ? 'indeterminate' : 'determinate'}\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 * The built-in plugin group's pure logic: which global Loader entries no\n * installed bundle contributes, how each one may be written, and the two answer\n * shapes the official remote namespaces return.\n *\n * \"Built-in\" is a subtraction, not a roster of ours: the inventory's Loader\n * entries minus every entry an installed bundle's patch inserts. That covers the\n * rows a profile patch inserts itself — the Computer Use pair among them — and\n * the rows the host ships globally, without this package keeping a list that\n * would drift. The modules the official manager protects are refused by the\n * manager itself and reported per row as `readOnlyReason`, so no second\n * whitelist lives here.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n/** Literal text or translations indexed by language id, as package metadata carries it. */\nexport type DisplayText = string | { readonly en: string; readonly [locale: string]: string }\n\n/** Display metadata the inventory attaches to a Loader entry. */\nexport interface EntryMeta {\n readonly title?: DisplayText\n readonly description?: DisplayText\n readonly icon?: string\n readonly error?: string\n}\n\n/** A Loader entry's fiber phase, or null when the entry has no live root. */\nexport type FiberPhase = null | 'failed' | 'pending' | 'active' | 'loading' | 'unloading'\n\n/** One Loader entry as `pluginInventory.list()` reports it. */\nexport interface LoaderEntry {\n readonly entryId: string\n readonly moduleName: string\n readonly meta?: EntryMeta\n readonly enabled: boolean\n readonly fiberPhase: FiberPhase\n}\n\n/** One composition row of an agent preset. */\nexport interface AgentPresetRow {\n readonly entryId: string | null\n readonly moduleName: string\n readonly meta?: EntryMeta\n readonly enabled: boolean | 'conditional'\n /** The row's own `!!js` disabled expression, when it carries one. */\n readonly condition?: string\n readonly fiberPhase: FiberPhase\n}\n\n/** One composed agent preset. */\nexport interface AgentPreset {\n readonly id: string\n readonly name?: string\n readonly isDefault: boolean\n /** Why this preset's composition cannot be read; absent when rows answer. */\n readonly broken?: string\n readonly rows: readonly AgentPresetRow[]\n}\n\n/** The `pluginInventory.list()` snapshot this group consumes. */\nexport interface PluginInventory {\n readonly managementAvailable?: boolean\n readonly entries: readonly LoaderEntry[]\n readonly agentPresets?: readonly AgentPreset[]\n}\n\n/** The slice of `pluginManager.listBundles()` this group subtracts. */\nexport interface BundleFacts {\n /** The installed bundle's package name; the row's owner reads as this. */\n readonly name?: string\n /**\n * Whether the profile actually declares this bundle. The roster also reports\n * bundles that are only available, and their declared rows are no mounted\n * Loader entries — counting them would take a live row out of the default scope\n * over a package that is not even installed, so `false` is skipped. Absent\n * keeps the bundle in play, which is how the manager always answers.\n */\n readonly installed?: boolean\n readonly rows?: readonly { readonly entryId?: string }[]\n}\n\n/** The slice of `pluginManager.listPlugins()` that decides a row's writability. */\nexport interface PluginFacts {\n readonly entryId: string\n readonly readOnlyReason?: 'management-required' | 'unaddressable'\n}\n\n/** Why a row's switch is locked, or that the manager will take a write. */\nexport type WriteState = 'writable' | 'management-required' | 'unaddressable' | 'unknown'\n\n/** One row of the built-in group, in whichever scope it is shown. */\nexport interface BuiltinRow {\n readonly entryId: string\n readonly moduleName: string\n readonly meta?: EntryMeta\n readonly enabled: boolean\n readonly write: WriteState\n /**\n * The installed bundle whose patch inserts this entry, by package name. Absent\n * on a row no bundle contributes — the rows the group lists by default.\n */\n readonly ownedBy?: string\n}\n\n/** The group's two scopes, the ownership behind them, and the roster state. */\nexport interface BuiltinSelection {\n /** The default scope: the entries no installed bundle contributes. */\n readonly rows: readonly BuiltinRow[]\n /**\n * Every Loader entry in Loader order, with `ownedBy` on the ones a bundle\n * contributes. Same row shape as {@link BuiltinSelection.rows}, so the two\n * scopes render through one path.\n */\n readonly allRows: readonly BuiltinRow[]\n /** Loader entry id to the package name of the bundle that inserts it. */\n readonly owners: ReadonlyMap<string, string>\n /**\n * `confirmed` when every installed bundle was read and its rows subtracted;\n * `unconfirmed` when that read failed and every entry is listed instead.\n */\n readonly bundles: 'confirmed' | 'unconfirmed'\n}\n\n/**\n * Select the built-in group's two scopes in one pass: every Loader entry, the\n * ones no installed bundle contributes, and which bundle contributes the rest.\n *\n * The default scope is the subtraction the group shipped with; the wider scope is\n * the same rows plus the ones a bundle's patch inserts, each named after that\n * bundle — the reason a reader meets them again on the bundle's own page.\n * @param inventory - the Loader snapshot.\n * @param bundles - every installed bundle, or undefined when `listBundles()`\n * failed; both scopes then list every entry and the group says so.\n * @param plugins - the manager's plugin rows, or undefined when that read\n * failed; an unread row is reported as `unknown` rather than guessed writable.\n * @returns both scopes, the ownership map behind them, and the roster state.\n */\nexport function selectBuiltinEntries(\n inventory: PluginInventory,\n bundles: readonly BundleFacts[] | undefined,\n plugins: readonly PluginFacts[] | undefined,\n): BuiltinSelection {\n const owners = new Map<string, string>()\n for (const bundle of bundles ?? []) {\n if (bundle.installed === false) continue\n for (const row of bundle.rows ?? []) {\n // First writer wins: a row two patches touch still names the bundle that\n // contributes it, and a bundle without a readable name keeps the id out of\n // the default scope either way.\n if (row.entryId !== undefined && !owners.has(row.entryId)) owners.set(row.entryId, bundle.name ?? '')\n }\n }\n const writability = new Map<string, WriteState>()\n for (const plugin of plugins ?? []) {\n writability.set(plugin.entryId, plugin.readOnlyReason ?? 'writable')\n }\n const allRows = inventory.entries.map((entry): BuiltinRow => {\n const shared = {\n entryId: entry.entryId,\n moduleName: entry.moduleName,\n meta: entry.meta,\n enabled: entry.enabled,\n write: writability.get(entry.entryId) ?? 'unknown',\n }\n const ownedBy = owners.get(entry.entryId)\n return ownedBy === undefined ? shared : { ...shared, ownedBy }\n })\n return {\n rows: allRows.filter(row => row.ownedBy === undefined),\n allRows,\n owners,\n bundles: bundles === undefined ? 'unconfirmed' : 'confirmed',\n }\n}\n\n/** One official remote answer: the gateway's envelope, or a bare value. */\nexport type RemoteAnswer<T> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly code?: string }\n\n/**\n * Read one `remote.<namespace>` answer.\n *\n * The API gateway wraps every namespace result as `{ ok, value | error }`, and a\n * carrier that hands the bare value back must not be mistaken for a failure —\n * so an object is treated as an envelope only when its `ok` really is a boolean,\n * and anything else passes through as the value itself.\n * @param raw - the resolved answer, exactly as the namespace returned it.\n * @returns the unwrapped value, or the envelope's error code.\n */\nexport function readRemoteAnswer<T>(raw: unknown): RemoteAnswer<T> {\n if (typeof raw === 'object' && raw !== null && typeof (raw as { ok?: unknown }).ok === 'boolean') {\n const envelope = raw as { ok: boolean; value?: T; error?: { code?: string } }\n if (envelope.ok) return { ok: true, value: envelope.value as T }\n return { ok: false, code: envelope.error?.code }\n }\n return { ok: true, value: raw as T }\n}\n\n/** The applications one write can end in. */\nexport type ChangeApplication = 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled'\n\n/**\n * What a write achieved: the application the host settled on, or the code it\n * failed with. `overridden` is a resolved write a higher profile layer wins\n * over — the official page reports it as its own notice rather than a failure,\n * because the manager did accept the call.\n */\nexport type ChangeOutcome =\n | {\n readonly ok: true\n readonly application: 'applied' | 'overridden' | 'restart-required'\n /** Why `restart-required`, as the host named it. */\n readonly restartReason?: string\n }\n | { readonly ok: false; readonly code: string }\n\n/** The result fields of one `setPluginEnabled` answer. */\ninterface ChangeResultFields {\n readonly application?: ChangeApplication\n readonly restartReason?: string\n readonly error?: { readonly code?: string }\n}\n\n/**\n * Read one `setPluginEnabled` answer.\n *\n * The official manager folds a refusal into the resolved result\n * (`application: 'failed'` with an `error.code`) instead of rejecting, so a\n * resolved promise is not a success. Both answer shapes are accepted because\n * the gateway's envelope and the bare `ChangeResult` are the same call seen\n * through two carriers.\n * @param raw - the resolved answer.\n * @returns the outcome the switch should show.\n */\nexport function readChangeResult(raw: unknown): ChangeOutcome {\n const answer = readRemoteAnswer<ChangeResultFields>(raw)\n if (!answer.ok) return { ok: false, code: answer.code ?? 'operation-error' }\n const result = answer.value\n const application = result?.application\n if (application === undefined) return { ok: false, code: 'operation-error' }\n if (application === 'failed' || application === 'cancelled') {\n return { ok: false, code: result.error?.code ?? application }\n }\n return { ok: true, application, restartReason: result.restartReason }\n}\n","/**\n * The \"Built-in plugins\" group at the bottom of the official Plugins page.\n *\n * By default it lists every global Loader entry no installed bundle contributes —\n * the rows a profile patch inserts itself (the Computer Use pair among them) and\n * the rows the host ships globally — each with the official manager's own switch,\n * so a row is enabled or disabled by exactly the call the official page makes.\n * One control widens that list to every Loader entry and names, on each row a\n * bundle adds, the bundle that adds it: those rows are the ones a reader also\n * meets on that bundle's own page, and the answer to \"why is this here twice\" is\n * that sentence. Below it, the agent preset compositions the same inventory\n * reports are rendered read-only: a preset's rows are composed per session and\n * only a Loader context can decide a `!!js` condition, so nothing here offers\n * them a switch.\n *\n * Every state shown is the Loader's own: after an accepted write the group\n * re-reads instead of trusting the answer, a refusal is named by the code the\n * manager returned, and a locked row says which lock it is.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { useEffect, useId, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport { Switch } from '@deepseek-ai/dsh-client-ui-primitives'\nimport {\n readChangeResult,\n readRemoteAnswer,\n selectBuiltinEntries,\n type AgentPreset,\n type AgentPresetRow,\n type BuiltinRow,\n type BundleFacts,\n type DisplayText,\n type PluginFacts,\n type PluginInventory,\n type WriteState,\n} from '../core/builtin.ts'\nimport type { ManagerFace, RemoteSnapshot } from './native-faces.ts'\nimport css from './plugin-manager.module.css'\n\n/** The operations the group drives, all of them the official manager's own. */\nexport interface BuiltinPluginsInjected {\n /** The official faces, sampled on every render; its `version` moves on change. */\n remote: RemoteSnapshot\n /**\n * Resolve package metadata text through the language the GUI is showing. The\n * inventory hands back translations, not strings, and the mount owns no\n * language of its own.\n */\n resolveText: (text: DisplayText) => string\n}\n\n/** Full component props. */\nexport type BuiltinPluginsProps =\n & PropsLocale<'settings.pluginManager'>\n & BuiltinPluginsInjected\n\n/** What the group knows about the deployment right now. */\ntype GroupState =\n | { readonly kind: 'loading' }\n | { readonly kind: 'unavailable' }\n | { readonly kind: 'failed'; readonly code: string }\n | {\n readonly kind: 'ready'\n /** The default scope: the rows no installed bundle contributes. */\n readonly rows: readonly BuiltinRow[]\n /** Every Loader entry, with `ownedBy` on the rows a bundle contributes. */\n readonly allRows: readonly BuiltinRow[]\n readonly presets: readonly AgentPreset[]\n readonly bundles: 'confirmed' | 'unconfirmed'\n }\n\n/** One line of feedback under the heading. */\ninterface Notice {\n /** A refusal, or the passing note a resolved-but-not-live write deserves. */\n readonly tone: 'error' | 'note'\n readonly text: string\n}\n\n/** Which refusal code reads as which sentence. */\nconst REFUSAL_KEYS = {\n 'management-required': 'builtinReasonManagementRequired',\n 'unaddressable': 'builtinReasonUnaddressable',\n} as const\n\n/** Which restart reason reads as which sentence. */\nconst RESTART_KEYS = {\n 'no-hmr': 'builtinRestartNoHmr',\n 'package-moved': 'builtinRestartPackageMoved',\n 'host-module': 'builtinRestartHostModule',\n 'unmanaged-plugin': 'builtinRestartUnmanagedPlugin',\n 'module-comparison': 'builtinRestartModuleComparison',\n} as const\n\n/** Translate in this package's namespace. */\ntype Translate = BuiltinPluginsProps['t']\n\n/**\n * The one reason a failure this component could not name may show: the manager's\n * own generic code. A caught exception keeps its message out of the interface —\n * a host diagnostic can carry an absolute path — and is logged instead.\n */\nconst FALLBACK_CODE = 'operation-error'\n\n/** Keep the expanded inventory bounded: the full result stays available to search. */\nconst BUILTIN_PAGE_SIZE = 20\n\n/** Log one caught failure where a developer can read it, naming what failed. */\nfunction warnFailure(what: string, error: unknown): void {\n console.warn(`plugin-manager: ${what}`, error)\n}\n\n/**\n * What one refusal code reads as. A code this package has no sentence for is\n * shown as the code itself: the manager named it, and a guessed sentence would\n * be worse than the name it gave.\n */\nfunction refusalText(code: string, t: Translate): string {\n const key = REFUSAL_KEYS[code as keyof typeof REFUSAL_KEYS]\n return key === undefined ? code : t(key)\n}\n\n/** Why a row's switch is locked, in the reader's language. */\nfunction writeReason(write: WriteState, t: Translate): string {\n if (write === 'writable') return ''\n if (write === 'unknown') return t('builtinReasonUnknown')\n return refusalText(write, t)\n}\n\n/** Why a write needs a restart, in the reader's language. */\nfunction restartReason(reason: string | undefined, t: Translate): string {\n if (reason === undefined) return t('builtinRestartUnnamed')\n const key = RESTART_KEYS[reason as keyof typeof RESTART_KEYS]\n return key === undefined ? t('builtinRestartUnnamed') : t(key)\n}\n\n/** One row's display title, falling back to the module it names. */\nfunction rowTitle(\n row: { readonly meta?: { readonly title?: DisplayText }; readonly moduleName: string },\n resolveText: BuiltinPluginsInjected['resolveText'],\n): string {\n const title = row.meta?.title\n if (title === undefined) return row.moduleName\n const resolved = resolveText(title)\n return resolved === '' ? row.moduleName : resolved\n}\n\n/** One preset row's state, as the composition reports it. */\nfunction presetRowState(row: AgentPresetRow): 'on' | 'off' | 'conditional' {\n if (row.enabled === 'conditional') return 'conditional'\n return row.enabled ? 'on' : 'off'\n}\n\n/** One preset row's state text; a conditional row names its own expression. */\nfunction presetRowText(row: AgentPresetRow, t: Translate): string {\n if (row.enabled === 'conditional') {\n return row.condition === undefined\n ? t('presetRowConditionalUnnamed')\n : t('presetRowConditional', { condition: row.condition })\n }\n return row.enabled ? t('presetRowOn') : t('presetRowOff')\n}\n\n/**\n * Read one manager list, treating a refused or failed read as unknown. A row\n * whose writability could not be read is shown locked, never writable.\n */\nasync function readList<T>(read: () => Promise<unknown>): Promise<T | undefined> {\n try {\n const answer = readRemoteAnswer<T>(await read())\n if (!answer.ok) return undefined\n return Array.isArray(answer.value) ? answer.value as T : undefined\n } catch (error) {\n warnFailure('built-in group list read failed', error)\n return undefined\n }\n}\n\n/**\n * Whether an inventory answer is really a snapshot. The namespace hands back\n * `entries`; anything else — a bare null, an envelope with no value, a value\n * whose entries is not a list — is a failure this group reports rather than one\n * it walks into.\n */\nfunction isInventory(value: unknown): value is PluginInventory {\n return typeof value === 'object'\n && value !== null\n && Array.isArray((value as { entries?: unknown }).entries)\n}\n\n/**\n * Read the whole group: the Loader snapshot, then the two manager lists that\n * decide which entries are built-in and which of them can be written.\n * @param remote - the sampled official faces.\n * @returns the group's state; a read this deployment cannot serve stays a state,\n * never an exception.\n */\nasync function readGroup(remote: RemoteSnapshot): Promise<GroupState> {\n const inventoryFace = remote.inventory\n if (inventoryFace === null) return { kind: 'unavailable' }\n try {\n const answer = readRemoteAnswer<PluginInventory>(await inventoryFace.list())\n // A refusal keeps the code the host named; anything else that is not a\n // snapshot at all is reported as this component's own generic failure.\n if (!answer.ok) return { kind: 'failed', code: answer.code ?? FALLBACK_CODE }\n if (!isInventory(answer.value)) return { kind: 'failed', code: FALLBACK_CODE }\n const inventory = answer.value\n const manager: ManagerFace | null = remote.manager\n const [plugins, bundles] = await Promise.all([\n manager === null ? Promise.resolve(undefined) : readList<readonly PluginFacts[]>(() => manager.listPlugins()),\n manager === null ? Promise.resolve(undefined) : readList<readonly BundleFacts[]>(() => manager.listBundles()),\n ])\n const selection = selectBuiltinEntries(inventory, bundles, plugins)\n return {\n kind: 'ready',\n rows: selection.rows,\n allRows: selection.allRows,\n bundles: selection.bundles,\n presets: Array.isArray(inventory.agentPresets) ? inventory.agentPresets : [],\n }\n } catch (error) {\n // The whole read is guarded, not just the call: a malformed snapshot would\n // otherwise reject out of the effect below and leave the group reading for\n // ever, which reads as a hang rather than as the failure it is.\n warnFailure('built-in group read failed', error)\n return { kind: 'failed', code: FALLBACK_CODE }\n }\n}\n\n/**\n * The group itself. All state is local: the page around it owns the plugin list,\n * and the Loader is the only truth this component reports.\n */\nexport function BuiltinPlugins(props: BuiltinPluginsProps) {\n const { t, remote, resolveText } = props\n const [state, setState] = useState<GroupState>({ kind: 'loading' })\n /** Bumped after an accepted write, so the group reads the Loader again. */\n const [reload, setReload] = useState(0)\n /** The one write in flight, mirrored into the switches before the re-read. */\n const [pending, setPending] = useState<{ entryId: string; enabled: boolean } | undefined>(undefined)\n /** Synchronous in-flight mirror: two clicks can land in one frame. */\n const writingRef = useRef(false)\n const [notice, setNotice] = useState<Notice | undefined>(undefined)\n\n // A re-read keeps the rows it already shows until the new answer lands, so a\n // toggle never collapses the list under the pointer.\n useEffect(() => {\n let live = true\n void readGroup(remote).then(state => {\n if (live) setState(state)\n })\n return () => { live = false }\n }, [remote, reload])\n\n /**\n * Which scope the list shows. Switching it only picks between the two sets the\n * last read already answered with: it never reads again and never touches a\n * row's enablement, so a reader can widen the list without the Loader moving.\n */\n const [scope, setScope] = useState<'default' | 'all'>('default')\n const [query, setQuery] = useState('')\n const [page, setPage] = useState(1)\n const listId = useId()\n\n const ready = state.kind === 'ready' ? state : undefined\n const rows = ready === undefined ? [] : scope === 'all' ? ready.allRows : ready.rows\n /** Rows the default scope leaves out: what the scope control would add. */\n const ownedCount = ready === undefined ? 0 : ready.allRows.length - ready.rows.length\n const presets = ready === undefined ? [] : ready.presets\n const normalizedQuery = query.trim().toLowerCase()\n const filteredRows = normalizedQuery === ''\n ? rows\n : rows.filter(row => [\n rowTitle(row, resolveText),\n row.moduleName,\n row.entryId,\n row.ownedBy ?? '',\n ].some(text => text.toLowerCase().includes(normalizedQuery)))\n const pageCount = Math.max(1, Math.ceil(filteredRows.length / BUILTIN_PAGE_SIZE))\n const currentPage = Math.min(page, pageCount)\n const pageStart = (currentPage - 1) * BUILTIN_PAGE_SIZE\n const visibleRows = filteredRows.slice(pageStart, pageStart + BUILTIN_PAGE_SIZE)\n\n /**\n * The visible label of each row: its name, and the line under it — the module, or\n * the entry id when the name already is that module. Two rows carrying the same\n * pair read identically, which is the only case where the row has to say which\n * entry it is; a title two rows share is exactly that case, and so is a module\n * several rows name. Counted over the filtered result, so paging cannot hide\n * the other half of a collision; each scope still answers for itself.\n */\n const labels = new Map<string, string>()\n const labelCounts = new Map<string, number>()\n for (const row of filteredRows) {\n const title = rowTitle(row, resolveText)\n const label = `${title}\\u0000${title === row.moduleName ? row.entryId : row.moduleName}`\n labels.set(row.entryId, label)\n labelCounts.set(label, (labelCounts.get(label) ?? 0) + 1)\n }\n /** Whether this row's visible labels are shared with another row on screen. */\n const collides = (entryId: string): boolean => (labelCounts.get(labels.get(entryId) ?? '') ?? 0) > 1\n\n /**\n * Ask the official manager to enable or disable one row, then re-read. The\n * switch moves first and comes back on a refusal, so what it shows afterwards\n * is the answer this deployment gave rather than the click that produced it.\n */\n const toggle = (row: BuiltinRow, next: boolean): void => {\n const manager = remote.manager\n if (manager === null || row.write !== 'writable' || writingRef.current) return\n writingRef.current = true\n setPending({ entryId: row.entryId, enabled: next })\n setNotice(undefined)\n void (async () => {\n let outcome\n try {\n outcome = readChangeResult(await manager.setPluginEnabled(row.entryId, next))\n } catch (error) {\n warnFailure('built-in group write failed', error)\n outcome = { ok: false as const, code: FALLBACK_CODE }\n }\n writingRef.current = false\n setPending(undefined)\n if (!outcome.ok) {\n setNotice({\n tone: 'error',\n text: t(next ? 'builtinFailedEnable' : 'builtinFailedDisable', { reason: refusalText(outcome.code, t) }),\n })\n return\n }\n // A resolved write is not always a state the page will keep: the next start\n // loads a restart-required change, and a higher profile layer wins over an\n // overridden one. The re-read below is what makes the switch show the Loader\n // either way; this line is what tells the reader which of the two happened.\n // A restart-required write is not a success: the change is on disk and the\n // running process still serves the old state, so it is said in the same\n // passing tone as an overridden one.\n setNotice(outcome.application === 'restart-required'\n ? { tone: 'note', text: t('builtinRestartRequired', { reason: restartReason(outcome.restartReason, t) }) }\n : outcome.application === 'overridden'\n ? { tone: 'note', text: t('builtinOverridden', { name: rowTitle(row, resolveText) }) }\n : undefined)\n setReload(token => token + 1)\n })()\n }\n\n return (\n <section\n className={css.builtinGroup}\n data-dsh-plugin=\"plugin-manager\"\n data-dsh-part=\"builtin-group\"\n data-builtin-state={state.kind}\n data-builtin-bundles={state.kind === 'ready' ? state.bundles : undefined}\n data-builtin-scope={scope}\n aria-busy={state.kind === 'loading'}\n >\n <div className={css.builtinHead}>\n <h3 className={css.builtinTitle}>{t('builtinGroup')}</h3>\n {ready !== undefined && ready.bundles === 'confirmed' && (\n <span className={css.builtinCount} data-builtin-count={filteredRows.length}>{filteredRows.length}</span>\n )}\n {ownedCount > 0 && (\n <button\n type=\"button\"\n className={css.builtinScope}\n data-dsh-part=\"builtin-scope\"\n aria-expanded={scope === 'all'}\n aria-controls={listId}\n onClick={() => {\n setScope(scope === 'all' ? 'default' : 'all')\n setPage(1)\n }}\n >\n {t(scope === 'all' ? 'builtinScopeCollapse' : 'builtinScopeExpand', { count: String(ownedCount) })}\n </button>\n )}\n </div>\n\n {state.kind === 'loading' && <p className={css.hint} role=\"status\">{t('builtinReading')}</p>}\n {state.kind === 'unavailable' && <p className={css.hint}>{t('builtinUnavailable')}</p>}\n {state.kind === 'failed' && (\n <p className={css.error} role=\"alert\">{t('builtinFailed', { reason: state.code })}</p>\n )}\n {state.kind === 'ready' && state.bundles === 'unconfirmed' && (\n <p className={css.hint} data-builtin-unconfirmed>{t('builtinUnconfirmed')}</p>\n )}\n {notice !== undefined && (\n <p\n className={notice.tone === 'error' ? css.error : css.hint}\n role={notice.tone === 'error' ? 'alert' : 'status'}\n data-dsh-part=\"builtin-notice\"\n data-notice-tone={notice.tone}\n >\n {notice.text}\n </p>\n )}\n {ready !== undefined && rows.length === 0 && <p className={css.hint}>{t('builtinEmpty')}</p>}\n\n {rows.length > 0 && (\n <div className={css.builtinTools}>\n <input\n className={css.builtinSearch}\n type=\"search\"\n value={query}\n spellCheck={false}\n autoComplete=\"off\"\n aria-label={t('builtinSearchLabel')}\n aria-controls={listId}\n placeholder={t('builtinSearchPlaceholder')}\n data-builtin-search\n onChange={(event) => {\n setQuery(event.target.value)\n setPage(1)\n }}\n onKeyDown={(event) => {\n if (event.key === 'Escape' && query !== '') {\n setQuery('')\n setPage(1)\n }\n }}\n />\n </div>\n )}\n {rows.length > 0 && filteredRows.length === 0 && (\n <p className={css.hint} role=\"status\">{t('builtinSearchEmpty')}</p>\n )}\n\n {rows.length > 0 && (\n <ul className={css.builtinList} id={listId}>\n {visibleRows.map(row => {\n const title = rowTitle(row, resolveText)\n const reason = writeReason(row.write, t)\n const locked = row.write !== 'writable'\n const checked = pending?.entryId === row.entryId ? pending.enabled : row.enabled\n return (\n <li\n key={row.entryId}\n className={css.builtinRow}\n data-dsh-part=\"builtin-row\"\n data-entry-id={row.entryId}\n data-write={row.write}\n data-owned-by={row.ownedBy}\n >\n <span className={css.builtinMain}>\n <span className={css.builtinName}>{title}</span>\n <span className={css.builtinModule}>\n {title === row.moduleName ? row.entryId : row.moduleName}\n </span>\n {collides(row.entryId) && (\n <span className={css.builtinModule} data-entry-revealed={row.entryId}>{row.entryId}</span>\n )}\n {row.ownedBy !== undefined && row.ownedBy !== '' && (\n <span className={css.builtinOwner} data-dsh-part=\"builtin-owner\">\n {t('builtinOwnedBy', { name: row.ownedBy })}\n </span>\n )}\n {locked && <span className={css.builtinReason}>{reason}</span>}\n </span>\n <Switch\n checked={checked}\n label={t('builtinToggle', { name: title })}\n disabled={locked || pending !== undefined || remote.manager === null}\n {...locked ? { title: reason } : {}}\n onChange={next => { toggle(row, next) }}\n />\n </li>\n )\n })}\n </ul>\n )}\n {filteredRows.length > BUILTIN_PAGE_SIZE && (\n <div className={css.builtinPagination} data-dsh-part=\"pagination\">\n <button\n type=\"button\"\n className={css.button}\n disabled={currentPage === 1}\n onClick={() => { setPage(currentPage - 1) }}\n >\n {t('builtinPagePrevious')}\n </button>\n <span className={css.builtinPageInfo} aria-live=\"polite\">\n {t('builtinPageInfo', {\n page: String(currentPage),\n pages: String(pageCount),\n count: String(filteredRows.length),\n })}\n </span>\n <button\n type=\"button\"\n className={css.button}\n disabled={currentPage === pageCount}\n onClick={() => { setPage(currentPage + 1) }}\n >\n {t('builtinPageNext')}\n </button>\n </div>\n )}\n\n {presets.length > 0 && (\n <section className={css.presetGroup} data-dsh-part=\"preset-group\">\n <h4 className={css.presetTitle}>{t('presetGroup')}</h4>\n <ul className={css.presetList}>\n {presets.map(preset => (\n <li\n key={preset.id}\n className={css.presetCard}\n data-dsh-part=\"preset\"\n data-preset-id={preset.id}\n data-default={preset.isDefault ? 'yes' : 'no'}\n >\n <span className={css.presetHead}>\n <span className={css.presetName}>{preset.name ?? preset.id}</span>\n {preset.isDefault && <span className={css.presetTag}>{t('presetDefault')}</span>}\n </span>\n {preset.broken === undefined ? (\n <ul className={css.presetRows}>\n {preset.rows.map((row, index) => (\n <li\n key={row.entryId ?? `${preset.id}:${String(index)}`}\n className={css.presetRow}\n data-dsh-part=\"preset-row\"\n data-preset-state={presetRowState(row)}\n >\n <span className={css.presetRowName}>{row.moduleName}</span>\n <span className={css.presetRowState}>{presetRowText(row, t)}</span>\n </li>\n ))}\n </ul>\n ) : (\n <p className={css.hint}>{t('presetBroken', { reason: preset.broken })}</p>\n )}\n </li>\n ))}\n </ul>\n </section>\n )}\n </section>\n )\n}\n","/**\n * Mounting the built-in plugin group at the bottom of the official Plugins page.\n *\n * The page declares no seat at the list's end: its extension points are\n * `plugins.detail.*` (per page), `plugins.bundle.config` / `plugins.row.config` /\n * `plugins.item` (configuration entries) and `plugins.bundle.activation`. Its\n * list view is `<section data-plugin-panel> <header/> <div class=\"…_installedPanel\">\n * <section data-plugin-group=\"basic|extensions|bundles\"/> … </div> … </section>`,\n * and the class names are CSS-module hashes, so the seat is found through the\n * page's own data attributes plus DOM position: the section after the installed\n * panel, which is a flex column of 32px gaps whose direct children are exactly\n * the width of the groups above.\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 moves or drops the panel is\n * followed on the next frame, a panel switch that unmounts the list detaches\n * the container until the list returns, and the detail / \"all plugins\" views\n * (which render no bundles group) leave it off the page entirely.\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 { BuiltinPlugins, type BuiltinPluginsProps } from './BuiltinPlugins.tsx'\nimport css from './plugin-manager.module.css'\n\n/** Stable attribute identifying the injected container (mount idempotency). */\nexport const BUILTIN_GROUP_MOUNT_SELECTOR = '[data-dsh-plugin-manager-builtin]'\n\n/** The mount's inputs. */\nexport interface BuiltinGroupMountOptions {\n /** Build the group's props; called on mount and on every locale change. */\n props: () => BuiltinPluginsProps\n /** Locale change subscription (ctx.locale.subscribe); re-renders the group. */\n subscribe?: (listener: () => void) => () => void\n}\n\n/**\n * The official page's installed panel, when the list view is mounted.\n * @returns the element the group belongs after, or undefined off the list view.\n */\nexport function builtinGroupSeat(): HTMLElement | undefined {\n const page = document.querySelector('[data-plugin-panel]')\n const panel = page?.querySelector('[data-plugin-group=\"bundles\"]')?.parentElement\n return panel instanceof HTMLElement ? panel : undefined\n}\n\n/**\n * Mount the built-in plugin group after the installed panel.\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 mountBuiltinPluginGroup(options: BuiltinGroupMountOptions): () => void {\n if (typeof document === 'undefined') return () => {}\n // DOM-level idempotency: whatever path mounted a group before this call (a\n // duplicated apply, an HMR re-injection), never mount a second one.\n if (document.querySelector(BUILTIN_GROUP_MOUNT_SELECTOR) !== null) return () => {}\n\n const container = document.createElement('div')\n container.setAttribute('data-dsh-plugin-manager-builtin', '')\n container.className = css.builtinMount\n const root: Root = createRoot(container)\n const render = (): void => {\n root.render(createElement(BuiltinPlugins, options.props()))\n }\n render()\n\n /**\n * Keep the container immediately after the installed panel; detach while the\n * list is away. React owns the page's children and appends its own blocks\n * (a failure notice among them) after that panel, so the anchor is the\n * panel's next sibling rather than the panel's last child.\n */\n const place = (): void => {\n const seat = builtinGroupSeat()\n if (seat === undefined) {\n container.remove()\n return\n }\n if (container.previousElementSibling !== seat) seat.after(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 * Bridge to the official remote namespaces the built-in plugin group reads\n * through, and to the event that says the host rewrote the profile.\n *\n * - `remote.pluginInventory` — the Loader snapshot (entries and, when a roster is\n * composed, each agent preset's rows).\n * - `remote.pluginManager` — the very manager the official Plugins page drives:\n * per-row writability, the installed bundle roster, and enable/disable.\n * - `plugin-manager/changed` — forwarded on the `remote` root after a write, so a\n * second page (or the official page's own switch) re-reads instead of showing\n * a stale toggle.\n *\n * Every face is OPTIONAL: `ctx.inject` runs the effect when the namespace is\n * published and disposes it when it goes away, which clears the snapshot. An\n * absent face leaves the group's read-only \"unavailable\" state, never a write.\n *\n * CONTRACT OBSERVATION: cross-package value imports are forbidden and this\n * package does not depend on the api-remotes assembly types, so the members\n * called here are re-declared. Their shapes are the official manager's own\n * schemas, not ones this package invented.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport type { Context } from '@deepseek-ai/cordis'\n\n/** The inventory namespace's one method. */\nexport interface InventoryFace {\n /** Read the Loader, and every composed preset's rows, on each call. */\n list(): Promise<unknown>\n}\n\n/** The manager namespace's methods this package calls. */\nexport interface ManagerFace {\n /** Every Loader entry with its `patchId` or the reason it cannot be written. */\n listPlugins(): Promise<unknown>\n /** Every installed bundle, with the rows its patch inserts. */\n listBundles(): Promise<unknown>\n /** Enable or disable one Loader entry through the official manager. */\n setPluginEnabled(entryId: string, enabled: boolean): Promise<unknown>\n}\n\n/** The `remote` root's forwarded-event subscription. */\nexport interface RemoteEventFace {\n $on?(event: string, listener: (payload: unknown) => void): () => void\n}\n\n/** What the group reads, sampled per render; `version` moves on every change. */\nexport interface RemoteSnapshot {\n readonly version: number\n readonly inventory: InventoryFace | null\n readonly manager: ManagerFace | null\n}\n\nlet snapshot: RemoteSnapshot = { version: 0, inventory: null, manager: null }\nconst listeners = new Set<() => void>()\n\n/**\n * Merge one face change into the snapshot and notify subscribers. `version`\n * always moves, so a consumer that keys its read on it re-reads after a swap.\n * @param patch - the faces to replace; an omitted face keeps its current value.\n */\nfunction patchRemote(patch: { inventory?: InventoryFace | null; manager?: ManagerFace | null }): void {\n snapshot = {\n version: snapshot.version + 1,\n inventory: patch.inventory === undefined ? snapshot.inventory : patch.inventory,\n manager: patch.manager === undefined ? snapshot.manager : patch.manager,\n }\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 current snapshot (stable reference between changes). */\nexport function getRemoteSnapshot(): RemoteSnapshot {\n return snapshot\n}\n\n/**\n * Subscribe to snapshot changes.\n * @param listener - called after every face swap or forwarded change event.\n * @returns the unsubscribe function.\n */\nexport function subscribeRemote(listener: () => void): () => void {\n listeners.add(listener)\n return () => { listeners.delete(listener) }\n}\n\n/**\n * Bridge the official faces into the snapshot. Uses `ctx.inject` (not the\n * plugin's module-level inject array) so each face stays optional.\n * @param ctx - the client context the plugin runs in.\n */\nexport function bridgeRemoteNamespaces(ctx: Context): void {\n ctx.inject(['remote.pluginInventory'], inner => {\n inner.effect(() => {\n patchRemote({ inventory: (inner.get('remote.pluginInventory') as InventoryFace | undefined) ?? null })\n return () => { patchRemote({ inventory: null }) }\n }, 'plugin-manager: built-in group inventory face')\n })\n ctx.inject(['remote.pluginManager'], inner => {\n inner.effect(() => {\n patchRemote({ manager: (inner.get('remote.pluginManager') as ManagerFace | undefined) ?? null })\n return () => { patchRemote({ manager: null }) }\n }, 'plugin-manager: built-in group manager face')\n })\n ctx.inject(['remote'], inner => {\n inner.effect(() => {\n const remote = inner.get('remote') as RemoteEventFace | undefined\n let off: (() => void) | undefined\n try {\n off = remote?.$on?.('plugin-manager/changed', () => { patchRemote({}) })\n } catch {\n // Forwarded events need a Connection carrying interactions=answer. A\n // carrier without them keeps the group's own read-after-write path, and\n // this subscription stays empty instead of breaking the group.\n }\n return () => { off?.() }\n }, 'plugin-manager: built-in group change feed')\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 { PluginBatchUpdateResult, PluginUpdateItem, RestartMode, RestartPlanWire } 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 * Apply every listed update in one run and answer which rows landed and which\n * did not.\n *\n * One call rather than one call per plugin: the sequence (and the decision that\n * a refused row does not end the run) is the host's, so the toolbar no longer\n * spends a request and a job on each row. A row that landed but needs a restart\n * is still an applied row — it joins the restart list instead of failing.\n */\n updateAll: (ids: string[], onRow?: (row: UpdateCursor) => void) => Promise<PluginBatchUpdateResult>\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, a\n * systemd unit restart, or a manual restart), and a plan read has no side\n * effects. A systemd plan carries the unit it would restart.\n */\n restartPlan: () => Promise<RestartPlanWire>\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/** Translate in this package's namespace. */\ntype Translate = PluginListToolbarProps['t']\n\n/**\n * The consequence confirming produces, in the reader's language. It states\n * what the host will actually do, so a systemd plan names the unit that goes\n * down and comes back.\n */\nfunction planCopy(plan: RestartPlanWire | undefined, t: Translate): string {\n // The wire is a discriminated union: a systemd plan carries the unit this\n // copy must name, and no other mode has one to read.\n if (plan?.mode === 'systemd') return t('restartPlanSystemd', { unit: plan.unit })\n if (plan?.mode === 'shell') return t('restartPlanShell')\n if (plan?.mode === 'manual') return t('restartPlanManual')\n return t('restartPlanRelaunch')\n}\n\n/** Which row a running batch is on, as the face reports it. */\nexport interface UpdateCursor {\n /** Package name of the row in flight. */\n id: string\n /** One-based position of that row in the run. */\n index: number\n /** How many rows the run was asked to apply. */\n total: number\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, updateAll, 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 [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 /**\n * Rows the last run could not apply, with the host's reason. They stay in\n * `rows` — the user has to see which plugin is stuck and why, beside the\n * version it is stuck on — and only the whole-call failure reaches `error`.\n */\n const [failures, setFailures] = useState<{ id: string; error: 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<RestartPlanWire | 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 setApplied([])\n setRestartRequired([])\n setFailures([])\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 setFailures([])\n void updateAll(queue.map(row => row.id), row => {\n setCursor({ name: row.id, index: row.index, total: row.total })\n }).then(result => {\n // Every landed row leaves the list, including the ones this process cannot\n // load yet: those are applied (and name their restart), not failures.\n const landed = new Set(result.applied.map(row => row.id))\n const restart = result.applied\n .filter(row => row.restartRequired === true)\n .map(row => ({ id: row.id, version: row.landed ?? '' }))\n setApplied(current => [...current, ...result.applied.map(row => row.id)])\n setRestartRequired(current => [...current, ...restart])\n // A refused row stays listed with the reason the host gave, so the run's\n // partial result is visible row by row instead of as one alert line.\n setFailures(result.failed.map(row => ({ id: row.id, error: row.error ?? t('updateFailedUnknown') })))\n setRows(current => current.filter(item => !landed.has(item.id)))\n }).catch(reason => {\n // The request itself failed (route refused, transport, no writer): nothing\n // ran, so the list stays exactly as it was and the alert explains why.\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n setCursor(undefined)\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(answer => {\n setPlan(answer)\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 /**\n * The host leaves once the route accepts a relaunch or a systemd restart:\n * both replace this process, so the action is spent and reads as in progress.\n */\n const hostLeaves = restartMode === 'relaunch' || restartMode === 'systemd'\n /** The mode the plan read named; the confirmation only opens after one arrived. */\n const planMode = plan?.mode\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 = rows.length\n const failedCount = failures.length\n /**\n * One line for the whole run: the row in flight, what is still pending, and —\n * once nothing is — whether the run landed everything or only part of it. A\n * partial run must not read as a clean one.\n */\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 : failedCount > 0\n ? t('updateAllPartial', { done: String(applied.length), failed: String(failedCount) })\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 || hostLeaves}\n onClick={() => { if (panel === 'restart') { setPanel('none'); setPlan(undefined); return } onAskRestart() }}\n >\n {hostLeaves ? 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 && (\n <p className={css.ok} data-update-applied>\n {failedCount > 0\n ? t('updateAllPartial', { done: String(applied.length), failed: String(failedCount) })\n : t('updateAllDone')}\n </p>\n )}\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 const failure = failures.find(item => item.id === row.id)\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 {failure === undefined ? null : (\n <span className={css.compatBlocked} data-update-row-error={failure.id}>\n {t('updateFailedRow', { reason: failure.error })}\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={planMode} role=\"group\" aria-label={t('restartNow')}>\n {errorLine}\n <p className={css.hint} data-restart-plan-hint={planMode}>\n {planCopy(plan, t)}\n </p>\n {planMode === '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 {planMode !== '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 'updateAllPartial': '已更新 {done} 个,{failed} 个失败',\n 'updateFailedRow': '更新失败:{reason}',\n 'updateFailedUnknown': '宿主没有说明失败原因',\n 'updateRestartRequired': '已更新到 {version},需重启 DSH 后生效',\n 'updatesPanelTitle': '插件更新',\n 'thirdPartyOnly': '只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。',\n 'restartNow': '立即重启',\n 'restarting': '正在重启…',\n 'restartConfirm': '确认重启',\n 'restartPlanRelaunch': '会重启 DSH 服务,正在运行的任务会中断。',\n 'restartPlanShell': '桌面版重启由应用外壳执行:确认后宿主进程会退出,由外壳重新拉起。',\n 'restartPlanSystemd': '会由 systemd 重启 {unit},正在运行的任务会中断。',\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 'builtinGroup': '内置插件',\n 'builtinReading': '正在读取内置插件…',\n 'builtinEmpty': '没有内置插件。',\n 'builtinUnavailable': '当前部署没有提供插件清单接口,无法列出内置插件。',\n 'builtinFailed': '无法读取内置插件:{reason}',\n 'builtinUnconfirmed': '无法读取已安装组合包的行清单,这里按全部 Loader 条目列出。',\n 'builtinScopeExpand': '显示已归属组合包的行({count})',\n 'builtinScopeCollapse': '隐藏已归属组合包的行({count})',\n 'builtinSearchLabel': '搜索内置插件',\n 'builtinSearchPlaceholder': '搜索名称、包名或行 id',\n 'builtinSearchEmpty': '没有匹配的内置插件。',\n 'builtinPagePrevious': '上一页',\n 'builtinPageNext': '下一页',\n 'builtinPageInfo': '第 {page} / {pages} 页,共 {count} 项',\n 'builtinOwnedBy': '来自 {name}',\n 'builtinToggle': '启用插件 {name}',\n 'builtinFailedEnable': '启用失败:{reason}',\n 'builtinFailedDisable': '停用失败:{reason}',\n 'builtinReasonManagementRequired': '插件管理所需,不能停用或卸载',\n 'builtinReasonUnaddressable': '当前 profile 的 patch 无法唯一定位这一项',\n 'builtinReasonUnknown': '无法确定这一项能否改写',\n 'builtinRestartRequired': '这次改动需要重启 DSH 才能加载:{reason}',\n 'builtinOverridden': '更高层的 profile 覆盖了 {name} 的这一改动,未生效。',\n 'builtinRestartUnnamed': '当前 profile 只在启动时应用更改。',\n 'builtinRestartNoHmr': '这个 profile 只在启动时应用更改。',\n 'builtinRestartPackageMoved': '已安装的插件包解析到了另一个目录,或者改动替换了 DSH 安装自带的包。',\n 'builtinRestartHostModule': '改动涉及 DSH 自身已加载的模块。',\n 'builtinRestartUnmanagedPlugin': '改动涉及一个不受插件列表管理的插件。',\n 'builtinRestartModuleComparison': 'DSH 无法把已加载的插件与磁盘上的文件做比较。',\n 'presetGroup': 'Agent 预设',\n 'presetDefault': '默认',\n 'presetBroken': '无法读取该预设的组合:{reason}',\n 'presetRowOn': '已开启',\n 'presetRowOff': '已关闭',\n 'presetRowConditional': '条件启用:{condition}',\n 'presetRowConditionalUnnamed': '条件启用',\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 'updateAllPartial': 'Updated {done}; {failed} failed',\n 'updateFailedRow': 'Update failed: {reason}',\n 'updateFailedUnknown': 'The host gave no reason',\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 'restartPlanSystemd': 'systemd restarts {unit}; running tasks are interrupted.',\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 'builtinGroup': 'Built-in plugins',\n 'builtinReading': 'Reading built-in plugins…',\n 'builtinEmpty': 'No built-in plugins.',\n 'builtinUnavailable': 'This deployment publishes no plugin inventory, so built-in plugins cannot be listed.',\n 'builtinFailed': 'Could not read the built-in plugins: {reason}',\n 'builtinUnconfirmed': 'The installed bundles could not be read, so every Loader entry is listed here.',\n 'builtinScopeExpand': 'Show the rows these bundles own ({count})',\n 'builtinScopeCollapse': 'Hide the rows these bundles own ({count})',\n 'builtinSearchLabel': 'Search built-in plugins',\n 'builtinSearchPlaceholder': 'Search by name, package, or entry id',\n 'builtinSearchEmpty': 'No built-in plugins match this search.',\n 'builtinPagePrevious': 'Previous',\n 'builtinPageNext': 'Next',\n 'builtinPageInfo': 'Page {page} of {pages} · {count} items',\n 'builtinOwnedBy': 'From {name}',\n 'builtinToggle': 'Enable plugin {name}',\n 'builtinFailedEnable': 'Could not enable it: {reason}',\n 'builtinFailedDisable': 'Could not disable it: {reason}',\n 'builtinReasonManagementRequired': 'Plugin management needs it; it cannot be switched off or uninstalled',\n 'builtinReasonUnaddressable': 'The profile patch cannot address this one uniquely',\n 'builtinReasonUnknown': 'Whether this one can be written is unknown',\n 'builtinRestartRequired': 'This change needs a DSH restart: {reason}',\n 'builtinOverridden': 'A higher profile layer overrides this change to {name}, so it did not take effect.',\n 'builtinRestartUnnamed': 'This profile applies changes only at startup.',\n 'builtinRestartNoHmr': 'This profile applies changes only at startup.',\n 'builtinRestartPackageMoved': 'An installed package now resolves to another directory, or the change replaces a package the DSH installation provides.',\n 'builtinRestartHostModule': 'The change reaches modules DSH itself loaded.',\n 'builtinRestartUnmanagedPlugin': 'The change reaches a plugin running outside the plugin list.',\n 'builtinRestartModuleComparison': 'DSH could not compare the loaded plugins with their files.',\n 'presetGroup': 'Agent presets',\n 'presetDefault': 'Default',\n 'presetBroken': 'This preset composition cannot be read: {reason}',\n 'presetRowOn': 'On',\n 'presetRowOff': 'Off',\n 'presetRowConditional': 'Conditional: {condition}',\n 'presetRowConditionalUnnamed': 'Conditional',\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; `systemd` —\n * this host runs as a systemd service and asks its own unit to restart it;\n * `manual` — none of these is possible here, the user restarts DSH themselves.\n */\nexport type RestartMode = 'relaunch' | 'shell' | 'systemd' | 'manual'\n\n/**\n * The unit name shape a systemd restart may name. Deliberately conservative:\n * the host derives the value from its own cgroup and the browser re-validates\n * it before the confirmation names a unit, so a value outside this shape is\n * wire drift rather than a unit worth restarting. The one position that is\n * refused is a leading `-`: this name travels as the last argv element of\n * `systemctl --user restart --no-block <unit>`, where a leading `-` reads as\n * another option instead of a unit. Everything else systemd itself accepts is\n * kept, including a first `_` or `:` (`_x.service` and `:x.service` are\n * valid unit names).\n */\nconst SYSTEMD_UNIT_RE = /^(?!-)[a-zA-Z0-9:_.@-]+\\.service$/\n\n/** Whether a value is a systemd unit name this package asks systemd to restart. */\nexport function isSystemdUnitName(value: string): boolean {\n return SYSTEMD_UNIT_RE.test(value)\n}\n\n/**\n * What the host would do with a restart request, as the plan read answers it.\n *\n * A discriminated union rather than a mode beside an optional unit: a systemd\n * plan always names the unit it restarts (the parser refuses one that does\n * not) and no other mode carries a unit at all, so the confirmation reads the\n * unit off the plan instead of guarding a field that cannot be missing.\n */\nexport type RestartPlanWire =\n | { mode: 'systemd'; unit: string }\n | { mode: '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/**\n * One row of a batch update, as the host reported it.\n *\n * A batch is the host's sequence over the official manager's single-plugin\n * update, so its progress is a row per requested plugin rather than one\n * aggregate verdict: each row carries the version the host resolved, where it\n * ended, and — when it could not be applied — the reason.\n */\nexport interface PluginUpdateOutcome {\n /** Installed package name this row applies. */\n id: string\n /** Where this row is: still queued, in flight, applied, or refused. */\n phase: 'pending' | 'running' | 'done' | 'error'\n /** The exact version the host resolved for this row; absent when it was refused up front. */\n targetVersion?: string\n /** The version that landed, present on an applied row. */\n landed?: string\n /** Why this row could not be applied, present on a refused row. */\n error?: string\n /**\n * Whether the landed version is on disk but not loaded in the running host\n * (the official manager answered `application: 'restart-required'`).\n */\n restartRequired?: boolean\n}\n\n/**\n * What one batch update run produced.\n *\n * Both halves are carried: the refused rows stay in the panel beside the version\n * they are stuck on, and the applied rows leave it. Reporting only one half would\n * make a partial run read as either a clean one or no run at all.\n */\nexport interface PluginBatchUpdateResult {\n /** Rows that landed, at the version that landed. */\n applied: PluginUpdateOutcome[]\n /** Rows that did not, each carrying the host's reason. */\n failed: PluginUpdateOutcome[]\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 the rows of a batch update, as a gateway job carries\n * them under `results`.\n *\n * Deliberately tolerant in the same way {@link parseRestartRequired} is: every\n * row is an outcome the panel has to render, and refusing the whole list over one\n * malformed row would hide the rows that did land. A row missing its id or phase\n * is that row's problem, so it is dropped rather than thrown; an unreadable\n * `results` value reads as \"no rows\", which the caller shows as a run without a\n * per-row verdict.\n * @param value - decoded but untrusted job value.\n * @returns the typed rows, in the order the host applied them.\n */\nexport function parseUpdateOutcomes(value: unknown): PluginUpdateOutcome[] {\n if (!Array.isArray(value)) return []\n const rows: PluginUpdateOutcome[] = []\n for (const item of value) {\n if (!isRecord(item) || !isString(item.id) || item.id === '') continue\n const phase = item.phase\n if (phase !== 'pending' && phase !== 'running' && phase !== 'done' && phase !== 'error') continue\n const row: PluginUpdateOutcome = { id: item.id, phase }\n if (isString(item.targetVersion) && item.targetVersion !== '') row.targetVersion = item.targetVersion\n if (isString(item.landed) && item.landed !== '') row.landed = item.landed\n if (isString(item.error) && item.error !== '') row.error = item.error\n if (item.restartRequired === true) row.restartRequired = true\n rows.push(row)\n }\n return rows\n}\n\n/**\n * Split a finished batch's rows by outcome, the shape the toolbar renders.\n * A row still in flight is neither: it is simply not in either half.\n * @param rows - the rows the host reported.\n * @returns the applied and failed rows.\n */\nexport function batchUpdateResult(rows: readonly PluginUpdateOutcome[]): PluginBatchUpdateResult {\n const applied: PluginUpdateOutcome[] = []\n const failed: PluginUpdateOutcome[] = []\n for (const row of rows) {\n if (row.phase === 'done') applied.push(row)\n else if (row.phase === 'error') failed.push(row)\n }\n return { applied, failed }\n}\n\n/**\n * Validate and normalize a `restart` response value, reading the mode a POST\n * answer carries.\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 !== 'systemd' && 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 restart PLAN response value (the GET answer).\n *\n * The plan is read before the confirmation is shown, so this parser fails\n * closed: an unknown mode, or a systemd plan that does not name a unit of the\n * accepted shape, throws instead of letting the panel promise a restart the\n * host cannot actually perform.\n * @param value - decoded but untrusted response value.\n * @returns the plan the host would carry out.\n */\nexport function parseRestartPlan(value: unknown): RestartPlanWire {\n const mode = parseRestartMode(value)\n if (mode !== 'systemd') return { mode }\n const restart = isRecord(value) ? value.restart : undefined\n const unit = isRecord(restart) ? restart.unit : undefined\n if (!isString(unit) || !isSystemdUnitName(unit)) {\n throw new Error('plugin-manager: response must name the systemd unit a systemd restart uses')\n }\n return { mode, unit }\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 this package's surfaces on the\n * official Plugins page — the check-for-updates block, the list-level update\n * toolbar, and the built-in plugin group at the list's bottom — and provides the\n * dual-channel face as the `'pluginManager'` cordis service for sibling client\n * 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 { mountBuiltinPluginGroup } from './builtin-plugins-mount.tsx'\nimport { bridgeRemoteNamespaces, getRemoteSnapshot, subscribeRemote } from './native-faces.ts'\nimport { mountPluginListToolbar } from './plugin-toolbar-mount.tsx'\nimport { en, zh, type PluginManagerKey } from './locales.ts'\nimport {\n batchUpdateResult,\n parseFailuresSnapshot,\n parseInstallStatus,\n parseInstalledPlugin,\n parsePluginList,\n parseRestartMode,\n parseRestartPlan,\n parseRestartRequired,\n parseUpdateList,\n parseUpdateOutcomes,\n type InstalledPluginItem,\n type InstallProgressItem,\n type PluginBatchUpdateResult,\n type PluginFailuresSnapshot,\n type PluginUpdateItem,\n type PluginUpdateOutcome,\n type PluginUpdateResult,\n type RestartMode,\n type RestartPlanWire,\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 UPDATES_ENDPOINT = 'updates'\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 * The per-row outcomes of a batch update job, read through\n * {@link parseUpdateOutcomes}: one entry per requested plugin with the phase\n * it reached and, when it could not be applied, the host's reason.\n */\n results?: 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, and a\n * systemd host can name the unit that restarts, instead of surprising the\n * user with either.\n */\n restartPlan: () => Promise<RestartPlanWire>\n /**\n * Apply every listed update in one run, answering the rows that landed and the\n * rows that did not.\n *\n * The list-level toolbar used to drive one update job per plugin from the\n * browser, which spent a request and a job on each row and left the sequence —\n * and the decision to stop at the first refusal — in the component. The gateway\n * half now runs that sequence on the host as one job; the official installer\n * channel has no batch endpoint, so there the batch stays a loop of its own\n * single update, which is the only writer that channel accepts.\n */\n updateAll: (ids: readonly string[]) => Promise<PluginBatchUpdateResult>\n}\n\n/** Error text for a failed call, keeping the reason a thrown value carries. */\nfunction failureText(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\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 // One official update per id: this channel publishes no batch endpoint, and\n // its single call is the only writer it accepts. A refused row is collected\n // rather than thrown, so one plugin cannot discard the rest of the run.\n updateAll: async (ids: readonly string[]): Promise<PluginBatchUpdateResult> => {\n const applied: PluginUpdateOutcome[] = []\n const failed: PluginUpdateOutcome[] = []\n for (const id of ids) {\n try {\n const result = await official.update(id)\n applied.push({\n id,\n phase: 'done',\n landed: result.plugin.version,\n ...result.restartRequired.length > 0 ? { restartRequired: true } : {},\n })\n } catch (error) {\n failed.push({ id, phase: 'error', error: failureText(error) })\n }\n }\n return { applied, failed }\n },\n }\n\n // Gateway channel implementations.\n\n const gatewayJson = async (path: string, init?: RequestInit): Promise<unknown> => {\n const response = await fetch(path, {\n ...init,\n headers: { 'content-type': 'application/json', ...init?.headers },\n })\n if (response.status === 403) {\n throw new Error('plugin-manager: plugin management is only available from a local browser')\n }\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string }\n throw new Error(body.error ?? `plugin-manager: gateway ${path} failed: HTTP ${String(response.status)}`)\n }\n return response.json()\n }\n\n /** Wait for one gateway job to settle, returning its wire state. */\n const waitJob = async (jobId: string): Promise<GatewayJobWire> => {\n const deadline = Date.now() + JOB_WAIT_MS\n for (;;) {\n const body = await gatewayJson(`${GATEWAY_PREFIX}/status?job=${encodeURIComponent(jobId)}`) as { job?: GatewayJobWire }\n const job = body.job\n if (job === undefined) throw new Error('plugin-manager: gateway job vanished')\n if (job.phase === 'done') return job\n if (job.phase === 'error') throw new Error(job.error ?? 'plugin-manager: gateway job failed')\n if (Date.now() > deadline) throw new Error('plugin-manager: gateway job timed out')\n await new Promise(resolve => { setTimeout(resolve, JOB_POLL_MS) })\n }\n }\n\n /** 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 updateAll: async (ids: readonly string[]): Promise<PluginBatchUpdateResult> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/${UPDATES_ENDPOINT}`, {\n method: 'POST',\n body: JSON.stringify({ ids: [...ids] }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway updates returned no job')\n const job = await waitJob(started.jobId)\n return batchUpdateResult(parseUpdateOutcomes(job.results))\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<RestartPlanWire> =>\n parseRestartPlan(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 updateAll: async ids => {\n const result = await ((await ensureMode()) === 'official' ? official.updateAll(ids) : gateway.updateAll(ids))\n // Only a landed row is a change a consumer has to react to; a run whose\n // every row was refused leaves the installed set exactly as it was.\n if (result.applied.length > 0) notifyChange()\n return result\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 official remote namespaces the built-in group reads are OPTIONAL faces:\n // injecting each one keeps its arrival and withdrawal observable, so the\n // group shows what this deployment publishes instead of assuming it.\n try {\n bridgeRemoteNamespaces(ctx)\n } catch (error) {\n // A carrier without them keeps the group's own unavailable state; the\n // failure is logged so it is not mistaken for a deployment that has them.\n console.warn('plugin-manager: bridging the official plugin faces failed', error)\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 updateAll: face.updateAll,\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 built-in group sits at the list's bottom the way the toolbar sits beside\n // its heading: the page declares no seat there, so it is inserted after the\n // page's own installed panel and follows the page through the shared mutation\n // hub. The official faces are sampled per render and the subscription below\n // covers both a language switch and a host-side change event, so the mounted\n // copy never holds a stale answer.\n ctx.effect(() => {\n try {\n return mountBuiltinPluginGroup({\n props: () => ({\n remote: getRemoteSnapshot(),\n resolveText: text => ctx.locale.resolveText(text),\n t: ctx.locale.bind(NS),\n }),\n subscribe: listener => {\n const offLocale = ctx.locale.subscribe(listener)\n const offRemote = subscribeRemote(listener)\n return () => {\n offLocale()\n offRemote()\n }\n },\n })\n } catch (error) {\n // The group is chrome on someone else's page: a failed mount must not take\n // the page down, but it must not disappear without a trace either.\n console.warn('plugin-manager: mounting the built-in plugin group failed', error)\n return () => {}\n }\n }, 'plugin-manager: built-in plugin group')\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,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Y,IAAI;OAChD,GAAG,IAAI,OAAO,KAAK,EAAE;MACvB;MACA,YAAW,aAAY;OACrB,MAAM,YAAY,IAAI,OAAO,UAAU,QAAQ;OAC/C,MAAM,YAAY,gBAAgB,QAAQ;OAC1C,aAAa;QACX,UAAU;QACV,UAAU;OACZ;MACF;KACF,CAAC;IACH,SAAS,OAAO;KAGd,QAAQ,KAAK,6DAA6D,KAAK;KAC/E,aAAa,CAAC;IAChB;GACF,GAAG,uCAAuC;GAM1C,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","Switch","css","css","css"],"sources":["../../../packages/dsh-plugin-manager/src/core/updates.ts","../../../packages/dsh-plugin-manager/src/core/version.ts","../../../packages/dsh-plugin-manager/src/client/ignored-updates.ts","../../../packages/dsh-plugin-manager/src/client/PluginUpdatePatch.tsx","../../../packages/dsh-plugin-manager/src/client/body-mutations.ts","../../../packages/dsh-plugin-manager/src/core/builtin.ts","../../../packages/dsh-plugin-manager/src/client/BuiltinPlugins.tsx","../../../packages/dsh-plugin-manager/src/client/builtin-plugins-mount.tsx","../../../packages/dsh-plugin-manager/src/client/native-faces.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 * 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/** One exact registry version the user chose not to install. */\nexport interface IgnoredPluginUpdate {\n id: string\n version: string\n}\n\n/** Whether this exact offer is ignored; a newer version does not match. */\nexport function isUpdateIgnored(item: PluginUpdateItem, ignored: readonly IgnoredPluginUpdate[]): boolean {\n return ignored.some(entry => entry.id === item.id && entry.version === item.latest)\n}\n\n/** Rows still offered to the user and to the bulk-update queue. */\nexport function unignoredUpdates(items: readonly PluginUpdateItem[], ignored: readonly IgnoredPluginUpdate[]): PluginUpdateItem[] {\n return items.filter(item => !isUpdateIgnored(item, ignored))\n}\n\n/** Rows currently hidden by an exact-version ignore rule. */\nexport function ignoredUpdates(items: readonly PluginUpdateItem[], ignored: readonly IgnoredPluginUpdate[]): PluginUpdateItem[] {\n return items.filter(item => isUpdateIgnored(item, ignored))\n}\n\n/** Add an idempotent exact-version ignore rule. */\nexport function withIgnoredUpdate(current: readonly IgnoredPluginUpdate[], item: PluginUpdateItem): IgnoredPluginUpdate[] {\n if (isUpdateIgnored(item, current)) return [...current]\n return [...current, { id: item.id, version: item.latest }]\n}\n\n/** Remove this exact offer's ignore rule, leaving other plugins untouched. */\nexport function withoutIgnoredUpdate(current: readonly IgnoredPluginUpdate[], item: PluginUpdateItem): IgnoredPluginUpdate[] {\n return current.filter(entry => entry.id !== item.id || entry.version !== item.latest)\n}\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 * 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","/** Browser-local exact-version update ignore rules (issue #2078). */\nimport type { PluginUpdateItem } from '../core/protocol.ts'\nimport { withIgnoredUpdate, withoutIgnoredUpdate, type IgnoredPluginUpdate } from '../core/updates.ts'\n\n/** localStorage key for the versioned ignore-list document. */\nexport const IGNORED_UPDATES_STORAGE_KEY = 'dsh.plugin-manager.ignored-updates.v1'\n\ntype StorageLike = Pick<Storage, 'getItem' | 'setItem'>\n\nfunction browserStorage(): StorageLike | undefined {\n try {\n return globalThis.localStorage\n } catch {\n return undefined\n }\n}\n\n/** Read valid unique rules; malformed or unavailable storage yields an empty list. */\nexport function loadIgnoredUpdates(storage: StorageLike | undefined = browserStorage()): IgnoredPluginUpdate[] {\n if (storage === undefined) return []\n try {\n const parsed: unknown = JSON.parse(storage.getItem(IGNORED_UPDATES_STORAGE_KEY) ?? '[]')\n if (!Array.isArray(parsed)) return []\n const result: IgnoredPluginUpdate[] = []\n const seen = new Set<string>()\n for (const value of parsed) {\n if (typeof value !== 'object' || value === null) continue\n const row = value as Record<string, unknown>\n if (typeof row.id !== 'string' || row.id === '' || typeof row.version !== 'string' || row.version === '') continue\n const key = JSON.stringify([row.id, row.version])\n if (seen.has(key)) continue\n seen.add(key)\n result.push({ id: row.id, version: row.version })\n }\n return result\n } catch {\n return []\n }\n}\n\n/** Persist the list when storage permits; the in-memory answer remains usable either way. */\nexport function saveIgnoredUpdates(ignored: readonly IgnoredPluginUpdate[], storage: StorageLike | undefined = browserStorage()): void {\n try {\n storage?.setItem(IGNORED_UPDATES_STORAGE_KEY, JSON.stringify(ignored))\n } catch {\n // Private-mode and quota failures degrade the rule to this page session.\n }\n}\n\n/** Ignore one exact offer and persist the resulting independent list. */\nexport function rememberIgnoredUpdate(current: readonly IgnoredPluginUpdate[], item: PluginUpdateItem): IgnoredPluginUpdate[] {\n const next = withIgnoredUpdate(current, item)\n saveIgnoredUpdates(next)\n return next\n}\n\n/** Restore one exact offer and persist the resulting independent list. */\nexport function forgetIgnoredUpdate(current: readonly IgnoredPluginUpdate[], item: PluginUpdateItem): IgnoredPluginUpdate[] {\n const next = withoutIgnoredUpdate(current, item)\n saveIgnoredUpdates(next)\n return next\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, type CSSProperties } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { InstallProgressItem, PluginUpdateItem, PluginUpdateResult } from '../core/protocol.ts'\nimport { isUpdateIgnored } from '../core/updates.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport { forgetIgnoredUpdate, loadIgnoredUpdates, rememberIgnoredUpdate } from './ignored-updates.ts'\nimport css from './plugin-manager.module.css'\n\n/**\n * The custom property carrying the determinate fraction (0 to 1). The bar is a\n * full-width element the stylesheet scales along its own axis, so a progress\n * tick repaints one compositor property instead of re-laying-out the row.\n */\nconst PROGRESS_VARIABLE = '--plugin-manager-progress'\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 /** Whether the exact offer in found is currently ignored. */\n const [ignored, setIgnored] = useState(false)\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(snapshot => {\n if (!stopped && snapshot !== undefined) {\n setProgress(snapshot)\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 const update = items.find(item => item.id === name)\n setFound(update)\n setIgnored(update !== undefined && isUpdateIgnored(update, loadIgnoredUpdates()))\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 onIgnore = (): void => {\n if (busyRef.current || found === undefined) return\n rememberIgnoredUpdate(loadIgnoredUpdates(), found)\n setIgnored(true)\n }\n\n const onRestore = (): void => {\n if (busyRef.current || found === undefined) return\n forgetIgnoredUpdate(loadIgnoredUpdates(), found)\n setIgnored(false)\n }\n\n const onUpdate = (): void => {\n if (busyRef.current || found === undefined || ignored) 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 && !ignored && (\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 {found !== undefined && !ignored && (\n <button type=\"button\" className={css.button} data-update-ignore disabled={busy !== undefined} onClick={onIgnore}>\n {t('ignoreUpdate')}\n </button>\n )}\n {found !== undefined && ignored && (\n <span className={css.hint} data-update-ignored>{t('ignoredUpdate')}</span>\n )}\n {found !== undefined && ignored && (\n <button type=\"button\" className={css.button} data-update-restore disabled={busy !== undefined} onClick={onRestore}>\n {t('restoreUpdate')}\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\n ? undefined\n : { [PROGRESS_VARIABLE]: String(progress.percent / 100) } as CSSProperties}\n data-indeterminate={progress.percent === undefined ? 'true' : undefined}\n data-update-progress={progress.percent === undefined ? 'indeterminate' : 'determinate'}\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 * The built-in plugin group's pure logic: which global Loader entries no\n * installed bundle contributes, how each one may be written, and the two answer\n * shapes the official remote namespaces return.\n *\n * \"Built-in\" is a subtraction, not a roster of ours: the inventory's Loader\n * entries minus every entry an installed bundle's patch inserts. That covers the\n * rows a profile patch inserts itself — the Computer Use pair among them — and\n * the rows the host ships globally, without this package keeping a list that\n * would drift. The modules the official manager protects are refused by the\n * manager itself and reported per row as `readOnlyReason`, so no second\n * whitelist lives here.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\n/** Literal text or translations indexed by language id, as package metadata carries it. */\nexport type DisplayText = string | { readonly en: string; readonly [locale: string]: string }\n\n/** Display metadata the inventory attaches to a Loader entry. */\nexport interface EntryMeta {\n readonly title?: DisplayText\n readonly description?: DisplayText\n readonly icon?: string\n readonly error?: string\n}\n\n/** A Loader entry's fiber phase, or null when the entry has no live root. */\nexport type FiberPhase = null | 'failed' | 'pending' | 'active' | 'loading' | 'unloading'\n\n/** One Loader entry as `pluginInventory.list()` reports it. */\nexport interface LoaderEntry {\n readonly entryId: string\n readonly moduleName: string\n readonly meta?: EntryMeta\n readonly enabled: boolean\n readonly fiberPhase: FiberPhase\n}\n\n/** One composition row of an agent preset. */\nexport interface AgentPresetRow {\n readonly entryId: string | null\n readonly moduleName: string\n readonly meta?: EntryMeta\n readonly enabled: boolean | 'conditional'\n /** The row's own `!!js` disabled expression, when it carries one. */\n readonly condition?: string\n readonly fiberPhase: FiberPhase\n}\n\n/** One composed agent preset. */\nexport interface AgentPreset {\n readonly id: string\n readonly name?: string\n readonly isDefault: boolean\n /** Why this preset's composition cannot be read; absent when rows answer. */\n readonly broken?: string\n readonly rows: readonly AgentPresetRow[]\n}\n\n/** The `pluginInventory.list()` snapshot this group consumes. */\nexport interface PluginInventory {\n readonly managementAvailable?: boolean\n readonly entries: readonly LoaderEntry[]\n readonly agentPresets?: readonly AgentPreset[]\n}\n\n/** The slice of `pluginManager.listBundles()` this group subtracts. */\nexport interface BundleFacts {\n /** The installed bundle's package name; the row's owner reads as this. */\n readonly name?: string\n /**\n * Whether the profile actually declares this bundle. The roster also reports\n * bundles that are only available, and their declared rows are no mounted\n * Loader entries — counting them would take a live row out of the default scope\n * over a package that is not even installed, so `false` is skipped. Absent\n * keeps the bundle in play, which is how the manager always answers.\n */\n readonly installed?: boolean\n readonly rows?: readonly { readonly entryId?: string }[]\n}\n\n/** The slice of `pluginManager.listPlugins()` that decides a row's writability. */\nexport interface PluginFacts {\n readonly entryId: string\n readonly readOnlyReason?: 'management-required' | 'unaddressable'\n}\n\n/** Why a row's switch is locked, or that the manager will take a write. */\nexport type WriteState = 'writable' | 'management-required' | 'unaddressable' | 'unknown'\n\n/** One row of the built-in group, in whichever scope it is shown. */\nexport interface BuiltinRow {\n readonly entryId: string\n readonly moduleName: string\n readonly meta?: EntryMeta\n readonly enabled: boolean\n readonly write: WriteState\n /**\n * The installed bundle whose patch inserts this entry, by package name. Absent\n * on a row no bundle contributes — the rows the group lists by default.\n */\n readonly ownedBy?: string\n}\n\n/** The group's two scopes, the ownership behind them, and the roster state. */\nexport interface BuiltinSelection {\n /** The default scope: the entries no installed bundle contributes. */\n readonly rows: readonly BuiltinRow[]\n /**\n * Every Loader entry in Loader order, with `ownedBy` on the ones a bundle\n * contributes. Same row shape as {@link BuiltinSelection.rows}, so the two\n * scopes render through one path.\n */\n readonly allRows: readonly BuiltinRow[]\n /** Loader entry id to the package name of the bundle that inserts it. */\n readonly owners: ReadonlyMap<string, string>\n /**\n * `confirmed` when every installed bundle was read and its rows subtracted;\n * `unconfirmed` when that read failed and every entry is listed instead.\n */\n readonly bundles: 'confirmed' | 'unconfirmed'\n}\n\n/**\n * Select the built-in group's two scopes in one pass: every Loader entry, the\n * ones no installed bundle contributes, and which bundle contributes the rest.\n *\n * The default scope is the subtraction the group shipped with; the wider scope is\n * the same rows plus the ones a bundle's patch inserts, each named after that\n * bundle — the reason a reader meets them again on the bundle's own page.\n * @param inventory - the Loader snapshot.\n * @param bundles - every installed bundle, or undefined when `listBundles()`\n * failed; both scopes then list every entry and the group says so.\n * @param plugins - the manager's plugin rows, or undefined when that read\n * failed; an unread row is reported as `unknown` rather than guessed writable.\n * @returns both scopes, the ownership map behind them, and the roster state.\n */\nexport function selectBuiltinEntries(\n inventory: PluginInventory,\n bundles: readonly BundleFacts[] | undefined,\n plugins: readonly PluginFacts[] | undefined,\n): BuiltinSelection {\n const owners = new Map<string, string>()\n for (const bundle of bundles ?? []) {\n if (bundle.installed === false) continue\n for (const row of bundle.rows ?? []) {\n // First writer wins: a row two patches touch still names the bundle that\n // contributes it, and a bundle without a readable name keeps the id out of\n // the default scope either way.\n if (row.entryId !== undefined && !owners.has(row.entryId)) owners.set(row.entryId, bundle.name ?? '')\n }\n }\n const writability = new Map<string, WriteState>()\n for (const plugin of plugins ?? []) {\n writability.set(plugin.entryId, plugin.readOnlyReason ?? 'writable')\n }\n const allRows = inventory.entries.map((entry): BuiltinRow => {\n const shared = {\n entryId: entry.entryId,\n moduleName: entry.moduleName,\n meta: entry.meta,\n enabled: entry.enabled,\n write: writability.get(entry.entryId) ?? 'unknown',\n }\n const ownedBy = owners.get(entry.entryId)\n return ownedBy === undefined ? shared : { ...shared, ownedBy }\n })\n return {\n rows: allRows.filter(row => row.ownedBy === undefined),\n allRows,\n owners,\n bundles: bundles === undefined ? 'unconfirmed' : 'confirmed',\n }\n}\n\n/** One official remote answer: the gateway's envelope, or a bare value. */\nexport type RemoteAnswer<T> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly code?: string }\n\n/**\n * Read one `remote.<namespace>` answer.\n *\n * The API gateway wraps every namespace result as `{ ok, value | error }`, and a\n * carrier that hands the bare value back must not be mistaken for a failure —\n * so an object is treated as an envelope only when its `ok` really is a boolean,\n * and anything else passes through as the value itself.\n * @param raw - the resolved answer, exactly as the namespace returned it.\n * @returns the unwrapped value, or the envelope's error code.\n */\nexport function readRemoteAnswer<T>(raw: unknown): RemoteAnswer<T> {\n if (typeof raw === 'object' && raw !== null && typeof (raw as { ok?: unknown }).ok === 'boolean') {\n const envelope = raw as { ok: boolean; value?: T; error?: { code?: string } }\n if (envelope.ok) return { ok: true, value: envelope.value as T }\n return { ok: false, code: envelope.error?.code }\n }\n return { ok: true, value: raw as T }\n}\n\n/** The applications one write can end in. */\nexport type ChangeApplication = 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled'\n\n/**\n * What a write achieved: the application the host settled on, or the code it\n * failed with. `overridden` is a resolved write a higher profile layer wins\n * over — the official page reports it as its own notice rather than a failure,\n * because the manager did accept the call.\n */\nexport type ChangeOutcome =\n | {\n readonly ok: true\n readonly application: 'applied' | 'overridden' | 'restart-required'\n /** Why `restart-required`, as the host named it. */\n readonly restartReason?: string\n }\n | { readonly ok: false; readonly code: string }\n\n/** The result fields of one `setPluginEnabled` answer. */\ninterface ChangeResultFields {\n readonly application?: ChangeApplication\n readonly restartReason?: string\n readonly error?: { readonly code?: string }\n}\n\n/**\n * Read one `setPluginEnabled` answer.\n *\n * The official manager folds a refusal into the resolved result\n * (`application: 'failed'` with an `error.code`) instead of rejecting, so a\n * resolved promise is not a success. Both answer shapes are accepted because\n * the gateway's envelope and the bare `ChangeResult` are the same call seen\n * through two carriers.\n * @param raw - the resolved answer.\n * @returns the outcome the switch should show.\n */\nexport function readChangeResult(raw: unknown): ChangeOutcome {\n const answer = readRemoteAnswer<ChangeResultFields>(raw)\n if (!answer.ok) return { ok: false, code: answer.code ?? 'operation-error' }\n const result = answer.value\n const application = result?.application\n if (application === undefined) return { ok: false, code: 'operation-error' }\n if (application === 'failed' || application === 'cancelled') {\n return { ok: false, code: result.error?.code ?? application }\n }\n return { ok: true, application, restartReason: result.restartReason }\n}\n","/**\n * The \"Built-in plugins\" group at the bottom of the official Plugins page.\n *\n * By default it lists every global Loader entry no installed bundle contributes —\n * the rows a profile patch inserts itself (the Computer Use pair among them) and\n * the rows the host ships globally — each with the official manager's own switch,\n * so a row is enabled or disabled by exactly the call the official page makes.\n * One control widens that list to every Loader entry and names, on each row a\n * bundle adds, the bundle that adds it: those rows are the ones a reader also\n * meets on that bundle's own page, and the answer to \"why is this here twice\" is\n * that sentence. Below it, the agent preset compositions the same inventory\n * reports are rendered read-only: a preset's rows are composed per session and\n * only a Loader context can decide a `!!js` condition, so nothing here offers\n * them a switch.\n *\n * Every state shown is the Loader's own: after an accepted write the group\n * re-reads instead of trusting the answer, a refusal is named by the code the\n * manager returned, and a locked row says which lock it is.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport { useEffect, useId, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport { Switch } from '@deepseek-ai/dsh-client-ui-primitives'\nimport {\n readChangeResult,\n readRemoteAnswer,\n selectBuiltinEntries,\n type AgentPreset,\n type AgentPresetRow,\n type BuiltinRow,\n type BundleFacts,\n type DisplayText,\n type PluginFacts,\n type PluginInventory,\n type WriteState,\n} from '../core/builtin.ts'\nimport type { ManagerFace, RemoteSnapshot } from './native-faces.ts'\nimport css from './plugin-manager.module.css'\n\n/** The operations the group drives, all of them the official manager's own. */\nexport interface BuiltinPluginsInjected {\n /** The official faces, sampled on every render; its `version` moves on change. */\n remote: RemoteSnapshot\n /**\n * Resolve package metadata text through the language the GUI is showing. The\n * inventory hands back translations, not strings, and the mount owns no\n * language of its own.\n */\n resolveText: (text: DisplayText) => string\n}\n\n/** Full component props. */\nexport type BuiltinPluginsProps =\n & PropsLocale<'settings.pluginManager'>\n & BuiltinPluginsInjected\n\n/** What the group knows about the deployment right now. */\ntype GroupState =\n | { readonly kind: 'loading' }\n | { readonly kind: 'unavailable' }\n | { readonly kind: 'failed'; readonly code: string }\n | {\n readonly kind: 'ready'\n /** The default scope: the rows no installed bundle contributes. */\n readonly rows: readonly BuiltinRow[]\n /** Every Loader entry, with `ownedBy` on the rows a bundle contributes. */\n readonly allRows: readonly BuiltinRow[]\n readonly presets: readonly AgentPreset[]\n readonly bundles: 'confirmed' | 'unconfirmed'\n }\n\n/** One line of feedback under the heading. */\ninterface Notice {\n /** A refusal, or the passing note a resolved-but-not-live write deserves. */\n readonly tone: 'error' | 'note'\n readonly text: string\n}\n\n/** Which refusal code reads as which sentence. */\nconst REFUSAL_KEYS = {\n 'management-required': 'builtinReasonManagementRequired',\n 'unaddressable': 'builtinReasonUnaddressable',\n} as const\n\n/** Which restart reason reads as which sentence. */\nconst RESTART_KEYS = {\n 'no-hmr': 'builtinRestartNoHmr',\n 'package-moved': 'builtinRestartPackageMoved',\n 'host-module': 'builtinRestartHostModule',\n 'unmanaged-plugin': 'builtinRestartUnmanagedPlugin',\n 'module-comparison': 'builtinRestartModuleComparison',\n} as const\n\n/** Translate in this package's namespace. */\ntype Translate = BuiltinPluginsProps['t']\n\n/**\n * The one reason a failure this component could not name may show: the manager's\n * own generic code. A caught exception keeps its message out of the interface —\n * a host diagnostic can carry an absolute path — and is logged instead.\n */\nconst FALLBACK_CODE = 'operation-error'\n\n/** Keep the expanded inventory bounded: the full result stays available to search. */\nconst BUILTIN_PAGE_SIZE = 20\n\n/** Log one caught failure where a developer can read it, naming what failed. */\nfunction warnFailure(what: string, error: unknown): void {\n console.warn(`plugin-manager: ${what}`, error)\n}\n\n/**\n * What one refusal code reads as. A code this package has no sentence for is\n * shown as the code itself: the manager named it, and a guessed sentence would\n * be worse than the name it gave.\n */\nfunction refusalText(code: string, t: Translate): string {\n const key = REFUSAL_KEYS[code as keyof typeof REFUSAL_KEYS]\n return key === undefined ? code : t(key)\n}\n\n/** Why a row's switch is locked, in the reader's language. */\nfunction writeReason(write: WriteState, t: Translate): string {\n if (write === 'writable') return ''\n if (write === 'unknown') return t('builtinReasonUnknown')\n return refusalText(write, t)\n}\n\n/** Why a write needs a restart, in the reader's language. */\nfunction restartReason(reason: string | undefined, t: Translate): string {\n if (reason === undefined) return t('builtinRestartUnnamed')\n const key = RESTART_KEYS[reason as keyof typeof RESTART_KEYS]\n return key === undefined ? t('builtinRestartUnnamed') : t(key)\n}\n\n/** One row's display title, falling back to the module it names. */\nfunction rowTitle(\n row: { readonly meta?: { readonly title?: DisplayText }; readonly moduleName: string },\n resolveText: BuiltinPluginsInjected['resolveText'],\n): string {\n const title = row.meta?.title\n if (title === undefined) return row.moduleName\n const resolved = resolveText(title)\n return resolved === '' ? row.moduleName : resolved\n}\n\n/** One preset row's state, as the composition reports it. */\nfunction presetRowState(row: AgentPresetRow): 'on' | 'off' | 'conditional' {\n if (row.enabled === 'conditional') return 'conditional'\n return row.enabled ? 'on' : 'off'\n}\n\n/** One preset row's state text; a conditional row names its own expression. */\nfunction presetRowText(row: AgentPresetRow, t: Translate): string {\n if (row.enabled === 'conditional') {\n return row.condition === undefined\n ? t('presetRowConditionalUnnamed')\n : t('presetRowConditional', { condition: row.condition })\n }\n return row.enabled ? t('presetRowOn') : t('presetRowOff')\n}\n\n/**\n * Read one manager list, treating a refused or failed read as unknown. A row\n * whose writability could not be read is shown locked, never writable.\n */\nasync function readList<T>(read: () => Promise<unknown>): Promise<T | undefined> {\n try {\n const answer = readRemoteAnswer<T>(await read())\n if (!answer.ok) return undefined\n return Array.isArray(answer.value) ? answer.value as T : undefined\n } catch (error) {\n warnFailure('built-in group list read failed', error)\n return undefined\n }\n}\n\n/**\n * Whether an inventory answer is really a snapshot. The namespace hands back\n * `entries`; anything else — a bare null, an envelope with no value, a value\n * whose entries is not a list — is a failure this group reports rather than one\n * it walks into.\n */\nfunction isInventory(value: unknown): value is PluginInventory {\n return typeof value === 'object'\n && value !== null\n && Array.isArray((value as { entries?: unknown }).entries)\n}\n\n/**\n * Read the whole group: the Loader snapshot, then the two manager lists that\n * decide which entries are built-in and which of them can be written.\n * @param remote - the sampled official faces.\n * @returns the group's state; a read this deployment cannot serve stays a state,\n * never an exception.\n */\nasync function readGroup(remote: RemoteSnapshot): Promise<GroupState> {\n const inventoryFace = remote.inventory\n if (inventoryFace === null) return { kind: 'unavailable' }\n try {\n const answer = readRemoteAnswer<PluginInventory>(await inventoryFace.list())\n // A refusal keeps the code the host named; anything else that is not a\n // snapshot at all is reported as this component's own generic failure.\n if (!answer.ok) return { kind: 'failed', code: answer.code ?? FALLBACK_CODE }\n if (!isInventory(answer.value)) return { kind: 'failed', code: FALLBACK_CODE }\n const inventory = answer.value\n const manager: ManagerFace | null = remote.manager\n const [plugins, bundles] = await Promise.all([\n manager === null ? Promise.resolve(undefined) : readList<readonly PluginFacts[]>(() => manager.listPlugins()),\n manager === null ? Promise.resolve(undefined) : readList<readonly BundleFacts[]>(() => manager.listBundles()),\n ])\n const selection = selectBuiltinEntries(inventory, bundles, plugins)\n return {\n kind: 'ready',\n rows: selection.rows,\n allRows: selection.allRows,\n bundles: selection.bundles,\n presets: Array.isArray(inventory.agentPresets) ? inventory.agentPresets : [],\n }\n } catch (error) {\n // The whole read is guarded, not just the call: a malformed snapshot would\n // otherwise reject out of the effect below and leave the group reading for\n // ever, which reads as a hang rather than as the failure it is.\n warnFailure('built-in group read failed', error)\n return { kind: 'failed', code: FALLBACK_CODE }\n }\n}\n\n/**\n * The group itself. All state is local: the page around it owns the plugin list,\n * and the Loader is the only truth this component reports.\n */\nexport function BuiltinPlugins(props: BuiltinPluginsProps) {\n const { t, remote, resolveText } = props\n const [state, setState] = useState<GroupState>({ kind: 'loading' })\n /** Bumped after an accepted write, so the group reads the Loader again. */\n const [reload, setReload] = useState(0)\n /** The one write in flight, mirrored into the switches before the re-read. */\n const [pending, setPending] = useState<{ entryId: string; enabled: boolean } | undefined>(undefined)\n /** Synchronous in-flight mirror: two clicks can land in one frame. */\n const writingRef = useRef(false)\n const [notice, setNotice] = useState<Notice | undefined>(undefined)\n\n // A re-read keeps the rows it already shows until the new answer lands, so a\n // toggle never collapses the list under the pointer.\n useEffect(() => {\n let live = true\n void readGroup(remote).then(state => {\n if (live) setState(state)\n })\n return () => { live = false }\n }, [remote, reload])\n\n /**\n * Which scope the list shows. Switching it only picks between the two sets the\n * last read already answered with: it never reads again and never touches a\n * row's enablement, so a reader can widen the list without the Loader moving.\n */\n const [scope, setScope] = useState<'default' | 'all'>('default')\n const [query, setQuery] = useState('')\n const [page, setPage] = useState(1)\n const listId = useId()\n\n const ready = state.kind === 'ready' ? state : undefined\n const rows = ready === undefined ? [] : scope === 'all' ? ready.allRows : ready.rows\n /** Rows the default scope leaves out: what the scope control would add. */\n const ownedCount = ready === undefined ? 0 : ready.allRows.length - ready.rows.length\n const presets = ready === undefined ? [] : ready.presets\n const normalizedQuery = query.trim().toLowerCase()\n const filteredRows = normalizedQuery === ''\n ? rows\n : rows.filter(row => [\n rowTitle(row, resolveText),\n row.moduleName,\n row.entryId,\n row.ownedBy ?? '',\n ].some(text => text.toLowerCase().includes(normalizedQuery)))\n const pageCount = Math.max(1, Math.ceil(filteredRows.length / BUILTIN_PAGE_SIZE))\n const currentPage = Math.min(page, pageCount)\n const pageStart = (currentPage - 1) * BUILTIN_PAGE_SIZE\n const visibleRows = filteredRows.slice(pageStart, pageStart + BUILTIN_PAGE_SIZE)\n\n /**\n * The visible label of each row: its name, and the line under it — the module, or\n * the entry id when the name already is that module. Two rows carrying the same\n * pair read identically, which is the only case where the row has to say which\n * entry it is; a title two rows share is exactly that case, and so is a module\n * several rows name. Counted over the filtered result, so paging cannot hide\n * the other half of a collision; each scope still answers for itself.\n */\n const labels = new Map<string, string>()\n const labelCounts = new Map<string, number>()\n for (const row of filteredRows) {\n const title = rowTitle(row, resolveText)\n const label = `${title}\\u0000${title === row.moduleName ? row.entryId : row.moduleName}`\n labels.set(row.entryId, label)\n labelCounts.set(label, (labelCounts.get(label) ?? 0) + 1)\n }\n /** Whether this row's visible labels are shared with another row on screen. */\n const collides = (entryId: string): boolean => (labelCounts.get(labels.get(entryId) ?? '') ?? 0) > 1\n\n /**\n * Ask the official manager to enable or disable one row, then re-read. The\n * switch moves first and comes back on a refusal, so what it shows afterwards\n * is the answer this deployment gave rather than the click that produced it.\n */\n const toggle = (row: BuiltinRow, next: boolean): void => {\n const manager = remote.manager\n if (manager === null || row.write !== 'writable' || writingRef.current) return\n writingRef.current = true\n setPending({ entryId: row.entryId, enabled: next })\n setNotice(undefined)\n void (async () => {\n let outcome\n try {\n outcome = readChangeResult(await manager.setPluginEnabled(row.entryId, next))\n } catch (error) {\n warnFailure('built-in group write failed', error)\n outcome = { ok: false as const, code: FALLBACK_CODE }\n }\n writingRef.current = false\n setPending(undefined)\n if (!outcome.ok) {\n setNotice({\n tone: 'error',\n text: t(next ? 'builtinFailedEnable' : 'builtinFailedDisable', { reason: refusalText(outcome.code, t) }),\n })\n return\n }\n // A resolved write is not always a state the page will keep: the next start\n // loads a restart-required change, and a higher profile layer wins over an\n // overridden one. The re-read below is what makes the switch show the Loader\n // either way; this line is what tells the reader which of the two happened.\n // A restart-required write is not a success: the change is on disk and the\n // running process still serves the old state, so it is said in the same\n // passing tone as an overridden one.\n setNotice(outcome.application === 'restart-required'\n ? { tone: 'note', text: t('builtinRestartRequired', { reason: restartReason(outcome.restartReason, t) }) }\n : outcome.application === 'overridden'\n ? { tone: 'note', text: t('builtinOverridden', { name: rowTitle(row, resolveText) }) }\n : undefined)\n setReload(token => token + 1)\n })()\n }\n\n return (\n <section\n className={css.builtinGroup}\n data-dsh-plugin=\"plugin-manager\"\n data-dsh-part=\"builtin-group\"\n data-builtin-state={state.kind}\n data-builtin-bundles={state.kind === 'ready' ? state.bundles : undefined}\n data-builtin-scope={scope}\n aria-busy={state.kind === 'loading'}\n >\n <div className={css.builtinHead}>\n <h3 className={css.builtinTitle}>{t('builtinGroup')}</h3>\n {ready !== undefined && ready.bundles === 'confirmed' && (\n <span className={css.builtinCount} data-builtin-count={filteredRows.length}>{filteredRows.length}</span>\n )}\n {ownedCount > 0 && (\n <button\n type=\"button\"\n className={css.builtinScope}\n data-dsh-part=\"builtin-scope\"\n aria-expanded={scope === 'all'}\n aria-controls={listId}\n onClick={() => {\n setScope(scope === 'all' ? 'default' : 'all')\n setPage(1)\n }}\n >\n {t(scope === 'all' ? 'builtinScopeCollapse' : 'builtinScopeExpand', { count: String(ownedCount) })}\n </button>\n )}\n </div>\n\n {state.kind === 'loading' && <p className={css.hint} role=\"status\">{t('builtinReading')}</p>}\n {state.kind === 'unavailable' && <p className={css.hint}>{t('builtinUnavailable')}</p>}\n {state.kind === 'failed' && (\n <p className={css.error} role=\"alert\">{t('builtinFailed', { reason: state.code })}</p>\n )}\n {state.kind === 'ready' && state.bundles === 'unconfirmed' && (\n <p className={css.hint} data-builtin-unconfirmed>{t('builtinUnconfirmed')}</p>\n )}\n {notice !== undefined && (\n <p\n className={notice.tone === 'error' ? css.error : css.hint}\n role={notice.tone === 'error' ? 'alert' : 'status'}\n data-dsh-part=\"builtin-notice\"\n data-notice-tone={notice.tone}\n >\n {notice.text}\n </p>\n )}\n {ready !== undefined && rows.length === 0 && <p className={css.hint}>{t('builtinEmpty')}</p>}\n\n {rows.length > 0 && (\n <div className={css.builtinTools}>\n <input\n className={css.builtinSearch}\n type=\"search\"\n value={query}\n spellCheck={false}\n autoComplete=\"off\"\n aria-label={t('builtinSearchLabel')}\n aria-controls={listId}\n placeholder={t('builtinSearchPlaceholder')}\n data-builtin-search\n onChange={(event) => {\n setQuery(event.target.value)\n setPage(1)\n }}\n onKeyDown={(event) => {\n if (event.key === 'Escape' && query !== '') {\n setQuery('')\n setPage(1)\n }\n }}\n />\n </div>\n )}\n {rows.length > 0 && filteredRows.length === 0 && (\n <p className={css.hint} role=\"status\">{t('builtinSearchEmpty')}</p>\n )}\n\n {rows.length > 0 && (\n <ul className={css.builtinList} id={listId}>\n {visibleRows.map(row => {\n const title = rowTitle(row, resolveText)\n const reason = writeReason(row.write, t)\n const locked = row.write !== 'writable'\n const checked = pending?.entryId === row.entryId ? pending.enabled : row.enabled\n return (\n <li\n key={row.entryId}\n className={css.builtinRow}\n data-dsh-part=\"builtin-row\"\n data-entry-id={row.entryId}\n data-write={row.write}\n data-owned-by={row.ownedBy}\n >\n <span className={css.builtinMain}>\n <span className={css.builtinName}>{title}</span>\n <span className={css.builtinModule}>\n {title === row.moduleName ? row.entryId : row.moduleName}\n </span>\n {collides(row.entryId) && (\n <span className={css.builtinModule} data-entry-revealed={row.entryId}>{row.entryId}</span>\n )}\n {row.ownedBy !== undefined && row.ownedBy !== '' && (\n <span className={css.builtinOwner} data-dsh-part=\"builtin-owner\">\n {t('builtinOwnedBy', { name: row.ownedBy })}\n </span>\n )}\n {locked && <span className={css.builtinReason}>{reason}</span>}\n </span>\n <Switch\n checked={checked}\n label={t('builtinToggle', { name: title })}\n disabled={locked || pending !== undefined || remote.manager === null}\n {...locked ? { title: reason } : {}}\n onChange={next => { toggle(row, next) }}\n />\n </li>\n )\n })}\n </ul>\n )}\n {filteredRows.length > BUILTIN_PAGE_SIZE && (\n <div className={css.builtinPagination} data-dsh-part=\"pagination\">\n <button\n type=\"button\"\n className={css.button}\n disabled={currentPage === 1}\n onClick={() => { setPage(currentPage - 1) }}\n >\n {t('builtinPagePrevious')}\n </button>\n <span className={css.builtinPageInfo} aria-live=\"polite\">\n {t('builtinPageInfo', {\n page: String(currentPage),\n pages: String(pageCount),\n count: String(filteredRows.length),\n })}\n </span>\n <button\n type=\"button\"\n className={css.button}\n disabled={currentPage === pageCount}\n onClick={() => { setPage(currentPage + 1) }}\n >\n {t('builtinPageNext')}\n </button>\n </div>\n )}\n\n {presets.length > 0 && (\n <section className={css.presetGroup} data-dsh-part=\"preset-group\">\n <h4 className={css.presetTitle}>{t('presetGroup')}</h4>\n <ul className={css.presetList}>\n {presets.map(preset => (\n <li\n key={preset.id}\n className={css.presetCard}\n data-dsh-part=\"preset\"\n data-preset-id={preset.id}\n data-default={preset.isDefault ? 'yes' : 'no'}\n >\n <span className={css.presetHead}>\n <span className={css.presetName}>{preset.name ?? preset.id}</span>\n {preset.isDefault && <span className={css.presetTag}>{t('presetDefault')}</span>}\n </span>\n {preset.broken === undefined ? (\n <ul className={css.presetRows}>\n {preset.rows.map((row, index) => (\n <li\n key={row.entryId ?? `${preset.id}:${String(index)}`}\n className={css.presetRow}\n data-dsh-part=\"preset-row\"\n data-preset-state={presetRowState(row)}\n >\n <span className={css.presetRowName}>{row.moduleName}</span>\n <span className={css.presetRowState}>{presetRowText(row, t)}</span>\n </li>\n ))}\n </ul>\n ) : (\n <p className={css.hint}>{t('presetBroken', { reason: preset.broken })}</p>\n )}\n </li>\n ))}\n </ul>\n </section>\n )}\n </section>\n )\n}\n","/**\n * Mounting the built-in plugin group at the bottom of the official Plugins page.\n *\n * The page declares no seat at the list's end: its extension points are\n * `plugins.detail.*` (per page), `plugins.bundle.config` / `plugins.row.config` /\n * `plugins.item` (configuration entries) and `plugins.bundle.activation`. Its\n * list view is `<section data-plugin-panel> <header/> <div class=\"…_installedPanel\">\n * <section data-plugin-group=\"basic|extensions|bundles\"/> … </div> … </section>`,\n * and the class names are CSS-module hashes, so the seat is found through the\n * page's own data attributes plus DOM position: the section after the installed\n * panel, which is a flex column of 32px gaps whose direct children are exactly\n * the width of the groups above.\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 moves or drops the panel is\n * followed on the next frame, a panel switch that unmounts the list detaches\n * the container until the list returns, and the detail / \"all plugins\" views\n * (which render no bundles group) leave it off the page entirely.\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 { BuiltinPlugins, type BuiltinPluginsProps } from './BuiltinPlugins.tsx'\nimport css from './plugin-manager.module.css'\n\n/** Stable attribute identifying the injected container (mount idempotency). */\nexport const BUILTIN_GROUP_MOUNT_SELECTOR = '[data-dsh-plugin-manager-builtin]'\n\n/** The mount's inputs. */\nexport interface BuiltinGroupMountOptions {\n /** Build the group's props; called on mount and on every locale change. */\n props: () => BuiltinPluginsProps\n /** Locale change subscription (ctx.locale.subscribe); re-renders the group. */\n subscribe?: (listener: () => void) => () => void\n}\n\n/**\n * The official page's installed panel, when the list view is mounted.\n * @returns the element the group belongs after, or undefined off the list view.\n */\nexport function builtinGroupSeat(): HTMLElement | undefined {\n const page = document.querySelector('[data-plugin-panel]')\n const panel = page?.querySelector('[data-plugin-group=\"bundles\"]')?.parentElement\n return panel instanceof HTMLElement ? panel : undefined\n}\n\n/**\n * Mount the built-in plugin group after the installed panel.\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 mountBuiltinPluginGroup(options: BuiltinGroupMountOptions): () => void {\n if (typeof document === 'undefined') return () => {}\n // DOM-level idempotency: whatever path mounted a group before this call (a\n // duplicated apply, an HMR re-injection), never mount a second one.\n if (document.querySelector(BUILTIN_GROUP_MOUNT_SELECTOR) !== null) return () => {}\n\n const container = document.createElement('div')\n container.setAttribute('data-dsh-plugin-manager-builtin', '')\n container.className = css.builtinMount\n const root: Root = createRoot(container)\n const render = (): void => {\n root.render(createElement(BuiltinPlugins, options.props()))\n }\n render()\n\n /**\n * Keep the container immediately after the installed panel; detach while the\n * list is away. React owns the page's children and appends its own blocks\n * (a failure notice among them) after that panel, so the anchor is the\n * panel's next sibling rather than the panel's last child.\n */\n const place = (): void => {\n const seat = builtinGroupSeat()\n if (seat === undefined) {\n container.remove()\n return\n }\n if (container.previousElementSibling !== seat) seat.after(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 * Bridge to the official remote namespaces the built-in plugin group reads\n * through, and to the event that says the host rewrote the profile.\n *\n * - `remote.pluginInventory` — the Loader snapshot (entries and, when a roster is\n * composed, each agent preset's rows).\n * - `remote.pluginManager` — the very manager the official Plugins page drives:\n * per-row writability, the installed bundle roster, and enable/disable.\n * - `plugin-manager/changed` — forwarded on the `remote` root after a write, so a\n * second page (or the official page's own switch) re-reads instead of showing\n * a stale toggle.\n *\n * Every face is OPTIONAL: `ctx.inject` runs the effect when the namespace is\n * published and disposes it when it goes away, which clears the snapshot. An\n * absent face leaves the group's read-only \"unavailable\" state, never a write.\n *\n * CONTRACT OBSERVATION: cross-package value imports are forbidden and this\n * package does not depend on the api-remotes assembly types, so the members\n * called here are re-declared. Their shapes are the official manager's own\n * schemas, not ones this package invented.\n * @module @linxin666/dsh-client-ui-plugin-manager/client\n */\n\nimport type { Context } from '@deepseek-ai/cordis'\n\n/** The inventory namespace's one method. */\nexport interface InventoryFace {\n /** Read the Loader, and every composed preset's rows, on each call. */\n list(): Promise<unknown>\n}\n\n/** The manager namespace's methods this package calls. */\nexport interface ManagerFace {\n /** Every Loader entry with its `patchId` or the reason it cannot be written. */\n listPlugins(): Promise<unknown>\n /** Every installed bundle, with the rows its patch inserts. */\n listBundles(): Promise<unknown>\n /** Enable or disable one Loader entry through the official manager. */\n setPluginEnabled(entryId: string, enabled: boolean): Promise<unknown>\n}\n\n/** The `remote` root's forwarded-event subscription. */\nexport interface RemoteEventFace {\n $on?(event: string, listener: (payload: unknown) => void): () => void\n}\n\n/** What the group reads, sampled per render; `version` moves on every change. */\nexport interface RemoteSnapshot {\n readonly version: number\n readonly inventory: InventoryFace | null\n readonly manager: ManagerFace | null\n}\n\nlet snapshot: RemoteSnapshot = { version: 0, inventory: null, manager: null }\nconst listeners = new Set<() => void>()\n\n/**\n * Merge one face change into the snapshot and notify subscribers. `version`\n * always moves, so a consumer that keys its read on it re-reads after a swap.\n * @param patch - the faces to replace; an omitted face keeps its current value.\n */\nfunction patchRemote(patch: { inventory?: InventoryFace | null; manager?: ManagerFace | null }): void {\n snapshot = {\n version: snapshot.version + 1,\n inventory: patch.inventory === undefined ? snapshot.inventory : patch.inventory,\n manager: patch.manager === undefined ? snapshot.manager : patch.manager,\n }\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 current snapshot (stable reference between changes). */\nexport function getRemoteSnapshot(): RemoteSnapshot {\n return snapshot\n}\n\n/**\n * Subscribe to snapshot changes.\n * @param listener - called after every face swap or forwarded change event.\n * @returns the unsubscribe function.\n */\nexport function subscribeRemote(listener: () => void): () => void {\n listeners.add(listener)\n return () => { listeners.delete(listener) }\n}\n\n/**\n * Bridge the official faces into the snapshot. Uses `ctx.inject` (not the\n * plugin's module-level inject array) so each face stays optional.\n * @param ctx - the client context the plugin runs in.\n */\nexport function bridgeRemoteNamespaces(ctx: Context): void {\n ctx.inject(['remote.pluginInventory'], inner => {\n inner.effect(() => {\n patchRemote({ inventory: (inner.get('remote.pluginInventory') as InventoryFace | undefined) ?? null })\n return () => { patchRemote({ inventory: null }) }\n }, 'plugin-manager: built-in group inventory face')\n })\n ctx.inject(['remote.pluginManager'], inner => {\n inner.effect(() => {\n patchRemote({ manager: (inner.get('remote.pluginManager') as ManagerFace | undefined) ?? null })\n return () => { patchRemote({ manager: null }) }\n }, 'plugin-manager: built-in group manager face')\n })\n ctx.inject(['remote'], inner => {\n inner.effect(() => {\n const remote = inner.get('remote') as RemoteEventFace | undefined\n let off: (() => void) | undefined\n try {\n off = remote?.$on?.('plugin-manager/changed', () => { patchRemote({}) })\n } catch {\n // Forwarded events need a Connection carrying interactions=answer. A\n // carrier without them keeps the group's own read-after-write path, and\n // this subscription stays empty instead of breaking the group.\n }\n return () => { off?.() }\n }, 'plugin-manager: built-in group change feed')\n })\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 { PluginBatchUpdateResult, PluginUpdateItem, RestartMode, RestartPlanWire } from '../core/protocol.ts'\nimport { applicableUpdates, ignoredUpdates, thirdPartyUpdates, unignoredUpdates, type IgnoredPluginUpdate } from '../core/updates.ts'\nimport { displayMinimumVersion } from '../core/version.ts'\nimport { forgetIgnoredUpdate, loadIgnoredUpdates, rememberIgnoredUpdate } from './ignored-updates.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 * Apply every listed update in one run and answer which rows landed and which\n * did not.\n *\n * One call rather than one call per plugin: the sequence (and the decision that\n * a refused row does not end the run) is the host's, so the toolbar no longer\n * spends a request and a job on each row. A row that landed but needs a restart\n * is still an applied row — it joins the restart list instead of failing.\n */\n updateAll: (ids: string[], onRow?: (row: UpdateCursor) => void) => Promise<PluginBatchUpdateResult>\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, a\n * systemd unit restart, or a manual restart), and a plan read has no side\n * effects. A systemd plan carries the unit it would restart.\n */\n restartPlan: () => Promise<RestartPlanWire>\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/** Translate in this package's namespace. */\ntype Translate = PluginListToolbarProps['t']\n\n/**\n * The consequence confirming produces, in the reader's language. It states\n * what the host will actually do, so a systemd plan names the unit that goes\n * down and comes back.\n */\nfunction planCopy(plan: RestartPlanWire | undefined, t: Translate): string {\n // The wire is a discriminated union: a systemd plan carries the unit this\n // copy must name, and no other mode has one to read.\n if (plan?.mode === 'systemd') return t('restartPlanSystemd', { unit: plan.unit })\n if (plan?.mode === 'shell') return t('restartPlanShell')\n if (plan?.mode === 'manual') return t('restartPlanManual')\n return t('restartPlanRelaunch')\n}\n\n/** Which row a running batch is on, as the face reports it. */\nexport interface UpdateCursor {\n /** Package name of the row in flight. */\n id: string\n /** One-based position of that row in the run. */\n index: number\n /** How many rows the run was asked to apply. */\n total: number\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, updateAll, 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 [rows, setRows] = useState<PluginUpdateItem[]>([])\n /** Exact-version offers hidden by the user; the rows remain available for restore. */\n const [ignored, setIgnored] = useState<IgnoredPluginUpdate[]>(() => loadIgnoredUpdates())\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 /**\n * Rows the last run could not apply, with the host's reason. They stay in\n * `rows` — the user has to see which plugin is stuck and why, beside the\n * version it is stuck on — and only the whole-call failure reaches `error`.\n */\n const [failures, setFailures] = useState<{ id: string; error: 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<RestartPlanWire | 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 visibleRows = unignoredUpdates(rows, ignored)\n const ignoredRows = ignoredUpdates(rows, ignored)\n const pending = applicableUpdates(visibleRows)\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 // Re-read on every check so a rule written by the per-plugin block is honored too.\n setIgnored(loadIgnoredUpdates())\n void checkUpdates().then(items => {\n const thirdParty = thirdPartyUpdates(items)\n setRows(thirdParty)\n setApplied([])\n setRestartRequired([])\n setFailures([])\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 onIgnore = (row: PluginUpdateItem): void => {\n if (busyRef.current) return\n setIgnored(rememberIgnoredUpdate(ignored, row))\n }\n\n const onRestore = (row: PluginUpdateItem): void => {\n if (busyRef.current) return\n setIgnored(forgetIgnoredUpdate(ignored, row))\n }\n\n const onUpdateAll = (): void => {\n if (busyRef.current) return\n const queue = applicableUpdates(unignoredUpdates(rows, ignored))\n if (queue.length === 0) return\n busyRef.current = true\n setPhase('updating')\n setError(undefined)\n setFailures([])\n void updateAll(queue.map(row => row.id), row => {\n setCursor({ name: row.id, index: row.index, total: row.total })\n }).then(result => {\n // Every landed row leaves the list, including the ones this process cannot\n // load yet: those are applied (and name their restart), not failures.\n const landed = new Set(result.applied.map(row => row.id))\n const restart = result.applied\n .filter(row => row.restartRequired === true)\n .map(row => ({ id: row.id, version: row.landed ?? '' }))\n setApplied(current => [...current, ...result.applied.map(row => row.id)])\n setRestartRequired(current => [...current, ...restart])\n // A refused row stays listed with the reason the host gave, so the run's\n // partial result is visible row by row instead of as one alert line.\n setFailures(result.failed.map(row => ({ id: row.id, error: row.error ?? t('updateFailedUnknown') })))\n setRows(current => current.filter(item => !landed.has(item.id)))\n }).catch(reason => {\n // The request itself failed (route refused, transport, no writer): nothing\n // ran, so the list stays exactly as it was and the alert explains why.\n setError(t('failed', { reason: messageOf(reason) }))\n }).finally(() => {\n setCursor(undefined)\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(answer => {\n setPlan(answer)\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 /**\n * The host leaves once the route accepts a relaunch or a systemd restart:\n * both replace this process, so the action is spent and reads as in progress.\n */\n const hostLeaves = restartMode === 'relaunch' || restartMode === 'systemd'\n /** The mode the plan read named; the confirmation only opens after one arrived. */\n const planMode = plan?.mode\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 = visibleRows.length\n const failedCount = failures.length\n /**\n * One line for the whole run: the row in flight, what is still pending, and —\n * once nothing is — whether the run landed everything or only part of it. A\n * partial run must not read as a clean one.\n */\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 : failedCount > 0\n ? t('updateAllPartial', { done: String(applied.length), failed: String(failedCount) })\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 || hostLeaves}\n onClick={() => { if (panel === 'restart') { setPanel('none'); setPlan(undefined); return } onAskRestart() }}\n >\n {hostLeaves ? 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 && (\n <p className={css.ok} data-update-applied>\n {failedCount > 0\n ? t('updateAllPartial', { done: String(applied.length), failed: String(failedCount) })\n : t('updateAllDone')}\n </p>\n )}\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 {visibleRows.length === 0 && applied.length === 0 && error === undefined && <p className={css.hint}>{t('noUpdates')}</p>}\n {visibleRows.length > 0 && (\n <ul className={css.panelList}>\n {visibleRows.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 const failure = failures.find(item => item.id === row.id)\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 {failure === undefined ? null : (\n <span className={css.compatBlocked} data-update-row-error={failure.id}>\n {t('updateFailedRow', { reason: failure.error })}\n </span>\n )}\n <button\n type=\"button\"\n className={`${css.toolbarButton} ${css.rowAction}`}\n data-update-ignore={row.id}\n disabled={busy}\n onClick={() => { onIgnore(row) }}\n >\n {t('ignoreUpdate')}\n </button>\n </li>\n )\n })}\n </ul>\n )}\n {ignoredRows.length > 0 && (\n <div data-ignored-updates>\n <p className={css.hint}>{t('ignoredUpdates', { count: String(ignoredRows.length) })}</p>\n <ul className={css.panelList}>\n {ignoredRows.map(row => (\n <li key={row.id} className={css.panelRow} data-ignored-update-row={row.id}>\n <span className={css.panelName}>{row.id}</span>\n <span className={css.panelVersion}>{row.current} → {row.latest}</span>\n <button\n type=\"button\"\n className={`${css.toolbarButton} ${css.rowAction}`}\n data-update-restore={row.id}\n disabled={busy}\n onClick={() => { onRestore(row) }}\n >\n {t('restoreUpdate')}\n </button>\n </li>\n ))}\n </ul>\n </div>\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={planMode} role=\"group\" aria-label={t('restartNow')}>\n {errorLine}\n <p className={css.hint} data-restart-plan-hint={planMode}>\n {planCopy(plan, t)}\n </p>\n {planMode === '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 {planMode !== '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 'updateAllPartial': '已更新 {done} 个,{failed} 个失败',\n 'updateFailedRow': '更新失败:{reason}',\n 'updateFailedUnknown': '宿主没有说明失败原因',\n 'updateRestartRequired': '已更新到 {version},需重启 DSH 后生效',\n 'updatesPanelTitle': '插件更新',\n 'ignoreUpdate': '忽略此版本',\n 'ignoredUpdate': '已忽略此版本。',\n 'ignoredUpdates': '已忽略 {count} 个版本',\n 'restoreUpdate': '恢复更新',\n 'thirdPartyOnly': '只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。',\n 'restartNow': '立即重启',\n 'restarting': '正在重启…',\n 'restartConfirm': '确认重启',\n 'restartPlanRelaunch': '会重启 DSH 服务,正在运行的任务会中断。',\n 'restartPlanShell': '桌面版重启由应用外壳执行:确认后宿主进程会退出,由外壳重新拉起。',\n 'restartPlanSystemd': '会由 systemd 重启 {unit},正在运行的任务会中断。',\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 'builtinGroup': '内置插件',\n 'builtinReading': '正在读取内置插件…',\n 'builtinEmpty': '没有内置插件。',\n 'builtinUnavailable': '当前部署没有提供插件清单接口,无法列出内置插件。',\n 'builtinFailed': '无法读取内置插件:{reason}',\n 'builtinUnconfirmed': '无法读取已安装组合包的行清单,这里按全部 Loader 条目列出。',\n 'builtinScopeExpand': '显示已归属组合包的行({count})',\n 'builtinScopeCollapse': '隐藏已归属组合包的行({count})',\n 'builtinSearchLabel': '搜索内置插件',\n 'builtinSearchPlaceholder': '搜索名称、包名或行 id',\n 'builtinSearchEmpty': '没有匹配的内置插件。',\n 'builtinPagePrevious': '上一页',\n 'builtinPageNext': '下一页',\n 'builtinPageInfo': '第 {page} / {pages} 页,共 {count} 项',\n 'builtinOwnedBy': '来自 {name}',\n 'builtinToggle': '启用插件 {name}',\n 'builtinFailedEnable': '启用失败:{reason}',\n 'builtinFailedDisable': '停用失败:{reason}',\n 'builtinReasonManagementRequired': '插件管理所需,不能停用或卸载',\n 'builtinReasonUnaddressable': '当前 profile 的 patch 无法唯一定位这一项',\n 'builtinReasonUnknown': '无法确定这一项能否改写',\n 'builtinRestartRequired': '这次改动需要重启 DSH 才能加载:{reason}',\n 'builtinOverridden': '更高层的 profile 覆盖了 {name} 的这一改动,未生效。',\n 'builtinRestartUnnamed': '当前 profile 只在启动时应用更改。',\n 'builtinRestartNoHmr': '这个 profile 只在启动时应用更改。',\n 'builtinRestartPackageMoved': '已安装的插件包解析到了另一个目录,或者改动替换了 DSH 安装自带的包。',\n 'builtinRestartHostModule': '改动涉及 DSH 自身已加载的模块。',\n 'builtinRestartUnmanagedPlugin': '改动涉及一个不受插件列表管理的插件。',\n 'builtinRestartModuleComparison': 'DSH 无法把已加载的插件与磁盘上的文件做比较。',\n 'presetGroup': 'Agent 预设',\n 'presetDefault': '默认',\n 'presetBroken': '无法读取该预设的组合:{reason}',\n 'presetRowOn': '已开启',\n 'presetRowOff': '已关闭',\n 'presetRowConditional': '条件启用:{condition}',\n 'presetRowConditionalUnnamed': '条件启用',\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 'updateAllPartial': 'Updated {done}; {failed} failed',\n 'updateFailedRow': 'Update failed: {reason}',\n 'updateFailedUnknown': 'The host gave no reason',\n 'updateRestartRequired': 'Updated to {version}; restart DSH for it to take effect',\n 'updatesPanelTitle': 'Plugin updates',\n 'ignoreUpdate': 'Ignore this version',\n 'ignoredUpdate': 'This version is ignored.',\n 'ignoredUpdates': '{count} ignored versions',\n 'restoreUpdate': 'Restore update',\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 'restartPlanSystemd': 'systemd restarts {unit}; running tasks are interrupted.',\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 'builtinGroup': 'Built-in plugins',\n 'builtinReading': 'Reading built-in plugins…',\n 'builtinEmpty': 'No built-in plugins.',\n 'builtinUnavailable': 'This deployment publishes no plugin inventory, so built-in plugins cannot be listed.',\n 'builtinFailed': 'Could not read the built-in plugins: {reason}',\n 'builtinUnconfirmed': 'The installed bundles could not be read, so every Loader entry is listed here.',\n 'builtinScopeExpand': 'Show the rows these bundles own ({count})',\n 'builtinScopeCollapse': 'Hide the rows these bundles own ({count})',\n 'builtinSearchLabel': 'Search built-in plugins',\n 'builtinSearchPlaceholder': 'Search by name, package, or entry id',\n 'builtinSearchEmpty': 'No built-in plugins match this search.',\n 'builtinPagePrevious': 'Previous',\n 'builtinPageNext': 'Next',\n 'builtinPageInfo': 'Page {page} of {pages} · {count} items',\n 'builtinOwnedBy': 'From {name}',\n 'builtinToggle': 'Enable plugin {name}',\n 'builtinFailedEnable': 'Could not enable it: {reason}',\n 'builtinFailedDisable': 'Could not disable it: {reason}',\n 'builtinReasonManagementRequired': 'Plugin management needs it; it cannot be switched off or uninstalled',\n 'builtinReasonUnaddressable': 'The profile patch cannot address this one uniquely',\n 'builtinReasonUnknown': 'Whether this one can be written is unknown',\n 'builtinRestartRequired': 'This change needs a DSH restart: {reason}',\n 'builtinOverridden': 'A higher profile layer overrides this change to {name}, so it did not take effect.',\n 'builtinRestartUnnamed': 'This profile applies changes only at startup.',\n 'builtinRestartNoHmr': 'This profile applies changes only at startup.',\n 'builtinRestartPackageMoved': 'An installed package now resolves to another directory, or the change replaces a package the DSH installation provides.',\n 'builtinRestartHostModule': 'The change reaches modules DSH itself loaded.',\n 'builtinRestartUnmanagedPlugin': 'The change reaches a plugin running outside the plugin list.',\n 'builtinRestartModuleComparison': 'DSH could not compare the loaded plugins with their files.',\n 'presetGroup': 'Agent presets',\n 'presetDefault': 'Default',\n 'presetBroken': 'This preset composition cannot be read: {reason}',\n 'presetRowOn': 'On',\n 'presetRowOff': 'Off',\n 'presetRowConditional': 'Conditional: {condition}',\n 'presetRowConditionalUnnamed': 'Conditional',\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; `systemd` —\n * this host runs as a systemd service and asks its own unit to restart it;\n * `manual` — none of these is possible here, the user restarts DSH themselves.\n */\nexport type RestartMode = 'relaunch' | 'shell' | 'systemd' | 'manual'\n\n/**\n * The unit name shape a systemd restart may name. Deliberately conservative:\n * the host derives the value from its own cgroup and the browser re-validates\n * it before the confirmation names a unit, so a value outside this shape is\n * wire drift rather than a unit worth restarting. The one position that is\n * refused is a leading `-`: this name travels as the last argv element of\n * `systemctl --user restart --no-block <unit>`, where a leading `-` reads as\n * another option instead of a unit. Everything else systemd itself accepts is\n * kept, including a first `_` or `:` (`_x.service` and `:x.service` are\n * valid unit names).\n */\nconst SYSTEMD_UNIT_RE = /^(?!-)[a-zA-Z0-9:_.@-]+\\.service$/\n\n/** Whether a value is a systemd unit name this package asks systemd to restart. */\nexport function isSystemdUnitName(value: string): boolean {\n return SYSTEMD_UNIT_RE.test(value)\n}\n\n/**\n * What the host would do with a restart request, as the plan read answers it.\n *\n * A discriminated union rather than a mode beside an optional unit: a systemd\n * plan always names the unit it restarts (the parser refuses one that does\n * not) and no other mode carries a unit at all, so the confirmation reads the\n * unit off the plan instead of guarding a field that cannot be missing.\n */\nexport type RestartPlanWire =\n | { mode: 'systemd'; unit: string }\n | { mode: '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/**\n * One row of a batch update, as the host reported it.\n *\n * A batch is the host's sequence over the official manager's single-plugin\n * update, so its progress is a row per requested plugin rather than one\n * aggregate verdict: each row carries the version the host resolved, where it\n * ended, and — when it could not be applied — the reason.\n */\nexport interface PluginUpdateOutcome {\n /** Installed package name this row applies. */\n id: string\n /** Where this row is: still queued, in flight, applied, or refused. */\n phase: 'pending' | 'running' | 'done' | 'error'\n /** The exact version the host resolved for this row; absent when it was refused up front. */\n targetVersion?: string\n /** The version that landed, present on an applied row. */\n landed?: string\n /** Why this row could not be applied, present on a refused row. */\n error?: string\n /**\n * Whether the landed version is on disk but not loaded in the running host\n * (the official manager answered `application: 'restart-required'`).\n */\n restartRequired?: boolean\n}\n\n/**\n * What one batch update run produced.\n *\n * Both halves are carried: the refused rows stay in the panel beside the version\n * they are stuck on, and the applied rows leave it. Reporting only one half would\n * make a partial run read as either a clean one or no run at all.\n */\nexport interface PluginBatchUpdateResult {\n /** Rows that landed, at the version that landed. */\n applied: PluginUpdateOutcome[]\n /** Rows that did not, each carrying the host's reason. */\n failed: PluginUpdateOutcome[]\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 the rows of a batch update, as a gateway job carries\n * them under `results`.\n *\n * Deliberately tolerant in the same way {@link parseRestartRequired} is: every\n * row is an outcome the panel has to render, and refusing the whole list over one\n * malformed row would hide the rows that did land. A row missing its id or phase\n * is that row's problem, so it is dropped rather than thrown; an unreadable\n * `results` value reads as \"no rows\", which the caller shows as a run without a\n * per-row verdict.\n * @param value - decoded but untrusted job value.\n * @returns the typed rows, in the order the host applied them.\n */\nexport function parseUpdateOutcomes(value: unknown): PluginUpdateOutcome[] {\n if (!Array.isArray(value)) return []\n const rows: PluginUpdateOutcome[] = []\n for (const item of value) {\n if (!isRecord(item) || !isString(item.id) || item.id === '') continue\n const phase = item.phase\n if (phase !== 'pending' && phase !== 'running' && phase !== 'done' && phase !== 'error') continue\n const row: PluginUpdateOutcome = { id: item.id, phase }\n if (isString(item.targetVersion) && item.targetVersion !== '') row.targetVersion = item.targetVersion\n if (isString(item.landed) && item.landed !== '') row.landed = item.landed\n if (isString(item.error) && item.error !== '') row.error = item.error\n if (item.restartRequired === true) row.restartRequired = true\n rows.push(row)\n }\n return rows\n}\n\n/**\n * Split a finished batch's rows by outcome, the shape the toolbar renders.\n * A row still in flight is neither: it is simply not in either half.\n * @param rows - the rows the host reported.\n * @returns the applied and failed rows.\n */\nexport function batchUpdateResult(rows: readonly PluginUpdateOutcome[]): PluginBatchUpdateResult {\n const applied: PluginUpdateOutcome[] = []\n const failed: PluginUpdateOutcome[] = []\n for (const row of rows) {\n if (row.phase === 'done') applied.push(row)\n else if (row.phase === 'error') failed.push(row)\n }\n return { applied, failed }\n}\n\n/**\n * Validate and normalize a `restart` response value, reading the mode a POST\n * answer carries.\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 !== 'systemd' && 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 restart PLAN response value (the GET answer).\n *\n * The plan is read before the confirmation is shown, so this parser fails\n * closed: an unknown mode, or a systemd plan that does not name a unit of the\n * accepted shape, throws instead of letting the panel promise a restart the\n * host cannot actually perform.\n * @param value - decoded but untrusted response value.\n * @returns the plan the host would carry out.\n */\nexport function parseRestartPlan(value: unknown): RestartPlanWire {\n const mode = parseRestartMode(value)\n if (mode !== 'systemd') return { mode }\n const restart = isRecord(value) ? value.restart : undefined\n const unit = isRecord(restart) ? restart.unit : undefined\n if (!isString(unit) || !isSystemdUnitName(unit)) {\n throw new Error('plugin-manager: response must name the systemd unit a systemd restart uses')\n }\n return { mode, unit }\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 this package's surfaces on the\n * official Plugins page — the check-for-updates block, the list-level update\n * toolbar, and the built-in plugin group at the list's bottom — and provides the\n * dual-channel face as the `'pluginManager'` cordis service for sibling client\n * 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 { mountBuiltinPluginGroup } from './builtin-plugins-mount.tsx'\nimport { bridgeRemoteNamespaces, getRemoteSnapshot, subscribeRemote } from './native-faces.ts'\nimport { mountPluginListToolbar } from './plugin-toolbar-mount.tsx'\nimport { en, zh, type PluginManagerKey } from './locales.ts'\nimport {\n batchUpdateResult,\n parseFailuresSnapshot,\n parseInstallStatus,\n parseInstalledPlugin,\n parsePluginList,\n parseRestartMode,\n parseRestartPlan,\n parseRestartRequired,\n parseUpdateList,\n parseUpdateOutcomes,\n type InstalledPluginItem,\n type InstallProgressItem,\n type PluginBatchUpdateResult,\n type PluginFailuresSnapshot,\n type PluginUpdateItem,\n type PluginUpdateOutcome,\n type PluginUpdateResult,\n type RestartMode,\n type RestartPlanWire,\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 UPDATES_ENDPOINT = 'updates'\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 * The per-row outcomes of a batch update job, read through\n * {@link parseUpdateOutcomes}: one entry per requested plugin with the phase\n * it reached and, when it could not be applied, the host's reason.\n */\n results?: 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, and a\n * systemd host can name the unit that restarts, instead of surprising the\n * user with either.\n */\n restartPlan: () => Promise<RestartPlanWire>\n /**\n * Apply every listed update in one run, answering the rows that landed and the\n * rows that did not.\n *\n * The list-level toolbar used to drive one update job per plugin from the\n * browser, which spent a request and a job on each row and left the sequence —\n * and the decision to stop at the first refusal — in the component. The gateway\n * half now runs that sequence on the host as one job; the official installer\n * channel has no batch endpoint, so there the batch stays a loop of its own\n * single update, which is the only writer that channel accepts.\n */\n updateAll: (ids: readonly string[]) => Promise<PluginBatchUpdateResult>\n}\n\n/** Error text for a failed call, keeping the reason a thrown value carries. */\nfunction failureText(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\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 // One official update per id: this channel publishes no batch endpoint, and\n // its single call is the only writer it accepts. A refused row is collected\n // rather than thrown, so one plugin cannot discard the rest of the run.\n updateAll: async (ids: readonly string[]): Promise<PluginBatchUpdateResult> => {\n const applied: PluginUpdateOutcome[] = []\n const failed: PluginUpdateOutcome[] = []\n for (const id of ids) {\n try {\n const result = await official.update(id)\n applied.push({\n id,\n phase: 'done',\n landed: result.plugin.version,\n ...result.restartRequired.length > 0 ? { restartRequired: true } : {},\n })\n } catch (error) {\n failed.push({ id, phase: 'error', error: failureText(error) })\n }\n }\n return { applied, failed }\n },\n }\n\n // Gateway channel implementations.\n\n const gatewayJson = async (path: string, init?: RequestInit): Promise<unknown> => {\n const response = await fetch(path, {\n ...init,\n headers: { 'content-type': 'application/json', ...init?.headers },\n })\n if (response.status === 403) {\n throw new Error('plugin-manager: plugin management is only available from a local browser')\n }\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string }\n throw new Error(body.error ?? `plugin-manager: gateway ${path} failed: HTTP ${String(response.status)}`)\n }\n return response.json()\n }\n\n /** Wait for one gateway job to settle, returning its wire state. */\n const waitJob = async (jobId: string): Promise<GatewayJobWire> => {\n const deadline = Date.now() + JOB_WAIT_MS\n for (;;) {\n const body = await gatewayJson(`${GATEWAY_PREFIX}/status?job=${encodeURIComponent(jobId)}`) as { job?: GatewayJobWire }\n const job = body.job\n if (job === undefined) throw new Error('plugin-manager: gateway job vanished')\n if (job.phase === 'done') return job\n if (job.phase === 'error') throw new Error(job.error ?? 'plugin-manager: gateway job failed')\n if (Date.now() > deadline) throw new Error('plugin-manager: gateway job timed out')\n await new Promise(resolve => { setTimeout(resolve, JOB_POLL_MS) })\n }\n }\n\n /** 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 updateAll: async (ids: readonly string[]): Promise<PluginBatchUpdateResult> => {\n gatewayInflight = true\n try {\n const started = await gatewayJson(`${GATEWAY_PREFIX}/${UPDATES_ENDPOINT}`, {\n method: 'POST',\n body: JSON.stringify({ ids: [...ids] }),\n }) as { jobId?: string }\n if (started.jobId === undefined) throw new Error('plugin-manager: gateway updates returned no job')\n const job = await waitJob(started.jobId)\n return batchUpdateResult(parseUpdateOutcomes(job.results))\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<RestartPlanWire> =>\n parseRestartPlan(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 updateAll: async ids => {\n const result = await ((await ensureMode()) === 'official' ? official.updateAll(ids) : gateway.updateAll(ids))\n // Only a landed row is a change a consumer has to react to; a run whose\n // every row was refused leaves the installed set exactly as it was.\n if (result.applied.length > 0) notifyChange()\n return result\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 official remote namespaces the built-in group reads are OPTIONAL faces:\n // injecting each one keeps its arrival and withdrawal observable, so the\n // group shows what this deployment publishes instead of assuming it.\n try {\n bridgeRemoteNamespaces(ctx)\n } catch (error) {\n // A carrier without them keeps the group's own unavailable state; the\n // failure is logged so it is not mistaken for a deployment that has them.\n console.warn('plugin-manager: bridging the official plugin faces failed', error)\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 updateAll: face.updateAll,\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 built-in group sits at the list's bottom the way the toolbar sits beside\n // its heading: the page declares no seat there, so it is inserted after the\n // page's own installed panel and follows the page through the shared mutation\n // hub. The official faces are sampled per render and the subscription below\n // covers both a language switch and a host-side change event, so the mounted\n // copy never holds a stale answer.\n ctx.effect(() => {\n try {\n return mountBuiltinPluginGroup({\n props: () => ({\n remote: getRemoteSnapshot(),\n resolveText: text => ctx.locale.resolveText(text),\n t: ctx.locale.bind(NS),\n }),\n subscribe: listener => {\n const offLocale = ctx.locale.subscribe(listener)\n const offRemote = subscribeRemote(listener)\n return () => {\n offLocale()\n offRemote()\n }\n },\n })\n } catch (error) {\n // The group is chrome on someone else's page: a failed mount must not take\n // the page down, but it must not disappear without a trace either.\n console.warn('plugin-manager: mounting the built-in plugin group failed', error)\n return () => {}\n }\n }, 'plugin-manager: built-in plugin group')\n\n // The official Plugins page declares this seat on its main-panel entry and\n // renders one section per contribution on each bundle / row / plugin page;\n // `inject` waits for that declaration, exactly like the family plugin cards\n // that register into `plugins.bundle.config`.\n ctx.slots.inject('plugins.detail.section', () => {\n try {\n return ctx.slots.register({\n name: 'plugins.detail.section',\n id: 'family-update-check',\n order: 30,\n locale: NS,\n inject: () => face,\n }, PluginUpdatePatch)\n } catch {\n return () => {}\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;EAuBA,MAAa,iBAAiB;;EAS9B,SAAgB,gBAAgB,MAAwB,SAAkD;GACxG,OAAO,QAAQ,MAAK,UAAS,MAAM,OAAO,KAAK,MAAM,MAAM,YAAY,KAAK,MAAM;EACpF;;EAGA,SAAgB,iBAAiB,OAAoC,SAA6D;GAChI,OAAO,MAAM,QAAO,SAAQ,CAAC,gBAAgB,MAAM,OAAO,CAAC;EAC7D;;EAGA,SAAgB,eAAe,OAAoC,SAA6D;GAC9H,OAAO,MAAM,QAAO,SAAQ,gBAAgB,MAAM,OAAO,CAAC;EAC5D;;EAGA,SAAgB,kBAAkB,SAAyC,MAA+C;GACxH,IAAI,gBAAgB,MAAM,OAAO,GA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