{"version":3,"file":"pluginRegistry.cjs","names":["HOST_SLOTS","collectWebTemplates","mergeScopedPlugins","collectNativeTemplates","collectPluginThemes","collectPluginLocales","registerLocaleCatalog","pluginsAtScope","qualifyHostId","leaderConflicts","parseOnboarding","parseHomeContribution","activityGroupSlot","isSelfHostShell","defaultHostId","splitHostId","homeAppEntries"],"sources":["../../../src/web/lib/pluginRegistry.ts"],"sourcesContent":["import type {\n  ActivityGroupContribution,\n  ContextActionContribution,\n  DashboardTileData,\n  DockFaceContribution,\n  FileLinkSource,\n  LeaderBindingContribution,\n  ModeContribution,\n  OnboardingContribution,\n  PaletteCommandContribution,\n  RepositorySettingsPanelContribution,\n  SettingsPanelContribution,\n  SettingsSectionContribution,\n  SelectionAxisContribution,\n  SessionChannelContribution,\n  SlotDeclaration,\n  SlotFillContribution,\n  SurfaceContribution,\n  TabContribution,\n  ToolRendererContribution,\n  UserMessageActionContribution,\n  WebPluginDefinition,\n  WebPluginMount,\n  WebPluginRuntime,\n  WebPluginSlotProps,\n} from '@agimon-ai/po-core/web';\nimport {\n  activityGroupSlot,\n  HOST_SLOTS,\n  parseHomeContribution,\n  parseOnboarding,\n  registerLocaleCatalog,\n  type HomeContribution,\n} from '@agimon-ai/po-core/web';\nexport { activityGroupSlot, HOST_SLOTS } from '@agimon-ai/po-core/web';\nimport type { ComponentType, ReactNode } from 'react';\n\nimport { homeAppEntries } from './homeApps';\nimport { defaultHostId, qualifyHostId, splitHostId } from './hostIdentity';\nimport { leaderConflicts } from './leaderTree';\nimport { collectPluginLocales, type InstalledPluginLocale } from './pluginLocales';\nimport { mergeScopedPlugins, pluginsAtScope } from './pluginScopes';\nimport { collectPluginThemes, type InstalledPluginTheme } from './pluginThemes';\nimport { isSelfHostShell } from './selfHostShell';\nimport {\n  collectNativeTemplates,\n  collectWebTemplates,\n  type NativeTemplateCatalog,\n  type WebTemplateCatalog,\n} from './templateCatalog';\nimport { noteStoreUpdate } from './uiTrace';\n\n/**\n * The installed plugin set.\n *\n * Plain module state rather than a reactive store: the generated plugin list\n * is installed once at startup, before the first render, so every read during\n * render is stable. Install runs in two phases. The first collects every\n * plugin's contributions in the generated order, which is (registrationOrder,\n * pluginId); the second resolves every relation between plugins by name, so\n * a plugin may fill a slot whichever of the two installs first.\n *\n * Plugins are independent and a user may install any of them, so a collision\n * between two plugins never fails the install: a shared name goes to the\n * first plugin (a Leader Space leaf to the later one, as the TUI documents)\n * and the loser is recorded as a diagnostic. Only a malformed contribution\n * inside one plugin throws, because that is a developer error its own tests\n * catch. resetWebPlugins exists for unit tests only.\n */\n\nexport type InstallDiagnosticKind =\n  | 'duplicate-plugin'\n  | 'duplicate-tab'\n  | 'duplicate-dock-face'\n  | 'duplicate-channel'\n  | 'duplicate-tool'\n  | 'duplicate-activity-group'\n  | 'duplicate-mode'\n  | 'duplicate-selection-axis'\n  | 'duplicate-palette-command'\n  | 'duplicate-settings-section'\n  | 'leader-leaf-override'\n  | 'leader-group-label'\n  | 'orphan-fill'\n  | 'rejected-fill'\n  | 'rejected-theme'\n  | 'duplicate-theme'\n  | 'rejected-locale'\n  | 'invalid-onboarding'\n  | 'invalid-template'\n  | 'duplicate-template'\n  | 'slot-load-failed'\n  | 'render-failed'\n  | 'start-failed'\n  | 'invalid-plugin';\n\nexport interface InstallDiagnostic {\n  /** The plugin that lost or misfiled the contribution. */\n  pluginId: string;\n  kind: InstallDiagnosticKind;\n  message: string;\n}\n\n/** One placed fill, as the owner's renderSlot and slotData read it. */\nexport interface ResolvedFill {\n  slot: string;\n  pluginId: string;\n  id: string;\n  order: number;\n  data?: unknown;\n  component?: ComponentType<WebPluginSlotProps>;\n}\n\nexport interface InstalledDashboardTile extends ResolvedFill {\n  data: DashboardTileData;\n}\n\n/** Reject malformed tile presentation without executing its body. */\nexport function parseDashboardTileData(input: unknown): DashboardTileData | null {\n  if (typeof input !== 'object' || input === null || Array.isArray(input)) return null;\n  const data = input as Record<string, unknown>;\n  if (data.version !== 1 || typeof data.title !== 'string' || data.title.trim() === '') return null;\n  if (data.size !== undefined && !['small', 'wide', 'tall', 'large'].includes(data.size as string)) return null;\n  if (data.column !== undefined && data.column !== 'main' && data.column !== 'side') return null;\n  if (\n    data.icon !== undefined &&\n    typeof data.icon !== 'function' &&\n    (typeof data.icon !== 'object' || data.icon === null)\n  )\n    return null;\n  if (data.combinesComputers !== undefined && typeof data.combinesComputers !== 'boolean') return null;\n  if (data.dataScope !== undefined && data.dataScope !== 'host' && data.dataScope !== 'global') return null;\n  if (\n    data.surfaces !== undefined &&\n    (!Array.isArray(data.surfaces) || data.surfaces.some((surface) => surface !== 'home' && surface !== 'workspace'))\n  )\n    return null;\n  if (data.open !== undefined) {\n    if (typeof data.open !== 'object' || data.open === null || Array.isArray(data.open)) return null;\n    const open = data.open as Record<string, unknown>;\n    if ((open.kind !== 'page' && open.kind !== 'settings') || typeof open.id !== 'string' || open.id.trim() === '')\n      return null;\n  }\n  return input as DashboardTileData;\n}\n\nexport interface InstalledContextAction extends ContextActionContribution {\n  pluginId: string;\n}\n\nexport interface InstalledUserMessageAction extends UserMessageActionContribution {\n  pluginId: string;\n}\n\nconst SLOT_SEPARATOR = '.';\nconst DEFAULT_FILL_ORDER = 1000;\nconst RESERVED_PLUGIN_IDS: ReadonlySet<string> = new Set(Object.values(HOST_SLOTS));\n\ninterface RegistryState {\n  plugins: WebPluginDefinition[];\n  tabs: TabContribution[];\n  dockFaces: DockFaceContribution[];\n  channels: Map<string, SessionChannelContribution>;\n  commands: PaletteCommandContribution[];\n  contextActions: InstalledContextAction[];\n  userMessageActions: InstalledUserMessageAction[];\n  leaderBindings: LeaderBindingContribution[];\n  selectionAxes: SelectionAxisContribution[];\n  modes: ModeContribution[];\n  activityGroups: ActivityGroupContribution[];\n  settingsSections: InstalledSettingsSection[];\n  onboarding: InstalledOnboarding[];\n  settingsPanels: InstalledSettingsPanel[];\n  toolRenderers: Map<string, ToolRendererContribution>;\n  toolMatchers: ToolRendererContribution[];\n  slots: Map<string, SlotDeclaration>;\n  fills: Map<string, ResolvedFill[]>;\n  fileLinks: FileLinkSource[];\n  diagnostics: InstallDiagnostic[];\n}\n\nfunction emptyState(): RegistryState {\n  return {\n    plugins: [],\n    tabs: [],\n    dockFaces: [],\n    channels: new Map(),\n    commands: [],\n    contextActions: [],\n    userMessageActions: [],\n    leaderBindings: [],\n    selectionAxes: [],\n    modes: [],\n    activityGroups: [],\n    settingsSections: [],\n    onboarding: [],\n    settingsPanels: [],\n    toolRenderers: new Map(),\n    toolMatchers: [],\n    slots: new Map(),\n    fills: new Map(),\n    fileLinks: [],\n    diagnostics: [],\n  };\n}\n\nexport interface InstalledRepositorySettingsPanel extends RepositorySettingsPanelContribution {\n  pluginId: string;\n}\nexport interface InstalledSettingsSection extends SettingsSectionContribution {\n  pluginId: string;\n}\nexport interface InstalledOnboarding extends OnboardingContribution {\n  pluginId: string;\n  /** The package that ships it, which is how a curated plugin finds its own setup. */\n  packageName?: string;\n}\nexport interface InstalledSettingsPanel extends SettingsPanelContribution {\n  pluginId: string;\n}\nexport interface InstalledHostPluginProvider {\n  pluginId: string;\n  provider: ComponentType<{ children?: ReactNode }>;\n}\n\nexport interface InstalledHomeContribution {\n  pluginId: string;\n  id: string;\n  order: number;\n  data: HomeContribution;\n  mount: Exclude<WebPluginMount, { scope: 'session' }>;\n  /** A web fill may name its icon beside the wire fields; the phone draws none. */\n  icon?: DashboardTileData['icon'];\n}\n\n/** An independently owned host plugin registry. */\nexport function createWebPluginRegistry(hostId?: string) {\n  let defaultState = emptyState();\n  let installingState = defaultState;\n  let defaultInstalled = false;\n  let providers: readonly InstalledHostPluginProvider[] = [];\n  let themes: readonly InstalledPluginTheme[] = [];\n  let locales: readonly InstalledPluginLocale[] = [];\n  let removeLocales: (() => void)[] = [];\n  const sessionStates = new Map<string, RegistryState>();\n  const workspaceStates = new Map<string, RegistryState>();\n  const sessionPlugins = new Map<string, readonly WebPluginDefinition[]>();\n  const sessionWorkspaces = new Map<string, string>();\n  let activeWorkspaceId: string | null = null;\n  const pendingSessionFrames = new Map<string, Map<string, Record<string, unknown>>>();\n  const MAX_PENDING_CHANNEL_TYPES = 64;\n  let activeSessionId: string | null = null;\n  /** Slots each mount could not load, keyed `host`, `workspace:<id>` or `session:<id>`. */\n  const loadDiagnostics = new Map<string, readonly InstallDiagnostic[]>();\n  let registryRevision = 0;\n  const registryListeners = new Set<() => void>();\n  const renderDiagnostics = new Map<string, InstallDiagnostic>();\n\n  function activeState(sessionId?: string | null): RegistryState {\n    if (sessionId !== undefined && sessionId !== null) {\n      const workspaceId = sessionWorkspaces.get(sessionId);\n      return (\n        sessionStates.get(sessionId) ??\n        (workspaceId === undefined ? undefined : workspaceStates.get(workspaceId)) ??\n        defaultState\n      );\n    }\n    return (\n      (activeSessionId === null ? undefined : sessionStates.get(activeSessionId)) ?? workspaceState() ?? defaultState\n    );\n  }\n\n  function workspaceState(): RegistryState | undefined {\n    return activeWorkspaceId === null ? undefined : workspaceStates.get(activeWorkspaceId);\n  }\n\n  /** Settings requests an explicit scope; the cockpit reads its active session composition. */\n  function webTemplateCatalog(mount?: WebPluginMount): WebTemplateCatalog {\n    if (mount === undefined) {\n      const scope = activeSessionId === null ? (activeWorkspaceId === null ? 'host' : 'workspace') : 'session';\n      return collectWebTemplates(activeState().plugins, scope);\n    }\n    if (mount.scope === 'host') return collectWebTemplates(defaultState.plugins, 'host');\n    const workspace = workspaceStates.get(mount.workspaceId);\n    const plugins = mount.scope === 'session' ? sessionStates.get(mount.sessionId)?.plugins : undefined;\n    return collectWebTemplates(\n      plugins ?? mergeScopedPlugins(defaultState.plugins, workspace?.plugins ?? []),\n      mount.scope,\n    );\n  }\n\n  /** The phone app's layouts at the server-resolved `native.template` mount. */\n  function nativeTemplateCatalog(mount: WebPluginMount): NativeTemplateCatalog {\n    if (mount.scope === 'host') return collectNativeTemplates(defaultState.plugins, 'host');\n    const workspace = workspaceStates.get(mount.workspaceId);\n    const plugins = mount.scope === 'session' ? sessionStates.get(mount.sessionId)?.plugins : undefined;\n    return collectNativeTemplates(\n      plugins ?? mergeScopedPlugins(defaultState.plugins, workspace?.plugins ?? []),\n      mount.scope,\n    );\n  }\n  function rebuildSession(sessionId: string): RegistryState {\n    const previous = sessionStates.get(sessionId);\n    const workspaceId = sessionWorkspaces.get(sessionId);\n    const workspace = workspaceId === undefined ? undefined : workspaceStates.get(workspaceId);\n    const state = buildLiveState(\n      mergeScopedPlugins(defaultState.plugins, workspace?.plugins ?? [], sessionPlugins.get(sessionId) ?? []),\n    );\n    sessionStates.set(sessionId, state);\n    // Drop stale stores before replay, since replacement channels may share a store.\n    for (const [type, channel] of previous?.channels.entries() ?? [])\n      if (state.channels.get(type) !== channel) channel.drop(sessionId);\n    const pending = pendingSessionFrames.get(sessionId);\n    if (pending !== undefined) {\n      for (const [type, frame] of pending) if (dispatchFrameToState(state, frame)) pending.delete(type);\n      if (pending.size === 0) pendingSessionFrames.delete(sessionId);\n    }\n    return state;\n  }\n\n  /** Themes are the person's, so only the host plugins contribute them. */\n  function installThemes(plugins: readonly WebPluginDefinition[]): void {\n    const collected = collectPluginThemes(plugins);\n    themes = collected.themes;\n    defaultState.diagnostics.push(...collected.diagnostics);\n  }\n\n  /** Language packs follow themes: host plugins only, published into the shared translation store. */\n  function installLocales(plugins: readonly WebPluginDefinition[]): void {\n    const collected = collectPluginLocales(plugins);\n    for (const remove of removeLocales) remove();\n    locales = collected.locales;\n    removeLocales = locales.map(({ locale }) => registerLocaleCatalog(locale.name, locale.messages));\n    defaultState.diagnostics.push(...collected.diagnostics);\n  }\n\n  function installHostWebPlugins(plugins: readonly WebPluginDefinition[]): void {\n    defaultState = buildLiveState(pluginsAtScope(plugins, 'host'), plugins);\n    providers = defaultState.plugins.flatMap((plugin) => {\n      const provider = plugins.find((definition) => definition.id === plugin.id)?.host?.provider;\n      return provider === undefined\n        ? []\n        : [{ pluginId: hostId === undefined ? plugin.id : qualifyHostId(hostId, plugin.id), provider }];\n    });\n    installThemes(plugins);\n    installLocales(plugins);\n    for (const id of sessionStates.keys()) rebuildSession(id);\n    emitRegistryChange();\n  }\n\n  function installWorkspaceWebPlugins(workspaceId: string, plugins: readonly WebPluginDefinition[]): void {\n    const state = buildLiveState(pluginsAtScope(plugins, 'workspace'), plugins);\n    workspaceStates.set(workspaceId, state);\n    for (const [id, owner] of sessionWorkspaces) if (owner === workspaceId) rebuildSession(id);\n    emitRegistryChange();\n  }\n\n  function removeWorkspaceWebPlugins(workspaceId: string): void {\n    workspaceStates.delete(workspaceId);\n    loadDiagnostics.delete(`workspace:${workspaceId}`);\n    for (const [id, owner] of sessionWorkspaces) if (owner === workspaceId) rebuildSession(id);\n    if (activeWorkspaceId === workspaceId) activeWorkspaceId = null;\n    emitRegistryChange();\n  }\n\n  function activateWebPluginWorkspace(workspaceId: string | null): void {\n    if (activeWorkspaceId === workspaceId) return;\n    activeWorkspaceId = workspaceId;\n    emitRegistryChange();\n  }\n\n  function bindSessionWebWorkspace(sessionId: string, workspaceId: string): void {\n    sessionWorkspaces.set(sessionId, workspaceId);\n    rebuildSession(sessionId);\n  }\n\n  function emitRegistryChange(): void {\n    renderDiagnostics.clear();\n    registryRevision += 1;\n    for (const listener of registryListeners) listener();\n  }\n\n  /** The TUI's leader alphabet: one lowercase letter or digit per segment. */\n  const LEADER_KEY = /^[a-z0-9]$/;\n  const MAX_LEADER_PATH = 4;\n\n  /**\n   * A malformed binding fails the install rather than the keypress: the plugin\n   * set is generated at build time, so this is a developer error, and the TUI's\n   * registry refuses the same shapes.\n   */\n  function checkLeaderBinding(pluginId: string, binding: LeaderBindingContribution): void {\n    if (binding.path.length === 0 || binding.path.length > MAX_LEADER_PATH) {\n      throw new Error(\n        `Web plugin '${pluginId}' leader binding '${binding.id}' needs 1 to ${MAX_LEADER_PATH} path segments.`,\n      );\n    }\n    for (const segment of binding.path) {\n      if (!LEADER_KEY.test(segment.key)) {\n        throw new Error(\n          `Web plugin '${pluginId}' leader binding '${binding.id}' key '${segment.key}' must be one lowercase letter or digit.`,\n        );\n      }\n      if (segment.label.trim() === '') {\n        throw new Error(`Web plugin '${pluginId}' leader binding '${binding.id}' has an unlabeled segment.`);\n      }\n    }\n  }\n\n  interface PendingFill {\n    pluginId: string;\n    fill: SlotFillContribution;\n  }\n\n  interface PendingSection {\n    pluginId: string;\n    section: SurfaceContribution;\n  }\n\n  interface PendingBinding {\n    pluginId: string;\n    binding: LeaderBindingContribution;\n  }\n\n  type SharedNamespace =\n    | 'plugin'\n    | 'tab'\n    | 'dock-face'\n    | 'channel'\n    | 'tool'\n    | 'activity-group'\n    | 'mode'\n    | 'selection-axis'\n    | 'palette-command'\n    | 'settings-section';\n\n  /**\n   * Claims `id` in one shared namespace: false, with a diagnostic, when another\n   * plugin already holds it; a throw when this plugin declared it twice, which\n   * is a developer error rather than a composition.\n   */\n  function claim(owners: Map<string, string>, thing: SharedNamespace, id: string, pluginId: string): boolean {\n    const holder = owners.get(id);\n    if (holder === pluginId) {\n      throw new Error(`Web plugin '${pluginId}' declares ${thing.replace('-', ' ')} '${id}' twice.`);\n    }\n    if (holder !== undefined) {\n      installingState.diagnostics.push({\n        pluginId,\n        kind: `duplicate-${thing}`,\n        message: `Web plugin '${pluginId}' ${thing.replace('-', ' ')} '${id}' is already provided by '${holder}'; keeping the first.`,\n      });\n      return false;\n    }\n    owners.set(id, pluginId);\n    return true;\n  }\n\n  function surfaceFill(slot: string, surface: SurfaceContribution): SlotFillContribution {\n    return { slot, id: surface.id, component: surface.component };\n  }\n\n  function checkSlotDeclaration(pluginId: string, declared: Set<string>, declaration: SlotDeclaration): void {\n    const prefix = `${pluginId}${SLOT_SEPARATOR}`;\n    if (!declaration.slot.startsWith(prefix) || declaration.slot.length === prefix.length) {\n      throw new Error(\n        `Web plugin '${pluginId}' declares slot '${declaration.slot}', which must be named '${prefix}<name>'.`,\n      );\n    }\n    if (declared.has(declaration.slot)) {\n      throw new Error(`Web plugin '${pluginId}' declares slot '${declaration.slot}' twice.`);\n    }\n    declared.add(declaration.slot);\n  }\n\n  function checkFill(pluginId: string, seen: Set<string>, fill: SlotFillContribution): void {\n    if (fill.id === '') throw new Error(`Web plugin '${pluginId}' has a fill into '${fill.slot}' with an empty id.`);\n    if (fill.component === undefined && fill.data === undefined) {\n      throw new Error(\n        `Web plugin '${pluginId}' fill '${fill.id}' into '${fill.slot}' has neither a component nor data.`,\n      );\n    }\n    const key = `${fill.slot} ${fill.id}`;\n    if (seen.has(key)) throw new Error(`Web plugin '${pluginId}' fills '${fill.slot}' with id '${fill.id}' twice.`);\n    seen.add(key);\n  }\n\n  function checkContextAction(pluginId: string, seen: Set<string>, action: ContextActionContribution): void {\n    if (action.id.trim() === '') throw new Error(`Web plugin '${pluginId}' has a context action with an empty id.`);\n    if (seen.has(action.id)) throw new Error(`Web plugin '${pluginId}' declares context action '${action.id}' twice.`);\n    if (action.label.trim() === '')\n      throw new Error(`Web plugin '${pluginId}' context action '${action.id}' has an empty label.`);\n    if (action.kinds.length === 0 || action.kinds.some((kind) => kind.trim() === '')) {\n      throw new Error(`Web plugin '${pluginId}' context action '${action.id}' needs non-empty kinds.`);\n    }\n    seen.add(action.id);\n  }\n\n  function checkUserMessageAction(pluginId: string, seen: Set<string>, action: UserMessageActionContribution): void {\n    if (action.id.trim() === '')\n      throw new Error(`Web plugin '${pluginId}' has a user message action with an empty id.`);\n    if (seen.has(action.id))\n      throw new Error(`Web plugin '${pluginId}' declares user message action '${action.id}' twice.`);\n    if (action.label.trim() === '')\n      throw new Error(`Web plugin '${pluginId}' user message action '${action.id}' has an empty label.`);\n    seen.add(action.id);\n  }\n\n  const byFillOrder = (left: ResolvedFill, right: ResolvedFill): number =>\n    left.order - right.order || left.pluginId.localeCompare(right.pluginId) || left.id.localeCompare(right.id);\n\n  const byDisplayOrder = (left: { order?: number; name: string }, right: { order?: number; name: string }): number =>\n    (left.order ?? DEFAULT_FILL_ORDER) - (right.order ?? DEFAULT_FILL_ORDER) || left.name.localeCompare(right.name);\n\n  function placeFill(pluginId: string, fill: SlotFillContribution): void {\n    const declaration = installingState.slots.get(fill.slot);\n    if (declaration === undefined) {\n      installingState.diagnostics.push({\n        pluginId,\n        kind: 'orphan-fill',\n        message: `Web plugin '${pluginId}' fills slot '${fill.slot}', which no installed plugin declares; nothing is placed.`,\n      });\n      return;\n    }\n    let data = fill.data;\n    if (data !== undefined && declaration.parse !== undefined) {\n      const parsed = declaration.parse(data);\n      if (parsed === null) {\n        installingState.diagnostics.push({\n          pluginId,\n          kind: 'rejected-fill',\n          message: `Web plugin '${pluginId}' fill '${fill.id}' into '${fill.slot}' was rejected by the slot's parse gate.`,\n        });\n        return;\n      }\n      data = parsed;\n    }\n    const placed: ResolvedFill = {\n      slot: fill.slot,\n      pluginId,\n      id: fill.id,\n      order: fill.order ?? DEFAULT_FILL_ORDER,\n      ...(data === undefined ? {} : { data }),\n      ...(fill.component === undefined ? {} : { component: fill.component }),\n    };\n    const list = installingState.fills.get(fill.slot);\n    if (list === undefined) installingState.fills.set(fill.slot, [placed]);\n    else list.push(placed);\n  }\n\n  function resolveLeaderConflicts(bindings: readonly PendingBinding[]): void {\n    const owner = new Map<LeaderBindingContribution, string>(bindings.map((entry) => [entry.binding, entry.pluginId]));\n    for (const conflict of leaderConflicts(bindings.map((entry) => entry.binding))) {\n      const winner = owner.get(conflict.winner) ?? '';\n      const loser = owner.get(conflict.loser) ?? '';\n      if (winner === loser) {\n        throw new Error(\n          `Web plugin '${winner}' binds Leader Space '${conflict.path}' twice ('${conflict.loser.id}' and '${conflict.winner.id}').`,\n        );\n      }\n      if (conflict.kind === 'leaf-override') {\n        installingState.diagnostics.push({\n          pluginId: loser,\n          kind: 'leader-leaf-override',\n          message: `Web plugin '${loser}' Leader Space leaf '${conflict.path}' ('${conflict.loser.id}') is taken over by '${winner}' ('${conflict.winner.id}').`,\n        });\n      } else {\n        installingState.diagnostics.push({\n          pluginId: loser,\n          kind: 'leader-group-label',\n          message: `Web plugin '${loser}' words Leader Space group '${conflict.path}' differently from '${winner}', which named it first; keeping the first label.`,\n        });\n      }\n    }\n  }\n\n  function buildWebPluginState(\n    plugins: readonly WebPluginDefinition[],\n    definitions: readonly WebPluginDefinition[] = plugins,\n  ): RegistryState {\n    const previous = installingState;\n    installingState = emptyState();\n    try {\n      const owners: Record<SharedNamespace, Map<string, string>> = {\n        plugin: new Map(),\n        tab: new Map(),\n        'dock-face': new Map(),\n        channel: new Map(),\n        tool: new Map(),\n        'activity-group': new Map(),\n        mode: new Map(),\n        'selection-axis': new Map(),\n        'palette-command': new Map(),\n        'settings-section': new Map(),\n      };\n      const pendingFills: PendingFill[] = [];\n      const pendingSections: PendingSection[] = [];\n      const pendingBindings: PendingBinding[] = [];\n      const pendingSlots: SlotDeclaration[] = [];\n\n      // Phase 1: collect, in the generated (registrationOrder, pluginId) order.\n      for (const plugin of plugins) {\n        if (RESERVED_PLUGIN_IDS.has(plugin.id)) {\n          throw new Error(`Web plugin id '${plugin.id}' is reserved for a host slot.`);\n        }\n        if (owners.plugin.has(plugin.id)) {\n          installingState.diagnostics.push({\n            pluginId: plugin.id,\n            kind: 'duplicate-plugin',\n            message: `Web plugin id '${plugin.id}' is declared twice; keeping the first definition.`,\n          });\n          continue;\n        }\n        owners.plugin.set(plugin.id, plugin.id);\n        const onboarding: OnboardingContribution[] = [];\n        const candidates: unknown[] = Array.isArray(plugin.onboarding)\n          ? plugin.onboarding\n          : plugin.onboarding === undefined\n            ? []\n            : [plugin.onboarding];\n        for (const candidate of candidates) {\n          const parsed = parseOnboarding(candidate);\n          if (parsed === undefined) {\n            installingState.diagnostics.push({\n              pluginId: plugin.id,\n              kind: 'invalid-onboarding',\n              message: `Web plugin '${plugin.id}' has malformed onboarding; ignoring it.`,\n            });\n            continue;\n          }\n          onboarding.push(parsed);\n          installingState.onboarding.push({\n            ...parsed,\n            pluginId: plugin.id,\n            ...(plugin.packageName === undefined ? {} : { packageName: plugin.packageName }),\n          });\n        }\n        installingState.plugins.push(plugin.onboarding === undefined ? plugin : { ...plugin, onboarding });\n        for (const tab of plugin.tabs ?? []) {\n          if (claim(owners.tab, 'tab', tab.id, plugin.id)) installingState.tabs.push(tab);\n        }\n        for (const face of plugin.dockFaces ?? []) {\n          if (face.id === 'activity' || face.id === 'context') {\n            throw new Error(`Web plugin '${plugin.id}' dock face '${face.id}' is reserved by the host.`);\n          }\n          if (face.id.trim() === '' || face.label.trim() === '') {\n            throw new Error(`Web plugin '${plugin.id}' has an unlabeled dock face.`);\n          }\n          if (claim(owners['dock-face'], 'dock-face', face.id, plugin.id)) installingState.dockFaces.push(face);\n        }\n        // A panel and a section both become a /settings/:id route, so the two\n        // share one id namespace rather than racing to own the same URL.\n        for (const section of plugin.settingsSections ?? []) {\n          if (claim(owners['settings-section'], 'settings-section', section.id, plugin.id)) {\n            installingState.settingsSections.push({ ...section, pluginId: plugin.id });\n          }\n        }\n        for (const panel of plugin.settingsPanels ?? []) {\n          if (claim(owners['settings-section'], 'settings-section', panel.id, plugin.id)) {\n            installingState.settingsPanels.push({ ...panel, pluginId: plugin.id });\n          }\n        }\n        for (const channel of plugin.channels ?? []) {\n          if (claim(owners.channel, 'channel', channel.channel, plugin.id))\n            installingState.channels.set(channel.channel, channel);\n        }\n        for (const command of plugin.paletteCommands ?? []) {\n          if (claim(owners['palette-command'], 'palette-command', command.id, plugin.id))\n            installingState.commands.push(command);\n        }\n        const contextActions = new Set<string>();\n        for (const action of plugin.contextActions ?? []) {\n          checkContextAction(plugin.id, contextActions, action);\n          installingState.contextActions.push({ pluginId: plugin.id, ...action });\n        }\n        const userMessageActions = new Set<string>();\n        for (const action of plugin.userMessageActions ?? []) {\n          checkUserMessageAction(plugin.id, userMessageActions, action);\n          installingState.userMessageActions.push({ pluginId: plugin.id, ...action });\n        }\n        for (const binding of plugin.leaderBindings ?? []) {\n          checkLeaderBinding(plugin.id, binding);\n          pendingBindings.push({ pluginId: plugin.id, binding });\n        }\n        for (const axis of plugin.selectionAxes ?? []) {\n          if (claim(owners['selection-axis'], 'selection-axis', axis.name, plugin.id))\n            installingState.selectionAxes.push(axis);\n        }\n        for (const mode of plugin.modes ?? []) {\n          if (claim(owners['mode'], 'mode', mode.name, plugin.id)) installingState.modes.push(mode);\n        }\n        for (const group of plugin.activityGroups ?? []) {\n          if (claim(owners['activity-group'], 'activity-group', group.name, plugin.id))\n            installingState.activityGroups.push(group);\n        }\n        for (const renderer of plugin.toolRenderers ?? []) {\n          for (const tool of renderer.tools) {\n            if (claim(owners.tool, 'tool', tool, plugin.id)) installingState.toolRenderers.set(tool, renderer);\n          }\n          if (renderer.matches !== undefined) installingState.toolMatchers.push(renderer);\n        }\n        const declared = new Set<string>();\n        for (const declaration of plugin.slots ?? []) {\n          checkSlotDeclaration(plugin.id, declared, declaration);\n          pendingSlots.push(declaration);\n        }\n        const filled = new Set<string>();\n        for (const fill of plugin.fills ?? []) {\n          checkFill(plugin.id, filled, fill);\n          pendingFills.push({ pluginId: plugin.id, fill });\n        }\n        for (const surface of plugin.overlays ?? []) {\n          pendingFills.push({ pluginId: plugin.id, fill: surfaceFill(HOST_SLOTS.overlay, surface) });\n        }\n        for (const surface of plugin.railSections ?? []) {\n          pendingFills.push({ pluginId: plugin.id, fill: surfaceFill(HOST_SLOTS.rail, surface) });\n        }\n        for (const surface of plugin.contextSections ?? []) {\n          pendingFills.push({ pluginId: plugin.id, fill: surfaceFill(HOST_SLOTS.context, surface) });\n        }\n        for (const surface of plugin.selectionBarItems ?? []) {\n          pendingFills.push({ pluginId: plugin.id, fill: surfaceFill(HOST_SLOTS.selectionBar, surface) });\n        }\n        for (const surface of plugin.composerActions ?? []) {\n          pendingFills.push({ pluginId: plugin.id, fill: surfaceFill(HOST_SLOTS.composerActions, surface) });\n        }\n        for (const surface of plugin.composerMenuItems ?? []) {\n          pendingFills.push({ pluginId: plugin.id, fill: surfaceFill(HOST_SLOTS.composerMenu, surface) });\n        }\n        for (const section of plugin.activitySections ?? []) pendingSections.push({ pluginId: plugin.id, section });\n        if (plugin.fileLinks !== undefined) installingState.fileLinks.push(plugin.fileLinks);\n      }\n\n      installingState.diagnostics.push(...collectWebTemplates(installingState.plugins).diagnostics);\n\n      // Phase 2: resolve by name, now that every declaration is known.\n      for (const slot of Object.values(HOST_SLOTS)) installingState.slots.set(slot, { slot });\n      installingState.slots.set(HOST_SLOTS.home, { slot: HOST_SLOTS.home, parse: parseHomeContribution });\n      for (const group of installingState.activityGroups) {\n        installingState.slots.set(activityGroupSlot(group.name), { slot: activityGroupSlot(group.name) });\n      }\n      for (const declaration of pendingSlots) installingState.slots.set(declaration.slot, declaration);\n      for (const { pluginId, section } of pendingSections) {\n        const keyed = activityGroupSlot(section.id);\n        pendingFills.push({\n          pluginId,\n          fill: surfaceFill(installingState.slots.has(keyed) ? keyed : HOST_SLOTS.activity, section),\n        });\n      }\n      for (const { pluginId, fill } of pendingFills) {\n        if (\n          fill.slot === HOST_SLOTS.dashboardTiles &&\n          (parseDashboardTileData(fill.data) === null || fill.component === undefined)\n        ) {\n          installingState.diagnostics.push({\n            pluginId,\n            kind: 'rejected-fill',\n            message: `Web plugin '${pluginId}' dashboard tile '${fill.id}' needs valid presentation data and a body component.`,\n          });\n          continue;\n        }\n        if (fill.slot === HOST_SLOTS.home) {\n          const data = parseHomeContribution(fill.data);\n          const definition = definitions.find((plugin) => plugin.id === pluginId);\n          const sources = [definition, definition?.host, definition?.workspace, definition?.session].flatMap(\n            (contribution) => contribution?.channels ?? [],\n          );\n          if (data === null || !sources.some((channel) => channel.channel === data.source)) {\n            installingState.diagnostics.push({\n              pluginId,\n              kind: 'rejected-fill',\n              message: `Web plugin '${pluginId}' Home fill '${fill.id}' needs valid data and an owned source channel.`,\n            });\n            continue;\n          }\n        }\n        placeFill(pluginId, fill);\n      }\n      for (const list of installingState.fills.values()) list.sort(byFillOrder);\n\n      resolveLeaderConflicts(pendingBindings);\n      installingState.leaderBindings.push(...pendingBindings.map((entry) => entry.binding));\n      installingState.contextActions.sort(\n        (left, right) =>\n          (left.order ?? DEFAULT_FILL_ORDER) - (right.order ?? DEFAULT_FILL_ORDER) ||\n          left.pluginId.localeCompare(right.pluginId) ||\n          left.id.localeCompare(right.id),\n      );\n      installingState.userMessageActions.sort(\n        (left, right) =>\n          (left.order ?? DEFAULT_FILL_ORDER) - (right.order ?? DEFAULT_FILL_ORDER) ||\n          left.pluginId.localeCompare(right.pluginId) ||\n          left.id.localeCompare(right.id),\n      );\n      installingState.selectionAxes.sort(byDisplayOrder);\n      installingState.modes.sort(byDisplayOrder);\n      installingState.activityGroups.sort(byDisplayOrder);\n      installingState.dockFaces.sort(\n        (left, right) =>\n          (left.order ?? DEFAULT_FILL_ORDER) - (right.order ?? DEFAULT_FILL_ORDER) || left.id.localeCompare(right.id),\n      );\n      return installingState;\n    } finally {\n      installingState = previous;\n    }\n  }\n\n  /**\n   * Live mounts load developer plugins at runtime, so a plugin whose own build\n   * throws is skipped with a diagnostic instead of blanking every other plugin.\n   */\n  function buildLiveState(\n    plugins: readonly WebPluginDefinition[],\n    definitions: readonly WebPluginDefinition[] = plugins,\n  ): RegistryState {\n    const rejected: InstallDiagnostic[] = [];\n    const admitted = plugins.filter((plugin) => {\n      try {\n        buildWebPluginState([plugin], definitions);\n        return true;\n      } catch (error) {\n        rejected.push({\n          pluginId: plugin.id,\n          kind: 'invalid-plugin',\n          message: `Web plugin '${plugin.id}' was skipped: ${error instanceof Error ? error.message : String(error)}`,\n        });\n        return false;\n      }\n    });\n    const state = buildWebPluginState(admitted, definitions);\n    state.diagnostics.unshift(...rejected);\n    return state;\n  }\n\n  function installWebPlugins(plugins: readonly WebPluginDefinition[]): void {\n    if (defaultInstalled) throw new Error('Web plugins are already installed.');\n    defaultState = buildWebPluginState(plugins);\n    providers = defaultState.plugins.flatMap((plugin) => {\n      const provider = plugin.host?.provider;\n      return provider === undefined\n        ? []\n        : [{ pluginId: hostId === undefined ? plugin.id : qualifyHostId(hostId, plugin.id), provider }];\n    });\n    installThemes(plugins);\n    installLocales(plugins);\n    installingState = defaultState;\n    defaultInstalled = true;\n  }\n\n  function webPluginsInstalled(): boolean {\n    return defaultInstalled;\n  }\n\n  /** Unit-test escape hatch; production installs exactly once. */\n  function resetWebPlugins(): void {\n    defaultState = emptyState();\n    installingState = defaultState;\n    defaultInstalled = false;\n    providers = [];\n    themes = [];\n    for (const remove of removeLocales) remove();\n    removeLocales = [];\n    locales = [];\n    sessionStates.clear();\n    mcpAppRenderers.clear();\n    workspaceStates.clear();\n    sessionPlugins.clear();\n    sessionWorkspaces.clear();\n    activeWorkspaceId = null;\n    pendingSessionFrames.clear();\n    loadDiagnostics.clear();\n    activeSessionId = null;\n    emitRegistryChange();\n  }\n\n  /** Installs or atomically replaces one session's independently synchronized plugin definitions. */\n  function installSessionWebPlugins(sessionId: string, plugins: readonly WebPluginDefinition[]): void {\n    sessionPlugins.set(\n      sessionId,\n      plugins.flatMap((plugin) => (plugin.session === undefined ? [plugin] : pluginsAtScope([plugin], 'session'))),\n    );\n    rebuildSession(sessionId);\n    // Background-session consumers also wait for their verified composition to arrive.\n    emitRegistryChange();\n  }\n\n  /** Selects which session composition the no-argument contribution readers expose. */\n  function activateWebPluginSession(sessionId: string | null): void {\n    if (activeSessionId === sessionId) return;\n    activeSessionId = sessionId;\n    emitRegistryChange();\n  }\n\n  /** Removes one session registry after its plugin-owned stores have been dropped. */\n  function removeSessionWebPlugins(sessionId: string): void {\n    const sessionState = sessionStates.get(sessionId);\n    pendingSessionFrames.delete(sessionId);\n    loadDiagnostics.delete(`session:${sessionId}`);\n    if (sessionState === undefined) return;\n    for (const channel of sessionState.channels.values()) channel.drop(sessionId);\n    sessionStates.delete(sessionId);\n    sessionPlugins.delete(sessionId);\n    sessionWorkspaces.delete(sessionId);\n    if (sessionId === activeSessionId) emitRegistryChange();\n  }\n\n  function subscribeWebPluginRegistry(listener: () => void): () => void {\n    registryListeners.add(listener);\n    return () => registryListeners.delete(listener);\n  }\n\n  function webPluginRegistryRevision(): number {\n    return registryRevision;\n  }\n\n  /**\n   * Records the slots one mount could not load, replacing its previous record. The mount still\n   * installs the slots that loaded, so one broken plugin never hides the others.\n   */\n  function setWebPluginLoadDiagnostics(mount: WebPluginMount, diagnostics: readonly InstallDiagnostic[]): void {\n    const key =\n      mount.scope === 'host'\n        ? 'host'\n        : mount.scope === 'workspace'\n          ? `workspace:${mount.workspaceId}`\n          : `session:${mount.sessionId}`;\n    if (diagnostics.length === 0 && !loadDiagnostics.has(key)) return;\n    if (diagnostics.length === 0) loadDiagnostics.delete(key);\n    else loadDiagnostics.set(key, [...diagnostics]);\n    emitRegistryChange();\n  }\n\n  function recordWebPluginRenderFailure(pluginId: string, fillId: string, slot: string): void {\n    const key = `${pluginId}:${fillId}`;\n    if (renderDiagnostics.has(key)) return;\n    renderDiagnostics.set(key, {\n      pluginId,\n      kind: 'render-failed',\n      message: `Slot '${slot}' fill '${fillId}' threw while rendering.`,\n    });\n  }\n\n  /**\n   * What the install had to resolve between plugins, plus the slots the visible mounts could not\n   * load; empty for a composition whose plugins all load and never collide.\n   */\n  function webPluginDiagnostics(): readonly InstallDiagnostic[] {\n    const workspaceId =\n      (activeSessionId === null ? undefined : sessionWorkspaces.get(activeSessionId)) ?? activeWorkspaceId;\n    const failed = [\n      'host',\n      ...(workspaceId === null ? [] : [`workspace:${workspaceId}`]),\n      ...(activeSessionId === null ? [] : [`session:${activeSessionId}`]),\n    ].flatMap((key) => loadDiagnostics.get(key) ?? []);\n    const installed = activeState().diagnostics;\n    const rendered = [...renderDiagnostics.values()];\n    if (failed.length === 0 && rendered.length === 0) return installed;\n    return [...installed, ...failed, ...rendered];\n  }\n\n  /** Every installed plugin definition, in install order; the settings page lists them. */\n  function installedWebPlugins(): readonly WebPluginDefinition[] {\n    return activeState().plugins;\n  }\n\n  /** Package panels placed under the host's repository controls, in stable display order. */\n  function pluginRepositorySettingsPanels(): readonly InstalledRepositorySettingsPanel[] {\n    return (workspaceState() ?? emptyState()).plugins\n      .flatMap((plugin) =>\n        plugin.repositorySettingsPanel === undefined\n          ? []\n          : [{ ...plugin.repositorySettingsPanel, pluginId: plugin.id }],\n      )\n      .sort(\n        (left, right) =>\n          (left.order ?? DEFAULT_FILL_ORDER) - (right.order ?? DEFAULT_FILL_ORDER) ||\n          left.pluginId.localeCompare(right.pluginId),\n      );\n  }\n\n  function webTabs(sessionId?: string | null): readonly TabContribution[] {\n    return activeState(sessionId).tabs;\n  }\n\n  /** Optional right-dock faces from the active session composition, in display order. */\n  function pluginDockFaces(): readonly DockFaceContribution[] {\n    return activeState().dockFaces;\n  }\n\n  /** UI discovery only. Requests still require a proof injected by Electron's main process. */\n  function isDesktopClient(): boolean {\n    return hostPlatform === 'desktop';\n  }\n  /**\n   * The settings pages plugins contribute, in menu order. Sorted here rather than\n   * at the reader so the menu and the page agree without either sorting twice.\n   */\n  function pluginSettingsSections(scope: 'host' | 'workspace' = 'host'): readonly InstalledSettingsSection[] {\n    const sections = (scope === 'host' ? defaultState : workspaceState())?.settingsSections ?? [];\n    const visible = isDesktopClient() ? sections : sections.filter((section) => !section.desktopOnly);\n    if (!isSelfHostShell()) return visible;\n    return visible.map((section) => {\n      const fields = section.fields.filter((field) => !field.localOnly);\n      return {\n        ...section,\n        fields,\n        ...(section.groups === undefined\n          ? {}\n          : { groups: section.groups.filter((group) => fields.some((field) => field.group === group.id)) }),\n      };\n    });\n  }\n\n  /** Validated setup contributions. Setup is the host's and runs there, whichever workspace is open. */\n  function pluginOnboarding(): readonly InstalledOnboarding[] {\n    return defaultState.onboarding;\n  }\n\n  /** The settings pages plugins draw themselves, in install order; the reader sorts them with the sections. */\n  function pluginSettingsPanels(): readonly InstalledSettingsPanel[] {\n    return defaultState.settingsPanels;\n  }\n\n  /** The fills placed into one slot, in slot order; empty for a slot nobody declared. */\n  function slotFills(slot: string, sessionId?: string | null): readonly ResolvedFill[] {\n    return activeState(sessionId).fills.get(slot) ?? [];\n  }\n\n  /** One workspace's own fills for a slot, whichever session or workspace is focused. */\n  function workspaceSlotFills(workspaceId: string, slot: string): readonly ResolvedFill[] {\n    return workspaceStates.get(workspaceId)?.fills.get(slot) ?? [];\n  }\n\n  /** The host plugins' fills for a slot, whichever session or workspace is focused. */\n  function hostSlotFills(slot: string): readonly ResolvedFill[] {\n    return defaultState.fills.get(slot) ?? [];\n  }\n\n  /** Dashboard reads never inherit the currently focused session. */\n  function dashboardTileFills(mount: Exclude<WebPluginMount, { scope: 'session' }>): readonly InstalledDashboardTile[] {\n    const surface = mount.scope === 'workspace' ? 'workspace' : 'home';\n    const host = (defaultState.fills.get(HOST_SLOTS.dashboardTiles) ?? []).filter((fill) =>\n      ((fill.data as DashboardTileData).surfaces ?? ['home']).includes(surface),\n    );\n    const workspace =\n      mount.scope === 'workspace'\n        ? (workspaceStates.get(mount.workspaceId)?.fills.get(HOST_SLOTS.dashboardTiles) ?? [])\n        : [];\n    const merged = new Map<string, ResolvedFill>();\n    for (const fill of [...host, ...workspace]) merged.set(JSON.stringify([fill.pluginId, fill.id]), fill);\n    return [...merged.values()].sort(byFillOrder) as InstalledDashboardTile[];\n  }\n\n  /** A dual-publishing plugin uses its new Home tiles, never both card versions. */\n  function legacyHomeAppFills(): readonly ResolvedFill[] {\n    const tiled = new Set(dashboardTileFills({ scope: 'host' }).map((fill) => fill.pluginId));\n    return hostSlotFills(HOST_SLOTS.homeApps).filter((fill) => !tiled.has(fill.pluginId));\n  }\n\n  /** Home reads an explicit host mount, never the focused session or workspace. */\n  function pluginHomeContributions(\n    mount: Exclude<WebPluginMount, { scope: 'session' }>,\n  ): readonly InstalledHomeContribution[] {\n    const host = defaultState.fills.get(HOST_SLOTS.home) ?? [];\n    const workspace =\n      mount.scope === 'workspace' ? (workspaceStates.get(mount.workspaceId)?.fills.get(HOST_SLOTS.home) ?? []) : [];\n    const seen = new Set<string>();\n    const contributions: InstalledHomeContribution[] = [];\n    for (const fill of [...host, ...workspace]) {\n      const data = parseHomeContribution(fill.data);\n      if (data === null) continue;\n      const key = `${fill.pluginId}\\0${data.source}`;\n      if (seen.has(key)) continue;\n      seen.add(key);\n      const icon = (fill.data as { icon?: unknown }).icon;\n      contributions.push({\n        pluginId: fill.pluginId,\n        id: fill.id,\n        order: fill.order,\n        data,\n        mount: host.includes(fill) ? { scope: 'host' } : mount,\n        ...(typeof icon === 'function' || (typeof icon === 'object' && icon !== null)\n          ? { icon: icon as NonNullable<DashboardTileData['icon']> }\n          : {}),\n      });\n    }\n    return contributions.sort(\n      (left, right) =>\n        left.order - right.order || left.pluginId.localeCompare(right.pluginId) || left.id.localeCompare(right.id),\n    );\n  }\n\n  function paletteCommands(): readonly PaletteCommandContribution[] {\n    return activeState().commands;\n  }\n\n  /** Context actions from every installed plugin, in stable display order. */\n  function pluginContextActions(sessionId?: string | null): readonly InstalledContextAction[] {\n    return activeState(sessionId).contextActions;\n  }\n\n  /** User-message actions from every installed plugin, in stable display order. */\n  function pluginUserMessageActions(): readonly InstalledUserMessageAction[] {\n    return activeState().userMessageActions;\n  }\n\n  /** Leader Space bindings from every installed plugin, in install order: a later binding on a bound leaf wins. */\n  function pluginLeaderBindings(): readonly LeaderBindingContribution[] {\n    return activeState().leaderBindings;\n  }\n\n  /** Selection-axis declarations from every installed plugin, in display order. */\n  function pluginSelectionAxes(): readonly SelectionAxisContribution[] {\n    return activeState().selectionAxes;\n  }\n\n  /** Mode declarations from every installed plugin, in display order. */\n  function pluginModes(): readonly ModeContribution[] {\n    return activeState().modes;\n  }\n\n  /** Activity-dock group declarations from every installed plugin, in display order. */\n  function pluginActivityGroups(sessionId?: string | null): readonly ActivityGroupContribution[] {\n    const groups = activeState(sessionId).activityGroups;\n    return isDesktopClient() ? groups : groups.filter((group) => !group.desktopOnly);\n  }\n\n  /**\n   * The file-link sources installed plugins contribute, in install order.\n   *\n   * More than one is allowed and the first to claim a path wins, the same way a\n   * runtime tool matcher does: the host has no way to choose between two\n   * packages that both recognise a path, and the alternative is two tabs for one\n   * file.\n   */\n  function pluginFileLinks(sessionId?: string | null): readonly FileLinkSource[] {\n    return activeState(sessionId).fileLinks;\n  }\n\n  /**\n   * The renderer a plugin registered for one tool: the exact name claim first,\n   * then the first runtime matcher that accepts it, in install order (the one\n   * place besides `start` where that order is observable); undefined leaves\n   * the host's default card.\n   */\n  function pluginToolRenderer(\n    toolName: string,\n    statuses: Readonly<Record<string, string>> = {},\n    details?: unknown,\n  ): ToolRendererContribution | undefined {\n    return resolveToolRenderer(activeState(), toolName, statuses, details);\n  }\n\n  function resolveToolRenderer(\n    state: RegistryState,\n    toolName: string,\n    statuses: Readonly<Record<string, string>>,\n    details: unknown,\n  ): ToolRendererContribution | undefined {\n    return (\n      state.toolRenderers.get(toolName) ??\n      state.toolMatchers.find((renderer) => {\n        try {\n          return renderer.matches?.(toolName, statuses, details);\n        } catch {\n          // A plugin's predicate must not take down tool cards, prompts or completion routing.\n          return false;\n        }\n      })\n    );\n  }\n\n  /**\n   * A session-scoped renderer, resolved the way pluginToolRenderer resolves the\n   * active one, or undefined until that session's verified composition is installed.\n   */\n  function sessionToolRenderer(\n    sessionId: string,\n    toolName: string,\n    statuses: Readonly<Record<string, string>> = {},\n    details?: unknown,\n  ): ToolRendererContribution | undefined {\n    const state = sessionStates.get(sessionId);\n    return state === undefined ? undefined : resolveToolRenderer(state, toolName, statuses, details);\n  }\n\n  function sessionWebPluginsInstalled(sessionId: string): boolean {\n    return sessionPlugins.has(sessionId);\n  }\n\n  /**\n   * Routes one wire frame to the channel owning its type. Returns false when no\n   * channel claims it, so the demux can fall through silently the way unknown\n   * frames always have.\n   */\n  function dispatchFrameToState(state: RegistryState, frame: Record<string, unknown>): boolean {\n    if (typeof frame.type !== 'string' || typeof frame.sessionId !== 'string') return false;\n    const channel = state.channels.get(frame.type);\n    if (channel === undefined) return false;\n    const payload = channel.parse(frame.payload);\n    if (payload !== null) channel.apply(frame.sessionId, payload);\n    return true;\n  }\n\n  function dispatchChannelFrame(frame: Record<string, unknown>): boolean {\n    if (typeof frame.type !== 'string' || typeof frame.sessionId !== 'string') return false;\n    const state = sessionStates.get(frame.sessionId);\n    if (state !== undefined) {\n      if (dispatchFrameToState(state, frame)) return true;\n    } else if (activeSessionId === null) return dispatchFrameToState(defaultState, frame);\n    // Channel envelopes carry payload; protocol events do not and must not accumulate.\n    if (!Object.hasOwn(frame, 'payload')) return false;\n    const pending = pendingSessionFrames.get(frame.sessionId) ?? new Map<string, Record<string, unknown>>();\n    if (!pending.has(frame.type) && pending.size >= MAX_PENDING_CHANNEL_TYPES) {\n      const oldest = pending.keys().next().value as string | undefined;\n      if (oldest !== undefined) pending.delete(oldest);\n    }\n    pending.set(frame.type, frame);\n    pendingSessionFrames.set(frame.sessionId, pending);\n    return false;\n  }\n\n  /** Session teardown: every channel forgets the session's data. */\n  function dropPluginSessionData(sessionId: string): void {\n    pendingSessionFrames.delete(sessionId);\n    const state = sessionStates.get(sessionId) ?? (activeSessionId === null ? defaultState : undefined);\n    for (const channel of state?.channels.values() ?? []) channel.drop(sessionId);\n  }\n\n  const mcpAppRenderers = new Map<string, NonNullable<WebPluginSlotProps['renderMcpApp']>>();\n\n  function pluginMcpAppRenderer(sessionId: string | null) {\n    return sessionId === null ? undefined : mcpAppRenderers.get(sessionId);\n  }\n\n  /**\n   * Starts every plugin runtime in install order; the disposer runs in reverse, once. With `onFailure`\n   * a plugin whose start throws is reported and skipped, so the others still start. A disposer that\n   * throws does not stop the rest; the failures are rethrown together.\n   */\n  function startPluginDefinitions(\n    plugins: readonly WebPluginDefinition[],\n    runtime: WebPluginRuntime,\n    onFailure?: (pluginId: string, error: unknown) => void,\n  ): () => void {\n    const disposers: Array<() => void> = [];\n    const disposeStarted = (): void => {\n      const failures: unknown[] = [];\n      for (const dispose of disposers.splice(0).reverse()) {\n        try {\n          dispose();\n        } catch (error) {\n          failures.push(error);\n        }\n      }\n      if (failures.length > 0) throw new AggregateError(failures, 'Web plugin teardown failed');\n    };\n    for (const plugin of plugins) {\n      try {\n        const sessionId = runtime.mount?.scope === 'session' ? runtime.mount.sessionId : undefined;\n        const dispose = plugin.start?.({\n          ...runtime,\n          ...(sessionId === undefined\n            ? {}\n            : {\n                registerMcpAppRenderer(render) {\n                  mcpAppRenderers.set(sessionId, render);\n                  const unregister = () => {\n                    if (mcpAppRenderers.get(sessionId) === render) mcpAppRenderers.delete(sessionId);\n                  };\n                  disposers.push(unregister);\n                  return unregister;\n                },\n              }),\n        });\n        if (typeof dispose === 'function') disposers.push(dispose);\n      } catch (error) {\n        if (onFailure) {\n          onFailure(plugin.id, error);\n          continue;\n        }\n        try {\n          disposeStarted();\n        } catch (cleanup) {\n          throw new AggregateError([error, cleanup], 'Web plugin start failed and its rollback failed', {\n            cause: error,\n          });\n        }\n        throw error instanceof Error ? error : new Error(`Web plugin '${plugin.id}' failed to start`, { cause: error });\n      }\n    }\n    return disposeStarted;\n  }\n\n  function startWebPlugins(runtime: WebPluginRuntime): () => void {\n    return startPluginDefinitions(activeState().plugins, runtime);\n  }\n\n  const owner = <T extends { pluginId: string }>(entry: T): T =>\n    hostId === undefined ? entry : { ...entry, pluginId: qualifyHostId(hostId, entry.pluginId) };\n  return {\n    hostPluginProviders: (): readonly InstalledHostPluginProvider[] => providers,\n    pluginThemes: (): readonly InstalledPluginTheme[] => themes,\n    pluginLocales: (): readonly InstalledPluginLocale[] => locales,\n    webTemplateCatalog,\n    nativeTemplateCatalog,\n    pluginOnboarding,\n    installHostWebPlugins,\n    installWorkspaceWebPlugins,\n    removeWorkspaceWebPlugins,\n    activateWebPluginWorkspace,\n    bindSessionWebWorkspace,\n    installWebPlugins,\n    webPluginsInstalled,\n    resetWebPlugins,\n    installSessionWebPlugins,\n    activateWebPluginSession,\n    removeSessionWebPlugins,\n    subscribeWebPluginRegistry,\n    webPluginRegistryRevision,\n    setWebPluginLoadDiagnostics,\n    recordWebPluginRenderFailure,\n    webPluginDiagnostics: (...args: Parameters<typeof webPluginDiagnostics>) =>\n      webPluginDiagnostics(...args).map(owner),\n    installedWebPlugins: () =>\n      installedWebPlugins().map((plugin) =>\n        hostId === undefined ? plugin : { ...plugin, id: qualifyHostId(hostId, plugin.id) },\n      ),\n    pluginRepositorySettingsPanels: (...args: Parameters<typeof pluginRepositorySettingsPanels>) =>\n      pluginRepositorySettingsPanels(...args).map(owner),\n    webTabs,\n    pluginDockFaces,\n    isDesktopClient,\n    pluginSettingsSections,\n    pluginSettingsPanels: (...args: Parameters<typeof pluginSettingsPanels>) =>\n      pluginSettingsPanels(...args).map(owner),\n    slotFills: (...args: Parameters<typeof slotFills>) => slotFills(...args).map(owner),\n    workspaceSlotFills: (...args: Parameters<typeof workspaceSlotFills>) => workspaceSlotFills(...args).map(owner),\n    hostSlotFills: (...args: Parameters<typeof hostSlotFills>) => hostSlotFills(...args).map(owner),\n    dashboardTileFills: (...args: Parameters<typeof dashboardTileFills>) => dashboardTileFills(...args).map(owner),\n    legacyHomeAppFills: () => legacyHomeAppFills().map(owner),\n    pluginHomeContributions: (...args: Parameters<typeof pluginHomeContributions>) =>\n      pluginHomeContributions(...args).map(owner),\n    paletteCommands,\n    pluginContextActions: (...args: Parameters<typeof pluginContextActions>) =>\n      pluginContextActions(...args).map(owner),\n    pluginUserMessageActions: (...args: Parameters<typeof pluginUserMessageActions>) =>\n      pluginUserMessageActions(...args).map(owner),\n    pluginLeaderBindings,\n    pluginSelectionAxes,\n    pluginModes,\n    pluginActivityGroups,\n    pluginFileLinks,\n    pluginToolRenderer,\n    pluginMcpAppRenderer,\n    sessionToolRenderer,\n    sessionWebPluginsInstalled,\n    dispatchChannelFrame,\n    dropPluginSessionData,\n    startPluginDefinitions,\n    startWebPlugins,\n  };\n}\n\nexport type WebPluginRegistry = ReturnType<typeof createWebPluginRegistry>;\nconst defaultRegistry = createWebPluginRegistry();\nconst hostRegistries = new Map<string, WebPluginRegistry>();\nlet activeHostId: string | undefined;\n\n/** Hosts whose plugin definitions are available to this dashboard. */\nexport function registeredWebPluginHostIds(): readonly string[] {\n  return [...hostRegistries.keys()];\n}\nexport function webPluginRegistryForHost(hostId: string): WebPluginRegistry {\n  // The Worker's own host is the default registry, even when its session IDs are qualified.\n  if (hostId === defaultHostId()) return observeRegistry(defaultRegistry);\n  let registry = hostRegistries.get(hostId);\n  if (!registry) {\n    registry = observeRegistry(createWebPluginRegistry(hostId));\n    hostRegistries.set(hostId, registry);\n  }\n  return registry;\n}\nexport function removeHostWebPlugins(hostId: string): void {\n  hostRegistries.get(hostId)?.resetWebPlugins();\n  hostRegistries.delete(hostId);\n  if (activeHostId === hostId) activeHostId = undefined;\n}\n\nconst registrySubscribers = new Set<() => void>();\nfunction notifyRegistrySubscribers(): void {\n  noteStoreUpdate('pluginRegistry', combinedRevision, combinedRevision + 1);\n  for (const listener of registrySubscribers) listener();\n}\nlet combinedRevision = 0;\nconst observedRegistries = new WeakSet<WebPluginRegistry>();\nfunction observeRegistry(registry: WebPluginRegistry): WebPluginRegistry {\n  if (!observedRegistries.has(registry)) {\n    observedRegistries.add(registry);\n    registry.subscribeWebPluginRegistry(() => {\n      combinedRevision += 1;\n      notifyRegistrySubscribers();\n    });\n  }\n  return registry;\n}\n/** Selects host-owned host surfaces when no session or workspace is focused. */\nexport function activateWebPluginHost(hostId: string | undefined): void {\n  if (activeHostId === hostId) return;\n  activeHostId = hostId;\n  combinedRevision += 1;\n  notifyRegistrySubscribers();\n}\n\nfunction selectedRegistry(): WebPluginRegistry {\n  return activeHostId === undefined ? defaultRegistry : webPluginRegistryForHost(activeHostId);\n}\nfunction registryForKey(key: string): WebPluginRegistry {\n  const qualified = splitHostId(key);\n  return observeRegistry(qualified === undefined ? defaultRegistry : webPluginRegistryForHost(qualified.hostId));\n}\nfunction registryForMount(mount?: WebPluginMount): WebPluginRegistry {\n  return mount === undefined || mount.scope === 'host'\n    ? selectedRegistry()\n    : registryForKey(mount.scope === 'session' ? mount.sessionId : mount.workspaceId);\n}\n\nexport const webTemplateCatalog: WebPluginRegistry['webTemplateCatalog'] = (...args) =>\n  registryForMount(args[0]).webTemplateCatalog(...args);\n\nexport const nativeTemplateCatalog: WebPluginRegistry['nativeTemplateCatalog'] = (...args) =>\n  registryForMount(args[0]).nativeTemplateCatalog(...args);\n\n/** Installs the shell's own host composition, regardless of which session is focused. */\nexport const installHostWebPlugins: WebPluginRegistry['installHostWebPlugins'] = (...args) =>\n  observeRegistry(defaultRegistry).installHostWebPlugins(...args);\n\nexport const installWorkspaceWebPlugins: WebPluginRegistry['installWorkspaceWebPlugins'] = (...args) =>\n  registryForKey(args[0]).installWorkspaceWebPlugins(...args);\n\nexport const removeWorkspaceWebPlugins: WebPluginRegistry['removeWorkspaceWebPlugins'] = (...args) =>\n  registryForKey(args[0]).removeWorkspaceWebPlugins(...args);\n\nexport const bindSessionWebWorkspace: WebPluginRegistry['bindSessionWebWorkspace'] = (...args) =>\n  registryForKey(args[0]).bindSessionWebWorkspace(...args);\n\nexport const installWebPlugins: WebPluginRegistry['installWebPlugins'] = (...args) =>\n  selectedRegistry().installWebPlugins(...args);\n\nexport const webPluginsInstalled: WebPluginRegistry['webPluginsInstalled'] = (...args) =>\n  selectedRegistry().webPluginsInstalled(...args);\n\nexport const installSessionWebPlugins: WebPluginRegistry['installSessionWebPlugins'] = (...args) =>\n  registryForKey(args[0]).installSessionWebPlugins(...args);\n\nexport const removeSessionWebPlugins: WebPluginRegistry['removeSessionWebPlugins'] = (...args) =>\n  registryForKey(args[0]).removeSessionWebPlugins(...args);\n\nexport const setWebPluginLoadDiagnostics: WebPluginRegistry['setWebPluginLoadDiagnostics'] = (...args) =>\n  registryForMount(args[0]).setWebPluginLoadDiagnostics(...args);\n\nexport const recordWebPluginRenderFailure: WebPluginRegistry['recordWebPluginRenderFailure'] = (...args) =>\n  selectedRegistry().recordWebPluginRenderFailure(...args);\n\nexport const webPluginDiagnostics: WebPluginRegistry['webPluginDiagnostics'] = (...args) =>\n  selectedRegistry().webPluginDiagnostics(...args);\n\nexport const installedWebPlugins: WebPluginRegistry['installedWebPlugins'] = (...args) =>\n  selectedRegistry().installedWebPlugins(...args);\n\nexport const pluginRepositorySettingsPanels: WebPluginRegistry['pluginRepositorySettingsPanels'] = (...args) =>\n  selectedRegistry().pluginRepositorySettingsPanels(...args);\n\nexport const webTabs: WebPluginRegistry['webTabs'] = (...args) =>\n  (typeof args[0] === 'string' ? registryForKey(args[0]) : selectedRegistry()).webTabs(...args);\n\nexport const pluginDockFaces: WebPluginRegistry['pluginDockFaces'] = (...args) =>\n  selectedRegistry().pluginDockFaces(...args);\n\nexport const isDesktopClient: WebPluginRegistry['isDesktopClient'] = (...args) =>\n  selectedRegistry().isDesktopClient(...args);\n\nexport const pluginSettingsSections: WebPluginRegistry['pluginSettingsSections'] = (...args) =>\n  selectedRegistry().pluginSettingsSections(...args);\n\nexport const pluginSettingsPanels: WebPluginRegistry['pluginSettingsPanels'] = (...args) =>\n  selectedRegistry().pluginSettingsPanels(...args);\n\nexport const slotFills: WebPluginRegistry['slotFills'] = (...args) =>\n  (typeof args[1] === 'string' ? registryForKey(args[1]) : selectedRegistry()).slotFills(...args);\n\nexport const workspaceSlotFills: WebPluginRegistry['workspaceSlotFills'] = (...args) =>\n  registryForKey(args[0]).workspaceSlotFills(...args);\n\n/** The themes this browser's own host plugins contribute; a remote host's themes are not the person's. */\nexport function pluginThemes(): readonly InstalledPluginTheme[] {\n  return defaultRegistry.pluginThemes();\n}\n\n/** The languages every paired host's plugins contribute, one per tag, for the language picker. */\nexport function allPluginLocales(): readonly InstalledPluginLocale[] {\n  const seen = new Set<string>();\n  return [defaultRegistry, ...hostRegistries.values()]\n    .flatMap((registry) => registry.pluginLocales())\n    .filter(({ locale }) => {\n      if (seen.has(locale.name)) return false;\n      seen.add(locale.name);\n      return true;\n    });\n}\n\n/**\n * The themes the person's paired computers contribute, for the phone, which pairs only with their\n * own computers. One plugin on two computers is offered once, under its first computer's colours.\n */\nexport function allPluginThemes(): readonly InstalledPluginTheme[] {\n  const seen = new Set<string>();\n  return [defaultRegistry, ...hostRegistries.values()]\n    .flatMap((registry) => registry.pluginThemes())\n    .filter(({ theme }) => {\n      if (seen.has(theme.name)) return false;\n      seen.add(theme.name);\n      return true;\n    });\n}\n\n/** All host-host providers, default first then host registry creation order, independent of focus. */\nexport function hostPluginProviders(): readonly InstalledHostPluginProvider[] {\n  return [defaultRegistry, ...hostRegistries.values()].flatMap((registry) => registry.hostPluginProviders());\n}\n\n/**\n * Plugins the client app ships itself (the phone's account plugin). Their host fills join every\n * host-scope read before any host is paired and survive host selection, replacement and removal.\n */\nconst bundledRegistry = observeRegistry(createWebPluginRegistry());\n\nexport function installBundledWebPlugins(plugins: readonly WebPluginDefinition[]): void {\n  bundledRegistry.installHostWebPlugins(plugins);\n}\n\n/** A host's copy of a bundled plugin never renders: the app's own copy wins, whichever host is selected. */\nexport const hostSlotFills: WebPluginRegistry['hostSlotFills'] = (slot) => {\n  const host = selectedRegistry().hostSlotFills(slot);\n  const own = new Set(bundledRegistry.installedWebPlugins().map((plugin) => plugin.id));\n  if (own.size === 0) return host;\n  const bundled = bundledRegistry.hostSlotFills(slot);\n  return [...host.filter((fill) => !own.has(splitHostId(fill.pluginId)?.localId ?? fill.pluginId)), ...bundled].sort(\n    (left, right) =>\n      left.order - right.order || left.pluginId.localeCompare(right.pluginId) || left.id.localeCompare(right.id),\n  );\n};\n\nexport const dashboardTileFills: WebPluginRegistry['dashboardTileFills'] = (...args) =>\n  registryForMount(args[0]).dashboardTileFills(...args);\n\n/** Home contributions keep their supplying host, deduplicating only explicitly shared data. */\nexport function dashboardTileFillsAcrossHosts(\n  hosts: Parameters<typeof homeAppEntries>[0],\n  admit: (hostId: string, pluginId: string) => boolean = () => true,\n) {\n  return homeAppEntries(hosts, (hostId) =>\n    webPluginRegistryForHost(hostId)\n      .dashboardTileFills({ scope: 'host' })\n      .filter((fill) => admit(hostId, fill.pluginId)),\n  );\n}\n\n/** Host-host slots are joined independently of the focused session or workspace. */\nexport function hostSlotFillsAcrossHosts(\n  hosts: Parameters<typeof homeAppEntries>[0],\n  slot: string,\n  admit: (hostId: string, pluginId: string) => boolean = () => true,\n) {\n  return homeAppEntries(hosts, (hostId) =>\n    webPluginRegistryForHost(hostId)\n      .hostSlotFills(slot)\n      .filter((fill) => admit(hostId, fill.pluginId)),\n  );\n}\n\nexport const legacyHomeAppFills: WebPluginRegistry['legacyHomeAppFills'] = () =>\n  selectedRegistry().legacyHomeAppFills();\n\nexport const pluginHomeContributions: WebPluginRegistry['pluginHomeContributions'] = (...args) =>\n  registryForMount(args[0]).pluginHomeContributions(...args);\n\nexport const paletteCommands: WebPluginRegistry['paletteCommands'] = (...args) =>\n  selectedRegistry().paletteCommands(...args);\n\nexport const pluginContextActions: WebPluginRegistry['pluginContextActions'] = (...args) =>\n  (typeof args[0] === 'string' ? registryForKey(args[0]) : selectedRegistry()).pluginContextActions(...args);\n\nexport const pluginUserMessageActions: WebPluginRegistry['pluginUserMessageActions'] = (...args) =>\n  selectedRegistry().pluginUserMessageActions(...args);\n\nexport const pluginLeaderBindings: WebPluginRegistry['pluginLeaderBindings'] = (...args) =>\n  selectedRegistry().pluginLeaderBindings(...args);\n\nexport const pluginSelectionAxes: WebPluginRegistry['pluginSelectionAxes'] = (...args) =>\n  selectedRegistry().pluginSelectionAxes(...args);\n\nexport const pluginModes: WebPluginRegistry['pluginModes'] = (...args) => selectedRegistry().pluginModes(...args);\n\nexport const pluginActivityGroups: WebPluginRegistry['pluginActivityGroups'] = (...args) =>\n  (typeof args[0] === 'string' ? registryForKey(args[0]) : selectedRegistry()).pluginActivityGroups(...args);\n\nexport const pluginFileLinks: WebPluginRegistry['pluginFileLinks'] = (...args) =>\n  (typeof args[0] === 'string' ? registryForKey(args[0]) : selectedRegistry()).pluginFileLinks(...args);\n\nexport const pluginToolRenderer: WebPluginRegistry['pluginToolRenderer'] = (...args) =>\n  selectedRegistry().pluginToolRenderer(...args);\n\nexport const sessionToolRenderer: WebPluginRegistry['sessionToolRenderer'] = (...args) =>\n  registryForKey(args[0]).sessionToolRenderer(...args);\n\nexport const sessionWebPluginsInstalled: WebPluginRegistry['sessionWebPluginsInstalled'] = (...args) =>\n  registryForKey(args[0]).sessionWebPluginsInstalled(...args);\n\nexport const dispatchChannelFrame: WebPluginRegistry['dispatchChannelFrame'] = (...args) =>\n  (typeof args[0].sessionId === 'string' ? registryForKey(args[0].sessionId) : selectedRegistry()).dispatchChannelFrame(\n    ...args,\n  );\n\nexport const dropPluginSessionData: WebPluginRegistry['dropPluginSessionData'] = (...args) =>\n  registryForKey(args[0]).dropPluginSessionData(...args);\n\nexport const startPluginDefinitions: WebPluginRegistry['startPluginDefinitions'] = (...args) =>\n  selectedRegistry().startPluginDefinitions(...args);\n\nexport const startWebPlugins: WebPluginRegistry['startWebPlugins'] = (...args) =>\n  selectedRegistry().startWebPlugins(...args);\n\nexport function subscribeWebPluginRegistry(listener: () => void): () => void {\n  observeRegistry(defaultRegistry);\n  registrySubscribers.add(listener);\n  return () => registrySubscribers.delete(listener);\n}\nexport function webPluginRegistryRevision(): number {\n  return combinedRevision;\n}\nexport function activateWebPluginSession(sessionId: string | null): void {\n  const nextHost = sessionId === null ? activeHostId : splitHostId(sessionId)?.hostId;\n  const changed = activeHostId !== nextHost;\n  activeHostId = nextHost;\n  observeRegistry(selectedRegistry()).activateWebPluginSession(sessionId);\n  if (changed) {\n    combinedRevision += 1;\n    notifyRegistrySubscribers();\n  }\n}\nexport function activateWebPluginWorkspace(workspaceId: string | null): void {\n  const nextHost = workspaceId === null ? activeHostId : splitHostId(workspaceId)?.hostId;\n  const changed = activeHostId !== nextHost;\n  activeHostId = nextHost;\n  observeRegistry(selectedRegistry()).activateWebPluginWorkspace(workspaceId);\n  if (changed) {\n    combinedRevision += 1;\n    notifyRegistrySubscribers();\n  }\n}\nlet hostPlatform: string | undefined;\n\n/** Sets the shell platform identity from the web shell entrypoint instead of sniffing `window.poDesktop`. */\nexport function setWebPluginHostPlatform(platform: string | undefined): void {\n  hostPlatform = platform;\n}\n\nexport function resetWebPlugins(): void {\n  hostPlatform = undefined;\n  for (const registry of hostRegistries.values()) registry.resetWebPlugins();\n  hostRegistries.clear();\n  activeHostId = undefined;\n  observeRegistry(defaultRegistry).resetWebPlugins();\n}\n\nexport const pluginMcpAppRenderer: WebPluginRegistry['pluginMcpAppRenderer'] = (...args) =>\n  (typeof args[0] === 'string' ? registryForKey(args[0]) : selectedRegistry()).pluginMcpAppRenderer(...args);\n\nexport const pluginOnboarding: WebPluginRegistry['pluginOnboarding'] = (...args) =>\n  selectedRegistry().pluginOnboarding(...args);\n"],"mappings":";;;;;;;;;;;;AAsHA,SAAgB,uBAAuB,OAA0C;CAC/E,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO;CAChF,MAAM,OAAO;CACb,IAAI,KAAK,YAAY,KAAK,OAAO,KAAK,UAAU,YAAY,KAAK,MAAM,KAAK,MAAM,IAAI,OAAO;CAC7F,IAAI,KAAK,SAAS,KAAA,KAAa,CAAC;EAAC;EAAS;EAAQ;EAAQ;CAAO,CAAC,CAAC,SAAS,KAAK,IAAc,GAAG,OAAO;CACzG,IAAI,KAAK,WAAW,KAAA,KAAa,KAAK,WAAW,UAAU,KAAK,WAAW,QAAQ,OAAO;CAC1F,IACE,KAAK,SAAS,KAAA,KACd,OAAO,KAAK,SAAS,eACpB,OAAO,KAAK,SAAS,YAAY,KAAK,SAAS,OAEhD,OAAO;CACT,IAAI,KAAK,sBAAsB,KAAA,KAAa,OAAO,KAAK,sBAAsB,WAAW,OAAO;CAChG,IAAI,KAAK,cAAc,KAAA,KAAa,KAAK,cAAc,UAAU,KAAK,cAAc,UAAU,OAAO;CACrG,IACE,KAAK,aAAa,KAAA,MACjB,CAAC,MAAM,QAAQ,KAAK,QAAQ,KAAK,KAAK,SAAS,MAAM,YAAY,YAAY,UAAU,YAAY,WAAW,IAE/G,OAAO;CACT,IAAI,KAAK,SAAS,KAAA,GAAW;EAC3B,IAAI,OAAO,KAAK,SAAS,YAAY,KAAK,SAAS,QAAQ,MAAM,QAAQ,KAAK,IAAI,GAAG,OAAO;EAC5F,MAAM,OAAO,KAAK;EAClB,IAAK,KAAK,SAAS,UAAU,KAAK,SAAS,cAAe,OAAO,KAAK,OAAO,YAAY,KAAK,G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