import { useState } from 'react' import { useFormatDate } from '../../../hooks/useDateFormat' import MPluginVersionDate from './MPluginVersionDate' import { Blocks, AlertTriangle, PackageOpen, RefreshCw, Trash2, Download, Bug, X, ShieldCheck, UploadCloud, ArrowUpCircle, Github, ExternalLink, ChevronDown, Check, Lock, Search, Link2, KeyRound, ShieldAlert, SlidersHorizontal, ArrowUpDown, CircleDot, MoreHorizontal, RotateCw, Database, Globe, Info, History, PauseCircle, Puzzle, Bot, ListChecks } from 'lucide-react' import PluginIcon from '../../../components/shared/PluginIcon' import { type RangeWarning } from '../../../components/Admin/useRangeBypass' import { deriveCaps } from '../../../components/Admin/pluginCaps' import PluginPoiCategoryList from '../../../components/Admin/PluginPoiCategoryList' import { useTranslation } from '../../../i18n' import MToggle from '../../components/MToggle' import MSheet from '../../components/MSheet' import MSegmented from '../../components/MSegmented' import MConfirmSheet from '../settings/MConfirmSheet' import { MAdminButton, MAdminSheetFrame } from './MAdminUi' import { KNOWN_TYPES, PERM_KEYS, blockIsCurrent, dependencyRows, deriveDeps, fingerprint, formatCompactCount, installOffer, isRegistrySourced, parseJson, signatureBlockView, sortLabel, statusLabel, type PluginDep, type PluginRow, type RegistryDetail, type RegistryItem, type SigSubject, type SortKey, type StatusFilter, type T, type TypeFilter, type VersionInfo, type VersionMismatch, } from '../../../components/Admin/plugins/pluginModel' import { usePluginDetail } from '../../../components/Admin/plugins/usePluginDetail' import { usePluginsAdmin } from '../../../components/Admin/plugins/usePluginsAdmin' type DetailManifest = NonNullable /** The detail as the phone reads it: its sheet takes the manifest's lists as always present. */ type MRegistryDetail = Omit & { manifest: (DetailManifest & Required>) | null } /** * Admin → Plugins, mobile skin. A drop-in replacement for the desktop * AdminPluginsPanel: the same logic from usePluginsAdmin (segmented Installed/Discover switch, * search + type/status/sort filters, updates bar, installed rows with capability * chips, a registry list, an enriched detail sheet and the update re-consent * gate) with the mobile design system as the presentation layer. Every dialog is * an MSheet; every boolean is an MToggle. */ // Runtime health → dot colour on the icon tile (mobile status tokens). const HEALTH: Record = { active: 'bg-[color:var(--m-st-confirmed)]', starting: 'bg-[color:var(--m-st-info)] animate-pulse', error: 'bg-[color:var(--m-st-danger)]', inactive: 'bg-[color:var(--m-faint)]', disabled: 'bg-[color:var(--m-st-pending)]', incompatible: 'bg-[color:var(--m-st-pending)]', } // ── Chip / badge tone helpers (mobile status tokens) ──────────────────────── const CHIP_NEUTRAL = 'text-m-muted border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]' const CHIP_INFO = 'text-[color:var(--m-st-info)] border-[color:color-mix(in_srgb,var(--m-st-info)_28%,transparent)] bg-[color:color-mix(in_srgb,var(--m-st-info)_10%,transparent)]' const CHIP_PENDING = 'text-[color:var(--m-st-pending)] border-[color:color-mix(in_srgb,var(--m-st-pending)_28%,transparent)] bg-[color:color-mix(in_srgb,var(--m-st-pending)_10%,transparent)]' const PENDING_CARD = 'border-[color:color-mix(in_srgb,var(--m-st-pending)_28%,transparent)] bg-[color:color-mix(in_srgb,var(--m-st-pending)_10%,transparent)]' const ACT_PILL = 'inline-flex flex-none items-center justify-center gap-[5px] whitespace-nowrap rounded-full px-3 py-[7px] text-[0.6875rem] font-bold bg-m-act text-m-actfg disabled:opacity-50' function ReviewedBadge({ t }: { t: T }) { return } /** Marks a manually-uploaded (sideloaded) plugin: no registry, unsigned, not reviewed. */ function SideloadedBadge({ t }: { t: T }) { return ( {t('admin.plugins.sideloaded')} ) } /** * Signed / Unsigned, for registry plugins only (see isRegistrySourced). * * Signed is a quiet neutral tick, NOT a green celebration; unsigned is an amber note, NOT * a red alarm. Roughly two thirds of the live registry is unsigned, so an alarming * treatment would fire on most of the catalog and teach admins to ignore it — and the * honest delta is small: sha256 proves the bytes are what the REGISTRY vouches for, a * signature proves they came from the AUTHOR. Unsigned is one fewer guarantee, not "unsafe". */ function TrustBadge({ signed, t }: { signed: boolean; t: T }) { if (signed) { return ( {t('admin.plugins.signed')} ) } return ( {t('admin.plugins.unsigned')} ) } /** Marks a dev-linked plugin: loaded from a local build dir + hot-reloaded (dev only). */ function DevLinkBadge({ t }: { t: T }) { return ( {t('admin.plugins.devLinkBadge')} ) } function TypeBadge({ type, t }: { type: string; t: T }) { return ( {KNOWN_TYPES.includes(type) ? t(`admin.plugins.type.${type}` as never) : type} ) } export default function MAdminPluginsPanel() { const { t, locale } = useTranslation() const { bypass, settings, runtimeOn, devLink, linkPath, setLinkPath, plugins, loading, error, busy, view, setView, registry, latest, regById, signatureBlock, setSignatureBlock, retrusting, detailFor, setDetailFor, errorsFor, setErrorsFor, egressFor, setEgressFor, egressDraft, setEgressDraft, egressSaving, egressError, confirmUninstall, setConfirmUninstall, versionPicker, setVersionPicker, confirmDowngrade, setConfirmDowngrade, consentQueue, depResolve, setDepResolve, menu, setMenu, q, setQ, typeFilter, setTypeFilter, statusFilter, setStatusFilter, sort, setSort, dragActive, uploadInputRef, openDiscover, rescan, uploadPlugin, pickUpload, onDragEnter, onDragLeave, onDrop, openEgress, saveEgress, openInstanceSettings, openErrors, updateAvailable, resumeUpdates, newerIncompatible, install, restart, linkLocal, installedIds, toggle, runUpdate, openVersionPicker, pickVersion, updatable, updateAll, shownInstalled, shownRegistry, anyFilter, ignoreTrekRange, rowMenuPlugin, reviewBlock, askUninstall, uninstallConfirmed, downgradeConfirmed, retrustBlocked, consentUnsigned, approveConsent, deferConsent, downloadDependency, } = usePluginsAdmin() return (
{ if (dragActive) e.preventDefault() }} onDragLeave={onDragLeave} onDrop={onDrop}> {/* Hidden input for the "Upload plugin" button (drag-drop uses the same handler). */} { const f = e.target.files?.[0]; if (f) void uploadPlugin(f); e.target.value = '' }} /> {/* Drag-to-install overlay */} {dragActive && (
{t('admin.plugins.dropToUpload')}
)} {/* Header */}

{t('admin.plugins.title')}

{t('admin.plugins.subtitle')}

{runtimeOn && ignoreTrekRange && ( {t('admin.plugins.rangeBypass.pill')} )} {runtimeOn && ( {t('admin.plugins.runtimeOn')} )}
{/* Runtime-disabled notice */} {!runtimeOn && !loading && !error && (

{t('admin.plugins.disabledTitle')}

{t('admin.plugins.disabledBody')}

)} {/* Dev-link: register + hot-reload a plugin from a local build dir (dev only). */} {devLink && runtimeOn && !loading && !error && (
{ e.preventDefault(); void linkLocal() }} className={`flex flex-col gap-2.5 rounded-[18px] border p-3 ${CHIP_INFO}`}>
{t('admin.plugins.devLinkTitle')}
setLinkPath(e.target.value)} spellCheck={false} placeholder={t('admin.plugins.devLinkPathPlaceholder')} className="h-[42px] w-full rounded-xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-sheetop)] px-3 text-[0.84375rem] text-m-ink outline-none placeholder:text-m-faint" /> void linkLocal()} disabled={!linkPath.trim() || busy === '__link'} className="self-start"> {t('admin.plugins.devLinkButton')}
)} {/* Toolbar */} {runtimeOn && !loading && !error && (
{ if (v === 'discover') openDiscover(); else setView('installed') }} options={[ { value: 'installed', label: }, { value: 'discover', label: }, ]} />
setQ(e.target.value)} type="search" placeholder={t('admin.plugins.searchPlaceholder')} className="h-[42px] w-full rounded-xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] ps-9 pe-3 text-[0.84375rem] text-m-ink outline-none placeholder:text-m-faint focus:border-[color:var(--m-faint)]" />
} onClick={() => setMenu('type')} /> {view === 'installed' && ( } onClick={() => setMenu('status')} /> )} } onClick={() => setMenu('sort')} />
)} {/* Body */} {loading ? (
{t('common.loading')}
) : error ? (
{t('admin.plugins.loadError')}
) : !runtimeOn ? null : view === 'discover' ? ( ) : plugins.length === 0 ? ( ) : (
{updatable.length > 0 && statusFilter !== 'err' && (
{t('admin.plugins.updatesAvailable', { count: updatable.length })}
)} {shownInstalled.length === 0 ? (

{t('admin.plugins.noMatchInstalled')}

) : shownInstalled.map(p => ( toggle(p)} onUpdate={() => runUpdate(p)} onResume={() => void resumeUpdates(p)} onReviewBlock={() => reviewBlock(p)} onEgress={() => openEgress(p.id)} onMenu={() => setMenu(`row:${p.id}`)} /> ))}
)} {/* Registry detail sheet */} {detailFor && ( setDetailFor(null)} /> )} {/* TREK_PLUGINS_IGNORE_TREK_RANGE: confirm before a registry install the server would otherwise refuse (onConfirm set), or a plain notice after a path that could not ask first — sideload, dev-link, update, dependency download. */} {bypass.copy && ( )} {/* Row ⋯ action sheet */} {rowMenuPlugin && ( setMenu(null)} onRestart={() => restart(rowMenuPlugin.id)} onErrors={() => openErrors(rowMenuPlugin.id)} onEgress={() => openEgress(rowMenuPlugin.id)} onSettings={() => openInstanceSettings(rowMenuPlugin)} onChangeVersion={() => openVersionPicker(rowMenuPlugin)} onUninstall={() => askUninstall(rowMenuPlugin)} /> )} {/* Version picker sheet */} {versionPicker && ( setVersionPicker(null)} /> )} {/* Downgrade confirm */} setConfirmDowngrade(null)} onConfirm={downgradeConfirmed} title={t('admin.plugins.downgradeTitle')} message={t('admin.plugins.downgradeBody', { from: confirmDowngrade?.plugin.version ?? '', to: confirmDowngrade?.version ?? '' })} confirmLabel={t('admin.plugins.downgradeConfirm')} cancelLabel={t('common.cancel')} danger /> {/* Filter picker sheets */} setMenu(null)} title={t('admin.plugins.filterType')} value={typeFilter} options={[ ['all', t('admin.plugins.allTypes')], ['widget', t('admin.plugins.type.widget')], ['integration', t('admin.plugins.type.integration')], ['page', t('admin.plugins.type.page')], ['trip-page', t('admin.plugins.type.trip-page')], ]} onPick={v => setTypeFilter(v as TypeFilter)} /> setMenu(null)} title={t('admin.plugins.filterStatus')} value={statusFilter} options={[ ['all', t('admin.plugins.allStatuses')], ['on', t('admin.plugins.status.active')], ['off', t('admin.plugins.stateOff')], ['update', t('admin.plugins.filterUpdate')], ['err', t('admin.plugins.status.error')], ]} onPick={v => setStatusFilter(v as StatusFilter)} /> setMenu(null)} title={t('admin.plugins.sortBy')} value={sort} options={view === 'discover' ? [['name', t('admin.plugins.sortName')], ['recent', t('admin.plugins.sortRecent')], ['downloads', t('admin.plugins.sortDownloads')]] : [['name', t('admin.plugins.sortName')], ['recent', t('admin.plugins.sortRecent')], ['updates', t('admin.plugins.sortUpdates')]]} onPick={v => setSort(v as SortKey)} /> {/* Error-log sheet */} {errorsFor && ( setErrorsFor(null)} variant="bottom" material="glass" ariaLabel={t('admin.plugins.errorLog')}> } title={<>{errorsFor.id} — {t('admin.plugins.errorLog')}} onClose={() => setErrorsFor(null)} >
{errorsFor.rows.length === 0 ?

{t('admin.plugins.noErrors')}

: errorsFor.rows.map((r, i) => (
{r.level} {r.ts} {r.message}
))}
)} {/* Operator-supplied egress hosts */} {egressFor && ( setEgressFor(null)} variant="bottom" material="glass" ariaLabel={t('admin.plugins.allowedHosts')}> } title={<>{egressFor.id} — {t('admin.plugins.allowedHosts')}} onClose={() => setEgressFor(null)} > {!egressFor.supported ? (

{t('admin.plugins.allowedHosts.unsupported')}

) : (

{t('admin.plugins.allowedHosts.hint')}

{egressFor.hosts.length === 0 && (

{t('admin.plugins.allowedHosts.none')}

)} {egressFor.hosts.map(h => (
{h}
))}
setEgressDraft(e.target.value)} placeholder="gotify.example.com" className="h-[42px] min-w-0 flex-1 rounded-xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] px-3 text-[0.84375rem] text-m-ink outline-none placeholder:text-m-faint focus:border-[color:var(--m-faint)]" /> saveEgress([...egressFor.hosts, egressDraft.trim()])} className="h-[42px]" >{t('common.add')}
{egressError &&

{egressError}

}

{t('admin.plugins.allowedHosts.restartNote')}

)}
)} {/* Instance-wide settings (the admin-owned scope:'instance' fields) */} {settings.form && ( } title={<>{settings.form.id} — {t('admin.plugins.instanceSettings')}} onClose={settings.close} >
{settings.form.fields.map(f => ( ))} {(() => { const form = settings.form if (!form || form.actions.length === 0) return null return (
{t('admin.plugins.actions')} {!form.active && (

{t('admin.plugins.actions.inactive')}

)}
{form.actions.map(a => { const res = settings.actionResult[a.key] return (
settings.runAction(a)} > {a.label} {a.hint && {a.hint}} {res && ( {res.message || (res.ok ? t('common.success') : t('common.error'))} )}
) })}
) })()} {settings.error &&

{settings.error}

} void settings.save()} className="h-[42px] w-full"> {t('common.save')}
)} {/* Uninstall confirm */} setConfirmUninstall(null)} onConfirm={uninstallConfirmed} title={t('admin.plugins.uninstallTitle')} message={t('admin.plugins.uninstallBody')} confirmLabel={t('common.delete')} cancelLabel={t('common.cancel')} danger /> {/* Instance action confirm */} {signatureBlock && ( setSignatureBlock(null)} /> )} {consentQueue[0] && ( )} {depResolve && ( setDepResolve(null)} /> )}
) } // ── Toolbar bits ──────────────────────────────────────────────────────────── function TabLabel({ text, count, active }: { text: string; count?: number; active: boolean }) { return ( {text} {count != null && ( {count} )} ) } function ToolIcon({ label, onClick, children }: { label: string; onClick: () => void; children: React.ReactNode }) { return ( ) } function FilterPill({ label, value, active, icon, onClick }: { label: string; value: string; active: boolean; icon: React.ReactNode; onClick: () => void }) { return ( ) } function typeLabel(f: TypeFilter, t: T): string { return f === 'all' ? t('admin.plugins.allTypes') : t(`admin.plugins.type.${f}` as never) } function PickerSheet({ open, onClose, title, options, value, onPick }: { open: boolean; onClose: () => void; title: string options: Array<[string, string]>; value: string; onPick: (v: string) => void }) { return ( } title={title} onClose={onClose}>
{options.map(([v, lbl]) => ( ))}
) } // ── Installed row ────────────────────────────────────────────────────────── function InstalledRow({ p, t, busy, hasUpdate, latestVer, newerIncompatible, blocked, onToggle, onUpdate, onResume, onReviewBlock, onEgress, onMenu }: { p: PluginRow; t: T; busy: string | null hasUpdate: boolean; latestVer?: string; newerIncompatible: { version: string; range: string } | null; blocked: boolean onToggle: () => void; onUpdate: () => void; onResume: () => void; onReviewBlock: () => void onEgress: () => void; onMenu: () => void }) { const caps = deriveCaps(parseJson(p.permissions, []), parseJson<{ widget?: { slot?: string } }>(p.capabilities, {}), t) const deps = deriveDeps(p, t) return (
{p.name} {p.version && v{p.version}} {p.reviewed_at && } {p.source_repo === 'local:upload' && } {p.source_repo === 'local:link' && } {/* Registry plugins only — a sideloaded/dev-linked plugin already says something strictly stronger, and stacking "Unsigned" on top of it just dilutes the amber. */} {isRegistrySourced(p.source_repo) && }
{p.description &&

{p.description}

}
{/* A refused update leaves a WORKING plugin pinned at its old version — so this is its own row state, not an error state, and it persists until it is resolved rather than dying with the toast that first reported it. */} {blocked && p.updateBlock && (
{t('admin.plugins.updateBlocked', { reason: p.updateBlock.detail ?? p.updateBlock.code })}
)} {/* A newer version this TREK can't run — informational, never a button: the fix is a TREK upgrade, so the row must not nag or offer a doomed install. */} {newerIncompatible && (
{t('admin.plugins.newerNeedsTrek', { version: newerIncompatible.version, range: newerIncompatible.range })}
)} {/* Held: the admin deliberately installed a non-latest version, so updates are paused rather than nagged — resuming is one click, right where the pause shows. */} {p.updateHold && (
{t('admin.plugins.updatesHeld', { version: p.version ?? '' })}
)} {p.status === 'error' && p.last_error ? (
{p.last_error}
) : (caps.length > 0 || p.operatorEgress) && (
{caps.map((c, i) => ( {c.label} ))} {/* This plugin talks to a service only the OPERATOR can name (a self-hosted Gotify/ntfy), so its manifest can't list the host — the admin adds it. Actionable, and warning-toned until at least one host exists, because until then the plugin cannot reach anything and looks silently broken. */} {p.operatorEgress && ( )}
)} {deps.length > 0 && (
{deps.map((d, i) => ( {d.label} ))}
)} {hasUpdate && (
)}
) } // Row ⋯ action sheet — the desktop portal menu re-expressed as a bottom sheet. function RowActionsSheet({ p, t, onClose, onRestart, onErrors, onEgress, onSettings, onChangeVersion, onUninstall }: { p: PluginRow; t: T; onClose: () => void onRestart: () => void; onErrors: () => void; onEgress: () => void; onSettings: () => void; onChangeVersion: () => void; onUninstall: () => void }) { const linkable = p.source_repo && p.source_repo !== 'local:upload' && p.source_repo !== 'local:link' const rowClass = 'flex w-full items-center gap-2.5 rounded-xl px-3 py-3 text-start text-[0.8125rem] font-semibold text-m-ink' return ( } title={p.name} onClose={onClose}>
{p.enabled === 1 && ( )} {/* A plugin gets the action if it declares scope:'instance' fields OR actions — an action-only plugin still needs the sheet to run them. */} {((p.instanceSettingsCount ?? 0) > 0 || (p.instanceActionsCount ?? 0) > 0) && ( )} {/* Only a plugin that DECLARED operatorEgress gets the action — an admin must never be invited to widen egress for a plugin that didn't ask for it (same rule the row's egress chip follows). */} {p.operatorEgress && ( )} {/* Registry plugins only — a sideload/dev-link has no registry versions to pick from. */} {isRegistrySourced(p.source_repo) && ( )} {linkable && ( <> {t('admin.plugins.sourceRepo')} {t('admin.plugins.reportIssue')} )}
) } /** * "Change version…" for an INSTALLED plugin. Rows render the server's per-version compat * verdict: the installed version is marked, a compatible one gets a Switch action (the * caller routes a DOWNGRADE through the data-risk confirm), an incompatible one is * explained and never offered. */ function VersionPickerSheet({ plugin, versions, failed, busy, t, onPick, onClose }: { plugin: PluginRow; versions: VersionInfo[] | null; failed: boolean; busy: string | null t: T; onPick: (version: string) => void; onClose: () => void }) { return ( } title={t('admin.plugins.versionPickerTitle', { name: plugin.name })} onClose={onClose}>
{failed &&

{t('admin.plugins.detailError')}

} {!failed && !versions &&

{t('common.loading')}

} {versions?.length === 0 &&

{t('admin.plugins.noVersions')}

} {versions?.map(v => { const current = v.version === plugin.version return (
v{v.version} {v.signed && } {current ? ( {t('admin.plugins.installed')} ) : v.compatible ? ( ) : ( {t('admin.plugins.versionNeedsTrek', { range: v.trek ?? '' })} )}
) })}
) } // ── Registry (Discover) ──────────────────────────────────────────────────── function EmptyState({ t, onDiscover }: { t: T; onDiscover: () => void }) { return (

{t('admin.plugins.empty')}

) } function Screenshot({ url, className, iconSize = 28 }: { url: string | null; className: string; iconSize?: number }) { const [failed, setFailed] = useState(false) return (
{url && !failed ? ( setFailed(true)} /> ) : (
)}
) } function RegistryList({ items, onInstall, onOpenDetail, busy, t, installedIds, filtered, ignoreTrekRange }: { items: RegistryItem[] | null onInstall: (id: string, version?: string, warn?: RangeWarning) => void onOpenDetail: (item: RegistryItem) => void busy: string | null t: T installedIds: Set filtered: boolean ignoreTrekRange: boolean }) { if (!items) return
{t('common.loading')}
if (items.length === 0) return (

{filtered ? t('admin.plugins.noMatchRegistry') : t('admin.plugins.registryEmpty')}

) return (
{items.map(item => { const installed = installedIds.has(item.id) const offer = installOffer(item, t, ignoreTrekRange) return (
onOpenDetail(item)} // Same press-scale opt-out as the desktop Discover card (#2158). data-no-press onKeyDown={e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onOpenDetail(item) } }} className="overflow-hidden rounded-[18px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-sheetop)]">
{item.reviewedAt && ( {t('admin.plugins.reviewed')} )}
{item.name} {item.author}

{item.description}

{/* Everything in Discover is registry-sourced, so the badge always applies. */} {item.latest && v{item.latest}} {typeof item.downloadCount === 'number' && item.downloadCount > 0 && ( {formatCompactCount(item.downloadCount)} )}
) })}
) } // A permission rendered human-readable when known, else as its raw code. function PermLabel({ perm, t }: { perm: string; t: T }) { return PERM_KEYS.includes(perm) ? {t(`admin.plugins.perm.${perm}` as never)} : {perm} } function PluginDetailSheet({ item, installed, busy, onInstall, onClose, t, locale, ignoreTrekRange }: { item: RegistryItem; installed: boolean; busy: string | null; ignoreTrekRange: boolean onInstall: (id: string, version?: string, warn?: RangeWarning) => void; onClose: () => void; t: T; locale: string }) { const { formatDate: dateOf } = useFormatDate() const { detail, failed } = usePluginDetail(item.id) const manifest = detail?.manifest ?? null const caps = manifest ? deriveCaps(manifest.permissions, manifest.capabilities ?? {}, t) : [] const repoUrl = `https://github.com/${item.repo}` const homepage = item.homepage && /^https?:\/\//i.test(item.homepage) && item.homepage !== repoUrl ? item.homepage : null const sizeKb = detail?.size ? Math.max(1, Math.round(detail.size / 1024)) : null // The detail fetch carries the same compat verdict as the browse list; prefer it once // it lands (it is keyed to the same entry) and fall back to the grid item until then. const offer = installOffer(detail ?? item, t, ignoreTrekRange) const linkClass = 'inline-flex items-center gap-1.5 rounded-lg border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] px-3 py-1.5 text-xs font-medium text-m-muted' const sectionH = 'text-[11px] font-semibold uppercase tracking-wider text-m-muted' return (

{item.name}

{item.reviewedAt && }

{item.author}{item.latest ? ` · v${item.latest}` : ''}

{item.description}

{failed &&

{t('admin.plugins.detailError')}

} {/* The reason the button is blocked (or offering an older version) — a tooltip alone would leave a touch user with a dead button and no explanation. */} {offer.title && !installed && (

{offer.title}

)} {manifest && (

{t('admin.plugins.accessTitle')}

{caps.filter(c => !c.net).length === 0 && !manifest.permissions.includes('db:own') ? (

{t('admin.plugins.noAccess')}

) : (
{caps.filter(c => !c.net).map((c, i) => (
{c.label}
))} {manifest.permissions.includes('db:own') && (
{t('admin.plugins.perm.db:own')}
)}
)}
)} {/* The tool text a plugin publishes goes straight into every user's assistant context once mcp:tools is granted, and nothing else in this dialog shows it. An admin approving the grant should read the names and descriptions first, not discover them in a chat. */} {manifest && (manifest.capabilities?.mcpTools?.length ?? 0) > 0 && (

{t('admin.plugins.mcpToolsTitle')}

    {(manifest.capabilities?.mcpTools ?? []).map(tool => (
  • {tool.name} {tool.title &&

    {tool.title}

    } {/* The description is the assistant-facing text: it is what the model reads to decide whether to call the tool, so it is the line an admin most needs to see. Never hidden behind a title. */}

    {tool.description}

  • ))}

{t('admin.plugins.mcpToolsHint')}

)} {manifest && ( )} {manifest && (manifest.egress.length > 0 || manifest.operatorEgress) && (

{t('admin.plugins.connectsTitle')}

{manifest.egress.map(h => ( {h} ))} {/* The hosts above are NOT the whole story for this plugin: it talks to a service only the operator can name, so its reach is whatever an admin adds after install. Say so HERE — this is the pre-install review, and a reviewer who reads only the host list would otherwise be misled. */} {manifest.operatorEgress && ( {t('admin.plugins.operatorEgressPill')} )}
{manifest.operatorEgress && (

{t('admin.plugins.operatorEgressHint')}

)}
)} {manifest && manifest.settings.length > 0 && (

{t('admin.plugins.setupTitle')}

    {manifest.settings.map(s => (
  • {s.label} {t(`admin.plugins.scope.${s.scope}` as never)} {s.required && {t('admin.plugins.fieldRequired')}}
  • ))}
)}

{t('admin.plugins.detailsTitle')}

{item.latest && } {sizeKb !== null && } {/* The range, not just its lower bound: "TREK 3.2.0+" reads as "and anything newer", which is exactly the claim a `<4.0.0` upper bound denies. */} {(item.trek || item.minTrekVersion) && ( )} {item.reviewedAt && } {typeof item.downloadCount === 'number' && item.downloadCount > 0 && ( )}
{/* Every published version, installable individually. The compat verdict per version is SERVER-computed — an incompatible one is explained, never offered. */} {(detail?.versions?.length ?? 0) > 1 && (

{t('admin.plugins.versionsTitle')}

{detail!.versions!.map(v => (
v{v.version} {v.signed && } {v.compatible ? ( !installed && ( ) ) : ( {t('admin.plugins.versionNeedsTrek', { range: v.trek ?? '' })} )}
))}
)}
) } function Meta({ k, v }: { k: string; v: string }) { return
{k}
{v}
} /** * A signature check refused an install/update. * * The override lives here, and it is scoped to exactly one code. A rotated key has a * benign explanation — the author rotated it, or lost it and made a new one. A signature * that does NOT verify does not: it means the bytes are not what the author signed, which * is corruption or an attack, and there is no story where the right answer is "let the * admin wave it through". So SIGNATURE_INVALID / _MISSING / _INCOMPLETE get a clear * explanation and no override button AT ALL — not a disabled one, not one behind a * confirm. The absence of an escape hatch is the feature. * * (The server enforces this too — it re-derives the condition and refuses anything but a * changed key. This dialog is the convenience, not the control.) */ function SignatureBlockSheet({ data, entry, busy, t, onRetrust, onClose }: { data: { subject: SigSubject; code: string; detail: string | null } entry: RegistryItem | undefined busy: boolean; t: T onRetrust: (version: string, publicKey: string) => void onClose: () => void }) { const { canRetrust, newKey, retrust, bodyKey } = signatureBlockView(data.code, entry) const offerRetrust = retrust !== null return (

{t('admin.plugins.sig.title', { name: data.subject.name })}

{t(bodyKey as never)}

{/* Fingerprints, not full keys: these exist to be COMPARED by a human — read the new one back to the author over the phone. The full key travels in the request. */} {canRetrust && (

{t('admin.plugins.sig.confirmOutOfBand')}

)} {!canRetrust && data.detail && (

{data.detail}

)}
{offerRetrust ? t('admin.plugins.sig.cancel') : t('common.close')} {retrust && ( onRetrust(retrust.version, retrust.newKey)}> {t('admin.plugins.sig.retrustConfirm')} )}
) } function KeyRow({ label, value, highlight }: { label: string; value: string; highlight?: boolean }) { return (
{label} {value}
) } function UpdateConsentSheet({ data, unsigned, t, onApprove, onLater }: { data: { plugin: PluginRow; version: string; newPermissions: string[]; newEgress: string[] } unsigned: boolean t: T; onApprove: () => void; onLater: () => void }) { return (

{t('admin.plugins.updateConsentTitle')}

{t('admin.plugins.updateConsentBody', { name: data.plugin.name, version: data.version })}

{/* The admin is about to widen what this code may do — so say, right here, that nothing ties this code to its author. One line, no checkbox, no extra click: this informs, it does not block. */} {unsigned && (

{t('admin.plugins.sig.consentUnsigned')}

)} {data.newPermissions.length > 0 && (

{t('admin.plugins.updateNewPermissions')}

    {data.newPermissions.map(perm => (
  • ))}
)} {data.newEgress.length > 0 && (

{t('admin.plugins.updateNewEgress')}

{data.newEgress.map(host => {host})}
)}
{t('admin.plugins.updateLater')} {t('admin.plugins.updateApprove')}
) } // Shown when enabling a plugin is blocked by missing/outdated plugin dependencies. // Each dependency gets a one-click download (latest version satisfying its range, // transitively) that then retries enabling the plugin. function DependencyResolveSheet({ data, t, busy, installedIds, onDownload, onClose }: { data: { plugin: PluginRow; missing: PluginDep[]; versionMismatch: VersionMismatch[] } t: T; busy: boolean; installedIds: Set onDownload: (depId: string, constraint?: string) => void; onClose: () => void }) { const rows = dependencyRows(data) return (

{t('admin.plugins.dep.resolveTitle')}

{t('admin.plugins.dep.resolveBody', { name: data.plugin.name })}

{rows.map(r => (
{r.id}
{r.installed ? t('admin.plugins.dep.mismatch', { wanted: r.constraint, installed: r.installed }) : t('admin.plugins.dep.requires', { version: r.constraint })}
))} {rows.some(r => !installedIds.has(r.id)) && (

{t('admin.plugins.dep.resolveHint')}

)}
{t('common.cancel')}
) } // Footer: a plain-language note on what "Reviewed" means, plus a collapsible // panel that lays out how plugins are contained, the limits, and the worst case. function SecurityInfo({ t }: { t: T }) { const [open, setOpen] = useState(false) const sections: Array<[string, string]> = [ ['admin.plugins.security.isolationTitle', 'admin.plugins.security.isolationBody'], ['admin.plugins.security.permsTitle', 'admin.plugins.security.permsBody'], ['admin.plugins.security.limitsTitle', 'admin.plugins.security.limitsBody'], ['admin.plugins.security.worstTitle', 'admin.plugins.security.worstBody'], ['admin.plugins.security.reviewedTitle', 'admin.plugins.security.reviewedBody'], ['admin.plugins.security.signedTitle', 'admin.plugins.security.signedBody'], ['admin.plugins.security.trustTitle', 'admin.plugins.security.trustBody'], ] return (

{t('admin.plugins.reviewedMeaning')}

{open && (
{sections.map(([h, b]) => (

{t(h as never)}

{t(b as never)}

))}
)}
) }