@ai-matrx/agents 0.38.4 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/catalog/index.cjs +3 -1
- package/dist/catalog/index.cjs.map +1 -1
- package/dist/catalog/index.d.cts +2 -2
- package/dist/catalog/index.d.ts +2 -2
- package/dist/catalog/index.js +3 -1
- package/dist/catalog/index.js.map +1 -1
- package/dist/catalog/native/index.cjs +4 -1
- package/dist/catalog/native/index.cjs.map +1 -1
- package/dist/catalog/native/index.d.cts +8 -3
- package/dist/catalog/native/index.d.ts +8 -3
- package/dist/catalog/native/index.js +4 -1
- package/dist/catalog/native/index.js.map +1 -1
- package/dist/catalog/react/index.cjs +1 -0
- package/dist/catalog/react/index.cjs.map +1 -1
- package/dist/catalog/react/index.d.cts +13 -1
- package/dist/catalog/react/index.d.ts +13 -1
- package/dist/catalog/react/index.js +1 -0
- package/dist/catalog/react/index.js.map +1 -1
- package/dist/content-transfer/index.cjs.map +1 -1
- package/dist/content-transfer/index.js.map +1 -1
- package/dist/content-transfer/react/index.cjs.map +1 -1
- package/dist/content-transfer/react/index.js.map +1 -1
- package/dist/context/index.cjs +0 -25
- package/dist/context/index.cjs.map +1 -1
- package/dist/context/index.d.cts +2 -17
- package/dist/context/index.d.ts +2 -17
- package/dist/context/index.js +0 -25
- package/dist/context/index.js.map +1 -1
- package/dist/context/react/index.cjs +280 -98
- package/dist/context/react/index.cjs.map +1 -1
- package/dist/context/react/index.d.cts +134 -16
- package/dist/context/react/index.d.ts +134 -16
- package/dist/context/react/index.js +283 -101
- package/dist/context/react/index.js.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/{keys.generated-DxG5tgWt.d.cts → keys.generated-ClN6zfUo.d.cts} +4 -4
- package/dist/{keys.generated-DxG5tgWt.d.ts → keys.generated-ClN6zfUo.d.ts} +4 -4
- package/dist/mandates/index.cjs +2 -2
- package/dist/mandates/index.cjs.map +1 -1
- package/dist/mandates/index.d.cts +2 -2
- package/dist/mandates/index.d.ts +2 -2
- package/dist/mandates/index.js +2 -2
- package/dist/mandates/index.js.map +1 -1
- package/dist/matrx/index.d.cts +1 -1
- package/dist/matrx/index.d.ts +1 -1
- package/dist/{orchestra-zpGHwOag.d.cts → orchestra-CiaTu58J.d.cts} +7 -0
- package/dist/{orchestra-zpGHwOag.d.ts → orchestra-CiaTu58J.d.ts} +7 -0
- package/mandates/snapshots/keys.0.39.0.json +653 -0
- package/mandates/snapshots/keys.0.40.0.json +653 -0
- package/mandates/snapshots/keys.0.41.0.json +653 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../catalog/react/context.tsx","../../../catalog/shared/context.tsx","../../../catalog/shared/useAgentConsumer.ts","../../../catalog/shared/useAgentListCore.ts","../../../catalog/types.ts","../../../catalog/labels.ts","../../../catalog/score.ts","../../../catalog/selectors.ts","../../../catalog/react/AgentListDropdown.tsx","../../../catalog/react/AgentListPanel.tsx","../../../catalog/react/primitives.tsx","../../../catalog/shared/icon-paths.ts","../../../catalog/react/icons.tsx","../../../catalog/react/AgentCategoriesPanel.tsx","../../../catalog/react/AgentDetailCard.tsx","../../../catalog/react/FavoriteAgentButton.tsx","../../../catalog/orchestra.ts","../../../catalog/react/AgentListContent.tsx","../../../catalog/react/types.ts","../../../catalog/react/AgentFilterBar.tsx","../../../catalog/react/AgentListTabs.tsx","../../../catalog/react/AgentRow.tsx","../../../catalog/react/AgentMobileSubView.tsx","../../../catalog/react/AgentSortPanel.tsx","../../../catalog/react/AgentTagsPanel.tsx","../../../catalog/react/AgentListInlinePicker.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * catalog/react/context.tsx — @ai-matrx/agents/catalog/react\n *\n * THE WEB BINDING of the one provider. Everything real — the context, the\n * store subscription, the port resolution — lives in `../shared/context`,\n * which the React Native entry reuses byte-for-byte (0.9.0). This file adds\n * only the three DOM defaults, so a web host that binds nothing still gets a\n * real `<a>`, a real navigation and real model text.\n *\n * `useAgentCatalog()` THROWS when no provider is mounted. A picker with no\n * catalogue is not a degraded picker, it is a lie on screen.\n */\n\nimport { useMemo, type ReactNode } from \"react\";\n\nimport {\n AgentCatalogProviderCore,\n type AgentCatalogLinkComponent,\n type AgentCatalogPlatformDefaults,\n type AgentCatalogRenderModelRef,\n type AgentCatalogUiPorts,\n} from \"../shared/context\";\nimport type { AgentCatalog } from \"../store\";\n\nexport {\n useAgentCatalog,\n useAgentCatalogRows,\n useAgentCatalogState,\n useAgentCatalogUiPorts,\n type AgentCatalogLinkComponent,\n type AgentCatalogPlatformDefaults,\n type AgentCatalogRenderModelRef,\n type AgentCatalogUiPorts,\n} from \"../shared/context\";\n\nexport interface AgentCatalogProviderProps extends AgentCatalogUiPorts {\n catalog: AgentCatalog;\n children: ReactNode;\n}\n\n/** The shipped web default: a real, working link in every framework. */\nconst DefaultLink: AgentCatalogLinkComponent = ({ children, ...props }) => (\n <a {...(props as Record<string, unknown>)}>{children}</a>\n);\n\nconst defaultRenderModelRef: AgentCatalogRenderModelRef = ({\n modelId,\n className,\n}) => <span className={className}>{modelId}</span>;\n\n/** The shipped web default: a real navigation. */\nconst webNavigate = (href: string): void => {\n if (typeof window !== \"undefined\") window.location.assign(href);\n};\n\nconst WEB_PLATFORM_DEFAULTS: AgentCatalogPlatformDefaults = {\n navigate: webNavigate,\n LinkComponent: DefaultLink,\n renderModelRef: defaultRenderModelRef,\n};\n\nexport function AgentCatalogProvider({\n catalog,\n children,\n ...ports\n}: AgentCatalogProviderProps) {\n const platform = useMemo(() => WEB_PLATFORM_DEFAULTS, []);\n return (\n <AgentCatalogProviderCore\n catalog={catalog}\n platform={platform}\n {...ports}\n >\n {children}\n </AgentCatalogProviderCore>\n );\n}\n","/**\n * catalog/shared/context.tsx — THE ONE React binding point, platform-neutral.\n *\n * 0.9.0 moved the provider, the context and the three subscription hooks OUT\n * of `catalog/react/context.tsx` and into this file so the React Native entry\n * (`@ai-matrx/agents/catalog/native`) reuses the SAME provider, the SAME store\n * subscription and the SAME hooks as the web picker. Only the VIEW layer, and\n * the three platform DEFAULTS below, differ between the two entries.\n *\n * 🚨 NOTHING IN THIS FILE MAY TOUCH THE DOM OR react-native. A default that\n * renders `<a>` is a web default and a default that renders `<Text>` is a\n * native default; both arrive through `platform`, which each entry's own\n * `AgentCatalogProvider` supplies. That is why `useAgentCatalogUiPorts()`\n * still answers with every default already applied on both platforms, and why\n * an unset port is never `undefined` on either.\n *\n * This file carries NO `\"use client\"` source directive on purpose: the stamp\n * is applied per BUILT ENTRY by tsup (the web entry gets it, the native entry\n * must not — React Native has no RSC and a stamped native module is a lie).\n */\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useSyncExternalStore,\n type ComponentType,\n type ReactNode,\n} from \"react\";\n\nimport type { AgentCatalog, AgentCatalogState } from \"../store\";\nimport type {\n AgentCatalogNavigate,\n AgentCatalogOpenPeek,\n} from \"../ports\";\nimport type { AgentSummary } from \"../types\";\n\n/**\n * The anchor a row renders for cmd/ctrl-click. DEFAULT (web): a plain `<a>` —\n * which is a REAL, working link in every framework. A Next.js host passes\n * `next/link`; a TanStack host passes its own `Link`. On React Native the\n * default is a pressable `Text` that routes through `navigate`.\n */\n/**\n * What a row's link handler receives. A DOM `React.MouseEvent` satisfies this\n * structurally, and the native default link supplies the two methods itself —\n * so a shared component can call `preventDefault()` on either platform\n * without a platform check.\n */\nexport interface AgentCatalogLinkClickEvent {\n metaKey?: boolean;\n ctrlKey?: boolean;\n preventDefault(): void;\n stopPropagation(): void;\n}\n\nexport type AgentCatalogLinkComponent = ComponentType<{\n href: string;\n className?: string;\n target?: string;\n rel?: string;\n title?: string;\n \"aria-label\"?: string;\n onClick?: (e: AgentCatalogLinkClickEvent) => void;\n children: ReactNode;\n}>;\n\n/** Render a model id as whatever door the host has. DEFAULT: plain text. */\nexport type AgentCatalogRenderModelRef = (args: {\n modelId: string;\n className?: string;\n}) => ReactNode;\n\nexport interface AgentCatalogUiPorts {\n /** DEFAULT (web): `window.location.assign`. DEFAULT (native): a reporting no-op. */\n navigate?: AgentCatalogNavigate;\n /** DEFAULT: a plain `<a>` (web) / a pressable `Text` (native). */\n LinkComponent?: AgentCatalogLinkComponent;\n /** DEFAULT: the model id as plain text. */\n renderModelRef?: AgentCatalogRenderModelRef;\n /** ABSENT: the sneak-peek affordance is HIDDEN — never a dead button. */\n openPeek?: AgentCatalogOpenPeek;\n /**\n * Portal container for the desktop popover, when the picker is mounted\n * inside a dialog. DEFAULT: the document body (Radix's own default).\n * Web only — the native entry ignores it.\n */\n popoverContainer?: HTMLElement | null;\n}\n\n/**\n * The three defaults a PLATFORM supplies. Never a host concern: a host\n * overrides an individual port through `AgentCatalogUiPorts`, and whatever it\n * leaves unset falls back to the platform's own working answer.\n */\nexport interface AgentCatalogPlatformDefaults {\n navigate: AgentCatalogNavigate;\n LinkComponent: AgentCatalogLinkComponent;\n renderModelRef: AgentCatalogRenderModelRef;\n}\n\ninterface AgentCatalogBinding extends AgentCatalogUiPorts {\n catalog: AgentCatalog;\n platform: AgentCatalogPlatformDefaults;\n}\n\nconst AgentCatalogContext = createContext<AgentCatalogBinding | null>(null);\n\nexport interface AgentCatalogProviderCoreProps extends AgentCatalogUiPorts {\n catalog: AgentCatalog;\n platform: AgentCatalogPlatformDefaults;\n children: ReactNode;\n}\n\n/**\n * The provider itself. Each entry wraps this with its own platform defaults\n * and re-exports it as `AgentCatalogProvider`; hosts never see this name.\n */\nexport function AgentCatalogProviderCore({\n catalog,\n platform,\n children,\n ...ports\n}: AgentCatalogProviderCoreProps) {\n const value = useMemo<AgentCatalogBinding>(\n () => ({ catalog, platform, ...ports }),\n // The ports are plain values a host declares once; re-binding on identity\n // change is correct and cheap.\n [\n catalog,\n platform,\n ports.navigate,\n ports.LinkComponent,\n ports.renderModelRef,\n ports.openPeek,\n ports.popoverContainer,\n ],\n );\n return (\n <AgentCatalogContext.Provider value={value}>\n {children}\n </AgentCatalogContext.Provider>\n );\n}\n\nfunction useBinding(): AgentCatalogBinding {\n const binding = useContext(AgentCatalogContext);\n if (!binding) {\n throw new Error(\n \"@ai-matrx/agents/catalog: no <AgentCatalogProvider> is mounted \" +\n \"above this component. Create the catalog once with \" +\n \"createAgentCatalog({ client, identity }) and mount \" +\n \"<AgentCatalogProvider catalog={catalog}> at the top of your tree.\",\n );\n }\n return binding;\n}\n\n/** The headless catalog this tree is bound to. Throws with no provider. */\nexport function useAgentCatalog(): AgentCatalog {\n return useBinding().catalog;\n}\n\n/** The UI ports this tree is bound to, with every default already applied. */\nexport function useAgentCatalogUiPorts(): Required<\n Pick<AgentCatalogUiPorts, \"navigate\" | \"LinkComponent\" | \"renderModelRef\">\n> & {\n openPeek: AgentCatalogOpenPeek | undefined;\n popoverContainer: HTMLElement | null | undefined;\n} {\n const binding = useBinding();\n const hostNavigate = binding.navigate;\n const platformNavigate = binding.platform.navigate;\n const navigate = useCallback<AgentCatalogNavigate>(\n (href) => {\n if (hostNavigate) {\n hostNavigate(href);\n return;\n }\n platformNavigate(href);\n },\n [hostNavigate, platformNavigate],\n );\n return {\n navigate,\n LinkComponent: binding.LinkComponent ?? binding.platform.LinkComponent,\n renderModelRef:\n binding.renderModelRef ?? binding.platform.renderModelRef,\n openPeek: binding.openPeek,\n popoverContainer: binding.popoverContainer,\n };\n}\n\n/**\n * Subscribe to a slice of catalog state. `useSyncExternalStore` because the\n * catalog is an external store and React 18/19 concurrency must not tear it.\n * `select` MUST return a stable reference for unchanged state — every\n * selector in `../selectors` does.\n */\nexport function useAgentCatalogState<T>(\n select: (state: AgentCatalogState) => T,\n): T {\n const catalog = useAgentCatalog();\n const getSnapshot = useCallback(\n () => select(catalog.getState()),\n [catalog, select],\n );\n return useSyncExternalStore(catalog.subscribe, getSnapshot, getSnapshot);\n}\n\n/** Every row currently in the catalogue, as one stable array. */\nexport function useAgentCatalogRows(): AgentSummary[] {\n return useAgentCatalogState(selectRows);\n}\n\nconst selectRows = (state: AgentCatalogState): AgentSummary[] => state.rows;\n","/**\n * catalog/shared/useAgentConsumer.ts — VERBATIM port of matrx-frontend\n * `features/agents/hooks/useAgentConsumer.ts`.\n *\n * Wraps a single consumer slot identified by `consumerId`. Registers the slot\n * on mount, optionally unregisters on unmount, and returns every filter/sort/\n * pagination value plus stable write helpers.\n *\n * Two seams inverted, nothing else:\n * - `useAppSelector`/`useAppDispatch` → `useAgentCatalog()` + the store's\n * own methods.\n * - `useServerAgentSearch` (a separate frontend hook) is folded IN, because\n * it was already wired here and nowhere else: EVERY agent surface that\n * uses a consumer searches the full server-side set. A local-only search\n * over a paginated list reports \"no results\" for agents that were merely\n * never fetched — a wrong answer, not a missing feature.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useAgentCatalog, useAgentCatalogState } from \"./context\";\nimport type {\n AgentAccessFilter,\n AgentArchFilter,\n AgentFavFilter,\n AgentSortOption,\n AgentTab,\n AgentConsumerPatch,\n AgentConsumerState,\n} from \"../types\";\nimport type { AgentCatalogState } from \"../store\";\n\nconst DEBOUNCE_MS = 250;\n\n/** Below this length a query matches too much to be worth a round trip. */\nconst MIN_QUERY_LENGTH = 2;\n\nexport interface UseAgentConsumerReturn {\n // ── Read ────────────────────────────────────────────────────────────────\n tab: AgentTab;\n sortBy: AgentSortOption;\n searchTerm: string;\n includedCats: string[];\n includedTags: string[];\n favFilter: AgentFavFilter;\n archFilter: AgentArchFilter;\n /**\n * The archive-filter state this catalog starts consumers in — the platform\n * default `\"active\"` unless the host set the knob. What \"not the default\n * state\" means on this surface, so the control and the footer can both say\n * it honestly.\n */\n archFilterDefault: AgentArchFilter;\n accessFilter: AgentAccessFilter;\n favoritesFirst: boolean;\n listPage: number;\n sharedPage: number;\n\n /** The whole slot, for the selectors that take a consumer state. */\n state: AgentConsumerState;\n\n /** True if any filter differs from its default value. */\n hasActiveFilters: boolean;\n\n /** Tier 2 search — also match against agent prompt content. */\n deepSearch: boolean;\n\n /** True while a server-side search is in flight. */\n isServerSearching: boolean;\n\n // ── Write ───────────────────────────────────────────────────────────────\n setSearchTerm: (value: string) => void;\n setDeepSearch: (value: boolean) => void;\n setSortBy: (value: AgentSortOption) => void;\n setTab: (value: AgentTab) => void;\n setFavFilter: (value: AgentFavFilter) => void;\n setArchFilter: (value: AgentArchFilter) => void;\n setAccessFilter: (value: AgentAccessFilter) => void;\n\n /** Add category to inclusion set; if already present, remove (toggle). */\n toggleCategory: (cat: string) => void;\n /** Add tag to inclusion set; if already present, remove (toggle). */\n toggleTag: (tag: string) => void;\n\n /**\n * Replace the WHOLE category inclusion set in one write.\n *\n * Prefer this over looping `toggleCategory` whenever more than one value\n * changes. Each `toggleCategory` call computes its next array from the\n * `includedCats` captured in the CURRENT render, so two toggles fired in the\n * same tick both start from the same snapshot and the second one's patch\n * overwrites the first — a \"Clear filter\" click with three categories active\n * removes only one. One write of the final set cannot drift that way.\n */\n setIncludedCats: (next: string[]) => void;\n /** Replace the WHOLE tag inclusion set in one write. See setIncludedCats. */\n setIncludedTags: (next: string[]) => void;\n\n toggleFavoritesFirst: () => void;\n\n loadMoreList: () => void;\n loadMoreShared: () => void;\n\n resetFilters: () => void;\n}\n\nexport function useAgentConsumer(\n consumerId: string,\n options?: {\n /** Delete the slot on unmount. Default false — persistent consumers keep state. */\n unregisterOnUnmount?: boolean;\n /** Applied only when the consumer is first registered (idempotent). */\n initialTab?: AgentTab;\n /**\n * THE ARCHIVED-ITEMS LAW's per-consumer override of the catalog-wide\n * `defaults.archiveFilter` knob. Applied only at first registration — the\n * state belongs to the person after that.\n */\n initialArchFilter?: AgentArchFilter;\n },\n): UseAgentConsumerReturn {\n const catalog = useAgentCatalog();\n const defaults = catalog.consumerDefaults;\n const selectConsumer = useCallback(\n (state: AgentCatalogState): AgentConsumerState =>\n state.consumers[consumerId] ?? defaults,\n [consumerId, defaults],\n );\n const consumer = useAgentCatalogState(selectConsumer);\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n useEffect(() => {\n const opts = optionsRef.current;\n const initial: AgentConsumerPatch = {\n ...(opts?.initialTab ? { tab: opts.initialTab } : {}),\n ...(opts?.initialArchFilter\n ? { archFilter: opts.initialArchFilter }\n : {}),\n };\n catalog.registerConsumer(\n consumerId,\n Object.keys(initial).length > 0 ? initial : undefined,\n );\n return () => {\n if (optionsRef.current?.unregisterOnUnmount) {\n catalog.unregisterConsumer(consumerId);\n }\n };\n }, [consumerId, catalog]);\n\n // ── Write helpers (stable references) ───────────────────────────────────\n\n const setSearchTerm = useCallback(\n (value: string) => catalog.setConsumerFilter(consumerId, { searchTerm: value }),\n [consumerId, catalog],\n );\n const setDeepSearch = useCallback(\n (value: boolean) => catalog.setConsumerFilter(consumerId, { deepSearch: value }),\n [consumerId, catalog],\n );\n const setSortBy = useCallback(\n (value: AgentSortOption) =>\n catalog.setConsumerFilter(consumerId, { sortBy: value }),\n [consumerId, catalog],\n );\n const setTab = useCallback(\n (value: AgentTab) => catalog.setConsumerFilter(consumerId, { tab: value }),\n [consumerId, catalog],\n );\n const setFavFilter = useCallback(\n (value: AgentFavFilter) =>\n catalog.setConsumerFilter(consumerId, { favFilter: value }),\n [consumerId, catalog],\n );\n const setArchFilter = useCallback(\n (value: AgentArchFilter) =>\n catalog.setConsumerFilter(consumerId, { archFilter: value }),\n [consumerId, catalog],\n );\n const setAccessFilter = useCallback(\n (value: AgentAccessFilter) =>\n catalog.setConsumerFilter(consumerId, { accessFilter: value }),\n [consumerId, catalog],\n );\n\n const toggleCategory = useCallback(\n (cat: string) => {\n const current = catalog.getConsumer(consumerId).includedCats;\n const next = current.includes(cat)\n ? current.filter((c) => c !== cat)\n : [...current, cat];\n catalog.setConsumerFilter(consumerId, { includedCats: next });\n },\n [consumerId, catalog],\n );\n\n const toggleTag = useCallback(\n (tag: string) => {\n const current = catalog.getConsumer(consumerId).includedTags;\n const next = current.includes(tag)\n ? current.filter((t) => t !== tag)\n : [...current, tag];\n catalog.setConsumerFilter(consumerId, { includedTags: next });\n },\n [consumerId, catalog],\n );\n\n const setIncludedCats = useCallback(\n (next: string[]) => catalog.setConsumerFilter(consumerId, { includedCats: next }),\n [consumerId, catalog],\n );\n const setIncludedTags = useCallback(\n (next: string[]) => catalog.setConsumerFilter(consumerId, { includedTags: next }),\n [consumerId, catalog],\n );\n\n const toggleFavoritesFirst = useCallback(\n () =>\n catalog.setConsumerFilter(consumerId, {\n favoritesFirst: !catalog.getConsumer(consumerId).favoritesFirst,\n }),\n [consumerId, catalog],\n );\n\n const loadMoreList = useCallback(\n () =>\n catalog.setConsumerPage(\n consumerId,\n \"list\",\n catalog.getConsumer(consumerId).listPage + 1,\n ),\n [consumerId, catalog],\n );\n const loadMoreShared = useCallback(\n () =>\n catalog.setConsumerPage(\n consumerId,\n \"shared\",\n catalog.getConsumer(consumerId).sharedPage + 1,\n ),\n [consumerId, catalog],\n );\n\n const resetFilters = useCallback(\n () => catalog.resetConsumerFilters(consumerId),\n [consumerId, catalog],\n );\n\n // ── Server-side search (folded in — see the file header) ────────────────\n //\n // Debounced, and stale responses are ignored so a slow reply for an old\n // query can never land after a newer one. Purely additive: local matches\n // keep rendering the whole time; server results merge in and simply appear.\n\n const [isSearching, setIsSearching] = useState(false);\n const [matchedIds, setMatchedIds] = useState<string[] | null>(null);\n const requestSeq = useRef(0);\n const query = consumer.searchTerm;\n const deep = consumer.deepSearch;\n\n useEffect(() => {\n const q = query.trim();\n if (q.length < MIN_QUERY_LENGTH) {\n setIsSearching(false);\n setMatchedIds(null);\n return undefined;\n }\n\n const seq = ++requestSeq.current;\n setIsSearching(true);\n\n const timer = setTimeout(() => {\n void catalog\n .searchServer(q, deep)\n .then((ids) => {\n if (seq !== requestSeq.current) return; // superseded\n setMatchedIds(ids);\n setIsSearching(false);\n })\n .catch((e: unknown) => {\n if (seq !== requestSeq.current) return; // superseded\n // Loud, but never destructive: local results stay on screen.\n catalog.errorSink({\n code: \"server_search_failed\",\n message: `agent search failed: ${e instanceof Error ? e.message : String(e)}`,\n context: { query: q, deep },\n });\n setIsSearching(false);\n });\n }, DEBOUNCE_MS);\n\n return () => clearTimeout(timer);\n }, [query, deep, catalog]);\n\n useEffect(() => {\n catalog.setConsumerServerSearch(consumerId, {\n matchedIds: matchedIds ?? [],\n isSearching,\n });\n }, [consumerId, catalog, matchedIds, isSearching]);\n\n // ── hasActiveFilters (verbatim) ─────────────────────────────────────────\n const hasActiveFilters =\n consumer.searchTerm !== \"\" ||\n consumer.includedCats.length > 0 ||\n consumer.includedTags.length > 0 ||\n consumer.favFilter !== \"all\" ||\n // The archive filter is compared to THIS CATALOG'S default, not to the\n // hardcoded platform one: a host that legitimately defaults to \"show all\"\n // must not have the reset control permanently lit.\n consumer.archFilter !== defaults.archFilter ||\n consumer.accessFilter !== \"any\" ||\n !consumer.favoritesFirst;\n\n return {\n tab: consumer.tab,\n sortBy: consumer.sortBy,\n searchTerm: consumer.searchTerm,\n includedCats: consumer.includedCats,\n includedTags: consumer.includedTags,\n favFilter: consumer.favFilter,\n archFilter: consumer.archFilter,\n archFilterDefault: defaults.archFilter,\n accessFilter: consumer.accessFilter,\n favoritesFirst: consumer.favoritesFirst,\n listPage: consumer.listPage,\n sharedPage: consumer.sharedPage,\n state: consumer,\n hasActiveFilters,\n deepSearch: consumer.deepSearch,\n isServerSearching: consumer.isServerSearching,\n setSearchTerm,\n setDeepSearch,\n setSortBy,\n setTab,\n setFavFilter,\n setArchFilter,\n setAccessFilter,\n toggleCategory,\n toggleTag,\n setIncludedCats,\n setIncludedTags,\n toggleFavoritesFirst,\n loadMoreList,\n loadMoreShared,\n resetFilters,\n };\n}\n","/**\n * catalog/shared/useAgentListCore.ts — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/useAgentListCore.ts`.\n *\n * Seams inverted:\n * - Redux (`useAppSelector`/`useAppDispatch`/`createSelector`) → the catalog\n * store and the plain memoized selectors in `../selectors`.\n * - `useRouter().push` → the `navigate` port (default `window.location.assign`).\n *\n * TWO BEHAVIOURAL DELTAS, recorded in the CHANGELOG rather than hidden:\n * 1. There is no app-wide \"active agent\" store in this package (that is host\n * state by ruling D1 — the picker's contract is `onSelect(agentId)`), so\n * the pinned row comes from the `activeAgentId` PROP alone. The\n * frontend's fallback to a Redux `activeAgentId` has no package twin.\n * 2. For the same reason, a call site that passes NEITHER `onSelect` NOR\n * `navigateTo` gets a loud `errorSink` report instead of the frontend's\n * `dispatch(setActiveAgentId(...))`. A click that does nothing silently\n * is the exact failure this package exists to stop.\n */\n\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { useAgentCatalog, useAgentCatalogRows, useAgentCatalogState, useAgentCatalogUiPorts } from \"./context\";\nimport { useAgentConsumer } from \"./useAgentConsumer\";\nimport { agentListFooterLabel, shouldDefaultAgentListToPublicTab } from \"../labels\";\nimport {\n makeSelectFilteredAgents,\n selectAllAgentCategories,\n selectAllAgentTags,\n selectAllSystemAgentCategories,\n selectAllSystemAgentTags,\n selectAgentTabCounts,\n} from \"../selectors\";\nimport type { AgentCatalogState } from \"../store\";\nimport type { DefaultRowState } from \"../default-row-types\";\nimport type { AgentArchFilter, AgentSummary, AgentTab } from \"../types\";\n\n/**\n * The four ownership counts a tab strip prints. Declared HERE, beside the code\n * that computes them, so both the web tab strip and the native one name the\n * same shape (0.9.0 — it used to live in the web-only `AgentListTabs`).\n *\n * 🚨 These are the numbers on the BADGES, and since 0.9.1 they count exactly\n * the rows the tab renders under the consumer's own archive filter. A badge\n * that counted rows the list hid was the screen telling the user something\n * untrue about her own agents.\n */\nexport interface AgentListTabCounts {\n mine: number;\n shared: number;\n all: number;\n system: number;\n}\n\nexport interface AgentListCoreOptions {\n consumerId: string;\n onSelect?: (agentId: string) => void;\n navigateTo?: string;\n /** Route-scoped agent id (chat/builder headers). `undefined` = nothing pinned. */\n activeAgentIdOverride?: string | null;\n /**\n * Tab this surface opens on, applied once on first mount. Admin surfaces\n * that manage system agents pass `\"system\"`. When omitted the normal\n * user heuristic applies (a user with no agents of their own lands on the\n * public/system catalogue).\n */\n initialTab?: AgentTab;\n /**\n * ADMIN reading of the \"All\" tab: blend system agents into it instead of\n * keeping them to their own tab. See `makeSelectFilteredAgents`.\n */\n includeSystemInAll?: boolean;\n /**\n * 🚨 THE OWNERSHIP TABS THIS CALL SITE MAY REACH — a HARD restriction, not a\n * default.\n *\n * `AgentListTabs` already hides the buttons this list omits, but hiding a\n * button never emptied the list behind it: the active tab lives in the\n * consumer's REMEMBERED state, and `initialTab` is applied exactly once per\n * mount (`defaultTabAppliedRef`). So a person who had been on \"Mine\" and\n * then moved a control that narrows the picker got the personal catalogue\n * with the tab bar removed — the forbidden list, and no way to see that it\n * was forbidden. That is the defect Arman named on the mandate binding\n * screen's global rung (VISION-RECONCILIATION D2, 2026-08-31: the picker\n * opened on \"Mine · 40\").\n *\n * Given here, the tab is COERCED into the allowed set on every change of it,\n * not just at mount — so a restriction that arrives later is enforced later.\n */\n visibleTabs?: readonly AgentTab[];\n /**\n * THE ARCHIVED-ITEMS LAW's per-consumer override of the catalog-wide\n * `defaults.archiveFilter` knob, applied once at first registration. Almost\n * nothing should pass it: the platform answer is \"hide archived\", and the\n * person reveals the archive from the control on the filter bar.\n */\n initialArchFilter?: AgentArchFilter;\n /** Hide records that are invalid for this call site. */\n excludeAgentIds?: readonly string[];\n /**\n * Show the platform DEFAULT agent for this mandate key at the top of the\n * list, resolved live through the server (never a hardcoded name). Requires\n * the catalog to have been built with a `transport`.\n */\n defaultMandateKey?: string;\n}\n\n/**\n * How long the hover-preview detail panel stays open after the cursor leaves\n * an agent row (or the panel itself) before it closes. Generous on purpose:\n * the panel renders to the side of the list, so the user needs ample time to\n * travel the cursor across the gap to reach it without it vanishing. Paired\n * with a reserved, non-resizing popover width so the target never moves.\n */\nexport const HOVER_GRACE_MS = 900;\n\n/**\n * THE RULE, ALONE AND TESTABLE: which tab a restricted picker must land on.\n *\n * Returns `null` when the current tab is already allowed (nothing to do), and\n * otherwise the tab to switch to — `initialTab` when that is itself allowed,\n * else the first allowed tab.\n */\nexport function coerceVisibleTab(\n current: AgentTab,\n allowed: readonly AgentTab[],\n initialTab?: AgentTab,\n): AgentTab | null {\n if (allowed.length === 0) return null;\n if (allowed.includes(current)) return null;\n return initialTab && allowed.includes(initialTab)\n ? initialTab\n : (allowed[0] ?? null);\n}\n\nconst EMPTY_EXCLUDES: readonly string[] = [];\n\nexport function useAgentListCore({\n consumerId,\n onSelect,\n navigateTo,\n activeAgentIdOverride,\n initialTab,\n includeSystemInAll = false,\n visibleTabs,\n initialArchFilter,\n excludeAgentIds = EMPTY_EXCLUDES,\n defaultMandateKey,\n}: AgentListCoreOptions) {\n const catalog = useAgentCatalog();\n const { navigate } = useAgentCatalogUiPorts();\n\n const hasFetchedRef = useRef(false);\n const [hoveredAgent, setHoveredAgent] = useState<AgentSummary | null>(null);\n const hoverLeaveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const defaultTabAppliedRef = useRef(false);\n\n const consumer = useAgentConsumer(consumerId, {\n unregisterOnUnmount: true,\n ...(initialArchFilter ? { initialArchFilter } : {}),\n });\n const rows = useAgentCatalogRows();\n const userId = catalog.getUserIdOrNull();\n const tabCountsForFilter = selectAgentTabCounts(rows, consumer.state.archFilter);\n const ownedCount = tabCountsForFilter.mine;\n\n const selectFiltered = useMemo(\n () => makeSelectFilteredAgents(includeSystemInAll),\n [includeSystemInAll],\n );\n const filteredAgents = selectFiltered(rows, consumer.state);\n const excludedAgentIds = useMemo(\n () => new Set(excludeAgentIds),\n [excludeAgentIds],\n );\n const applyExcludes = useCallback(\n (list: AgentSummary[]): AgentSummary[] =>\n excludedAgentIds.size === 0\n ? list\n : list.filter((agent) => !excludedAgentIds.has(agent.id)),\n [excludedAgentIds],\n );\n const agents = applyExcludes(filteredAgents);\n\n // ── THE ARCHIVE PROBE — what the default state is keeping off the screen ──\n //\n // Clause 2 of THE ARCHIVED-ITEMS LAW: a footer counts what the list renders\n // and never implies the list is everything. So while archived rows are\n // hidden we also measure how many there ARE behind this exact tab, search,\n // category and tag selection — the same pipeline, one value changed — and\n // the footer says so. A second memoized selector instance keeps this off\n // the main one's memo slot, so the two never evict each other.\n const selectArchivedProbe = useMemo(\n () => makeSelectFilteredAgents(includeSystemInAll),\n [includeSystemInAll],\n );\n const archiveProbeState = useMemo(\n () => ({ ...consumer.state, archFilter: \"archived\" as const }),\n [consumer.state],\n );\n const archivedHiddenCount =\n consumer.archFilter === \"active\"\n ? applyExcludes(selectArchivedProbe(rows, archiveProbeState)).length\n : 0;\n\n const status = useAgentCatalogState(selectStatus);\n // `null` is an intentional \"nothing selected\" value for assignment\n // dropdowns. There is no app-wide active agent in this package (D1) — the\n // pinned row is whatever the host passes and nothing else.\n const activeAgentId = activeAgentIdOverride ?? null;\n const pinnedAgent = activeAgentId ? catalog.getAgent(activeAgentId) : undefined;\n\n // Category/tag options follow the ACTIVE TAB's population: user agents on\n // mine/shared/all, builtins on system. Same controls either way.\n const onSystemTab = consumer.tab === \"system\";\n const allCategories = onSystemTab\n ? selectAllSystemAgentCategories(rows)\n : selectAllAgentCategories(rows);\n const allTags = onSystemTab\n ? selectAllSystemAgentTags(rows)\n : selectAllAgentTags(rows);\n\n const tabCounts: AgentListTabCounts = tabCountsForFilter;\n\n const isLoading = status === \"loading\";\n const agentsLoaded = status === \"succeeded\" || status === \"failed\";\n\n const ensureLoaded = useCallback(() => {\n if (!hasFetchedRef.current) {\n hasFetchedRef.current = true;\n void catalog.ensureLoaded().catch(() => {\n // Already reported through the errorSink and reflected in `status`;\n // this catch only stops an unhandled rejection.\n });\n }\n }, [catalog]);\n\n // ── The mandate default row ─────────────────────────────────────────────\n const selectDefaultRow = useCallback(\n (state: AgentCatalogState): DefaultRowState | undefined =>\n defaultMandateKey ? state.defaultRows[defaultMandateKey] : undefined,\n [defaultMandateKey],\n );\n const defaultRow = useAgentCatalogState(selectDefaultRow);\n useEffect(() => {\n if (!defaultMandateKey) return;\n catalog.ensureDefaultRow(defaultMandateKey);\n }, [catalog, defaultMandateKey]);\n\n useEffect(() => {\n if (defaultTabAppliedRef.current) return;\n\n // An explicit surface default wins over the heuristic below, but only\n // once — after that the tab belongs to the user.\n if (initialTab) {\n defaultTabAppliedRef.current = true;\n if (consumer.tab !== initialTab) consumer.setTab(initialTab);\n return;\n }\n\n if (consumer.tab !== \"mine\") {\n defaultTabAppliedRef.current = true;\n return;\n }\n\n const wantsPublic = shouldDefaultAgentListToPublicTab({\n userId,\n ownedCount,\n agentsLoaded,\n });\n\n if (!wantsPublic) {\n if (!userId || agentsLoaded) {\n defaultTabAppliedRef.current = true;\n }\n return;\n }\n\n consumer.setTab(\"system\");\n defaultTabAppliedRef.current = true;\n }, [\n userId,\n ownedCount,\n agentsLoaded,\n initialTab,\n consumer.tab,\n consumer.setTab,\n ]);\n\n // 🚨 THE RESTRICTION IS ENFORCED, NOT DECORATED. A hidden tab whose rows are\n // still the ones being listed is worse than an offered one: the person sees a\n // catalogue this call site forbids and no control that explains why. The tab\n // is therefore coerced into the allowed set whenever it falls outside it —\n // including long after mount, when a control elsewhere on the page narrows\n // what this picker may reach. Keyed by the joined list so an inline array\n // literal does not re-fire this every render.\n const allowedTabsKey = visibleTabs ? visibleTabs.join(\",\") : \"\";\n useEffect(() => {\n if (!allowedTabsKey) return;\n const next = coerceVisibleTab(\n consumer.tab,\n allowedTabsKey.split(\",\") as AgentTab[],\n initialTab,\n );\n if (next) consumer.setTab(next);\n }, [allowedTabsKey, initialTab, consumer.tab, consumer.setTab]);\n\n useEffect(() => {\n ensureLoaded();\n }, [ensureLoaded]);\n\n const handleSelectAgent = useCallback(\n (agent: AgentSummary) => {\n if (onSelect) {\n onSelect(agent.id);\n } else if (navigateTo) {\n navigate(navigateTo.replace(\"{id}\", agent.id));\n } else {\n // Never a silent no-op — see the file header's delta 2.\n catalog.errorSink({\n code: \"select_has_nowhere_to_go\",\n message:\n \"an agent was chosen but this picker was given neither onSelect \" +\n \"nor navigateTo, so the choice went nowhere.\",\n context: { consumerId, agentId: agent.id },\n });\n }\n },\n [onSelect, navigateTo, navigate, catalog, consumerId],\n );\n\n const activeFilterCount =\n (consumer.sortBy !== \"updated-desc\" ? 1 : 0) +\n (consumer.includedCats.length > 0 ? 1 : 0) +\n (consumer.includedTags.length > 0 ? 1 : 0) +\n (consumer.favFilter !== \"all\" ? 1 : 0) +\n // The archive filter counts like every other filter, so a list showing\n // archived rows offers the reset control that puts them away again.\n (consumer.archFilter !== consumer.archFilterDefault ? 1 : 0);\n\n const handleAgentHover = useCallback(\n (agent: AgentSummary, panelOpen: boolean) => {\n if (panelOpen) return;\n if (hoverLeaveTimerRef.current) {\n clearTimeout(hoverLeaveTimerRef.current);\n hoverLeaveTimerRef.current = null;\n }\n setHoveredAgent(agent);\n },\n [],\n );\n\n const handleAgentHoverEnd = useCallback(\n (agent: AgentSummary, onClear: () => void) => {\n if (hoveredAgent?.id === agent.id) {\n hoverLeaveTimerRef.current = setTimeout(() => {\n setHoveredAgent(null);\n onClear();\n }, HOVER_GRACE_MS);\n }\n },\n [hoveredAgent],\n );\n\n const handleDetailPanelMouseEnter = useCallback(() => {\n if (hoverLeaveTimerRef.current) {\n clearTimeout(hoverLeaveTimerRef.current);\n hoverLeaveTimerRef.current = null;\n }\n }, []);\n\n const handleDetailPanelMouseLeave = useCallback((onClear: () => void) => {\n hoverLeaveTimerRef.current = setTimeout(() => {\n setHoveredAgent(null);\n onClear();\n }, HOVER_GRACE_MS);\n }, []);\n\n useEffect(\n () => () => {\n if (hoverLeaveTimerRef.current) clearTimeout(hoverLeaveTimerRef.current);\n },\n [],\n );\n\n /**\n * The footer's words, computed once from the numbers the list actually\n * rendered — identical on web and native because neither shell formats it\n * itself. See `agentListFooterLabel`.\n */\n const footerLabel = agentListFooterLabel({\n count: agents.length,\n archFilter: consumer.archFilter,\n archivedHiddenCount,\n });\n\n return {\n agents,\n archivedHiddenCount,\n footerLabel,\n isLoading,\n activeAgentId,\n pinnedAgent: pinnedAgent ?? null,\n defaultRow: defaultRow ?? null,\n allCategories,\n allTags,\n consumer,\n tabCounts,\n activeFilterCount,\n hoveredAgent,\n setHoveredAgent,\n ensureLoaded,\n handleSelectAgent,\n handleAgentHover,\n handleAgentHoverEnd,\n handleDetailPanelMouseEnter,\n handleDetailPanelMouseLeave,\n };\n}\n\nconst selectStatus = (state: AgentCatalogState) => state.status;\n","/**\n * `@ai-matrx/agents/catalog` — the row shape and the per-consumer view state.\n *\n * `AgentSummary` is the 19-column row `agx_get_list_full()` returns, camelCased.\n * It is deliberately NOT the editable agent record: dirty tracking, undo,\n * messages, tools and `_fetchStatus` stay in whichever host owns the editor.\n * A list row is a list row.\n *\n * The view-state types are a VERBATIM port of matrx-frontend\n * `features/agents/redux/agent-consumers/slice.ts` — only the coupling seam\n * inverts (Redux reducers become store actions in `./store`).\n */\n\n/**\n * A branded agent id. Every id that reaches `onSelect` is one of these:\n * either a `agent.definition` UUID, or the `mandate:<key>` reference a\n * default row carries (byte-identical to the ref shape matrx-extend\n * `src/lib/mandates.ts` and matrx-local `desktop/src/lib/mandates.ts`\n * already hand back to their hosts).\n *\n * 🚨 The brand is a STRING LITERAL, never `unique symbol`. This package emits\n * `./catalog` and `./catalog/react` as two separate bundles, so each `.d.ts`\n * carries its own copy of these declarations. A `unique symbol` brand is\n * NOMINAL: two copies of it are unrelated types, so `createAgentCatalog()`\n * from `./catalog` was not assignable to `<AgentCatalogProvider catalog=…>`\n * from `./catalog/react` — the exact two-import wiring the README, the\n * CHANGELOG and every consumer use. A literal brand is structural, so the two\n * copies unify, while a bare `string` still cannot be passed where an\n * `AgentId` is required (which is the whole point of branding). Any future\n * brand in this package follows the same rule.\n */\nexport type AgentId = string & { readonly __agentId: \"ai-matrx.agent-id\" };\n\n/** Brand a raw string as an `AgentId`. */\nexport function asAgentId(value: string): AgentId {\n return value as AgentId;\n}\n\n/** The `mandate:<key>` ref shape every client already speaks. */\nexport function mandateAgentId(mandateKey: string): AgentId {\n return `mandate:${mandateKey}` as AgentId;\n}\n\n/** True when an id is a mandate default row rather than a stored agent. */\nexport function isMandateAgentId(id: string): boolean {\n return id.startsWith(\"mandate:\");\n}\n\n/** `agent_type` verbatim. Only `builtin` changes how a row is grouped. */\nexport type AgentCatalogAgentType = \"user\" | \"builtin\";\n\n/**\n * `access_level` verbatim from `agx_get_list_full`. Widened over the raw\n * string because it is a DB-owned vocabulary: an unknown level renders as\n * itself rather than being coerced into a wrong one.\n */\nexport type AgentAccessLevel =\n | \"owner\"\n | \"admin\"\n | \"editor\"\n | \"viewer\"\n | \"system\"\n | (string & {});\n\n/**\n * Present on a catalog row ONLY when that agent is an **Orchestra** — a\n * conductor that delegates to member agents at run time. Choosing one for a\n * step, a chat or a workflow node runs the whole ensemble, so a person has to\n * be able to SEE that before choosing, not discover it from the run.\n *\n * The DB decides. `agx_get_list_full` / `agx_get_list` / `agx_search` build\n * this from `platform.associations` (the conductor self-edge plus its member\n * edges) in one `agx_orchestra_badges()` join — never a second fetch, and\n * never a per-row read. `null` for every ordinary agent.\n *\n * History: the badge lived only in the Python `GET /agents` route, so every\n * client lost it when the pickers moved to the RPC. It is a ROW FIELD now, in\n * the one read every client shares.\n */\nexport interface OrchestraBadge {\n /** How the ensemble runs: `supervisor` | `sequential` | `parallel` | `dag`, or a future mode verbatim. */\n mode: string;\n /** The composition's one-line description, when its author wrote one. */\n tagline: string | null;\n /**\n * The per-composition delegation-depth budget AS DECLARED, or `null` when\n * the composition declares none. Deliberately NOT defaulted here: the\n * platform's fallback ceiling is enforced by the server that runs the\n * ensemble, and a badge that invented a number would be reporting a promise\n * nobody made.\n */\n depthBudget: number | null;\n /** Member edges. From the ROW count, so an unlabelled ensemble still counts. */\n memberCount: number;\n /** Only REAL role titles — an ensemble with unlabelled edges yields `[]`. */\n memberTitles: string[];\n}\n\n/**\n * One `agx_get_list_full()` row, camelCased. Nineteen columns, no more:\n * anything richer needs a different read and is a different type.\n */\nexport interface AgentSummary {\n id: AgentId;\n name: string | null;\n description: string | null;\n category: string | null;\n tags: string[];\n agentType: AgentCatalogAgentType;\n modelId: string | null;\n isActive: boolean;\n isArchived: boolean;\n isFavorite: boolean;\n createdBy: string | null;\n organizationId: string | null;\n taskId: string | null;\n sourceAgentId: string | null;\n createdAt: string | null;\n updatedAt: string | null;\n // Access metadata\n isOwner: boolean | null;\n accessLevel: AgentAccessLevel | null;\n sharedByEmail: string | null;\n /**\n * The Orchestra badge, or `null` for an ordinary agent. Strict: every row\n * carries the key, so a surface reads `agent.orchestra` and never has to ask\n * whether the column existed.\n */\n orchestra: OrchestraBadge | null;\n /**\n * Set only on a mandate default row — the key it resolved through, so a\n * host can tell \"the default\" from a stored agent without parsing the id.\n */\n mandateKey?: string;\n}\n\n// ── Per-consumer view state (verbatim port of the agent-consumers slice) ─────\n\nexport type AgentSortOption =\n | \"updated-desc\"\n | \"created-desc\"\n | \"name-asc\"\n | \"name-desc\"\n | \"category-asc\";\n\n/**\n * The sort choices a picker offers, in order. PURE DATA, so it lives in the\n * pure entry: a server-reachable manifest reads it at module scope, and\n * importing it from the client-stamped `./catalog/react` bundle dragged React\n * into a server graph for the sake of five string pairs. `./catalog/react`\n * re-exports it unchanged, so no consumer has to move.\n *\n * (Written \"client-stamped\", never with the literal directive: this comment is\n * emitted into `dist/catalog/index.d.ts`, and the tarball canary rightly\n * refuses that directive anywhere in a PURE entry.)\n */\nexport const SORT_OPTIONS: { value: AgentSortOption; label: string }[] = [\n { value: \"updated-desc\", label: \"Recent\" },\n { value: \"created-desc\", label: \"Created\" },\n { value: \"name-asc\", label: \"A → Z\" },\n { value: \"name-desc\", label: \"Z → A\" },\n { value: \"category-asc\", label: \"Category\" },\n];\n\n/** Which ownership tab is active in the agent list. */\nexport type AgentTab = \"mine\" | \"shared\" | \"all\" | \"system\";\n\n/** Favorite filter. */\nexport type AgentFavFilter = \"all\" | \"yes\" | \"no\";\n\n/**\n * The archive filter — THE ARCHIVED-ITEMS LAW's ONE control, in this\n * package's existing vocabulary.\n *\n * > \"everything should have an archive filter, and the default should always\n * > hide archived, but seeing archived items should be one or two clicks\n * > away.\" — Arman, 2026-09-09 (`common-docs/policies/archived-items.md`)\n *\n * Three states and no more, identical for every entity on the platform:\n *\n * | value | the platform's words | what the list shows |\n * |------------|----------------------|--------------------------|\n * | `active` | hide archived | only un-archived rows |\n * | `both` | show all | every row |\n * | `archived` | archived only | only archived rows |\n *\n * `active` is the platform default, and it is a KNOB — see\n * `AgentCatalogConfig.defaults.archiveFilter`.\n */\nexport type AgentArchFilter = \"active\" | \"archived\" | \"both\";\n\n/** Every legal archive-filter value, in the order the control cycles them. */\nexport const ARCHIVE_FILTER_ORDER: readonly AgentArchFilter[] = [\n \"active\",\n \"both\",\n \"archived\",\n];\n\nexport interface AgentArchFilterOption {\n value: AgentArchFilter;\n /** The platform's own words for the state — what a menu row would read. */\n label: string;\n /** What the filter-bar chip reads while this state is the active one. */\n chip: string;\n}\n\n/**\n * 🚨 ONE CONTROL, THREE STATES, SAME WORDS EVERYWHERE. A surface that invents\n * its own archive vocabulary breaks clause 3 of the law (\"the same primitive\n * everywhere … not a per-feature invention\").\n */\nexport const ARCHIVE_FILTER_OPTIONS: readonly AgentArchFilterOption[] = [\n { value: \"active\", label: \"Hide archived\", chip: \"Archive\" },\n { value: \"both\", label: \"Show all\", chip: \"All + archived\" },\n { value: \"archived\", label: \"Archived only\", chip: \"Archived only\" },\n];\n\n/**\n * The next state of the cycling control: hide archived → show all → archived\n * only → hide archived. Pure, so the web chip and the native chip cannot\n * drift apart, and so \"the control reveals archived rows in ONE action\" is a\n * testable claim rather than a UI opinion.\n */\nexport function nextArchFilter(current: AgentArchFilter): AgentArchFilter {\n const index = ARCHIVE_FILTER_ORDER.indexOf(current);\n if (index < 0) return ARCHIVE_FILTER_ORDER[0] as AgentArchFilter;\n return ARCHIVE_FILTER_ORDER[\n (index + 1) % ARCHIVE_FILTER_ORDER.length\n ] as AgentArchFilter;\n}\n\n/** True when `value` is one of the three legal states. */\nexport function isAgentArchFilter(value: unknown): value is AgentArchFilter {\n return value === \"active\" || value === \"archived\" || value === \"both\";\n}\n\n/**\n * Access level filter.\n * 'any' = no restriction (default).\n * 'owned' = only agents the user owns (isOwner = true).\n * 'shared' = only agents shared with the user (isOwner = false).\n * 'editable' = owner + admin + editor.\n */\nexport type AgentAccessFilter = \"any\" | \"owned\" | \"shared\" | \"editable\";\n\n/** Sentinel meaning \"include uncategorized / untagged\" items. */\nexport const AGENT_NONE_SENTINEL = \"__none__\";\n\nexport interface AgentConsumerState {\n tab: AgentTab;\n sortBy: AgentSortOption;\n searchTerm: string;\n\n /** INCLUSION model: empty = show all; non-empty = only matching. */\n includedCats: string[];\n\n /** INCLUSION model: empty = show all; non-empty = only matching. */\n includedTags: string[];\n\n favFilter: AgentFavFilter;\n archFilter: AgentArchFilter;\n accessFilter: AgentAccessFilter;\n favoritesFirst: boolean;\n\n /** Current page for owned-agent list items (after the card section). */\n listPage: number;\n\n /** Current page for shared-agent list items. */\n sharedPage: number;\n\n /**\n * Ids returned by the last server-side search (`agx_search`), in server rank\n * order. Additive: an agent in this list survives the search filter even\n * when the local scorer gives it 0.\n *\n * That is load-bearing for tier 2. A deep search matches an agent's prompt\n * content, which the client never loads — so the local scorer cannot see it.\n * Without this list the server would return prompt matches and the UI would\n * immediately filter them back out.\n *\n * Server-only matches sort BELOW every locally-scored match, in server rank\n * order, so obvious matches always come first.\n */\n serverMatchedIds: string[];\n\n /** True while a server search is in flight — drives the search spinner. */\n isServerSearching: boolean;\n\n /** Tier 2: also search agent prompt content. Opt-in, per consumer. */\n deepSearch: boolean;\n}\n\nexport const DEFAULT_AGENT_CONSUMER_STATE: AgentConsumerState = {\n tab: \"mine\",\n sortBy: \"updated-desc\",\n searchTerm: \"\",\n includedCats: [],\n includedTags: [],\n favFilter: \"all\",\n archFilter: \"active\",\n accessFilter: \"any\",\n favoritesFirst: true,\n listPage: 1,\n sharedPage: 1,\n serverMatchedIds: [],\n isServerSearching: false,\n deepSearch: false,\n};\n\n/** The subset of consumer state a caller may patch (paging is derived). */\nexport type AgentConsumerPatch = Partial<\n Omit<AgentConsumerState, \"listPage\" | \"sharedPage\">\n>;\n\n// ── Loud configuration failure ───────────────────────────────────────────────\n\n/**\n * Thrown by `createAgentCatalog` when a REQUIRED port is missing or an\n * optional feature was asked for without the port it needs. Never a warning,\n * never a degraded catalog: a picker that cannot read is not a picker.\n */\nexport class AgentCatalogConfigError extends Error {\n override readonly name = \"AgentCatalogConfigError\";\n /** Machine code, for a host that routes config failures. */\n readonly code: string;\n /** What the host must do, in a sentence a person can act on. */\n readonly remedy: string;\n\n constructor(args: { code: string; message: string; remedy: string }) {\n super(`${args.message} — ${args.remedy}`);\n this.code = args.code;\n this.remedy = args.remedy;\n }\n}\n","/**\n * catalog/labels.ts — @ai-matrx/agents/catalog\n *\n * VERBATIM port of matrx-frontend `features/agents/constants/agent-list-labels.ts`.\n * The only seam inverted: the two label constants moved into the `labels` port\n * (`DEFAULT_AGENT_CATALOG_LABELS.publicTab` / `.publicBadge`) so a host can\n * override them; the FUNCTIONS below keep their exact behaviour.\n */\n\nimport type { AgentCatalogLabels } from \"./ports\";\nimport { ARCHIVE_FILTER_OPTIONS, nextArchFilter } from \"./types\";\nimport type { AgentArchFilter, AgentTab } from \"./types\";\n\nexport function agentListEmptyLabel(\n tab: AgentTab,\n labels: AgentCatalogLabels,\n): string {\n switch (tab) {\n case \"system\":\n // 🚨 The tab IS the system tab, and the surfaces that mount this picker\n // call that rung \"System\" (V1 round 3). Saying \"public\" here made the\n // empty state name a different thing from the rung the person had just\n // chosen. The tab's own LABEL is a wider vocabulary question and is left\n // alone — this only stops the empty state contradicting its own case.\n return labels.emptySystem;\n case \"shared\":\n return labels.emptyShared;\n default:\n return labels.emptyDefault;\n }\n}\n\n/** Whether a list picker should default to the public (`system`) tab instead of Mine. */\nexport function shouldDefaultAgentListToPublicTab(args: {\n userId: string | null;\n ownedCount: number;\n agentsLoaded: boolean;\n}): boolean {\n if (!args.userId) return true;\n if (!args.agentsLoaded) return false;\n return args.ownedCount === 0;\n}\n\n// ── THE ARCHIVED-ITEMS LAW — the control's words, and the honest footer ─────\n//\n// `common-docs/policies/archived-items.md`, Arman 2026-09-09:\n//\n// \"everything should have an archive filter, and the default should always\n// hide archived, but seeing archived items should be one or two clicks\n// away.\"\n//\n// Clause 2 of that law is why these live here rather than inside a component:\n// \"Counts, badges, footers and pagination count what the list renders — a\n// screen never lies.\" The footer string is computed ONCE, from the same\n// numbers the list rendered, for both platforms.\n\n/** What the filter-bar chip reads in each state. */\nexport function agentArchiveFilterChipLabel(archFilter: AgentArchFilter): string {\n return (\n ARCHIVE_FILTER_OPTIONS.find((o) => o.value === archFilter)?.chip ?? \"Archive\"\n );\n}\n\n/** The platform's words for the state — menus, aria-labels, help text. */\nexport function agentArchiveFilterStateLabel(\n archFilter: AgentArchFilter,\n): string {\n return (\n ARCHIVE_FILTER_OPTIONS.find((o) => o.value === archFilter)?.label ??\n \"Hide archived\"\n );\n}\n\n/**\n * The accessible name of the ONE control, always naming the state it is IN\n * and the state one click moves it to. A control whose label does not say\n * what it currently does is the \"dead or dishonest\" shape the platform bans.\n */\nexport function agentArchiveFilterControlLabel(\n archFilter: AgentArchFilter,\n): string {\n return `Archive filter: ${agentArchiveFilterStateLabel(\n archFilter,\n ).toLowerCase()}. Click for ${agentArchiveFilterStateLabel(\n nextArchFilter(archFilter),\n ).toLowerCase()}`;\n}\n\n/**\n * THE FOOTER. It counts exactly what the list rendered and, whenever archived\n * rows are involved, says so — hidden ones included.\n *\n * hide archived, nothing archived behind it → \"412 agents\"\n * hide archived, 4 archived behind it → \"412 agents · 4 archived hidden\"\n * show all → \"416 agents · archived shown\"\n * archived only → \"4 archived shown\"\n */\nexport function agentListFooterLabel(args: {\n /** Rows actually rendered. */\n count: number;\n archFilter: AgentArchFilter;\n /**\n * Rows this view WOULD render if the filter were flipped to \"archived only\"\n * — exactly what the default state is keeping off the screen. Only ever\n * read in the `active` state.\n */\n archivedHiddenCount: number;\n}): string {\n const { count, archFilter, archivedHiddenCount } = args;\n if (archFilter === \"archived\") return `${count} archived shown`;\n const base = `${count} agent${count !== 1 ? \"s\" : \"\"}`;\n if (archFilter === \"both\") return `${base} · archived shown`;\n return archivedHiddenCount > 0\n ? `${base} · ${archivedHiddenCount} archived hidden`\n : base;\n}\n","// catalog/score.ts — @ai-matrx/agents/catalog\n//\n// THE canonical agent relevance scorer. One implementation, every surface,\n// every APP. Ported VERBATIM (behaviour byte-for-byte) from matrx-frontend\n// `features/agents/search/score.ts`; only the file header changed.\n//\n// This existed twice with drifted weights — the gallery copy in\n// `features/agents/redux/agent-consumers/selectors.ts` and a chat-side copy in\n// the (deleted 2026-08) legacy agentCache selectors. The chat copy scored an id\n// match at 50 with no exact-id bonus, so searching a chat-side picker by UUID\n// was effectively dead. Everything now delegates here.\n//\n// Pure: no Redux, no store types, no imports. Anything that can describe an\n// agent structurally can be scored.\n//\n// Adding a field? Add it here and it lights up on every surface at once.\n// Never fork this function.\n//\n// ── SQL PARITY (load-bearing) ───────────────────────────────────────────────\n// `public.agx_search_score` in migrations/agx_search_score.sql is the SQL\n// mirror of this function. Server-side paging FORCES a second implementation —\n// relevance has to be computed before LIMIT, which the browser cannot do — but\n// the two must stay in lockstep.\n//\n// CHANGE ONE, CHANGE THE OTHER IN THE SAME COMMIT, and keep the weights below\n// identical to the SQL constants. Guarded by score.parity.test.ts against the\n// shared fixture in __fixtures__/search-score-parity.json.\n//\n// This is not hypothetical: /agents/all shipped with a flat SQL `ILIKE OR` and\n// no ranking at all, so a description match tied with a name match and\n// searching \"image\" buried every image agent under unrelated ones.\n\n/**\n * The structural shape a record needs to be searchable. Every field except\n * `id` is optional so both the full gallery record and the slim chat record\n * satisfy it without adapters.\n */\nexport interface AgentSearchable {\n id: string;\n name?: string | null;\n description?: string | null;\n category?: string | null;\n tags?: string[] | null;\n modelId?: string | null;\n agentType?: string | null;\n outputFormat?: string | null;\n sharedByEmail?: string | null;\n}\n\n/**\n * Relevance score for an agent against a query. Higher = more relevant.\n * Returns 0 when nothing matches (0 is the \"no match\" contract — see\n * `agentMatchesSearch`).\n *\n * Scores only fields carried by the list-level fetches. Message content and\n * variable definitions are deliberately excluded: they are not loaded by the\n * list RPCs, so matching them here would be a false promise. Server-side\n * search owns deep content matching.\n */\nexport function computeAgentSearchScore(\n agent: AgentSearchable,\n query: string,\n): number {\n const q = query.trim().toLowerCase();\n if (!q) return 0;\n\n let score = 0;\n\n const name = (agent.name ?? \"\").toLowerCase();\n const desc = (agent.description ?? \"\").toLowerCase();\n\n if (name === q) score += 10000;\n else if (name.startsWith(q)) score += 5000;\n // Word-boundary beats a mid-word substring: \"image\" ranks\n // \"Basic Image Generator\" above \"Reimagine Helper\".\n else if (matchesWholeWord(name, q)) score += 3000;\n else if (name.includes(q)) score += 2000;\n\n if (desc === q) score += 1000;\n else if (desc.includes(q)) score += 500;\n\n if (agent.category?.toLowerCase().includes(q)) score += 300;\n if (agent.tags?.some((t) => t.toLowerCase().includes(q))) score += 300;\n if (agent.modelId?.toLowerCase().includes(q)) score += 100;\n if (agent.agentType?.toLowerCase().includes(q)) score += 100;\n if (agent.outputFormat?.toLowerCase().includes(q)) score += 100;\n\n // Id search — an exact UUID always wins outright so you can paste an id from\n // a URL or a log line and land on that agent, on any surface.\n const id = agent.id.toLowerCase();\n if (id === q) score += 100000;\n else if (id.includes(q)) score += 5000;\n\n // Helps find agents shared by a specific person.\n if (agent.sharedByEmail?.toLowerCase().includes(q)) score += 200;\n\n // Multi-term fallback: \"image gen\" matches nothing as a phrase. Score per\n // TERM, and only when EVERY term lands somewhere — so multi-word searches\n // work without degrading into a loose OR that matches half the list.\n if (score === 0 && q.includes(\" \")) {\n const terms = q.split(/\\s+/).filter(Boolean);\n let hits = 0;\n let termScore = 0;\n for (const term of terms) {\n const inName = name.includes(term);\n const matched =\n inName ||\n desc.includes(term) ||\n (agent.category?.toLowerCase().includes(term) ?? false) ||\n (agent.tags?.some((t) => t.toLowerCase().includes(term)) ?? false);\n if (matched) {\n hits += 1;\n termScore += inName ? 400 : 100;\n }\n }\n // All-or-nothing: a partial term match is not a match.\n if (hits === terms.length) score += termScore;\n }\n\n return score;\n}\n\n/** True when `q` appears in `haystack` on word boundaries. */\nfunction matchesWholeWord(haystack: string, q: string): boolean {\n const escaped = q.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`\\\\b${escaped}\\\\b`).test(haystack);\n}\n\n/** True when the agent matches the query at all. */\nexport function agentMatchesSearch(\n agent: AgentSearchable,\n query: string,\n): boolean {\n return computeAgentSearchScore(agent, query) > 0;\n}\n","/**\n * catalog/selectors.ts — @ai-matrx/agents/catalog\n *\n * VERBATIM port of matrx-frontend\n * `features/agents/redux/agent-consumers/selectors.ts`.\n *\n * ALL filter, sort, search-scoring, category/tag extraction and pagination\n * logic lives here — not in components. Two coupling seams inverted, nothing\n * else:\n *\n * 1. `createSelector` (reselect) → `memoize1`/`memoize2`/`memoize3` below,\n * the same last-arguments reference-equality memoization reselect\n * defaults to. No Redux, no store types.\n * 2. `AgentDefinitionRecord` → `AgentSummary`, the list-row shape\n * `agx_get_list_full` actually returns.\n *\n * One structural consequence of (2), recorded rather than hidden: the\n * frontend's `selectLiveAgents` filters `isVersion` snapshots out of a store\n * that also holds them. This catalog only ever holds list rows — a version\n * snapshot cannot enter it — so that filter is a no-op here and is not\n * ported.\n *\n * 🚨 TWO DELIBERATE DEPARTURES FROM THE ORIGINAL, both defects the port\n * inherited and 0.9.1 fixes at the class (see CHANGELOG 0.9.1):\n *\n * F1 — every sort now ends on `id` ASC, the same final key `agx_get_list`\n * ends on, so the order of TIED rows is defined by the rows instead of\n * by whichever transport the host used to fetch them.\n * F5 — the tab-badge counts honour the archive filter, so the badge, the\n * footer and the rendered rows are the same number.\n *\n * Everything else below is byte-identical to the original.\n */\n\nimport {\n agentMatchesSearch,\n computeAgentSearchScore,\n} from \"./score\";\nimport {\n AGENT_NONE_SENTINEL,\n type AgentArchFilter,\n type AgentConsumerState,\n type AgentSortOption,\n type AgentSummary,\n} from \"./types\";\n\nexport { computeAgentSearchScore, agentMatchesSearch };\nexport { AGENT_NONE_SENTINEL };\n\n// ── Constants (verbatim) ─────────────────────────────────────────────────────\n\nexport const AGENT_CARDS_LIMIT_DESKTOP = 8;\nexport const AGENT_CARDS_LIMIT_MOBILE = 4;\nexport const AGENT_LIST_ITEMS_PER_PAGE = 20;\n\n// ── Memoization (the reselect seam, inverted) ───────────────────────────────\n\n/**\n * Last-arguments memoization on reference equality — reselect's default\n * `defaultMemoize` behaviour, in eleven lines and with no dependency. A\n * selector built here is memoized PER INSTANCE, exactly like a\n * `createSelector` result, so the factories below keep their contract:\n * build the selector once per (consumerId, …) and reuse it.\n */\nexport function memoize1<A, R>(fn: (a: A) => R): (a: A) => R {\n let lastA: A | undefined;\n let last: R;\n let has = false;\n return (a: A): R => {\n if (!has || lastA !== a) {\n last = fn(a);\n lastA = a;\n has = true;\n }\n return last;\n };\n}\n\nexport function memoize2<A, B, R>(fn: (a: A, b: B) => R): (a: A, b: B) => R {\n let lastA: A | undefined;\n let lastB: B | undefined;\n let last: R;\n let has = false;\n return (a: A, b: B): R => {\n if (!has || lastA !== a || lastB !== b) {\n last = fn(a, b);\n lastA = a;\n lastB = b;\n has = true;\n }\n return last;\n };\n}\n\nexport function memoize3<A, B, C, R>(\n fn: (a: A, b: B, c: C) => R,\n): (a: A, b: B, c: C) => R {\n let lastA: A | undefined;\n let lastB: B | undefined;\n let lastC: C | undefined;\n let last: R;\n let has = false;\n return (a: A, b: B, c: C): R => {\n if (!has || lastA !== a || lastB !== b || lastC !== c) {\n last = fn(a, b, c);\n lastA = a;\n lastB = b;\n lastC = c;\n has = true;\n }\n return last;\n };\n}\n\n// ── Pure sort comparator ────────────────────────────────────────────────────\n\n/**\n * 🚨 THE FINAL TIEBREAKER. `agx_get_list` orders\n * `is_favorite DESC, updated_at DESC, id` — `id` ASCENDING is the unique key\n * that makes the SERVER's order TOTAL. Every sort in this file ends on the\n * same key, so the rendered order is a function of the ROWS and never of the\n * order they happened to arrive in.\n *\n * Why a raw `<` / `>` and not `localeCompare`: Postgres orders `uuid` by its\n * 16 raw bytes. The canonical text form is lowercase hex with dashes at fixed\n * positions, so a codepoint comparison of those strings reproduces the\n * database's order exactly. A locale collator does not — it is free to fold\n * case or ignore punctuation, and would silently diverge from the server on\n * precisely the ties this key exists to settle.\n */\nexport function compareAgentIds(a: AgentSummary, b: AgentSummary): number {\n const idA = a.id ?? \"\";\n const idB = b.id ?? \"\";\n if (idA < idB) return -1;\n if (idA > idB) return 1;\n return 0;\n}\n\n/**\n * The chosen sort key, then `id`. TOTAL for every option.\n *\n * Before 0.9.1 each branch below returned 0 for tied rows, which left their\n * relative order to whatever `Array.prototype.sort` had been handed — i.e. to\n * the transport. A host that fetched the RPC in one shot kept the server's\n * favourites-first/`updated_at DESC` order for ties; a host that paged it with\n * `order=id.asc` kept id-ASC. Same rows, same filters, two different screens.\n * The key below is the server's own, so both now render the server's answer.\n */\nexport function applyAgentSortComparator(\n a: AgentSummary,\n b: AgentSummary,\n sortBy: AgentSortOption,\n): number {\n const primary = compareAgentSortKey(a, b, sortBy);\n // An unparseable timestamp yields NaN, which `sort` reads as \"equal\" while\n // defeating `!== 0`. Collapse it to a tie so the id key still decides — a\n // total order must not depend on the data being clean.\n if (!Number.isFinite(primary) || primary === 0) return compareAgentIds(a, b);\n return primary;\n}\n\n/** The chosen key ALONE — no tiebreaker. Not total; not for rendering. */\nfunction compareAgentSortKey(\n a: AgentSummary,\n b: AgentSummary,\n sortBy: AgentSortOption,\n): number {\n switch (sortBy) {\n case \"name-asc\":\n return (a.name ?? \"\").localeCompare(b.name ?? \"\");\n case \"name-desc\":\n return (b.name ?? \"\").localeCompare(a.name ?? \"\");\n case \"created-desc\":\n return +new Date(b.createdAt ?? 0) - +new Date(a.createdAt ?? 0);\n case \"category-asc\":\n return (a.category ?? \"\").localeCompare(b.category ?? \"\");\n case \"updated-desc\":\n default:\n return +new Date(b.updatedAt ?? 0) - +new Date(a.updatedAt ?? 0);\n }\n}\n\n// ── Category / tag metadata (derived from live agents) ──────────────────────\n\n/** All unique categories across live USER agents, sorted alphabetically. */\nexport const selectAllAgentCategories = memoize1(\n (agents: readonly AgentSummary[]): string[] => {\n const cats = new Set<string>();\n for (const a of agents) {\n if (a.agentType === \"user\" && a.category) cats.add(a.category);\n }\n return Array.from(cats).sort();\n },\n);\n\n/**\n * All unique categories across live SYSTEM (builtin) agents. The system tab\n * gets the same category filter every other tab has — its options just come\n * from a different population.\n */\nexport const selectAllSystemAgentCategories = memoize1(\n (agents: readonly AgentSummary[]): string[] => {\n const cats = new Set<string>();\n for (const a of agents) {\n if (a.agentType === \"builtin\" && a.category) cats.add(a.category);\n }\n return Array.from(cats).sort();\n },\n);\n\n/** All unique tags across live user agents, sorted alphabetically. */\nexport const selectAllAgentTags = memoize1(\n (agents: readonly AgentSummary[]): string[] => {\n const tags = new Set<string>();\n for (const a of agents) {\n if (a.agentType === \"user\") a.tags?.forEach((t) => tags.add(t));\n }\n return Array.from(tags).sort();\n },\n);\n\n/** All unique tags across live SYSTEM (builtin) agents. */\nexport const selectAllSystemAgentTags = memoize1(\n (agents: readonly AgentSummary[]): string[] => {\n const tags = new Set<string>();\n for (const a of agents) {\n if (a.agentType === \"builtin\") a.tags?.forEach((t) => tags.add(t));\n }\n return Array.from(tags).sort();\n },\n);\n\n// ── User-owned + shared agents (excludes builtins) ─────────────────────────\n\n/** Live user-type agents (excludes builtins). */\nexport const selectUserTypeAgents = memoize1(\n (agents: readonly AgentSummary[]): AgentSummary[] =>\n agents.filter((a) => a.agentType === \"user\"),\n);\n\n/** Builtin/system agents only. For chat pickers and full catalogues. */\nexport const selectBuiltinTypeAgents = memoize1(\n (agents: readonly AgentSummary[]): AgentSummary[] =>\n agents.filter((a) => a.agentType === \"builtin\"),\n);\n\n// ── Pure filter pipelines (verbatim) ───────────────────────────────────────\n\n/**\n * The ONE ordering rule, and it is TOTAL on every path.\n *\n * searching: score DESC → server rank ASC → sort key → id ASC\n * not searching: favourites first (when asked) → sort key → id ASC\n *\n * `id` ASC is the final key `agx_get_list` itself ends on, so two hosts that\n * fetched the same rows through different transports render the same screen.\n */\nexport function sortFilteredAgents(\n filtered: AgentSummary[],\n consumer: AgentConsumerState,\n): AgentSummary[] {\n const { searchTerm, sortBy, favFilter, favoritesFirst } = consumer;\n\n if (searchTerm) {\n const scores = new Map<string, number>();\n filtered.forEach((a) => {\n scores.set(a.id, computeAgentSearchScore(a, searchTerm));\n });\n\n // Server rank, used only to order matches the local scorer cannot see\n // (tier-2 prompt hits). Locally-scored matches all have score > 0, so\n // they sort above this group unconditionally — obvious matches first.\n const serverRank = new Map<string, number>();\n consumer.serverMatchedIds.forEach((id, i) => serverRank.set(id, i));\n\n return [...filtered].sort((a, b) => {\n const sa = scores.get(a.id) ?? 0;\n const sb = scores.get(b.id) ?? 0;\n if (sb !== sa) return sb - sa;\n if (sa === 0) {\n const ra = serverRank.get(a.id);\n const rb = serverRank.get(b.id);\n if (ra !== undefined && rb !== undefined && ra !== rb) return ra - rb;\n }\n return applyAgentSortComparator(a, b, sortBy);\n });\n }\n\n return [...filtered].sort((a, b) => {\n if (favoritesFirst && favFilter === \"all\") {\n const aFav = a.isFavorite ? 1 : 0;\n const bFav = b.isFavorite ? 1 : 0;\n if (bFav !== aFav) return bFav - aFav;\n }\n return applyAgentSortComparator(a, b, sortBy);\n });\n}\n\n/** User-type agents — mine / shared / all tabs with full consumer filters. */\nexport function filterUserTypeAgents(\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n): AgentSummary[] {\n const {\n searchTerm,\n includedCats,\n includedTags,\n favFilter,\n archFilter,\n accessFilter,\n tab,\n } = consumer;\n\n // Built once, not per row — this runs on every keystroke over the full list.\n const serverMatched = new Set(consumer.serverMatchedIds);\n\n const filtered = agents.filter((agent) => {\n if (tab === \"mine\" && agent.isOwner !== true) return false;\n if (\n tab === \"shared\" &&\n !(agent.isOwner === false && agent.accessLevel != null)\n )\n return false;\n\n // THE ARCHIVED-ITEMS LAW, through the ONE predicate every tab, badge and\n // footer in this package shares.\n if (!agentMatchesArchiveFilter(agent, archFilter)) return false;\n\n if (favFilter === \"yes\" && !agent.isFavorite) return false;\n if (favFilter === \"no\" && agent.isFavorite) return false;\n\n if (accessFilter === \"owned\" && agent.isOwner !== true) return false;\n if (accessFilter === \"shared\" && agent.isOwner !== false) return false;\n if (\n accessFilter === \"editable\" &&\n agent.accessLevel !== \"owner\" &&\n agent.accessLevel !== \"admin\" &&\n agent.accessLevel !== \"editor\"\n )\n return false;\n\n if (includedCats.length > 0) {\n const category = agent.category;\n if (!category) {\n if (!includedCats.includes(AGENT_NONE_SENTINEL)) return false;\n } else if (!includedCats.includes(category)) {\n return false;\n }\n }\n\n if (includedTags.length > 0) {\n const isUntagged = !agent.tags?.length;\n if (isUntagged) {\n if (!includedTags.includes(AGENT_NONE_SENTINEL)) return false;\n } else if (!agent.tags?.some((t) => includedTags.includes(t))) {\n return false;\n }\n }\n\n // A server hit counts as a match even when the local scorer scores 0 —\n // that is the only way tier-2 prompt matches can reach the screen, since\n // the client never loads prompt content to score against.\n if (\n searchTerm &&\n !agentMatchesSearch(agent, searchTerm) &&\n !serverMatched.has(agent.id)\n )\n return false;\n\n return true;\n });\n\n return sortFilteredAgents(filtered, consumer);\n}\n\n/**\n * Builtin/system agents (tab === \"system\").\n *\n * Gets the SAME filter surface every other tab has — search, favorites,\n * category, tags, sort, AND THE ARCHIVE FILTER. Only the ownership/access\n * filters are skipped, because a builtin has no owner to filter on. A picker\n * that offers less on one tab than another is the exact half-built shape this\n * list exists to prevent.\n *\n * 🚨 0.9.2 — THE BUILTIN ARCHIVE EXEMPTION IS GONE, AND IT IS NOW ILLEGAL.\n *\n * Until 0.9.1 this function applied no archive filter, on the theory that \"a\n * builtin belongs to the platform and is never the user's to archive\". The\n * database disagreed: `Foundry Planner`\n * (`001b22f6-fa4d-40c6-a1a4-8575d4d04379`) is an ARCHIVED builtin, and it\n * rendered at Public index 216 and was pickable — while Mine / Shared / All\n * hid their archived rows. One picker, two rules, and a person could choose a\n * retired agent from the one tab that did not obey.\n *\n * THE ARCHIVED-ITEMS LAW (`common-docs/policies/archived-items.md`, Arman\n * 2026-09-09) closed the question for every entity at once: \"everything should\n * have an archive filter, and the default should always hide archived… all\n * archived items should always be treated the same.\" Clause 4 makes it a\n * class, not an instance — so there is no per-tab, per-entity or per-surface\n * exemption left to grant, here or anywhere.\n */\nexport function filterBuiltinTypeAgents(\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n): AgentSummary[] {\n const { searchTerm, favFilter, archFilter, includedCats, includedTags } =\n consumer;\n const serverMatched = new Set(consumer.serverMatchedIds);\n\n const filtered = agents.filter((agent) => {\n // THE LAW, first and unconditional — identical to the user-tab rule above.\n if (!agentMatchesArchiveFilter(agent, archFilter)) return false;\n\n if (favFilter === \"yes\" && !agent.isFavorite) return false;\n if (favFilter === \"no\" && agent.isFavorite) return false;\n\n if (includedCats.length > 0) {\n const category = agent.category;\n if (!category) {\n if (!includedCats.includes(AGENT_NONE_SENTINEL)) return false;\n } else if (!includedCats.includes(category)) {\n return false;\n }\n }\n\n if (includedTags.length > 0) {\n const isUntagged = !agent.tags?.length;\n if (isUntagged) {\n if (!includedTags.includes(AGENT_NONE_SENTINEL)) return false;\n } else if (!agent.tags?.some((t) => includedTags.includes(t))) {\n return false;\n }\n }\n\n if (\n searchTerm &&\n !agentMatchesSearch(agent, searchTerm) &&\n !serverMatched.has(agent.id)\n )\n return false;\n\n return true;\n });\n\n return sortFilteredAgents(filtered, consumer);\n}\n\n// ── Filtered agents (user + system tabs) ───────────────────────────────────\n\n/** Factory: owned user-type agents with consumer filters applied (ignores tab). */\nexport const makeSelectFilteredOwnedAgents = () =>\n memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] =>\n filterUserTypeAgents(selectUserTypeAgents(agents), {\n ...consumer,\n tab: \"mine\",\n }),\n );\n\n/** Factory: shared user-type agents with consumer filters applied (ignores tab). */\nexport const makeSelectFilteredSharedAgents = () =>\n memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] =>\n filterUserTypeAgents(selectUserTypeAgents(agents), {\n ...consumer,\n tab: \"shared\",\n }),\n );\n\n/**\n * Factory: filters and sorts agents for a consumer. User tabs (mine / shared /\n * all) draw from user-type agents; the system tab draws from builtins.\n *\n * `includeSystemInAll` is the ADMIN reading of the \"All\" tab. For a normal\n * user, system agents are a separate catalogue and \"All\" means \"all of MY\n * agents\". For an admin surface, system agents ARE their agents — so \"All\"\n * must be a single blended list, with each row still labelled (the `system`\n * badge on `AgentRow`) so the two are never confused.\n */\nexport const makeSelectFilteredAgents = (includeSystemInAll = false) =>\n memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] => {\n const userAgents = selectUserTypeAgents(agents);\n const builtinAgents = selectBuiltinTypeAgents(agents);\n if (consumer.tab === \"system\") {\n return filterBuiltinTypeAgents(builtinAgents, consumer);\n }\n if (includeSystemInAll && consumer.tab === \"all\") {\n return [\n ...filterUserTypeAgents(userAgents, consumer),\n ...filterBuiltinTypeAgents(builtinAgents, consumer),\n ];\n }\n return filterUserTypeAgents(userAgents, consumer);\n },\n );\n\n/** Factory: filters and sorts builtin agents for the chat agent picker. */\nexport const makeSelectFilteredBuiltinAgents = () =>\n memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] =>\n filterBuiltinTypeAgents(selectBuiltinTypeAgents(agents), consumer),\n );\n\n// ── Card / list split (verbatim) ───────────────────────────────────────────\n\nexport interface AgentListPage {\n items: AgentSummary[];\n hasMore: boolean;\n totalAfterCards: number;\n}\n\nfunction pageAfterCards(\n filtered: AgentSummary[],\n limit: number,\n page: number,\n): AgentListPage {\n const afterCards = filtered.slice(limit);\n const pageEnd = page * AGENT_LIST_ITEMS_PER_PAGE;\n const items = afterCards.slice(0, pageEnd);\n return {\n items,\n hasMore: items.length < afterCards.length,\n totalAfterCards: afterCards.length,\n };\n}\n\n/** Factory: slices filtered owned agents into the \"cards\" hero section. */\nexport const makeSelectOwnedAgentCards = (isMobile: boolean) => {\n const selectFiltered = makeSelectFilteredOwnedAgents();\n const limit = isMobile ? AGENT_CARDS_LIMIT_MOBILE : AGENT_CARDS_LIMIT_DESKTOP;\n return memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] => selectFiltered(agents, consumer).slice(0, limit),\n );\n};\n\n/** Factory: paginated list items for owned agents (everything after cards). */\nexport const makeSelectOwnedAgentListItems = (isMobile: boolean) => {\n const selectFiltered = makeSelectFilteredOwnedAgents();\n const limit = isMobile ? AGENT_CARDS_LIMIT_MOBILE : AGENT_CARDS_LIMIT_DESKTOP;\n return memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentListPage =>\n pageAfterCards(selectFiltered(agents, consumer), limit, consumer.listPage),\n );\n};\n\n/** Factory: slices filtered shared agents into the \"cards\" hero section. */\nexport const makeSelectSharedAgentCards = (isMobile: boolean) => {\n const selectFiltered = makeSelectFilteredSharedAgents();\n const limit = isMobile ? AGENT_CARDS_LIMIT_MOBILE : AGENT_CARDS_LIMIT_DESKTOP;\n return memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] => selectFiltered(agents, consumer).slice(0, limit),\n );\n};\n\n/** Factory: paginated list items for shared agents (everything after cards). */\nexport const makeSelectSharedAgentListItems = (isMobile: boolean) => {\n const selectFiltered = makeSelectFilteredSharedAgents();\n const limit = isMobile ? AGENT_CARDS_LIMIT_MOBILE : AGENT_CARDS_LIMIT_DESKTOP;\n return memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentListPage =>\n pageAfterCards(\n selectFiltered(agents, consumer),\n limit,\n consumer.sharedPage,\n ),\n );\n};\n\n// ── Convenience count selectors ────────────────────────────────────────────\n\n/** Factory: total count of filtered agents for a consumer. */\nexport const makeSelectFilteredAgentsCount = () => {\n const selectFiltered = makeSelectFilteredAgents();\n return memoize2(\n (agents: readonly AgentSummary[], consumer: AgentConsumerState): number =>\n selectFiltered(agents, consumer).length,\n );\n};\n\n/** Factory: total count of filtered builtin agents for a consumer. */\nexport const makeSelectFilteredBuiltinAgentsCount = () => {\n const selectFiltered = makeSelectFilteredBuiltinAgents();\n return memoize2(\n (agents: readonly AgentSummary[], consumer: AgentConsumerState): number =>\n selectFiltered(agents, consumer).length,\n );\n};\n\n// ── Consumer state convenience selectors ──────────────────────────────────\n\n/** Returns whether a consumer has any non-default filters active. */\nexport function agentConsumerHasActiveFilters(\n consumer: AgentConsumerState,\n defaults: AgentConsumerState,\n): boolean {\n return (\n consumer.tab !== defaults.tab ||\n consumer.sortBy !== defaults.sortBy ||\n consumer.searchTerm !== \"\" ||\n consumer.includedCats.length > 0 ||\n consumer.includedTags.length > 0 ||\n consumer.favFilter !== defaults.favFilter ||\n consumer.archFilter !== defaults.archFilter ||\n consumer.accessFilter !== defaults.accessFilter ||\n consumer.favoritesFirst !== defaults.favoritesFirst\n );\n}\n\n// ── Aggregate counts (for tab badges) ─────────────────────────────────────\n\n/**\n * 🚨 A BADGE COUNTS WHAT THE TAB RENDERS. Nothing else.\n *\n * Before 0.9.1 these five counted every user-type row, archived included,\n * while `filterUserTypeAgents` (archive filter `active`, the default) hid the\n * archived ones. The badge said \"Mine 416\", the list showed 412 rows and the\n * footer said \"412 agents\" — one screen, three numbers, one of them a lie\n * about agents the user cannot see or reach from there.\n *\n * `is_archived` is now honoured by the same rule the list uses, so the badge,\n * the footer and the rows agree on every tab and under every archive filter.\n *\n * 🚨 0.9.2 — AND THERE IS NO LONGER AN EXCEPTION. The system tab used to be\n * one (\"a builtin is never the user's to archive\"), which was false in the\n * database and illegal under THE ARCHIVED-ITEMS LAW. Its badge now counts\n * under the same archive rule its rows render under, so `Foundry Planner`\n * leaves the Public badge and the Public list together, or returns to both\n * together — never one without the other.\n */\nexport function agentMatchesArchiveFilter(\n agent: AgentSummary,\n archFilter: AgentArchFilter,\n): boolean {\n if (archFilter === \"active\") return !agent.isArchived;\n if (archFilter === \"archived\") return Boolean(agent.isArchived);\n return true;\n}\n\n/** Builtin rows matching an archive filter — the Public tab's badge. */\nfunction countBuiltinRows(\n agents: readonly AgentSummary[],\n archFilter: AgentArchFilter,\n): number {\n let n = 0;\n for (const a of agents) {\n if (a.agentType !== \"builtin\") continue;\n if (!agentMatchesArchiveFilter(a, archFilter)) continue;\n n += 1;\n }\n return n;\n}\n\nfunction countUserRows(\n agents: readonly AgentSummary[],\n archFilter: AgentArchFilter,\n predicate: (a: AgentSummary) => boolean,\n): number {\n let n = 0;\n for (const a of agents) {\n if (a.agentType !== \"user\") continue;\n if (!agentMatchesArchiveFilter(a, archFilter)) continue;\n if (predicate(a)) n += 1;\n }\n return n;\n}\n\nconst isOwned = (a: AgentSummary) => a.isOwner === true;\nconst isShared = (a: AgentSummary) =>\n a.isOwner === false && a.accessLevel != null;\nconst isAny = () => true;\nconst isFavorite = (a: AgentSummary) => Boolean(a.isFavorite);\n\n/**\n * The four tab badges for a consumer's CURRENT archive filter — the numbers\n * `useAgentListCore` puts on the tab strip. Flip the archive filter to\n * \"archived\" and the badges follow the list into the archive.\n */\nexport const selectAgentTabCounts = memoize2(\n (\n agents: readonly AgentSummary[],\n archFilter: AgentArchFilter,\n ): { mine: number; shared: number; all: number; system: number } => ({\n mine: countUserRows(agents, archFilter, isOwned),\n shared: countUserRows(agents, archFilter, isShared),\n all: countUserRows(agents, archFilter, isAny),\n system: countBuiltinRows(agents, archFilter),\n }),\n);\n\n/** Live user-type agents the default (`active`) list renders. */\nexport const selectTotalUserAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number =>\n countUserRows(agents, \"active\", isAny),\n);\n\nexport const selectTotalOwnedAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number =>\n countUserRows(agents, \"active\", isOwned),\n);\n\nexport const selectTotalSharedAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number =>\n countUserRows(agents, \"active\", isShared),\n);\n\n/**\n * Live builtin agents the DEFAULT (`active`) list renders — archived builtins\n * excluded, exactly like every other \"total\" beside it. Before 0.9.2 this\n * counted archived builtins too, which is how an archived `Foundry Planner`\n * reached the Public badge.\n */\nexport const selectTotalBuiltinAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number => countBuiltinRows(agents, \"active\"),\n);\n\nexport const selectTotalFavoriteAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number =>\n countUserRows(agents, \"active\", isFavorite),\n);\n","\"use client\";\n\n/**\n * catalog/react/AgentListDropdown.tsx — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/AgentListDropdown.tsx`.\n *\n * Seams inverted: every `@/components/ui/*` primitive → `@ai-matrx/design-system`\n * (Popover, Drawer, Tooltip); `useIsMobile` → design-system's; `useDialogContainer`\n * → the `popoverContainer` UI port; lucide → the package's inlined SVGs.\n *\n * The prop surface is unchanged, plus `defaultMandateKey`.\n */\n\nimport {\n cn,\n Drawer,\n DrawerContent,\n DrawerTitle,\n DrawerTrigger,\n Popover,\n PopoverContent,\n PopoverTrigger,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n useIsMobile,\n} from \"@ai-matrx/design-system\";\nimport { useMemo, useRef, useState } from \"react\";\n\nimport { AgentListPanelBody, PANEL_WIDTH } from \"./AgentListPanel\";\nimport { useAgentCatalog, useAgentCatalogUiPorts } from \"./context\";\nimport { ChevronDownIcon } from \"./icons\";\nimport { LIST_MAX_HEIGHT, PANEL_HEIGHT, panelHeightBelow, sideThatFits } from \"./types\";\nimport { useAgentListCore } from \"./useAgentListCore\";\nimport type { AgentSummary, AgentTab } from \"../types\";\n\nconst CONSUMER_ID = \"agent-list-dropdown\";\n\nexport interface AgentListDropdownProps {\n onSelect?: (agentId: string) => void;\n navigateTo?: string;\n className?: string;\n label?: string;\n /** Custom trigger element — replaces the default text button. */\n triggerSlot?: React.ReactNode;\n /** Remove the border from the default trigger button. */\n noBorder?: boolean;\n /** Use a compact (h-5) trigger instead of the default h-7. */\n compact?: boolean;\n /** Route-scoped agent id — highlights + pins the current agent in the list. */\n activeAgentId?: string | null;\n /**\n * Which side the desktop popover opens toward. Defaults to Radix's \"bottom\".\n * Pass \"right\" when the trigger lives in a narrow vertical rail so the panel\n * opens beside the rail instead of covering it. Ignored on mobile (Drawer).\n */\n contentSide?: \"top\" | \"right\" | \"bottom\" | \"left\";\n /**\n * Isolate this dropdown's filter/tab state under its own consumer id.\n * Defaults to the shared `agent-list-dropdown` consumer so ordinary chat\n * triggers keep one remembered set of filters across the app.\n */\n consumerId?: string;\n /** Tab to open on. Admin surfaces managing system agents pass `\"system\"`. */\n initialTab?: AgentTab;\n /** ADMIN variant: blend system agents into the \"All\" tab. */\n includeSystemInAll?: boolean;\n /** Restrict which ownership tabs are available for domain-constrained pickers. */\n visibleTabs?: readonly AgentTab[];\n /** Label override for the builtin-agent tab. Admin surfaces use \"System\". */\n systemTabLabel?: string;\n /** Resolve the route used by each named agent door. */\n resolveAgentHref?: (agent: AgentSummary) => string;\n /** Show the active agent above the filtered list. Default true. */\n showPinnedAgent?: boolean;\n /** Hide records that are invalid for this call site. */\n excludeAgentIds?: readonly string[];\n /**\n * Offer the platform DEFAULT agent for this mandate key at the top of the\n * list, named LIVE from the mandate's real Holder. `onSelect` receives\n * `mandate:<key>` for that row — the ref shape every client already speaks.\n */\n defaultMandateKey?: string;\n}\n\nexport function AgentListDropdown({\n onSelect,\n navigateTo,\n className,\n label,\n triggerSlot,\n noBorder = false,\n compact = false,\n activeAgentId: activeAgentIdProp,\n contentSide,\n consumerId = CONSUMER_ID,\n initialTab,\n includeSystemInAll = false,\n visibleTabs,\n systemTabLabel,\n resolveAgentHref: resolveAgentHrefProp,\n showPinnedAgent = true,\n excludeAgentIds,\n defaultMandateKey,\n}: AgentListDropdownProps) {\n const isMobile = useIsMobile();\n const { labels } = useAgentCatalog();\n const { popoverContainer } = useAgentCatalogUiPorts();\n const [open, setOpen] = useState(false);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [fitHeight, setFitHeight] = useState<string | null>(null);\n // The side actually used: the host's `contentSide`, re-chosen at open time\n // when the panel would not fit there (`sideThatFits`).\n const [openSide, setOpenSide] = useState(contentSide);\n\n const core = useAgentListCore({\n consumerId,\n ...(onSelect ? { onSelect } : {}),\n ...(navigateTo ? { navigateTo } : {}),\n ...(activeAgentIdProp !== undefined\n ? { activeAgentIdOverride: activeAgentIdProp }\n : {}),\n ...(initialTab ? { initialTab } : {}),\n includeSystemInAll,\n // The restriction has to reach the CORE, not just the tab strip — see\n // `AgentListCoreOptions.visibleTabs`.\n ...(visibleTabs ? { visibleTabs } : {}),\n ...(excludeAgentIds ? { excludeAgentIds } : {}),\n ...(defaultMandateKey ? { defaultMandateKey } : {}),\n });\n\n // 🚨 THE TRIGGER IS THE STATEMENT OF WHO IS ASSIGNED, so it never answers\n // \"Agents\" when an agent IS assigned — that reads as nothing selected. The\n // roster loads on mount (see `useAgentListCore`), so the interim is brief;\n // an id that never resolves says so rather than hiding behind the catalogue\n // label. Hosts that pass an explicit `label` are unaffected.\n // A mandate default's synthetic `mandate:<key>` id is intentionally absent\n // from the catalog's stored-agent map. Its resolved row is the one source\n // that can name that id, but only when it is the active id for this picker;\n // borrowing a different default row would misstate the assignment.\n const { pinnedAgent, defaultRow, activeAgentId, isLoading, activeFilterCount } =\n core;\n const activeDefaultRow =\n defaultRow?.row?.id === activeAgentId ? defaultRow.row : null;\n const displayLabel =\n label ??\n pinnedAgent?.name ??\n activeDefaultRow?.name ??\n (activeAgentId\n ? isLoading\n ? labels.triggerResolving\n : labels.triggerUnnameable\n : labels.triggerFallback);\n\n const showAssignedTooltip =\n Boolean(activeAgentId) &&\n displayLabel.trim().length > 0 &&\n displayLabel !== \"Select an agent\" &&\n displayLabel !== labels.triggerFallback;\n\n // Open-time behavior (load, pinned preview, focus) lives in the body, which\n // mounts with the popover/drawer; closing unmounts it and resets its panels.\n const handleOpen = (nextOpen: boolean) => {\n setOpen(nextOpen);\n if (nextOpen) {\n setFitHeight(contentSide || isMobile ? null : panelHeightBelow(triggerRef.current));\n setOpenSide(contentSide && !isMobile ? sideThatFits(triggerRef.current, contentSide) : contentSide);\n }\n };\n\n const resolveAgentHref = useMemo(() => {\n if (resolveAgentHrefProp) return resolveAgentHrefProp;\n if (!navigateTo) return undefined;\n return (agent: AgentSummary) => navigateTo.replace(\"{id}\", agent.id);\n }, [navigateTo, resolveAgentHrefProp]);\n\n\n const triggerButton = triggerSlot ?? (\n <button\n type=\"button\"\n className={cn(\n \"inline-flex items-center rounded-md text-xs font-medium transition-colors\",\n \"bg-background hover:bg-muted/50 text-foreground/80 hover:text-foreground\",\n compact ? \"h-5 gap-1 px-1.5\" : \"h-7 gap-1.5 px-2.5\",\n !noBorder && \"border border-border\",\n className,\n )}\n >\n <span className=\"min-w-0 max-w-[200px] flex-1 truncate text-left\">\n {displayLabel}\n </span>\n {activeFilterCount > 0 && (\n <span className=\"flex items-center justify-center w-4 h-4 rounded-md bg-primary text-primary-foreground text-[10px]\">\n {activeFilterCount}\n </span>\n )}\n <ChevronDownIcon className=\"w-3 h-3 text-muted-foreground/60\" />\n </button>\n );\n\n const wrapTrigger = (\n Trigger: typeof DrawerTrigger | typeof PopoverTrigger,\n ) => {\n if (!showAssignedTooltip) {\n return <Trigger asChild ref={triggerRef}>{triggerButton}</Trigger>;\n }\n return (\n <Tooltip {...(open ? { open: false } : {})}>\n <Trigger asChild ref={triggerRef}>\n <TooltipTrigger asChild>{triggerButton}</TooltipTrigger>\n </Trigger>\n <TooltipContent side=\"bottom\" className=\"max-w-xs\">\n {displayLabel}\n </TooltipContent>\n </Tooltip>\n );\n };\n\n const body = (\n <AgentListPanelBody\n core={core}\n includeSystemInAll={includeSystemInAll}\n showPinnedAgent={showPinnedAgent}\n onAfterSelect={() => setOpen(false)}\n {...(visibleTabs ? { visibleTabs } : {})}\n {...(systemTabLabel ? { systemTabLabel } : {})}\n {...(resolveAgentHref ? { resolveAgentHref } : {})}\n />\n );\n\n // ── Mobile ──\n if (isMobile) {\n return (\n <Drawer open={open} onOpenChange={handleOpen}>\n {wrapTrigger(DrawerTrigger)}\n <DrawerContent className=\"h-[85dvh]\">\n <DrawerTitle className=\"sr-only\">Select Agent</DrawerTitle>\n <div className=\"flex flex-col overflow-hidden flex-1 min-h-0\">\n {body}\n </div>\n </DrawerContent>\n </Drawer>\n );\n }\n\n // ── Desktop ──\n // The popover reserves its full two-column width for the entire time it is\n // open, so the hover-preview / filter panels toggle WITHOUT resizing or\n // repositioning the popover. A resizing popover in a narrow rail triggers\n // Radix collision-shifting that yanks the list out from under the cursor —\n // the panel \"appears, then runs away.\" A fixed footprint keeps the preview\n // a stationary, reachable target.\n return (\n <Popover open={open} onOpenChange={handleOpen} modal={false}>\n {wrapTrigger(PopoverTrigger)}\n {/* POPOVER-CENSUS 2026-09-22: sizing left \"fixed\" — fixed-shape two-column panel (340px list + 340px detail, fixed height) — not a single text label; sizing=content's 28rem ceiling would clip the panel layout, not fix clipped text. */}\n <PopoverContent\n {...(openSide ? { side: openSide } : fitHeight ? { side: \"bottom\" as const } : {})}\n align=\"start\"\n sideOffset={4}\n collisionPadding={12}\n sticky=\"always\"\n {...(popoverContainer ? { container: popoverContainer } : {})}\n className=\"p-0 overflow-hidden\"\n style={{ width: PANEL_WIDTH, height: fitHeight ?? PANEL_HEIGHT, maxHeight: fitHeight ?? LIST_MAX_HEIGHT }}\n >\n {body}\n </PopoverContent>\n </Popover>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentListPanel.tsx — THE agent picker body.\n *\n * The two-column picker a person sees when they open `AgentListDropdown`: the\n * list on the left (search, ownership tabs, filters, rows) and, on the right,\n * the hover peek (`AgentDetailCard`) or the sort / category / tag panel. On a\n * phone it is one column with the same detail and filter sub-views.\n *\n * It exists as its own component so every shell renders the SAME picker:\n * - `AgentListDropdown` puts it in a popover / drawer under a trigger;\n * - a host window (matrx-frontend's `agentPickerWindow`) puts it in a\n * floating window at the same 680 × 528 footprint.\n * Neither shell re-implements a row, a panel, or a hover rule.\n *\n * Two entry points:\n * - `AgentListPanel` — self-contained: owns its list core. Use it anywhere a\n * picker is a surface of its own (a window, a page region).\n * - `AgentListPanelBody` — takes a core the host already holds. The dropdown\n * uses it because its TRIGGER reads the same core (label, filter count)\n * and the core must outlive the popover closing.\n *\n * The body mounts when it is shown and unmounts when it is hidden, so \"open\"\n * behavior (load the roster, preview the pinned agent, focus search) runs on\n * mount and every transient panel resets by unmounting.\n */\n\nimport { cn, useIsMobile } from \"@ai-matrx/design-system\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { AgentCategoriesPanel } from \"./AgentCategoriesPanel\";\nimport { AgentDetailCard } from \"./AgentDetailCard\";\nimport { AgentListContent } from \"./AgentListContent\";\nimport { AgentMobileSubView } from \"./AgentMobileSubView\";\nimport { AgentSortPanel } from \"./AgentSortPanel\";\nimport { AgentTagsPanel } from \"./AgentTagsPanel\";\nimport { useAgentCatalog } from \"./context\";\nimport { ChevronRightIcon, MousePointerClickIcon } from \"./icons\";\nimport { PANEL_HEIGHT, type RightPanel } from \"./types\";\nimport { useAgentListCore } from \"./useAgentListCore\";\nimport type { AgentSummary, AgentTab } from \"../types\";\n\n/** The desktop picker's fixed footprint: a 340px list + a 340px peek. */\nexport const PANEL_WIDTH = \"680px\";\n\ntype AgentListCore = ReturnType<typeof useAgentListCore>;\n\ninterface AgentListPanelDisplayProps {\n /** Restrict which ownership tabs are available for domain-constrained pickers. */\n visibleTabs?: readonly AgentTab[];\n /** Label override for the builtin-agent tab. Admin surfaces use \"System\". */\n systemTabLabel?: string;\n /** ADMIN variant: blend system agents into the \"All\" tab (also labels it \"System\"). */\n includeSystemInAll?: boolean;\n /** Resolve the route used by each named agent door. */\n resolveAgentHref?: (agent: AgentSummary) => string;\n /** Show the active agent above the filtered list. Default true. */\n showPinnedAgent?: boolean;\n /** Focus the search field when the picker appears. Default true. */\n autoFocusSearch?: boolean;\n /** Runs after an agent is chosen (the core has already called `onSelect`). */\n onAfterSelect?: (agent: AgentSummary) => void;\n className?: string;\n}\n\nexport interface AgentListPanelBodyProps extends AgentListPanelDisplayProps {\n /** The list core the host holds (`useAgentListCore`). */\n core: AgentListCore;\n}\n\n/** The picker body over a core the host already holds. Fills its parent. */\nexport function AgentListPanelBody({\n core,\n visibleTabs,\n systemTabLabel,\n includeSystemInAll = false,\n resolveAgentHref,\n showPinnedAgent = true,\n autoFocusSearch = true,\n onAfterSelect,\n className,\n}: AgentListPanelBodyProps) {\n const isMobile = useIsMobile();\n const { labels } = useAgentCatalog();\n const [rightPanel, setRightPanel] = useState<RightPanel>(null);\n const [catSearch, setCatSearch] = useState(\"\");\n const [tagSearch, setTagSearch] = useState(\"\");\n const [mobileDetailAgent, setMobileDetailAgent] =\n useState<AgentSummary | null>(null);\n const [mobileSubView, setMobileSubView] = useState<\n \"sort\" | \"categories\" | \"tags\" | null\n >(null);\n const inputRef = useRef<HTMLInputElement>(null);\n\n const {\n agents,\n archivedHiddenCount,\n isLoading,\n activeAgentId,\n pinnedAgent,\n defaultRow,\n allCategories,\n allTags,\n consumer,\n tabCounts,\n activeFilterCount,\n hoveredAgent,\n setHoveredAgent,\n ensureLoaded,\n handleSelectAgent: coreSelectAgent,\n handleAgentHover: coreAgentHover,\n handleAgentHoverEnd: coreAgentHoverEnd,\n handleDetailPanelMouseEnter,\n handleDetailPanelMouseLeave: coreDetailMouseLeave,\n } = core;\n\n // \"Open\" = mount: load the roster and focus search.\n useEffect(() => {\n ensureLoaded();\n if (!autoFocusSearch) return undefined;\n const timer = setTimeout(() => inputRef.current?.focus(), 50);\n return () => clearTimeout(timer);\n }, [ensureLoaded, autoFocusSearch]);\n\n // Preview the pinned agent ONCE, as soon as it resolves — at mount when the\n // roster is already loaded (a dropdown re-opening), or when it lands (a\n // window opened cold). Never after the person has moved the peek themselves.\n const pinnedPreviewedRef = useRef(false);\n useEffect(() => {\n if (pinnedPreviewedRef.current || isMobile || !pinnedAgent) return;\n pinnedPreviewedRef.current = true;\n if (rightPanel !== null) return;\n setHoveredAgent(pinnedAgent);\n setRightPanel(\"detail\");\n }, [pinnedAgent, isMobile, rightPanel, setHoveredAgent]);\n\n const handleSelectAgent = (agent: AgentSummary) => {\n coreSelectAgent(agent);\n setMobileDetailAgent(null);\n setMobileSubView(null);\n onAfterSelect?.(agent);\n };\n\n const handleFilterChipClick = (panel: \"sort\" | \"categories\" | \"tags\") => {\n if (isMobile) {\n setMobileSubView(panel);\n } else {\n setRightPanel(rightPanel === panel ? null : panel);\n }\n };\n\n const handleAgentHover = useCallback(\n (agent: AgentSummary) => {\n if (isMobile) return;\n const filterPanelOpen =\n rightPanel === \"sort\" ||\n rightPanel === \"categories\" ||\n rightPanel === \"tags\";\n coreAgentHover(agent, filterPanelOpen);\n if (!filterPanelOpen) setRightPanel(\"detail\");\n },\n [isMobile, rightPanel, coreAgentHover],\n );\n\n const handleAgentHoverEnd = useCallback(\n (agent: AgentSummary) => {\n if (isMobile) return;\n if (rightPanel !== \"detail\") return;\n coreAgentHoverEnd(agent, () => setRightPanel(null));\n },\n [isMobile, rightPanel, coreAgentHoverEnd],\n );\n\n const handleDetailPanelMouseLeave = useCallback(() => {\n coreDetailMouseLeave(() => setRightPanel(null));\n }, [coreDetailMouseLeave]);\n\n const effectiveSystemTabLabel =\n systemTabLabel ?? (includeSystemInAll ? \"System\" : undefined);\n\n const listPanel = (\n <AgentListContent\n agents={agents}\n isLoading={isLoading}\n consumer={consumer}\n activeAgentId={activeAgentId}\n allCategories={allCategories}\n allTags={allTags}\n inputRef={inputRef}\n onSelectAgent={handleSelectAgent}\n {...(resolveAgentHref ? { resolveAgentHref } : {})}\n onReset={consumer.resetFilters}\n activeFilterCount={activeFilterCount}\n isMobile={isMobile}\n hoveredAgent={hoveredAgent}\n onAgentHover={handleAgentHover}\n onAgentHoverEnd={handleAgentHoverEnd}\n onDetailPress={setMobileDetailAgent}\n onFilterChipClick={handleFilterChipClick}\n rightPanel={rightPanel}\n tabCounts={tabCounts}\n archivedHiddenCount={archivedHiddenCount}\n {...(visibleTabs ? { visibleTabs } : {})}\n {...(effectiveSystemTabLabel\n ? { systemTabLabel: effectiveSystemTabLabel }\n : {})}\n pinnedAgent={showPinnedAgent ? pinnedAgent : null}\n defaultRow={defaultRow}\n listOpen\n />\n );\n\n // ── Mobile: one column, detail and filter panels as sub-views ──\n if (isMobile) {\n return (\n <div className={cn(\"flex min-h-0 flex-1 flex-col overflow-hidden\", className)}>\n {mobileDetailAgent ? (\n <div className=\"flex flex-col overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => setMobileDetailAgent(null)}\n className=\"flex items-center gap-1.5 px-3 py-2.5 text-sm font-medium text-primary hover:bg-muted/30 transition-colors border-b border-border shrink-0\"\n >\n <ChevronRightIcon className=\"w-4 h-4 rotate-180\" />\n Back\n </button>\n <div className=\"overflow-y-auto\">\n <AgentDetailCard\n agent={mobileDetailAgent}\n onSelect={() => handleSelectAgent(mobileDetailAgent)}\n />\n </div>\n </div>\n ) : mobileSubView ? (\n <AgentMobileSubView\n view={mobileSubView}\n consumer={consumer}\n allCategories={allCategories}\n allTags={allTags}\n catSearch={catSearch}\n setCatSearch={setCatSearch}\n tagSearch={tagSearch}\n setTagSearch={setTagSearch}\n onBack={() => {\n setMobileSubView(null);\n setCatSearch(\"\");\n setTagSearch(\"\");\n }}\n />\n ) : (\n listPanel\n )}\n </div>\n );\n }\n\n // ── Desktop: a fixed two-column footprint ──\n // Both columns are reserved for the whole time the picker is shown, so the\n // hover preview and filter panels toggle WITHOUT resizing anything. A\n // resizing panel in a narrow rail triggers collision-shifting that yanks the\n // list out from under the cursor; a fixed footprint keeps the preview a\n // stationary, reachable target.\n return (\n <div className={cn(\"flex h-full\", className)}>\n <div className=\"flex flex-col min-w-[340px] flex-1 border-r border-border\">\n {listPanel}\n </div>\n <div\n className=\"h-full w-[340px] shrink-0 overflow-hidden flex flex-col\"\n onMouseEnter={\n rightPanel === \"detail\" ? handleDetailPanelMouseEnter : undefined\n }\n onMouseLeave={\n rightPanel === \"detail\" ? handleDetailPanelMouseLeave : undefined\n }\n >\n {rightPanel === \"detail\" && hoveredAgent && (\n <div key={hoveredAgent.id} className=\"h-full matrx-agent-fade-in\">\n <AgentDetailCard\n agent={hoveredAgent}\n onSelect={() => handleSelectAgent(hoveredAgent)}\n />\n </div>\n )}\n {rightPanel === \"sort\" && (\n <AgentSortPanel\n consumer={consumer}\n onClose={() => setRightPanel(null)}\n />\n )}\n {rightPanel === \"categories\" && (\n <AgentCategoriesPanel\n consumer={consumer}\n allCategories={allCategories}\n search={catSearch}\n setSearch={setCatSearch}\n onClose={() => {\n setRightPanel(null);\n setCatSearch(\"\");\n }}\n />\n )}\n {rightPanel === \"tags\" && (\n <AgentTagsPanel\n consumer={consumer}\n allTags={allTags}\n search={tagSearch}\n setSearch={setTagSearch}\n onClose={() => {\n setRightPanel(null);\n setTagSearch(\"\");\n }}\n />\n )}\n {rightPanel === null && (\n <div className=\"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center\">\n <MousePointerClickIcon className=\"h-6 w-6 text-muted-foreground/40\" />\n <p className=\"text-xs text-muted-foreground/70 leading-relaxed\">\n {labels.hoverHint}\n </p>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nexport interface AgentListPanelProps extends AgentListPanelDisplayProps {\n /**\n * Fill the parent instead of the fixed `PANEL_WIDTH` × `PANEL_HEIGHT`\n * footprint — for a resizable host (a window). The list column takes the\n * extra width; the peek column stays 340px.\n */\n fill?: boolean;\n /** Unique consumer id for this picker's filter/tab state. */\n consumerId: string;\n /** The chosen agent's id (`mandate:<key>` for a mandate default row). */\n onSelect?: (agentId: string) => void;\n /** Navigate on select instead of (or besides) `onSelect`; `{id}` is replaced. */\n navigateTo?: string;\n /** Highlights + pins this agent in the list. */\n activeAgentId?: string | null;\n /** Tab to open on. Admin surfaces managing system agents pass `\"system\"`. */\n initialTab?: AgentTab;\n /** Hide records that are invalid for this call site. */\n excludeAgentIds?: readonly string[];\n /** Offer the mandate's live-resolved default agent at the top of the list. */\n defaultMandateKey?: string;\n}\n\n/**\n * The self-contained picker: owns its list core. Desktop renders at the fixed\n * `PANEL_WIDTH` × `PANEL_HEIGHT` footprint (or fills its parent with `fill`);\n * mobile fills its parent.\n */\nexport function AgentListPanel({\n consumerId,\n onSelect,\n navigateTo,\n activeAgentId,\n initialTab,\n includeSystemInAll = false,\n visibleTabs,\n excludeAgentIds,\n defaultMandateKey,\n resolveAgentHref: resolveAgentHrefProp,\n className,\n fill = false,\n ...display\n}: AgentListPanelProps) {\n const isMobile = useIsMobile();\n const core = useAgentListCore({\n consumerId,\n ...(onSelect ? { onSelect } : {}),\n ...(navigateTo ? { navigateTo } : {}),\n ...(activeAgentId !== undefined\n ? { activeAgentIdOverride: activeAgentId }\n : {}),\n ...(initialTab ? { initialTab } : {}),\n includeSystemInAll,\n ...(visibleTabs ? { visibleTabs } : {}),\n ...(excludeAgentIds ? { excludeAgentIds } : {}),\n ...(defaultMandateKey ? { defaultMandateKey } : {}),\n });\n const resolveAgentHref = useMemo(() => {\n if (resolveAgentHrefProp) return resolveAgentHrefProp;\n if (!navigateTo) return undefined;\n return (agent: AgentSummary) => navigateTo.replace(\"{id}\", agent.id);\n }, [navigateTo, resolveAgentHrefProp]);\n\n return (\n <div\n className={cn(\"flex min-h-0 flex-col overflow-hidden\", (isMobile || fill) && \"h-full w-full\", className)}\n style={isMobile || fill ? undefined : { width: PANEL_WIDTH, height: PANEL_HEIGHT }}\n >\n <AgentListPanelBody\n core={core}\n includeSystemInAll={includeSystemInAll}\n {...(visibleTabs ? { visibleTabs } : {})}\n {...(resolveAgentHref ? { resolveAgentHref } : {})}\n {...display}\n />\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/primitives.tsx — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/core/primitives.tsx`.\n * Seams: lucide icons → the package's own inlined SVGs (C19); `cn` from\n * `@ai-matrx/design-system`.\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\nimport type { ComponentType, Ref } from \"react\";\n\nimport { CheckIcon, SearchIcon, XIcon } from \"./icons\";\n\nexport const SearchInput = ({\n ref,\n value,\n onChange,\n placeholder,\n}: {\n ref?: Ref<HTMLInputElement>;\n value: string;\n onChange: (v: string) => void;\n placeholder: string;\n}) => (\n <div className=\"flex items-center gap-1.5 h-7 px-2 rounded-md bg-muted/40 border border-border/50\">\n <SearchIcon className=\"w-3 h-3 text-muted-foreground shrink-0\" />\n <input\n ref={ref}\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder}\n className=\"flex-1 bg-transparent text-xs text-foreground placeholder:text-muted-foreground/50 outline-none min-w-0\"\n style={{ fontSize: \"16px\" }}\n />\n {value && (\n <button\n type=\"button\"\n onClick={() => onChange(\"\")}\n className=\"text-muted-foreground hover:text-foreground\"\n aria-label=\"Clear search\"\n >\n <XIcon className=\"w-3 h-3\" />\n </button>\n )}\n </div>\n);\n\nexport function FilterChip({\n icon: Icon,\n label,\n active,\n focused,\n onClick,\n ariaLabel,\n testId,\n}: {\n icon: ComponentType<{ className?: string }>;\n label: string;\n active: boolean;\n focused?: boolean;\n onClick: () => void;\n /** Accessible name when the visible label alone would not say the state. */\n ariaLabel?: string;\n /** Stable hook so a shell test can measure the control, not a class name. */\n testId?: string;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n {...(testId ? { \"data-testid\": testId } : {})}\n className={cn(\n \"inline-flex items-center gap-1 h-6 px-1.5 rounded text-[11px] font-medium shrink-0 transition-colors\",\n focused\n ? \"bg-primary/15 text-primary border border-primary/30 ring-1 ring-primary/20\"\n : active\n ? \"bg-primary/10 text-primary border border-primary/20\"\n : \"text-muted-foreground hover:text-foreground hover:bg-muted/50 border border-transparent\",\n )}\n >\n <Icon className=\"w-3 h-3\" />\n <span>{label}</span>\n </button>\n );\n}\n\nexport function OptionRow({\n label,\n selected,\n onClick,\n}: {\n label: string;\n selected: boolean;\n onClick: () => void;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={cn(\n \"flex items-center w-full px-3 py-2 text-xs transition-colors\",\n \"hover:bg-muted/50 active:bg-muted/70\",\n selected && \"text-primary font-medium\",\n )}\n >\n <span className=\"flex-1 text-left\">{label}</span>\n {selected && <CheckIcon className=\"w-3.5 h-3.5 text-primary shrink-0\" />}\n </button>\n );\n}\n\nexport function CheckRow({\n label,\n checked,\n onClick,\n}: {\n label: string;\n checked: boolean;\n onClick: () => void;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className=\"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-muted/50 active:bg-muted/70 transition-colors\"\n >\n <div\n className={cn(\n \"w-3.5 h-3.5 rounded-sm border flex items-center justify-center shrink-0 transition-colors\",\n checked ? \"bg-primary border-primary\" : \"border-muted-foreground/30\",\n )}\n >\n {checked && <CheckIcon className=\"w-2.5 h-2.5 text-primary-foreground\" />}\n </div>\n <span className=\"flex-1 text-left truncate\">{label}</span>\n </button>\n );\n}\n\nexport function SidePanelHeader({\n title,\n onClose,\n}: {\n title: string;\n onClose: () => void;\n}) {\n return (\n <div className=\"flex items-center justify-between px-3 py-2 border-b border-border shrink-0\">\n <span className=\"text-xs font-semibold text-foreground\">{title}</span>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"w-5 h-5 rounded flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors\"\n aria-label=\"Close\"\n >\n <XIcon className=\"w-3.5 h-3.5\" />\n </button>\n </div>\n );\n}\n","/**\n * catalog/shared/icon-paths.ts — THE picker's glyph geometry, once.\n *\n * 🚨 C19: the package ships its OWN inlined SVGs (adapted from the Lucide\n * shapes the matrx-frontend originals used — same 24×24 grid, same 2px\n * stroke) rather than depending on an icon library. 0.9.0 lifted the path\n * data out of `catalog/react/icons.tsx` into this pure module so the React\n * Native entry draws the IDENTICAL shapes through `react-native-svg`: an\n * agent row wears the same star, and an Orchestra the same conductor mark, in\n * every Matrx client. A glyph added here appears on both platforms or on\n * neither; there is no way to give one platform a shape the other lacks.\n *\n * Pure data — no React, no DOM, no react-native.\n */\n\nexport interface AgentCatalogIconCircle {\n cx: number;\n cy: number;\n r: number;\n /** Painted with `currentColor` regardless of the icon's `filled` state. */\n filled?: boolean;\n}\n\nexport interface AgentCatalogIconShape {\n paths: readonly string[];\n circles?: readonly AgentCatalogIconCircle[];\n /** True when the icon supports a `filled` variant (only the star does). */\n fillable?: boolean;\n}\n\nconst SHAPES = {\n star: {\n paths: [\n \"M11.5 3.2a.6.6 0 0 1 1 0l2.3 4.7 5.2.8a.6.6 0 0 1 .3 1l-3.8 3.7.9 5.2a.6.6 0 0 1-.9.6L12 16.8l-4.6 2.4a.6.6 0 0 1-.9-.6l.9-5.2-3.8-3.7a.6.6 0 0 1 .3-1l5.2-.8Z\",\n ],\n fillable: true,\n },\n chevronRight: { paths: [\"m9 18 6-6-6-6\"] },\n chevronDown: { paths: [\"m6 9 6 6 6-6\"] },\n search: {\n paths: [\"m21 21-4.3-4.3\"],\n circles: [{ cx: 11, cy: 11, r: 8 }],\n },\n x: { paths: [\"M18 6 6 18\", \"m6 6 12 12\"] },\n check: { paths: [\"M20 6 9 17l-5-5\"] },\n arrowUpDown: {\n paths: [\"m21 16-4 4-4-4\", \"M17 20V4\", \"m3 8 4-4 4 4\", \"M7 4v16\"],\n },\n folder: {\n paths: [\n \"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z\",\n ],\n },\n tag: {\n paths: [\n \"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z\",\n ],\n circles: [{ cx: 7.5, cy: 7.5, r: 0.5, filled: true }],\n },\n rotateCcw: {\n paths: [\n \"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\",\n \"M3 3v5h5\",\n ],\n },\n loader: { paths: [\"M21 12a9 9 0 1 1-6.219-8.56\"] },\n alertTriangle: {\n paths: [\n \"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\",\n \"M12 9v4\",\n \"M12 17h.01\",\n ],\n },\n /**\n * The Orchestra marker (Lucide `music-4`): the glyph the Workflow Studio's\n * picker used for a conductor, kept identical so the same agent wears the\n * same mark in every client.\n */\n music4: {\n paths: [\"M9 18V5l12-2v13\", \"m9 9 12-2\"],\n circles: [\n { cx: 6, cy: 18, r: 3 },\n { cx: 18, cy: 16, r: 3 },\n ],\n },\n clock: {\n paths: [\"M12 6v6l4 2\"],\n circles: [{ cx: 12, cy: 12, r: 10 }],\n },\n globe: {\n paths: [\"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20\", \"M2 12h20\"],\n circles: [{ cx: 12, cy: 12, r: 10 }],\n },\n users: {\n paths: [\n \"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\",\n \"M22 21v-2a4 4 0 0 0-3-3.87\",\n \"M16 3.13a4 4 0 0 1 0 7.75\",\n ],\n circles: [{ cx: 9, cy: 7, r: 4 }],\n },\n externalLink: {\n paths: [\n \"M15 3h6v6\",\n \"M10 14 21 3\",\n \"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\",\n ],\n },\n messageCircle: { paths: [\"M7.9 20A9 9 0 1 0 4 16.1L2 22Z\"] },\n rocket: {\n paths: [\n \"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91 0\",\n \"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2\",\n \"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0\",\n \"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5\",\n ],\n },\n /**\n * THE ARCHIVE GLYPH (Lucide `archive`) — the ONE mark of the platform\n * archive filter, drawn identically in every Matrx client so the control a\n * person learns on one surface is recognisable on all of them.\n */\n archive: {\n paths: [\n \"M3 3h18a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z\",\n \"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8\",\n \"M10 12h4\",\n ],\n },\n circleCheck: {\n paths: [\"m9 12 2 2 4-4\"],\n circles: [{ cx: 12, cy: 12, r: 10 }],\n },\n} satisfies Record<string, AgentCatalogIconShape>;\n\nexport type AgentCatalogIconName = keyof typeof SHAPES;\n\n/** The glyph table, widened so every shape reads uniformly at a call site. */\nexport const ICON_PATHS: Record<AgentCatalogIconName, AgentCatalogIconShape> =\n SHAPES;\n\n/** Every glyph the picker can draw. Both entries must cover all of them. */\nexport const ICON_NAMES = Object.keys(ICON_PATHS) as AgentCatalogIconName[];\n","\"use client\";\n\n/**\n * catalog/react/icons.tsx — @ai-matrx/agents/catalog/react\n *\n * 🚨 C19 — NO ICON-LIBRARY DEPENDENCY, EVER. The picker's glyphs ship as\n * inlined SVGs (adapted from the Lucide shapes the matrx-frontend originals\n * used, same 24×24 grid, same 2px stroke), exactly as `@ai-matrx/tap-target`\n * does for its ~60 buttons. A dependency on `lucide-react` would cost every\n * consumer a version-skew risk for a fraction of a percent of bytes.\n *\n * 0.9.0: the PATH DATA moved to `../shared/icon-paths`, which the React Native\n * entry draws through `react-native-svg`. The components below are unchanged\n * in name, props and output — they now read their geometry from the shared\n * table instead of holding a private copy, so a glyph can never differ between\n * the web picker and the native one.\n *\n * Colour comes from `currentColor` only — no hardcoded fill anywhere.\n */\n\nimport type { SVGProps } from \"react\";\n\nimport { ICON_PATHS, type AgentCatalogIconName } from \"../shared/icon-paths\";\n\nexport type IconProps = SVGProps<SVGSVGElement> & { className?: string };\n\nfunction Svg({ children, ...props }: IconProps & { children: React.ReactNode }) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n {...props}\n >\n {children}\n </svg>\n );\n}\n\n/** Draw one shared shape. `filled` only affects the icons that declare it. */\nfunction Shape({ name, filled }: { name: AgentCatalogIconName; filled: boolean }) {\n const shape = ICON_PATHS[name];\n return (\n <>\n {shape.paths.map((d, index) => (\n <path\n key={`p${index}`}\n d={d}\n {...(filled && shape.fillable ? { fill: \"currentColor\" } : {})}\n />\n ))}\n {(shape.circles ?? []).map((circle, index) => (\n <circle\n key={`c${index}`}\n cx={circle.cx}\n cy={circle.cy}\n r={circle.r}\n {...(circle.filled ? { fill: \"currentColor\" } : {})}\n />\n ))}\n </>\n );\n}\n\nfunction makeIcon(name: AgentCatalogIconName) {\n return function Icon(props: IconProps) {\n return (\n <Svg {...props}>\n <Shape name={name} filled={false} />\n </Svg>\n );\n };\n}\n\n/** The favourite star. `filled` paints it with `currentColor`. */\nexport function StarIcon({\n filled = false,\n ...props\n}: IconProps & { filled?: boolean }) {\n return (\n <Svg {...props} fill={filled ? \"currentColor\" : \"none\"}>\n <Shape name=\"star\" filled={filled} />\n </Svg>\n );\n}\n\nexport const ChevronRightIcon = makeIcon(\"chevronRight\");\nexport const ChevronDownIcon = makeIcon(\"chevronDown\");\nexport const SearchIcon = makeIcon(\"search\");\nexport const XIcon = makeIcon(\"x\");\nexport const CheckIcon = makeIcon(\"check\");\nexport const ArrowUpDownIcon = makeIcon(\"arrowUpDown\");\nexport const FolderIcon = makeIcon(\"folder\");\nexport const TagIcon = makeIcon(\"tag\");\nexport const RotateCcwIcon = makeIcon(\"rotateCcw\");\nexport const ArchiveIcon = makeIcon(\"archive\");\nexport const LoaderIcon = makeIcon(\"loader\");\nexport const UsersIcon = makeIcon(\"users\");\nexport const ClockIcon = makeIcon(\"clock\");\nexport const GlobeIcon = makeIcon(\"globe\");\nexport const ExternalLinkIcon = makeIcon(\"externalLink\");\nexport const MessageCircleIcon = makeIcon(\"messageCircle\");\nexport const RocketIcon = makeIcon(\"rocket\");\nexport const CircleCheckIcon = makeIcon(\"circleCheck\");\n/** The drift banner's glyph. */\nexport const AlertTriangleIcon = makeIcon(\"alertTriangle\");\n/**\n * The Orchestra marker (Lucide `music-4`): the glyph the Workflow Studio's\n * picker used for a conductor, kept identical so the same agent wears the same\n * mark in every client.\n */\nexport const Music4Icon = makeIcon(\"music4\");\n\n/**\n * The empty-hover-panel hint glyph. Web-only: the native picker has no hover\n * panel, so this shape has no native twin and stays local to this file.\n */\nexport function MousePointerClickIcon(props: IconProps) {\n return (\n <Svg {...props}>\n <path d=\"M14 4.1 12 6\" />\n <path d=\"m5.1 8-2.9-.8\" />\n <path d=\"m6 12-1.9 2\" />\n <path d=\"M7.2 2.2 8 5.1\" />\n <path d=\"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z\" />\n </Svg>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentCategoriesPanel.tsx — port of `.../core/AgentCategoriesPanel.tsx`.\n *\n * 🚨 ONE DEFECT FIXED, NOT PRESERVED (C22 — a real defect found in the original\n * is fixed in the package AND recorded in the CHANGELOG). The original's\n * \"Clear (n)\" ran `consumer.includedCats.forEach(consumer.toggleCategory)`,\n * and `toggleCategory` computes its next array from the `includedCats`\n * captured in the CURRENT render — so three toggles fired in one tick all\n * start from the same snapshot and the last write wins: clicking Clear with\n * three categories active removed exactly ONE. matrx-frontend's own\n * `useAgentConsumer` documents this hazard and names `setIncludedCats` as the\n * fix; the call site never adopted it. It does here.\n */\n\nimport { CheckRow, SearchInput, SidePanelHeader } from \"./primitives\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\n\nexport interface AgentCategoriesPanelProps {\n consumer: UseAgentConsumerReturn;\n allCategories: string[];\n search: string;\n setSearch: (v: string) => void;\n onClose: () => void;\n}\n\nexport function AgentCategoriesPanel({\n consumer,\n allCategories,\n search,\n setSearch,\n onClose,\n}: AgentCategoriesPanelProps) {\n const filtered = allCategories.filter(\n (c) => !search || c.toLowerCase().includes(search.toLowerCase()),\n );\n return (\n <div className=\"flex flex-col h-full\">\n <SidePanelHeader title=\"Categories\" onClose={onClose} />\n <div className=\"px-2 pt-2 pb-1 shrink-0\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"Filter categories...\"\n />\n </div>\n {consumer.includedCats.length > 0 && (\n <button\n type=\"button\"\n onClick={() => consumer.setIncludedCats([])}\n className=\"mx-2 mb-1 h-6 rounded text-[11px] font-medium text-primary hover:bg-muted/50 transition-colors text-left shrink-0\"\n >\n Clear ({consumer.includedCats.length})\n </button>\n )}\n <div className=\"overflow-y-auto flex-1\">\n {filtered.length === 0 ? (\n <p className=\"text-xs text-muted-foreground text-center py-6\">\n No categories\n </p>\n ) : (\n filtered.map((cat) => (\n <CheckRow\n key={cat}\n label={cat}\n checked={consumer.includedCats.includes(cat)}\n onClick={() => consumer.toggleCategory(cat)}\n />\n ))\n )}\n </div>\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentDetailCard.tsx — VERBATIM port of matrx-frontend\n * `.../core/AgentDetailCard.tsx`. Seams:\n * - `HoverCard` + `Button` from `@/components/ui/*` → `@ai-matrx/design-system`.\n * - `AgentSneakPeekContent`/`AgentSneakPeekCopyMenu` → the `openPeek` port.\n * ABSENT → the peek affordance is HIDDEN. Never a dead button.\n * - `AiModelRef` → the `renderModelRef` port (default: the model id as text).\n * - `next/link` → the `LinkComponent` port.\n * - lucide icons → the package's inlined SVGs (C19).\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\n\nimport { FavoriteAgentButton } from \"./FavoriteAgentButton\";\nimport { useAgentCatalogUiPorts } from \"./context\";\nimport {\n ClockIcon,\n ExternalLinkIcon,\n FolderIcon,\n GlobeIcon,\n MessageCircleIcon,\n Music4Icon,\n RocketIcon,\n TagIcon,\n UsersIcon,\n} from \"./icons\";\nimport {\n orchestraDelegatesLine,\n orchestraDepthLine,\n orchestraLabel,\n} from \"../orchestra\";\nimport { isMandateAgentId, type AgentSummary } from \"../types\";\n\nexport interface AgentDetailCardProps {\n agent: AgentSummary;\n onSelect: () => void;\n}\n\nexport function AgentDetailCard({ agent, onSelect }: AgentDetailCardProps) {\n const { LinkComponent, renderModelRef, openPeek } = useAgentCatalogUiPorts();\n const updatedDate = agent.updatedAt ? new Date(agent.updatedAt) : null;\n const createdDate = agent.createdAt ? new Date(agent.createdAt) : null;\n // A mandate default row is a live reference, not a stored agent — it has no\n // agent door and no favorite. Its actions are the ones that make sense.\n const isDefaultRow = isMandateAgentId(agent.id);\n\n const formatDate = (d: Date | null) => {\n if (!d) return null;\n return d.toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n });\n };\n\n return (\n <div className=\"flex flex-col h-full\">\n <div className=\"px-4 pt-4 pb-3\">\n <div className=\"flex items-start gap-3\">\n <div className=\"w-9 h-9 rounded-lg bg-primary/10 flex items-center justify-center shrink-0\" />\n <div className=\"flex-1 min-w-0\">\n <h3 className=\"text-sm font-semibold text-foreground leading-tight truncate\">\n {agent.name || \"Untitled\"}\n </h3>\n {agent.isFavorite && (\n <div className=\"flex items-center gap-1 mt-0.5\">\n <span className=\"text-[11px] matrx-agent-star-on\">\n Pinned to favorites\n </span>\n </div>\n )}\n </div>\n {!isDefaultRow && <FavoriteAgentButton id={agent.id} variant=\"list\" />}\n </div>\n </div>\n\n <div className=\"h-px bg-border mx-3\" />\n\n <div className=\"flex-1 overflow-y-auto px-4 py-3 space-y-3\">\n {/* THE ORCHESTRA BLOCK COMES FIRST. Everything below describes an\n agent; this says the choice runs an ENSEMBLE, which changes what\n selecting it means. Ported from the Workflow Studio picker's\n selected-agent lines, which were the only place this ever showed. */}\n {agent.orchestra && (\n <div className=\"rounded-md border border-primary/20 bg-primary/5 px-2.5 py-2\">\n <div className=\"flex items-center gap-1.5\">\n <Music4Icon className=\"w-3.5 h-3.5 text-primary shrink-0\" />\n <span className=\"text-[11px] font-medium text-primary\">\n {orchestraLabel(agent.orchestra)}\n </span>\n </div>\n {agent.orchestra.tagline && (\n <p className=\"mt-1 text-xs text-foreground/80 leading-relaxed\">\n {agent.orchestra.tagline}\n </p>\n )}\n {orchestraDelegatesLine(agent.orchestra) && (\n <p\n className=\"mt-1 text-[11px] text-muted-foreground\"\n title={`Delegates to: ${agent.orchestra.memberTitles.join(\", \")}`}\n >\n {orchestraDelegatesLine(agent.orchestra)}\n </p>\n )}\n {orchestraDepthLine(agent.orchestra) && (\n <p className=\"mt-0.5 text-[11px] text-muted-foreground\">\n {orchestraDepthLine(agent.orchestra)}\n </p>\n )}\n </div>\n )}\n\n {agent.description && (\n <div>\n <p className=\"text-[11px] font-medium text-muted-foreground uppercase tracking-wider mb-1\">\n Description\n </p>\n <p className=\"text-xs text-foreground/80 leading-relaxed\">\n {agent.description}\n </p>\n </div>\n )}\n\n {agent.category && (\n <div className=\"flex items-center gap-2\">\n <FolderIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n <span className=\"text-xs text-foreground/80\">{agent.category}</span>\n </div>\n )}\n\n {agent.tags && agent.tags.length > 0 && (\n <div>\n <div className=\"flex items-center gap-1.5 mb-1.5\">\n <TagIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n <span className=\"text-[11px] font-medium text-muted-foreground\">\n Tags\n </span>\n </div>\n <div className=\"flex flex-wrap gap-1\">\n {agent.tags.map((tag) => (\n <span\n key={tag}\n className=\"inline-flex items-center h-5 px-1.5 rounded text-[10px] font-medium bg-muted text-muted-foreground\"\n >\n {tag}\n </span>\n ))}\n </div>\n </div>\n )}\n\n {agent.accessLevel && (\n <div className=\"flex items-center gap-2\">\n {agent.isOwner === false ? (\n <UsersIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n ) : (\n <GlobeIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n )}\n <div className=\"flex flex-col\">\n <span className=\"text-xs text-foreground/80 capitalize\">\n {agent.accessLevel === \"owner\"\n ? \"You own this\"\n : `Shared — ${agent.accessLevel}`}\n </span>\n {agent.sharedByEmail && (\n <span className=\"text-[10px] text-muted-foreground\">\n by {agent.sharedByEmail}\n </span>\n )}\n </div>\n </div>\n )}\n\n {agent.modelId && (\n <div className=\"flex items-center gap-2\">\n {renderModelRef({\n modelId: agent.modelId,\n className: \"max-w-full text-xs text-foreground/80\",\n })}\n </div>\n )}\n\n {(updatedDate || createdDate) && (\n <div className=\"pt-1 space-y-1\">\n {updatedDate && (\n <div className=\"flex items-center gap-2\">\n <ClockIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n <span className=\"text-[11px] text-muted-foreground\">\n Updated {formatDate(updatedDate)}\n </span>\n </div>\n )}\n {createdDate && (\n <div className=\"flex items-center gap-2\">\n <ClockIcon className=\"w-3.5 h-3.5 text-muted-foreground/50 shrink-0\" />\n <span className=\"text-[11px] text-muted-foreground/70\">\n Created {formatDate(createdDate)}\n </span>\n </div>\n )}\n </div>\n )}\n </div>\n\n <div className=\"h-px bg-border mx-3 mt-auto\" />\n <div className=\"px-3 py-2 shrink-0 flex items-center gap-1.5\">\n <button\n type=\"button\"\n onClick={onSelect}\n className=\"flex-1 h-7 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 active:bg-primary/80 transition-colors\"\n >\n Select\n </button>\n {openPeek && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n openPeek(agent);\n }}\n title=\"Sneak Peek\"\n aria-label=\"Sneak Peek\"\n className={iconButtonClass}\n >\n <RocketIcon className=\"w-3.5 h-3.5\" />\n </button>\n )}\n {!isDefaultRow && (\n <>\n <LinkComponent\n href={`/chat/a/${agent.id}`}\n onClick={(e) => e.stopPropagation()}\n title=\"Open in chat\"\n aria-label=\"Open in chat\"\n className={iconButtonClass}\n >\n <MessageCircleIcon className=\"w-3.5 h-3.5\" />\n </LinkComponent>\n <LinkComponent\n href={`/agents/go/${agent.id}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={(e) => e.stopPropagation()}\n title=\"Open in new tab\"\n aria-label=\"Open in new tab\"\n className={cn(\n iconButtonClass,\n \"hover:text-foreground\",\n )}\n >\n <ExternalLinkIcon className=\"w-3.5 h-3.5\" />\n </LinkComponent>\n </>\n )}\n </div>\n </div>\n );\n}\n\nconst iconButtonClass =\n \"flex items-center justify-center h-7 w-7 rounded-md border border-border bg-background text-muted-foreground hover:text-primary hover:bg-muted/50 transition-colors shrink-0\";\n","\"use client\";\n\n/**\n * catalog/react/FavoriteAgentButton.tsx — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/FavoriteAgentButton.tsx`.\n * Seams: Redux (`selectAgentById` + `saveAgentField`) → the catalog store's\n * `getAgent` + `setFavorite`; lucide `Star` → the inlined SVG; the amber\n * literal → the `--matrx-agent-favorite` token (C26 — no hardcoded colour in\n * package components).\n *\n * A star is PER-PERSON (`platform.user_entity_state`), so every agent the\n * caller can see is starrable — shared and system agents included. The old\n * \"Shared — cannot favorite\" gate existed only because the retired\n * `agent.definition.is_favorite` flag lived on the OWNER's row.\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\nimport { useCallback } from \"react\";\n\nimport { useAgentCatalog, useAgentCatalogState } from \"./context\";\nimport { StarIcon } from \"./icons\";\nimport type { AgentCatalogState } from \"../store\";\n\ninterface FavoriteAgentButtonProps {\n id: string;\n /** \"card\" = absolute-positioned corner star, \"list\" = inline icon button */\n variant?: \"card\" | \"list\";\n disabled?: boolean;\n}\n\nexport function FavoriteAgentButton({\n id,\n variant = \"card\",\n disabled,\n}: FavoriteAgentButtonProps) {\n const catalog = useAgentCatalog();\n const select = useCallback(\n (state: AgentCatalogState) => state.byId[id],\n [id],\n );\n const record = useAgentCatalogState(select);\n const isFavorite = record?.isFavorite ?? false;\n\n const handleClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (disabled) return;\n void catalog.setFavorite(id, !isFavorite).catch(() => {\n // Already rolled back and screamed by the store.\n });\n };\n\n const title = isFavorite ? \"Remove from favorites\" : \"Add to favorites\";\n\n if (variant === \"list\") {\n return (\n <button\n type=\"button\"\n className={cn(\n \"flex-shrink-0 p-0.5 rounded transition-all duration-150\",\n \"focus:outline-none focus-visible:ring-2 focus-visible:ring-primary\",\n disabled\n ? \"cursor-not-allowed\"\n : \"hover:scale-110 cursor-pointer\",\n )}\n onClick={handleClick}\n disabled={disabled}\n title={title}\n aria-label={isFavorite ? \"Remove from favorites\" : \"Add to favorites\"}\n >\n <StarIcon\n filled={isFavorite}\n className={cn(\n \"h-3.5 w-3.5 transition-all duration-150\",\n isFavorite\n ? \"matrx-agent-star-on\"\n : \"text-muted-foreground/40 hover:matrx-agent-star-on\",\n )}\n />\n </button>\n );\n }\n\n return (\n <button\n type=\"button\"\n className={cn(\n \"absolute top-2.5 right-2.5 z-10 p-0.5 rounded transition-all duration-150\",\n \"focus:outline-none focus-visible:ring-2 focus-visible:ring-primary\",\n disabled\n ? \"cursor-not-allowed\"\n : \"hover:scale-110 cursor-pointer\",\n isFavorite\n ? \"matrx-agent-star-on\"\n : \"text-muted-foreground/40 hover:matrx-agent-star-on\",\n )}\n onClick={handleClick}\n disabled={disabled}\n title={title}\n aria-label={isFavorite ? \"Remove from favorites\" : \"Add to favorites\"}\n >\n <StarIcon filled={isFavorite} className=\"w-4 h-4 transition-all duration-150\" />\n </button>\n );\n}\n","/**\n * catalog/orchestra.ts — @ai-matrx/agents/catalog\n *\n * Creator words for an Orchestra badge. A VERBATIM port of the helpers the\n * Workflow Studio's hand-rolled picker carried (`apps/workflow-studio/src/\n * hooks/use-agents.ts` before `c0f958b43`), lifted here so every client says\n * the same sentence about the same ensemble.\n *\n * Pure — no React, no DOM. The row shape is `OrchestraBadge` in `./types`.\n */\n\nimport type { OrchestraBadge } from \"./types\";\n\n/**\n * Creator words for an Orchestra's run mode. \"supervisor\" is already plain\n * English; the structural modes get humanized (never \"sequential/parallel/dag\"\n * at eye level). An unknown future mode falls through as its own word rather\n * than hiding — visible-but-unpolished beats invisible.\n */\nconst ORCHESTRA_MODE_LABEL: Record<string, string> = {\n supervisor: \"supervisor\",\n sequential: \"in order\",\n parallel: \"together\",\n dag: \"custom flow\",\n};\n\nexport function orchestraModeLabel(mode: string): string {\n return ORCHESTRA_MODE_LABEL[mode] ?? mode;\n}\n\n/** Human label for a badge: \"Orchestra · supervisor · 3 members\" (singular-safe). */\nexport function orchestraLabel(badge: OrchestraBadge): string {\n const n = badge.memberCount;\n return `Orchestra · ${orchestraModeLabel(badge.mode)} · ${n} ${\n n === 1 ? \"member\" : \"members\"\n }`;\n}\n\n/**\n * The member-call ceiling in Creator language (\"Team members can call helpers\n * up to 2 levels deep\"), or `null` when the composition declared none. A badge\n * never invents the platform default: the server that runs the ensemble owns\n * that number, and printing a promise nobody made is worse than printing\n * nothing.\n */\nexport function orchestraDepthLine(badge: OrchestraBadge): string | null {\n const n = badge.depthBudget;\n if (typeof n !== \"number\" || n <= 0) return null;\n return `Team members can call helpers up to ${n} ${\n n === 1 ? \"level\" : \"levels\"\n } deep`;\n}\n\n/**\n * One visible line naming who the Orchestra delegates to, collapsing past\n * `limit` into \"+N more\". `null` when no member carries a real role title —\n * \"Member, Member, Member\" is noise that reads like data.\n */\nexport function orchestraDelegatesLine(\n badge: OrchestraBadge,\n limit = 3,\n): string | null {\n const titles = badge.memberTitles;\n if (titles.length === 0) return null;\n const shown = titles.slice(0, limit);\n const extra = titles.length - shown.length;\n return `Delegates to: ${shown.join(\", \")}${\n extra > 0 ? ` +${extra} more` : \"\"\n }`;\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentListContent.tsx — port of `.../core/AgentListContent.tsx`.\n *\n * Additive to the original: the MANDATE DEFAULT ROW and its DRIFT BANNER. The\n * banner is the primary scream and it is PERSISTENT — it does not auto-dismiss\n * and it is not a console line (design D3). The `notifier` port fires beside\n * it, never instead of it.\n */\n\nimport { ErrorBox } from \"@ai-matrx/design-system\";\nimport { useEffect, useRef } from \"react\";\n\nimport { AgentFilterBar } from \"./AgentFilterBar\";\nimport { AgentListTabs, type AgentListTabCounts } from \"./AgentListTabs\";\nimport { AgentRow } from \"./AgentRow\";\nimport { useAgentCatalog } from \"./context\";\nimport { AlertTriangleIcon, LoaderIcon, XIcon } from \"./icons\";\nimport { SearchInput } from \"./primitives\";\nimport type { RightPanel } from \"./types\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\nimport type { DefaultRowState } from \"../default-row-types\";\nimport { agentListEmptyLabel, agentListFooterLabel } from \"../labels\";\nimport type { AgentSummary, AgentTab } from \"../types\";\n\nexport interface AgentListContentProps {\n agents: AgentSummary[];\n isLoading: boolean;\n consumer: UseAgentConsumerReturn;\n activeAgentId: string | null;\n allCategories: string[];\n allTags: string[];\n inputRef: React.RefObject<HTMLInputElement | null>;\n onSelectAgent: (a: AgentSummary) => void;\n /** Per-row href for cmd/ctrl+click. Defaults to `/agents/go/[id]`. */\n resolveAgentHref?: ((agent: AgentSummary) => string) | undefined;\n onReset: () => void;\n activeFilterCount: number;\n isMobile: boolean;\n hoveredAgent: AgentSummary | null;\n onAgentHover: (a: AgentSummary) => void;\n onAgentHoverEnd: (a: AgentSummary) => void;\n onDetailPress: (a: AgentSummary) => void;\n onFilterChipClick: (panel: \"sort\" | \"categories\" | \"tags\") => void;\n rightPanel: RightPanel;\n tabCounts: AgentListTabCounts;\n /** Limit the ownership tabs shown by this picker. */\n visibleTabs?: readonly AgentTab[] | undefined;\n /** Label override for the builtin tab — admin surfaces pass \"System\". */\n systemTabLabel?: string | undefined;\n /** Resolved current agent — pinned at the top when the list opens. */\n pinnedAgent?: AgentSummary | null | undefined;\n /** The mandate default row, when this picker was given a `defaultMandateKey`. */\n defaultRow?: DefaultRowState | null | undefined;\n /** When true, scroll the list to the pinned row (top). */\n listOpen?: boolean | undefined;\n /**\n * Rows the ARCHIVE FILTER is currently keeping off this screen — from\n * `useAgentListCore`. The footer names them (clause 2 of THE ARCHIVED-ITEMS\n * LAW: a screen never implies the list is everything). 0 means \"nothing\n * archived is hidden behind this view\", which is also what a host that\n * mounts this component directly and passes nothing gets.\n */\n archivedHiddenCount?: number | undefined;\n}\n\nexport function AgentListContent({\n agents,\n isLoading,\n consumer,\n activeAgentId,\n allCategories,\n allTags,\n inputRef,\n onSelectAgent,\n resolveAgentHref,\n onReset,\n activeFilterCount,\n isMobile,\n hoveredAgent,\n onAgentHover,\n onAgentHoverEnd,\n onDetailPress,\n onFilterChipClick,\n rightPanel,\n tabCounts,\n visibleTabs,\n systemTabLabel,\n pinnedAgent = null,\n defaultRow = null,\n listOpen = false,\n archivedHiddenCount = 0,\n}: AgentListContentProps) {\n const catalog = useAgentCatalog();\n const listScrollRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (listOpen && pinnedAgent) {\n listScrollRef.current?.scrollTo({ top: 0 });\n }\n }, [listOpen, pinnedAgent?.id]);\n\n const { labels } = catalog;\n const emptyLabel =\n catalog.getUserIdOrNull() === null\n ? labels.emptySignedOut\n : agentListEmptyLabel(consumer.tab, labels);\n const defaultAgent = defaultRow?.row ?? null;\n\n return (\n <div className=\"flex flex-col h-full\">\n {/* Search */}\n <div className=\"px-2 pt-2 pb-1 shrink-0\">\n <SearchInput\n ref={inputRef}\n value={consumer.searchTerm}\n onChange={consumer.setSearchTerm}\n placeholder={labels.searchPlaceholder}\n />\n </div>\n\n <AgentListTabs\n consumer={consumer}\n tabCounts={tabCounts}\n systemTabLabel={systemTabLabel}\n visibleTabs={visibleTabs}\n />\n\n {/* Filter bar */}\n <AgentFilterBar\n consumer={consumer}\n allCategories={allCategories}\n allTags={allTags}\n activeFilterCount={activeFilterCount}\n isMobile={isMobile}\n rightPanel={rightPanel}\n onFilterChipClick={onFilterChipClick}\n onReset={onReset}\n />\n\n {/* 🚨 THE DRIFT SCREAM — persistent, in the picker, never console-only. */}\n {defaultRow?.drift && (\n <div\n role=\"status\"\n className=\"matrx-agent-drift-banner mx-2 mb-1.5 flex items-start gap-2 rounded-md px-2 py-1.5 shrink-0\"\n >\n <AlertTriangleIcon className=\"w-3.5 h-3.5 shrink-0 mt-px\" />\n <span className=\"text-[11px] leading-snug flex-1\">\n {defaultRow.drift}\n </span>\n <button\n type=\"button\"\n aria-label=\"Dismiss\"\n onClick={() => catalog.dismissDefaultRowDrift(defaultRow.mandateKey)}\n className=\"shrink-0 opacity-70 hover:opacity-100\"\n >\n <XIcon className=\"w-3 h-3\" />\n </button>\n </div>\n )}\n {defaultRow?.error && (\n <ErrorBox\n as=\"div\"\n className=\"matrx-agent-drift-banner mx-2 mb-1.5 flex items-start gap-2 rounded-md px-2 py-1.5 shrink-0\"\n message={defaultRow.error}\n operation={`Load the default agent for ${defaultRow.mandateKey}`}\n origin=\"agents/AgentListContent\"\n >\n <AlertTriangleIcon className=\"w-3.5 h-3.5 shrink-0 mt-px\" />\n <span className=\"text-[11px] leading-snug flex-1\">\n {defaultRow.error}\n </span>\n <button\n type=\"button\"\n onClick={() => catalog.retryDefaultRow(defaultRow.mandateKey)}\n className=\"shrink-0 text-[11px] font-medium underline underline-offset-2 opacity-80 hover:opacity-100\"\n >\n Try again\n </button>\n </ErrorBox>\n )}\n\n <div className=\"h-px bg-border shrink-0\" />\n\n {/* Agent list */}\n <div ref={listScrollRef} className=\"overflow-y-auto flex-1 min-h-0\">\n {isLoading ? (\n <div className=\"flex items-center justify-center py-8 gap-2 text-muted-foreground\">\n <LoaderIcon className=\"w-4 h-4 matrx-agent-spin\" />\n <span className=\"text-xs\">{labels.loading}</span>\n </div>\n ) : agents.length === 0 && !pinnedAgent && !defaultAgent ? (\n <div className=\"flex flex-col items-center py-8 text-muted-foreground\">\n <span className=\"text-xs\">{emptyLabel}</span>\n </div>\n ) : (\n <div className=\"py-0.5\">\n {defaultAgent && (\n <>\n <div className=\"px-3 pt-1.5 pb-0.5\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n Default\n </span>\n </div>\n <AgentRow\n key={`default-${defaultAgent.id}`}\n agent={defaultAgent}\n isActive={defaultAgent.id === activeAgentId}\n isHovered={hoveredAgent?.id === defaultAgent.id}\n isMobile={isMobile}\n onClick={() => onSelectAgent(defaultAgent)}\n href={resolveAgentHref?.(defaultAgent)}\n onHover={() => onAgentHover(defaultAgent)}\n onHoverEnd={() => onAgentHoverEnd(defaultAgent)}\n onDetailPress={() => onDetailPress(defaultAgent)}\n />\n <div className=\"mx-2 my-0.5 h-px bg-border\" />\n </>\n )}\n {pinnedAgent && (\n <>\n <div className=\"px-3 pt-1.5 pb-0.5\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n {labels.currentAgentHeading}\n </span>\n </div>\n <AgentRow\n key={`pinned-${pinnedAgent.id}`}\n agent={pinnedAgent}\n isActive\n isHovered={hoveredAgent?.id === pinnedAgent.id}\n isMobile={isMobile}\n onClick={() => onSelectAgent(pinnedAgent)}\n href={resolveAgentHref?.(pinnedAgent)}\n onHover={() => onAgentHover(pinnedAgent)}\n onHoverEnd={() => onAgentHoverEnd(pinnedAgent)}\n onDetailPress={() => onDetailPress(pinnedAgent)}\n />\n <div className=\"mx-2 my-0.5 h-px bg-border\" />\n </>\n )}\n {agents.map((agent) => (\n <AgentRow\n key={agent.id}\n agent={agent}\n isActive={agent.id === activeAgentId}\n isHovered={hoveredAgent?.id === agent.id}\n isMobile={isMobile}\n onClick={() => onSelectAgent(agent)}\n href={resolveAgentHref?.(agent)}\n onHover={() => onAgentHover(agent)}\n onHoverEnd={() => onAgentHoverEnd(agent)}\n onDetailPress={() => onDetailPress(agent)}\n />\n ))}\n {agents.length === 0 && (pinnedAgent || defaultAgent) && (\n <div className=\"flex flex-col items-center py-4 text-muted-foreground\">\n <span className=\"text-xs\">{emptyLabel}</span>\n </div>\n )}\n </div>\n )}\n </div>\n\n {/* Footer count */}\n <div className=\"h-px bg-border shrink-0\" />\n <div className=\"flex items-center justify-between px-2.5 py-1.5 shrink-0\">\n <span\n data-testid=\"agent-list-footer\"\n className=\"text-[10px] text-muted-foreground tabular-nums\"\n >\n {agentListFooterLabel({\n count: agents.length,\n archFilter: consumer.archFilter,\n archivedHiddenCount,\n })}\n </span>\n {consumer.searchTerm && (\n <button\n type=\"button\"\n onClick={() => consumer.setSearchTerm(\"\")}\n className=\"text-[10px] text-muted-foreground hover:text-foreground transition-colors\"\n >\n Clear search\n </button>\n )}\n </div>\n </div>\n );\n}\n","/**\n * catalog/react/types.ts — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/core/types.ts`.\n */\n\nexport type RightPanel = \"detail\" | \"sort\" | \"categories\" | \"tags\" | null;\n\n/**\n * `SORT_OPTIONS` MOVED to the pure `@ai-matrx/agents/catalog` entry in 0.8.0 —\n * it is five string pairs, and importing it from this `\"use client\"` bundle\n * pulled React into server graphs that only wanted the labels. Re-exported here\n * unchanged so every existing import keeps working; prefer the pure entry.\n */\nexport { SORT_OPTIONS } from \"../types\";\n\nexport const PANEL_HEIGHT = \"528px\";\n\n/**\n * 🚨 THE PANEL NEVER OUTGROWS THE SPACE IT HAS.\n *\n * The popover reserves a FIXED footprint on purpose (a resizing panel in a\n * narrow rail gets collision-shifted out from under the cursor). But a flat\n * 528px is taller than the room above a trigger sitting mid-page on a laptop,\n * and Radix cannot shift what does not fit either way — so the top of the\n * panel, which is the SEARCH BOX, was rendered off-screen. Measured 2026-09-08\n * on the mandate Holder screen at 1280x900: the popover sat at `top: -76`.\n *\n * Clamping to Radix's own measurement keeps the footprint fixed whenever there\n * IS room and merely shortens the list when there is not — the panel still\n * never resizes while open, because the available height does not change while\n * the popover is open.\n */\nexport const LIST_MAX_HEIGHT =\n \"min(528px, var(--radix-popper-available-height, 528px))\";\n\n/**\n * 🚨 OPEN BELOW THE CONTROL WHENEVER THERE IS ROOM TO USE IT.\n *\n * Radix flips a popover to the side with more room using the panel's FULL\n * height, so a trigger in the middle of a dialog (the mandate \"Use my own\"\n * picker on a 1280x900 screen: 418px below, 528px panel) sent the whole panel\n * ABOVE it — over the dialog's own title and controls, reading as a list\n * floating at the top of the screen (2026-09-26). This measures the room\n * below at open time: when a usable list fits there, the panel is sized to it\n * and pinned to `side=\"bottom\"`; only when it does not is Radix left to flip.\n * The height is fixed for the whole time the panel is open, so nothing moves\n * under the cursor (the reason the footprint is fixed at all).\n *\n * Returns a px height, or `null` for \"use the default footprint and placement\".\n */\nexport function panelHeightBelow(\n trigger: Element | null,\n options: { full?: number; minUsable?: number; gap?: number } = {},\n): string | null {\n if (!trigger || typeof window === \"undefined\") return null;\n const full = options.full ?? 528;\n const minUsable = options.minUsable ?? 300;\n const gap = options.gap ?? 16; // sideOffset 4 + collisionPadding 12\n const below = window.innerHeight - trigger.getBoundingClientRect().bottom - gap;\n if (below >= full) return null;\n return below >= minUsable ? `${Math.floor(below)}px` : null;\n}\n\n/**\n * 🚨 A SIDE-OPENING PANEL NEVER LEAVES THE SCREEN.\n *\n * A host may ask for `side=\"left\"` / `\"right\"` (the chat composer's presets\n * panel opens \"All agents\" to its left). Radix shifts a side-placed popover\n * only VERTICALLY, so when the 680px panel does not fit on that side it runs\n * off the screen edge and the search box, tabs and names are cut off (blind run\n * PB-03, /chat/new in an 800px pane, 2026-10-01). Measured at open time: keep\n * the asked side when the panel fits there, else the opposite side when it\n * fits, else open below, where Radix can shift it horizontally into view.\n * Vertical sides pass through unchanged.\n */\nexport function sideThatFits(\n trigger: Element | null,\n side: \"top\" | \"right\" | \"bottom\" | \"left\",\n options: { width?: number; gap?: number } = {},\n): \"top\" | \"right\" | \"bottom\" | \"left\" {\n if (!trigger || typeof window === \"undefined\" || (side !== \"left\" && side !== \"right\")) return side;\n const width = options.width ?? 680;\n const gap = options.gap ?? 16; // sideOffset 4 + collisionPadding 12\n const rect = trigger.getBoundingClientRect();\n const room = { left: rect.left - gap, right: window.innerWidth - rect.right - gap };\n if (room[side] >= width) return side;\n const other = side === \"left\" ? \"right\" : \"left\";\n if (room[other] >= width) return other;\n return \"bottom\";\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentFilterBar.tsx — VERBATIM port of matrx-frontend\n * `.../core/AgentFilterBar.tsx`. Seams: lucide icons → inlined SVGs (C19);\n * `scrollbar-none` → the package's own class.\n */\n\nimport { FilterChip } from \"./primitives\";\nimport {\n ArchiveIcon,\n ArrowUpDownIcon,\n FolderIcon,\n RotateCcwIcon,\n StarIcon,\n TagIcon,\n} from \"./icons\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\nimport { SORT_OPTIONS, type RightPanel } from \"./types\";\nimport {\n agentArchiveFilterChipLabel,\n agentArchiveFilterControlLabel,\n} from \"../labels\";\nimport { nextArchFilter } from \"../types\";\n\nexport interface AgentFilterBarProps {\n consumer: UseAgentConsumerReturn;\n allCategories: string[];\n allTags: string[];\n activeFilterCount: number;\n isMobile: boolean;\n rightPanel: RightPanel;\n onFilterChipClick: (panel: \"sort\" | \"categories\" | \"tags\") => void;\n onReset: () => void;\n}\n\n/**\n * The filter bar is IDENTICAL on every tab, system included. A tab that offers\n * fewer controls than its neighbour is the half-built shape this list exists\n * to prevent — the system tab's category/tag options simply come from the\n * builtin population (see `selectAllSystemAgentCategories`).\n *\n * 🚨 THE ARCHIVE CONTROL IS NOT OPTIONAL (0.9.2). It renders here, on every\n * tab, for every consumer — including one whose `visibleTabs` removes the tab\n * strip above it, since this bar is mounted unconditionally by\n * `AgentListContent`. THE ARCHIVED-ITEMS LAW clause 3: revealing archived\n * items is one or two clicks away, \"on the surface itself — never zero\n * (impossible) and never buried in another page\". One click of this chip\n * shows all; a second shows archived only; a third hides them again.\n */\nexport function AgentFilterBar({\n consumer,\n allCategories,\n allTags,\n activeFilterCount,\n isMobile,\n rightPanel,\n onFilterChipClick,\n onReset,\n}: AgentFilterBarProps) {\n return (\n <div className=\"flex items-center gap-1 px-2 pb-1.5 overflow-x-auto matrx-agent-scrollbar-none shrink-0\">\n <FilterChip\n icon={ArrowUpDownIcon}\n label={\n SORT_OPTIONS.find((o) => o.value === consumer.sortBy)?.label ?? \"Sort\"\n }\n active={consumer.sortBy !== \"updated-desc\"}\n focused={!isMobile && rightPanel === \"sort\"}\n onClick={() => onFilterChipClick(\"sort\")}\n />\n <FilterChip\n icon={StarIcon}\n label={consumer.favFilter === \"no\" ? \"No Favs\" : \"Favs\"}\n active={consumer.favFilter !== \"all\"}\n onClick={() => {\n const next =\n consumer.favFilter === \"all\"\n ? \"yes\"\n : consumer.favFilter === \"yes\"\n ? \"no\"\n : \"all\";\n consumer.setFavFilter(next);\n }}\n />\n <FilterChip\n icon={ArchiveIcon}\n label={agentArchiveFilterChipLabel(consumer.archFilter)}\n active={consumer.archFilter !== consumer.archFilterDefault}\n ariaLabel={agentArchiveFilterControlLabel(consumer.archFilter)}\n testId=\"agent-archive-filter\"\n onClick={() => consumer.setArchFilter(nextArchFilter(consumer.archFilter))}\n />\n {allCategories.length > 0 && (\n <FilterChip\n icon={FolderIcon}\n label={\n consumer.includedCats.length > 0\n ? `${consumer.includedCats.length}`\n : \"Category\"\n }\n active={consumer.includedCats.length > 0}\n focused={!isMobile && rightPanel === \"categories\"}\n onClick={() => onFilterChipClick(\"categories\")}\n />\n )}\n {allTags.length > 0 && (\n <FilterChip\n icon={TagIcon}\n label={\n consumer.includedTags.length > 0\n ? `${consumer.includedTags.length}`\n : \"Tags\"\n }\n active={consumer.includedTags.length > 0}\n focused={!isMobile && rightPanel === \"tags\"}\n onClick={() => onFilterChipClick(\"tags\")}\n />\n )}\n {activeFilterCount > 0 && (\n <button\n type=\"button\"\n onClick={onReset}\n aria-label=\"Reset filters\"\n className=\"flex items-center gap-0.5 h-6 px-1.5 rounded text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors shrink-0\"\n >\n <RotateCcwIcon className=\"w-3 h-3\" />\n </button>\n )}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentListTabs.tsx — VERBATIM port of matrx-frontend\n * `.../core/AgentListTabs.tsx`. Seams: `cn` from design-system; the \"Public\"\n * literal → the `labels` port; `scrollbar-none` → the package's own\n * `matrx-agent-scrollbar-none` (a package never invents a Tailwind class name\n * and expects the consumer's `@source` scan to generate it — THE GENERATION\n * HAZARD).\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\n\nimport { useAgentCatalog } from \"./context\";\nimport type { AgentListTabCounts } from \"../shared/useAgentListCore\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\nimport type { AgentTab } from \"../types\";\n\nexport type { AgentListTabCounts } from \"../shared/useAgentListCore\";\n\ninterface AgentListTabsProps {\n consumer: UseAgentConsumerReturn;\n tabCounts: AgentListTabCounts;\n /** Limit the ownership tabs for constrained pickers. */\n visibleTabs?: readonly AgentTab[] | undefined;\n /**\n * Label for the builtin-agent tab. Users see \"Public\" (that is what a\n * platform agent is to them); ADMIN surfaces pass \"System\", because there\n * these are the agents they own and maintain.\n */\n systemTabLabel?: string | undefined;\n}\n\nexport function AgentListTabs({\n consumer,\n tabCounts,\n systemTabLabel,\n visibleTabs,\n}: AgentListTabsProps) {\n const { labels } = useAgentCatalog();\n const tabs: {\n value: AgentTab;\n label: string;\n countKey: keyof AgentListTabCounts;\n }[] = [\n { value: \"mine\", label: \"Mine\", countKey: \"mine\" },\n { value: \"shared\", label: \"Shared\", countKey: \"shared\" },\n { value: \"all\", label: \"All\", countKey: \"all\" },\n { value: \"system\", label: labels.publicTab, countKey: \"system\" },\n ];\n\n return (\n <div\n className=\"flex items-center gap-0.5 px-2 pb-1 overflow-x-auto matrx-agent-scrollbar-none shrink-0\"\n role=\"tablist\"\n aria-label=\"Agent ownership\"\n >\n {tabs\n .filter(({ value }) => !visibleTabs || visibleTabs.includes(value))\n .map(({ value, label: baseLabel, countKey }) => {\n const label =\n value === \"system\" ? (systemTabLabel ?? baseLabel) : baseLabel;\n const active = consumer.tab === value;\n const count = tabCounts[countKey];\n return (\n <button\n key={value}\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => consumer.setTab(value)}\n className={cn(\n \"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium transition-colors shrink-0\",\n active\n ? \"bg-primary text-primary-foreground\"\n : \"text-muted-foreground hover:text-foreground hover:bg-muted/50\",\n )}\n >\n <span>{label}</span>\n <span\n className={cn(\"tabular-nums opacity-70\", active && \"opacity-90\")}\n >\n {count}\n </span>\n </button>\n );\n })}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentRow.tsx — VERBATIM port of matrx-frontend\n * `.../core/AgentRow.tsx`. Seams: `next/link` → the `LinkComponent` port\n * (default a plain `<a>`, so cmd-click works with no host wiring); lucide →\n * inlined SVGs; the amber star literal → the `--matrx-agent-favorite` token.\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\n\nimport { useAgentCatalog, useAgentCatalogUiPorts } from \"./context\";\nimport { ChevronRightIcon, Music4Icon, StarIcon } from \"./icons\";\nimport {\n orchestraDelegatesLine,\n orchestraLabel,\n} from \"../orchestra\";\nimport type { AgentSummary } from \"../types\";\n\nexport interface AgentRowProps {\n agent: AgentSummary;\n isActive: boolean;\n isHovered: boolean;\n isMobile: boolean;\n /** Row href. Defaults to `/agents/go/[id]`. */\n href?: string | undefined;\n onClick: () => void;\n onHover: () => void;\n onHoverEnd: () => void;\n onDetailPress: () => void;\n}\n\nexport function AgentRow({\n agent,\n isActive,\n isHovered,\n isMobile,\n href,\n onClick,\n onHover,\n onHoverEnd,\n onDetailPress,\n}: AgentRowProps) {\n const { LinkComponent } = useAgentCatalogUiPorts();\n const { labels } = useAgentCatalog();\n const rowHref = href ?? `/agents/go/${agent.id}`;\n\n return (\n <div\n // Parity hook with the native row's `testID`. It is what lets the web\n // shell's ordering be MEASURED rather than asserted about — see\n // `catalog/react/total-order.test.tsx`.\n data-testid={`agent-row-${agent.id}`}\n className={cn(\n \"flex items-center w-full text-left transition-colors group\",\n \"hover:bg-muted/50 active:bg-muted/70\",\n isActive && \"bg-primary/5\",\n !isMobile && isHovered && \"bg-muted/40\",\n )}\n onMouseEnter={isMobile ? undefined : onHover}\n onMouseLeave={isMobile ? undefined : onHoverEnd}\n >\n <LinkComponent\n href={rowHref}\n onClick={(e) => {\n if (e.metaKey || e.ctrlKey) return;\n e.preventDefault();\n onClick();\n }}\n className=\"flex items-center gap-2 flex-1 min-w-0 px-3 py-2\"\n >\n {agent.isFavorite && (\n <StarIcon filled className=\"w-3 h-3 matrx-agent-star-on shrink-0\" />\n )}\n <span\n className={cn(\n \"text-[13px] font-medium truncate\",\n isActive ? \"text-primary\" : \"text-foreground\",\n )}\n >\n {agent.name || \"Untitled\"}\n </span>\n {/* Conductor marker. An Orchestra runs its WHOLE ensemble from this\n one choice, so the row says so where the choice is made — not in a\n run log afterwards. Icon + member count only: the row is a name,\n and the mode, tagline and member titles are one hover away in the\n detail card. Ported from the Workflow Studio picker this replaced. */}\n {agent.orchestra && (\n <span\n className=\"flex shrink-0 items-center gap-0.5 rounded-sm bg-primary/10 px-1 py-px text-[9px] font-medium text-primary\"\n title={\n orchestraDelegatesLine(agent.orchestra) ??\n orchestraLabel(agent.orchestra)\n }\n >\n <Music4Icon className=\"w-2.5 h-2.5\" />\n {agent.orchestra.memberCount}\n </span>\n )}\n {/* ARCHIVED rows stay offered (the archived-items law) and say so. */}\n {agent.isArchived ? (\n <span\n data-testid={`agent-archived-badge-${agent.id}`}\n className=\"text-[9px] font-medium text-muted-foreground bg-muted px-1 py-px rounded shrink-0 ml-auto\"\n >\n {labels.archivedBadge}\n </span>\n ) : null}\n {/* Origin badge. On a blended list (admin \"All\", search results) this\n is the only thing that tells a system agent from your own. */}\n {agent.agentType === \"builtin\" ? (\n <span className={cn(\"text-[9px] font-medium text-primary bg-primary/10 px-1 py-px rounded shrink-0\", !agent.isArchived && \"ml-auto\")}>\n {labels.systemBadge}\n </span>\n ) : agent.isOwner === false ? (\n <span className={cn(\"text-[9px] text-muted-foreground bg-muted px-1 py-px rounded shrink-0\", !agent.isArchived && \"ml-auto\")}>\n shared\n </span>\n ) : null}\n </LinkComponent>\n {isMobile && (\n <button\n type=\"button\"\n aria-label=\"Show details\"\n onClick={(e) => {\n e.stopPropagation();\n onDetailPress();\n }}\n className=\"flex items-center justify-center w-10 h-full shrink-0 text-muted-foreground/40 active:text-muted-foreground\"\n >\n <ChevronRightIcon className=\"w-4 h-4\" />\n </button>\n )}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentMobileSubView.tsx — port of `.../core/AgentMobileSubView.tsx`.\n * Carries the same \"Clear (n)\" fix as `AgentCategoriesPanel` — see its header.\n */\n\nimport { CheckRow, OptionRow, SearchInput } from \"./primitives\";\nimport { ChevronRightIcon } from \"./icons\";\nimport { SORT_OPTIONS } from \"./types\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\n\nexport interface AgentMobileSubViewProps {\n view: \"sort\" | \"categories\" | \"tags\";\n consumer: UseAgentConsumerReturn;\n allCategories: string[];\n allTags: string[];\n catSearch: string;\n setCatSearch: (v: string) => void;\n tagSearch: string;\n setTagSearch: (v: string) => void;\n onBack: () => void;\n}\n\nexport function AgentMobileSubView({\n view,\n consumer,\n allCategories,\n allTags,\n catSearch,\n setCatSearch,\n tagSearch,\n setTagSearch,\n onBack,\n}: AgentMobileSubViewProps) {\n const title =\n view === \"sort\" ? \"Sort\" : view === \"categories\" ? \"Categories\" : \"Tags\";\n\n return (\n <div className=\"flex flex-col\">\n <button\n type=\"button\"\n onClick={onBack}\n className=\"flex items-center gap-1.5 px-3 py-2.5 text-sm font-medium text-primary hover:bg-muted/30 transition-colors border-b border-border shrink-0\"\n >\n <ChevronRightIcon className=\"w-4 h-4 rotate-180\" />\n {title}\n </button>\n {view === \"sort\" &&\n SORT_OPTIONS.map((opt) => (\n <OptionRow\n key={opt.value}\n label={opt.label}\n selected={consumer.sortBy === opt.value}\n onClick={() => {\n consumer.setSortBy(opt.value);\n onBack();\n }}\n />\n ))}\n {view === \"categories\" && (\n <>\n <div className=\"px-2 pt-2 pb-1\">\n <SearchInput\n value={catSearch}\n onChange={setCatSearch}\n placeholder=\"Filter categories...\"\n />\n </div>\n {consumer.includedCats.length > 0 && (\n <button\n type=\"button\"\n onClick={() => consumer.setIncludedCats([])}\n className=\"mx-2 mb-1 h-6 rounded text-[11px] font-medium text-primary hover:bg-muted/50 transition-colors text-left\"\n >\n Clear ({consumer.includedCats.length})\n </button>\n )}\n <div className=\"overflow-y-auto max-h-[300px]\">\n {allCategories\n .filter(\n (c) =>\n !catSearch ||\n c.toLowerCase().includes(catSearch.toLowerCase()),\n )\n .map((cat) => (\n <CheckRow\n key={cat}\n label={cat}\n checked={consumer.includedCats.includes(cat)}\n onClick={() => consumer.toggleCategory(cat)}\n />\n ))}\n </div>\n </>\n )}\n {view === \"tags\" && (\n <>\n <div className=\"px-2 pt-2 pb-1\">\n <SearchInput\n value={tagSearch}\n onChange={setTagSearch}\n placeholder=\"Filter tags...\"\n />\n </div>\n {consumer.includedTags.length > 0 && (\n <button\n type=\"button\"\n onClick={() => consumer.setIncludedTags([])}\n className=\"mx-2 mb-1 h-6 rounded text-[11px] font-medium text-primary hover:bg-muted/50 transition-colors text-left\"\n >\n Clear ({consumer.includedTags.length})\n </button>\n )}\n <div className=\"overflow-y-auto max-h-[300px]\">\n {allTags\n .filter(\n (t) =>\n !tagSearch ||\n t.toLowerCase().includes(tagSearch.toLowerCase()),\n )\n .map((tag) => (\n <CheckRow\n key={tag}\n label={tag}\n checked={consumer.includedTags.includes(tag)}\n onClick={() => consumer.toggleTag(tag)}\n />\n ))}\n </div>\n </>\n )}\n </div>\n );\n}\n","\"use client\";\n\n/** catalog/react/AgentSortPanel.tsx — VERBATIM port of `.../core/AgentSortPanel.tsx`. */\n\nimport { OptionRow, SidePanelHeader } from \"./primitives\";\nimport { SORT_OPTIONS } from \"./types\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\n\nexport interface AgentSortPanelProps {\n consumer: UseAgentConsumerReturn;\n onClose: () => void;\n}\n\nexport function AgentSortPanel({ consumer, onClose }: AgentSortPanelProps) {\n return (\n <div className=\"flex flex-col h-full\">\n <SidePanelHeader title=\"Sort By\" onClose={onClose} />\n <div className=\"overflow-y-auto flex-1\">\n {SORT_OPTIONS.map((opt) => (\n <OptionRow\n key={opt.value}\n label={opt.label}\n selected={consumer.sortBy === opt.value}\n onClick={() => consumer.setSortBy(opt.value)}\n />\n ))}\n </div>\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentTagsPanel.tsx — port of `.../core/AgentTagsPanel.tsx`.\n * Carries the same \"Clear (n)\" fix as `AgentCategoriesPanel` — see its header.\n */\n\nimport { CheckRow, SearchInput, SidePanelHeader } from \"./primitives\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\n\nexport interface AgentTagsPanelProps {\n consumer: UseAgentConsumerReturn;\n allTags: string[];\n search: string;\n setSearch: (v: string) => void;\n onClose: () => void;\n}\n\nexport function AgentTagsPanel({\n consumer,\n allTags,\n search,\n setSearch,\n onClose,\n}: AgentTagsPanelProps) {\n const filtered = allTags.filter(\n (t) => !search || t.toLowerCase().includes(search.toLowerCase()),\n );\n return (\n <div className=\"flex flex-col h-full\">\n <SidePanelHeader title=\"Tags\" onClose={onClose} />\n <div className=\"px-2 pt-2 pb-1 shrink-0\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"Filter tags...\"\n />\n </div>\n {consumer.includedTags.length > 0 && (\n <button\n type=\"button\"\n onClick={() => consumer.setIncludedTags([])}\n className=\"mx-2 mb-1 h-6 rounded text-[11px] font-medium text-primary hover:bg-muted/50 transition-colors text-left shrink-0\"\n >\n Clear ({consumer.includedTags.length})\n </button>\n )}\n <div className=\"overflow-y-auto flex-1\">\n {filtered.length === 0 ? (\n <p className=\"text-xs text-muted-foreground text-center py-6\">\n No tags\n </p>\n ) : (\n filtered.map((tag) => (\n <CheckRow\n key={tag}\n label={tag}\n checked={consumer.includedTags.includes(tag)}\n onClick={() => consumer.toggleTag(tag)}\n />\n ))\n )}\n </div>\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentListInlinePicker.tsx — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/AgentListInlinePicker.tsx`.\n *\n * Embeddable agent browser with configurable ownership tabs. Reuses the same\n * core as `AgentListDropdown` (`useAgentListCore` + `AgentListContent`)\n * without a popover/drawer shell. Intended for surfaces that dedicate a panel\n * region to agent selection.\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { AgentDetailCard } from \"./AgentDetailCard\";\nimport { AgentListContent } from \"./AgentListContent\";\nimport { AgentMobileSubView } from \"./AgentMobileSubView\";\nimport { ChevronRightIcon } from \"./icons\";\nimport { useAgentListCore } from \"./useAgentListCore\";\nimport type { AgentSummary, AgentTab } from \"../types\";\n\nexport interface AgentListInlinePickerProps {\n /** Unique consumer id for filter/tab state (see `useAgentConsumer`). */\n consumerId: string;\n onSelect: (agentId: string) => void;\n activeAgentId?: string | null;\n className?: string;\n /** Auto-focus the search field on mount. Default true. */\n autoFocusSearch?: boolean;\n /** Tab to open on. Admin surfaces that manage system agents pass `\"system\"`. */\n initialTab?: AgentTab;\n /** ADMIN variant: blend system agents into the \"All\" tab. */\n includeSystemInAll?: boolean;\n /** Restrict which ownership tabs are available for domain-constrained pickers. */\n visibleTabs?: readonly AgentTab[];\n /** Label override for the builtin-agent tab. Admin surfaces use \"System\". */\n systemTabLabel?: string;\n /** Resolve the route used by each named agent door. */\n resolveAgentHref?: (agent: AgentSummary) => string;\n /** Show the globally active agent above the filtered list. Default true. */\n showPinnedAgent?: boolean;\n /** Hide records that are invalid for this call site. */\n excludeAgentIds?: readonly string[];\n /** Offer the mandate's live-resolved default agent at the top of the list. */\n defaultMandateKey?: string;\n}\n\nexport function AgentListInlinePicker({\n consumerId,\n onSelect,\n activeAgentId = null,\n className,\n autoFocusSearch = true,\n initialTab,\n includeSystemInAll = false,\n visibleTabs,\n systemTabLabel,\n resolveAgentHref,\n showPinnedAgent = true,\n excludeAgentIds,\n defaultMandateKey,\n}: AgentListInlinePickerProps) {\n const inputRef = useRef<HTMLInputElement>(null);\n const [catSearch, setCatSearch] = useState(\"\");\n const [tagSearch, setTagSearch] = useState(\"\");\n const [mobileDetailAgent, setMobileDetailAgent] =\n useState<AgentSummary | null>(null);\n const [mobileSubView, setMobileSubView] = useState<\n \"sort\" | \"categories\" | \"tags\" | null\n >(null);\n\n const {\n agents,\n archivedHiddenCount,\n isLoading,\n allCategories,\n allTags,\n consumer,\n tabCounts,\n activeFilterCount,\n hoveredAgent,\n pinnedAgent,\n defaultRow,\n ensureLoaded,\n handleSelectAgent: coreSelectAgent,\n handleAgentHover,\n handleAgentHoverEnd,\n } = useAgentListCore({\n consumerId,\n onSelect,\n activeAgentIdOverride: activeAgentId,\n ...(initialTab ? { initialTab } : {}),\n includeSystemInAll,\n // The restriction has to reach the CORE, not just the tab strip — see\n // `AgentListCoreOptions.visibleTabs`.\n ...(visibleTabs ? { visibleTabs } : {}),\n ...(excludeAgentIds ? { excludeAgentIds } : {}),\n ...(defaultMandateKey ? { defaultMandateKey } : {}),\n });\n\n useEffect(() => {\n ensureLoaded();\n if (!autoFocusSearch) return undefined;\n const timer = setTimeout(() => inputRef.current?.focus(), 50);\n return () => clearTimeout(timer);\n }, [ensureLoaded, autoFocusSearch]);\n\n const handleSelectAgent = (agent: AgentSummary) => {\n coreSelectAgent(agent);\n setMobileDetailAgent(null);\n setMobileSubView(null);\n };\n\n const handleFilterChipClick = (panel: \"sort\" | \"categories\" | \"tags\") => {\n setMobileSubView(panel);\n };\n\n // Single-column layout — no hover side panel (same as mobile drawer).\n const isMobile = true;\n\n if (mobileDetailAgent) {\n return (\n <div className={cn(\"flex h-full min-h-0 flex-col\", className)}>\n <button\n type=\"button\"\n onClick={() => setMobileDetailAgent(null)}\n className=\"flex shrink-0 items-center gap-1.5 border-b border-border px-3 py-2 text-sm font-medium text-primary transition-colors hover:bg-muted/30\"\n >\n <ChevronRightIcon className=\"h-4 w-4 rotate-180\" />\n Back\n </button>\n <div className=\"min-h-0 flex-1 overflow-y-auto\">\n <AgentDetailCard\n agent={mobileDetailAgent}\n onSelect={() => handleSelectAgent(mobileDetailAgent)}\n />\n </div>\n </div>\n );\n }\n\n if (mobileSubView) {\n return (\n <div className={cn(\"flex h-full min-h-0 flex-col\", className)}>\n <AgentMobileSubView\n view={mobileSubView}\n consumer={consumer}\n allCategories={allCategories}\n allTags={allTags}\n catSearch={catSearch}\n setCatSearch={setCatSearch}\n tagSearch={tagSearch}\n setTagSearch={setTagSearch}\n onBack={() => {\n setMobileSubView(null);\n setCatSearch(\"\");\n setTagSearch(\"\");\n }}\n />\n </div>\n );\n }\n\n return (\n <div className={cn(\"flex h-full min-h-0 flex-col\", className)}>\n <AgentListContent\n agents={agents}\n isLoading={isLoading}\n consumer={consumer}\n activeAgentId={activeAgentId}\n allCategories={allCategories}\n allTags={allTags}\n inputRef={inputRef}\n onSelectAgent={handleSelectAgent}\n {...(resolveAgentHref ? { resolveAgentHref } : {})}\n onReset={consumer.resetFilters}\n activeFilterCount={activeFilterCount}\n isMobile={isMobile}\n hoveredAgent={hoveredAgent}\n onAgentHover={(agent) => handleAgentHover(agent, false)}\n onAgentHoverEnd={(agent) => handleAgentHoverEnd(agent, () => {})}\n onDetailPress={setMobileDetailAgent}\n onFilterChipClick={handleFilterChipClick}\n rightPanel={null}\n tabCounts={tabCounts}\n archivedHiddenCount={archivedHiddenCount}\n {...(visibleTabs ? { visibleTabs } : {})}\n {...(systemTabLabel ?? (includeSystemInAll ? \"System\" : undefined)\n ? {\n systemTabLabel:\n systemTabLabel ?? (includeSystemInAll ? \"System\" : undefined),\n }\n : {})}\n pinnedAgent={showPinnedAgent ? pinnedAgent : null}\n defaultRow={defaultRow}\n listOpen\n />\n </div>\n );\n}\n"],"mappings":";;;;AAeA,SAAS,WAAAA,gBAA+B;;;ACMxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AA+GH;AAjCJ,IAAM,sBAAsB,cAA0C,IAAI;AAYnE,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAChC,QAAM,QAAQ;AAAA,IACZ,OAAO,EAAE,SAAS,UAAU,GAAG,MAAM;AAAA;AAAA;AAAA,IAGrC;AAAA,MACE;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AACA,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAC3B,UACH;AAEJ;AAEA,SAAS,aAAkC;AACzC,QAAM,UAAU,WAAW,mBAAmB;AAC9C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IAIF;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,kBAAgC;AAC9C,SAAO,WAAW,EAAE;AACtB;AAGO,SAAS,yBAKd;AACA,QAAM,UAAU,WAAW;AAC3B,QAAM,eAAe,QAAQ;AAC7B,QAAM,mBAAmB,QAAQ,SAAS;AAC1C,QAAM,WAAW;AAAA,IACf,CAAC,SAAS;AACR,UAAI,cAAc;AAChB,qBAAa,IAAI;AACjB;AAAA,MACF;AACA,uBAAiB,IAAI;AAAA,IACvB;AAAA,IACA,C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A;AAAA,MACA,eAAe;AAAA,MACd,GAAI,mBAAmB,EAAE,iBAAiB,IAAI,CAAC;AAAA,MAChD,SAAS,SAAS;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,CAAC,UAAU,iBAAiB,OAAO,KAAK;AAAA,MACtD,iBAAiB,CAAC,UAAU,oBAAoB,OAAO,MAAM;AAAA,MAAC,CAAC;AAAA,MAC/D,eAAe;AAAA,MACf,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACC,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;AAAA,MACrC,GAAI,mBAAmB,qBAAqB,WAAW,UACpD;AAAA,QACE,gBACE,mBAAmB,qBAAqB,WAAW;AAAA,MACvD,IACA,CAAC;AAAA,MACL,aAAa,kBAAkB,cAAc;AAAA,MAC7C;AAAA,MACA,UAAQ;AAAA;AAAA,EACV,GACF;AAEJ;","names":["useMemo","jsx","useMemo","useCallback","useCallback","useCallback","useEffect","useMemo","useRef","useState","useRef","useState","useMemo","useCallback","useEffect","cn","useIsMobile","useMemo","useRef","useState","cn","useCallback","useEffect","useMemo","useRef","useState","jsx","jsx","jsxs","jsx","jsxs","cn","cn","useCallback","jsx","useCallback","isFavorite","cn","Fragment","jsx","jsxs","cn","useEffect","useRef","jsx","jsxs","cn","jsx","jsxs","cn","cn","jsx","jsxs","cn","Fragment","jsx","jsxs","useRef","useEffect","Fragment","jsx","jsxs","jsx","jsxs","jsx","jsxs","jsx","jsxs","useState","useRef","useEffect","useCallback","cn","useMemo","jsx","jsxs","useIsMobile","useState","useRef","useMemo","cn","cn","useEffect","useRef","useState","jsx","jsxs","useRef","useState","useEffect","cn"]}
|
|
1
|
+
{"version":3,"sources":["../../../catalog/react/context.tsx","../../../catalog/shared/context.tsx","../../../catalog/shared/useAgentConsumer.ts","../../../catalog/shared/useAgentListCore.ts","../../../catalog/types.ts","../../../catalog/labels.ts","../../../catalog/score.ts","../../../catalog/selectors.ts","../../../catalog/react/AgentListDropdown.tsx","../../../catalog/react/AgentListPanel.tsx","../../../catalog/react/primitives.tsx","../../../catalog/shared/icon-paths.ts","../../../catalog/react/icons.tsx","../../../catalog/react/AgentCategoriesPanel.tsx","../../../catalog/react/AgentDetailCard.tsx","../../../catalog/react/FavoriteAgentButton.tsx","../../../catalog/orchestra.ts","../../../catalog/react/AgentListContent.tsx","../../../catalog/react/types.ts","../../../catalog/react/AgentFilterBar.tsx","../../../catalog/react/AgentListTabs.tsx","../../../catalog/react/AgentRow.tsx","../../../catalog/react/AgentMobileSubView.tsx","../../../catalog/react/AgentSortPanel.tsx","../../../catalog/react/AgentTagsPanel.tsx","../../../catalog/react/AgentListInlinePicker.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * catalog/react/context.tsx — @ai-matrx/agents/catalog/react\n *\n * THE WEB BINDING of the one provider. Everything real — the context, the\n * store subscription, the port resolution — lives in `../shared/context`,\n * which the React Native entry reuses byte-for-byte (0.9.0). This file adds\n * only the three DOM defaults, so a web host that binds nothing still gets a\n * real `<a>`, a real navigation and real model text.\n *\n * `useAgentCatalog()` THROWS when no provider is mounted. A picker with no\n * catalogue is not a degraded picker, it is a lie on screen.\n */\n\nimport { useMemo, type ReactNode } from \"react\";\n\nimport {\n AgentCatalogProviderCore,\n type AgentCatalogLinkComponent,\n type AgentCatalogPlatformDefaults,\n type AgentCatalogRenderModelRef,\n type AgentCatalogUiPorts,\n} from \"../shared/context\";\nimport type { AgentCatalog } from \"../store\";\n\nexport {\n useAgentCatalog,\n useAgentCatalogRows,\n useAgentCatalogState,\n useAgentCatalogUiPorts,\n type AgentCatalogLinkComponent,\n type AgentCatalogPlatformDefaults,\n type AgentCatalogRenderModelRef,\n type AgentCatalogUiPorts,\n} from \"../shared/context\";\n\nexport interface AgentCatalogProviderProps extends AgentCatalogUiPorts {\n catalog: AgentCatalog;\n children: ReactNode;\n}\n\n/** The shipped web default: a real, working link in every framework. */\nconst DefaultLink: AgentCatalogLinkComponent = ({ children, ...props }) => (\n <a {...(props as Record<string, unknown>)}>{children}</a>\n);\n\nconst defaultRenderModelRef: AgentCatalogRenderModelRef = ({\n modelId,\n className,\n}) => <span className={className}>{modelId}</span>;\n\n/** The shipped web default: a real navigation. */\nconst webNavigate = (href: string): void => {\n if (typeof window !== \"undefined\") window.location.assign(href);\n};\n\nconst WEB_PLATFORM_DEFAULTS: AgentCatalogPlatformDefaults = {\n navigate: webNavigate,\n LinkComponent: DefaultLink,\n renderModelRef: defaultRenderModelRef,\n};\n\nexport function AgentCatalogProvider({\n catalog,\n children,\n ...ports\n}: AgentCatalogProviderProps) {\n const platform = useMemo(() => WEB_PLATFORM_DEFAULTS, []);\n return (\n <AgentCatalogProviderCore\n catalog={catalog}\n platform={platform}\n {...ports}\n >\n {children}\n </AgentCatalogProviderCore>\n );\n}\n","/**\n * catalog/shared/context.tsx — THE ONE React binding point, platform-neutral.\n *\n * 0.9.0 moved the provider, the context and the three subscription hooks OUT\n * of `catalog/react/context.tsx` and into this file so the React Native entry\n * (`@ai-matrx/agents/catalog/native`) reuses the SAME provider, the SAME store\n * subscription and the SAME hooks as the web picker. Only the VIEW layer, and\n * the three platform DEFAULTS below, differ between the two entries.\n *\n * 🚨 NOTHING IN THIS FILE MAY TOUCH THE DOM OR react-native. A default that\n * renders `<a>` is a web default and a default that renders `<Text>` is a\n * native default; both arrive through `platform`, which each entry's own\n * `AgentCatalogProvider` supplies. That is why `useAgentCatalogUiPorts()`\n * still answers with every default already applied on both platforms, and why\n * an unset port is never `undefined` on either.\n *\n * This file carries NO `\"use client\"` source directive on purpose: the stamp\n * is applied per BUILT ENTRY by tsup (the web entry gets it, the native entry\n * must not — React Native has no RSC and a stamped native module is a lie).\n */\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useSyncExternalStore,\n type ComponentType,\n type ReactNode,\n} from \"react\";\n\nimport type { AgentCatalog, AgentCatalogState } from \"../store\";\nimport type {\n AgentCatalogNavigate,\n AgentCatalogOpenPeek,\n} from \"../ports\";\nimport type { AgentSummary } from \"../types\";\n\n/**\n * The anchor a row renders for cmd/ctrl-click. DEFAULT (web): a plain `<a>` —\n * which is a REAL, working link in every framework. A Next.js host passes\n * `next/link`; a TanStack host passes its own `Link`. On React Native the\n * default is a pressable `Text` that routes through `navigate`.\n */\n/**\n * What a row's link handler receives. A DOM `React.MouseEvent` satisfies this\n * structurally, and the native default link supplies the two methods itself —\n * so a shared component can call `preventDefault()` on either platform\n * without a platform check.\n */\nexport interface AgentCatalogLinkClickEvent {\n metaKey?: boolean;\n ctrlKey?: boolean;\n preventDefault(): void;\n stopPropagation(): void;\n}\n\nexport type AgentCatalogLinkComponent = ComponentType<{\n href: string;\n className?: string;\n target?: string;\n rel?: string;\n title?: string;\n \"aria-label\"?: string;\n onClick?: (e: AgentCatalogLinkClickEvent) => void;\n children: ReactNode;\n}>;\n\n/**\n * Render a model id as whatever door the host has. DEFAULT: plain text.\n * `offeringId` is the agent's class pin when the row carries it (`null` = no\n * pin, the preferred class runs); ABSENT = unknown — name the model alone.\n */\nexport type AgentCatalogRenderModelRef = (args: {\n modelId: string;\n offeringId?: string | null;\n className?: string;\n}) => ReactNode;\n\nexport interface AgentCatalogUiPorts {\n /** DEFAULT (web): `window.location.assign`. DEFAULT (native): a reporting no-op. */\n navigate?: AgentCatalogNavigate;\n /** DEFAULT: a plain `<a>` (web) / a pressable `Text` (native). */\n LinkComponent?: AgentCatalogLinkComponent;\n /** DEFAULT: the model id as plain text. */\n renderModelRef?: AgentCatalogRenderModelRef;\n /** ABSENT: the sneak-peek affordance is HIDDEN — never a dead button. */\n openPeek?: AgentCatalogOpenPeek;\n /**\n * Portal container for the desktop popover, when the picker is mounted\n * inside a dialog. DEFAULT: the document body (Radix's own default).\n * Web only — the native entry ignores it.\n */\n popoverContainer?: HTMLElement | null;\n}\n\n/**\n * The three defaults a PLATFORM supplies. Never a host concern: a host\n * overrides an individual port through `AgentCatalogUiPorts`, and whatever it\n * leaves unset falls back to the platform's own working answer.\n */\nexport interface AgentCatalogPlatformDefaults {\n navigate: AgentCatalogNavigate;\n LinkComponent: AgentCatalogLinkComponent;\n renderModelRef: AgentCatalogRenderModelRef;\n}\n\ninterface AgentCatalogBinding extends AgentCatalogUiPorts {\n catalog: AgentCatalog;\n platform: AgentCatalogPlatformDefaults;\n}\n\nconst AgentCatalogContext = createContext<AgentCatalogBinding | null>(null);\n\nexport interface AgentCatalogProviderCoreProps extends AgentCatalogUiPorts {\n catalog: AgentCatalog;\n platform: AgentCatalogPlatformDefaults;\n children: ReactNode;\n}\n\n/**\n * The provider itself. Each entry wraps this with its own platform defaults\n * and re-exports it as `AgentCatalogProvider`; hosts never see this name.\n */\nexport function AgentCatalogProviderCore({\n catalog,\n platform,\n children,\n ...ports\n}: AgentCatalogProviderCoreProps) {\n const value = useMemo<AgentCatalogBinding>(\n () => ({ catalog, platform, ...ports }),\n // The ports are plain values a host declares once; re-binding on identity\n // change is correct and cheap.\n [\n catalog,\n platform,\n ports.navigate,\n ports.LinkComponent,\n ports.renderModelRef,\n ports.openPeek,\n ports.popoverContainer,\n ],\n );\n return (\n <AgentCatalogContext.Provider value={value}>\n {children}\n </AgentCatalogContext.Provider>\n );\n}\n\nfunction useBinding(): AgentCatalogBinding {\n const binding = useContext(AgentCatalogContext);\n if (!binding) {\n throw new Error(\n \"@ai-matrx/agents/catalog: no <AgentCatalogProvider> is mounted \" +\n \"above this component. Create the catalog once with \" +\n \"createAgentCatalog({ client, identity }) and mount \" +\n \"<AgentCatalogProvider catalog={catalog}> at the top of your tree.\",\n );\n }\n return binding;\n}\n\n/** The headless catalog this tree is bound to. Throws with no provider. */\nexport function useAgentCatalog(): AgentCatalog {\n return useBinding().catalog;\n}\n\n/** The UI ports this tree is bound to, with every default already applied. */\nexport function useAgentCatalogUiPorts(): Required<\n Pick<AgentCatalogUiPorts, \"navigate\" | \"LinkComponent\" | \"renderModelRef\">\n> & {\n openPeek: AgentCatalogOpenPeek | undefined;\n popoverContainer: HTMLElement | null | undefined;\n} {\n const binding = useBinding();\n const hostNavigate = binding.navigate;\n const platformNavigate = binding.platform.navigate;\n const navigate = useCallback<AgentCatalogNavigate>(\n (href) => {\n if (hostNavigate) {\n hostNavigate(href);\n return;\n }\n platformNavigate(href);\n },\n [hostNavigate, platformNavigate],\n );\n return {\n navigate,\n LinkComponent: binding.LinkComponent ?? binding.platform.LinkComponent,\n renderModelRef:\n binding.renderModelRef ?? binding.platform.renderModelRef,\n openPeek: binding.openPeek,\n popoverContainer: binding.popoverContainer,\n };\n}\n\n/**\n * Subscribe to a slice of catalog state. `useSyncExternalStore` because the\n * catalog is an external store and React 18/19 concurrency must not tear it.\n * `select` MUST return a stable reference for unchanged state — every\n * selector in `../selectors` does.\n */\nexport function useAgentCatalogState<T>(\n select: (state: AgentCatalogState) => T,\n): T {\n const catalog = useAgentCatalog();\n const getSnapshot = useCallback(\n () => select(catalog.getState()),\n [catalog, select],\n );\n return useSyncExternalStore(catalog.subscribe, getSnapshot, getSnapshot);\n}\n\n/** Every row currently in the catalogue, as one stable array. */\nexport function useAgentCatalogRows(): AgentSummary[] {\n return useAgentCatalogState(selectRows);\n}\n\nconst selectRows = (state: AgentCatalogState): AgentSummary[] => state.rows;\n","/**\n * catalog/shared/useAgentConsumer.ts — VERBATIM port of matrx-frontend\n * `features/agents/hooks/useAgentConsumer.ts`.\n *\n * Wraps a single consumer slot identified by `consumerId`. Registers the slot\n * on mount, optionally unregisters on unmount, and returns every filter/sort/\n * pagination value plus stable write helpers.\n *\n * Two seams inverted, nothing else:\n * - `useAppSelector`/`useAppDispatch` → `useAgentCatalog()` + the store's\n * own methods.\n * - `useServerAgentSearch` (a separate frontend hook) is folded IN, because\n * it was already wired here and nowhere else: EVERY agent surface that\n * uses a consumer searches the full server-side set. A local-only search\n * over a paginated list reports \"no results\" for agents that were merely\n * never fetched — a wrong answer, not a missing feature.\n */\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useAgentCatalog, useAgentCatalogState } from \"./context\";\nimport type {\n AgentAccessFilter,\n AgentArchFilter,\n AgentFavFilter,\n AgentSortOption,\n AgentTab,\n AgentConsumerPatch,\n AgentConsumerState,\n} from \"../types\";\nimport type { AgentCatalogState } from \"../store\";\n\nconst DEBOUNCE_MS = 250;\n\n/** Below this length a query matches too much to be worth a round trip. */\nconst MIN_QUERY_LENGTH = 2;\n\nexport interface UseAgentConsumerReturn {\n // ── Read ────────────────────────────────────────────────────────────────\n tab: AgentTab;\n sortBy: AgentSortOption;\n searchTerm: string;\n includedCats: string[];\n includedTags: string[];\n favFilter: AgentFavFilter;\n archFilter: AgentArchFilter;\n /**\n * The archive-filter state this catalog starts consumers in — the platform\n * default `\"active\"` unless the host set the knob. What \"not the default\n * state\" means on this surface, so the control and the footer can both say\n * it honestly.\n */\n archFilterDefault: AgentArchFilter;\n accessFilter: AgentAccessFilter;\n favoritesFirst: boolean;\n listPage: number;\n sharedPage: number;\n\n /** The whole slot, for the selectors that take a consumer state. */\n state: AgentConsumerState;\n\n /** True if any filter differs from its default value. */\n hasActiveFilters: boolean;\n\n /** Tier 2 search — also match against agent prompt content. */\n deepSearch: boolean;\n\n /** True while a server-side search is in flight. */\n isServerSearching: boolean;\n\n // ── Write ───────────────────────────────────────────────────────────────\n setSearchTerm: (value: string) => void;\n setDeepSearch: (value: boolean) => void;\n setSortBy: (value: AgentSortOption) => void;\n setTab: (value: AgentTab) => void;\n setFavFilter: (value: AgentFavFilter) => void;\n setArchFilter: (value: AgentArchFilter) => void;\n setAccessFilter: (value: AgentAccessFilter) => void;\n\n /** Add category to inclusion set; if already present, remove (toggle). */\n toggleCategory: (cat: string) => void;\n /** Add tag to inclusion set; if already present, remove (toggle). */\n toggleTag: (tag: string) => void;\n\n /**\n * Replace the WHOLE category inclusion set in one write.\n *\n * Prefer this over looping `toggleCategory` whenever more than one value\n * changes. Each `toggleCategory` call computes its next array from the\n * `includedCats` captured in the CURRENT render, so two toggles fired in the\n * same tick both start from the same snapshot and the second one's patch\n * overwrites the first — a \"Clear filter\" click with three categories active\n * removes only one. One write of the final set cannot drift that way.\n */\n setIncludedCats: (next: string[]) => void;\n /** Replace the WHOLE tag inclusion set in one write. See setIncludedCats. */\n setIncludedTags: (next: string[]) => void;\n\n toggleFavoritesFirst: () => void;\n\n loadMoreList: () => void;\n loadMoreShared: () => void;\n\n resetFilters: () => void;\n}\n\nexport function useAgentConsumer(\n consumerId: string,\n options?: {\n /** Delete the slot on unmount. Default false — persistent consumers keep state. */\n unregisterOnUnmount?: boolean;\n /** Applied only when the consumer is first registered (idempotent). */\n initialTab?: AgentTab;\n /**\n * THE ARCHIVED-ITEMS LAW's per-consumer override of the catalog-wide\n * `defaults.archiveFilter` knob. Applied only at first registration — the\n * state belongs to the person after that.\n */\n initialArchFilter?: AgentArchFilter;\n },\n): UseAgentConsumerReturn {\n const catalog = useAgentCatalog();\n const defaults = catalog.consumerDefaults;\n const selectConsumer = useCallback(\n (state: AgentCatalogState): AgentConsumerState =>\n state.consumers[consumerId] ?? defaults,\n [consumerId, defaults],\n );\n const consumer = useAgentCatalogState(selectConsumer);\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n useEffect(() => {\n const opts = optionsRef.current;\n const initial: AgentConsumerPatch = {\n ...(opts?.initialTab ? { tab: opts.initialTab } : {}),\n ...(opts?.initialArchFilter\n ? { archFilter: opts.initialArchFilter }\n : {}),\n };\n catalog.registerConsumer(\n consumerId,\n Object.keys(initial).length > 0 ? initial : undefined,\n );\n return () => {\n if (optionsRef.current?.unregisterOnUnmount) {\n catalog.unregisterConsumer(consumerId);\n }\n };\n }, [consumerId, catalog]);\n\n // ── Write helpers (stable references) ───────────────────────────────────\n\n const setSearchTerm = useCallback(\n (value: string) => catalog.setConsumerFilter(consumerId, { searchTerm: value }),\n [consumerId, catalog],\n );\n const setDeepSearch = useCallback(\n (value: boolean) => catalog.setConsumerFilter(consumerId, { deepSearch: value }),\n [consumerId, catalog],\n );\n const setSortBy = useCallback(\n (value: AgentSortOption) =>\n catalog.setConsumerFilter(consumerId, { sortBy: value }),\n [consumerId, catalog],\n );\n const setTab = useCallback(\n (value: AgentTab) => catalog.setConsumerFilter(consumerId, { tab: value }),\n [consumerId, catalog],\n );\n const setFavFilter = useCallback(\n (value: AgentFavFilter) =>\n catalog.setConsumerFilter(consumerId, { favFilter: value }),\n [consumerId, catalog],\n );\n const setArchFilter = useCallback(\n (value: AgentArchFilter) =>\n catalog.setConsumerFilter(consumerId, { archFilter: value }),\n [consumerId, catalog],\n );\n const setAccessFilter = useCallback(\n (value: AgentAccessFilter) =>\n catalog.setConsumerFilter(consumerId, { accessFilter: value }),\n [consumerId, catalog],\n );\n\n const toggleCategory = useCallback(\n (cat: string) => {\n const current = catalog.getConsumer(consumerId).includedCats;\n const next = current.includes(cat)\n ? current.filter((c) => c !== cat)\n : [...current, cat];\n catalog.setConsumerFilter(consumerId, { includedCats: next });\n },\n [consumerId, catalog],\n );\n\n const toggleTag = useCallback(\n (tag: string) => {\n const current = catalog.getConsumer(consumerId).includedTags;\n const next = current.includes(tag)\n ? current.filter((t) => t !== tag)\n : [...current, tag];\n catalog.setConsumerFilter(consumerId, { includedTags: next });\n },\n [consumerId, catalog],\n );\n\n const setIncludedCats = useCallback(\n (next: string[]) => catalog.setConsumerFilter(consumerId, { includedCats: next }),\n [consumerId, catalog],\n );\n const setIncludedTags = useCallback(\n (next: string[]) => catalog.setConsumerFilter(consumerId, { includedTags: next }),\n [consumerId, catalog],\n );\n\n const toggleFavoritesFirst = useCallback(\n () =>\n catalog.setConsumerFilter(consumerId, {\n favoritesFirst: !catalog.getConsumer(consumerId).favoritesFirst,\n }),\n [consumerId, catalog],\n );\n\n const loadMoreList = useCallback(\n () =>\n catalog.setConsumerPage(\n consumerId,\n \"list\",\n catalog.getConsumer(consumerId).listPage + 1,\n ),\n [consumerId, catalog],\n );\n const loadMoreShared = useCallback(\n () =>\n catalog.setConsumerPage(\n consumerId,\n \"shared\",\n catalog.getConsumer(consumerId).sharedPage + 1,\n ),\n [consumerId, catalog],\n );\n\n const resetFilters = useCallback(\n () => catalog.resetConsumerFilters(consumerId),\n [consumerId, catalog],\n );\n\n // ── Server-side search (folded in — see the file header) ────────────────\n //\n // Debounced, and stale responses are ignored so a slow reply for an old\n // query can never land after a newer one. Purely additive: local matches\n // keep rendering the whole time; server results merge in and simply appear.\n\n const [isSearching, setIsSearching] = useState(false);\n const [matchedIds, setMatchedIds] = useState<string[] | null>(null);\n const requestSeq = useRef(0);\n const query = consumer.searchTerm;\n const deep = consumer.deepSearch;\n\n useEffect(() => {\n const q = query.trim();\n if (q.length < MIN_QUERY_LENGTH) {\n setIsSearching(false);\n setMatchedIds(null);\n return undefined;\n }\n\n const seq = ++requestSeq.current;\n setIsSearching(true);\n\n const timer = setTimeout(() => {\n void catalog\n .searchServer(q, deep)\n .then((ids) => {\n if (seq !== requestSeq.current) return; // superseded\n setMatchedIds(ids);\n setIsSearching(false);\n })\n .catch((e: unknown) => {\n if (seq !== requestSeq.current) return; // superseded\n // Loud, but never destructive: local results stay on screen.\n catalog.errorSink({\n code: \"server_search_failed\",\n message: `agent search failed: ${e instanceof Error ? e.message : String(e)}`,\n context: { query: q, deep },\n });\n setIsSearching(false);\n });\n }, DEBOUNCE_MS);\n\n return () => clearTimeout(timer);\n }, [query, deep, catalog]);\n\n useEffect(() => {\n catalog.setConsumerServerSearch(consumerId, {\n matchedIds: matchedIds ?? [],\n isSearching,\n });\n }, [consumerId, catalog, matchedIds, isSearching]);\n\n // ── hasActiveFilters (verbatim) ─────────────────────────────────────────\n const hasActiveFilters =\n consumer.searchTerm !== \"\" ||\n consumer.includedCats.length > 0 ||\n consumer.includedTags.length > 0 ||\n consumer.favFilter !== \"all\" ||\n // The archive filter is compared to THIS CATALOG'S default, not to the\n // hardcoded platform one: a host that legitimately defaults to \"show all\"\n // must not have the reset control permanently lit.\n consumer.archFilter !== defaults.archFilter ||\n consumer.accessFilter !== \"any\" ||\n !consumer.favoritesFirst;\n\n return {\n tab: consumer.tab,\n sortBy: consumer.sortBy,\n searchTerm: consumer.searchTerm,\n includedCats: consumer.includedCats,\n includedTags: consumer.includedTags,\n favFilter: consumer.favFilter,\n archFilter: consumer.archFilter,\n archFilterDefault: defaults.archFilter,\n accessFilter: consumer.accessFilter,\n favoritesFirst: consumer.favoritesFirst,\n listPage: consumer.listPage,\n sharedPage: consumer.sharedPage,\n state: consumer,\n hasActiveFilters,\n deepSearch: consumer.deepSearch,\n isServerSearching: consumer.isServerSearching,\n setSearchTerm,\n setDeepSearch,\n setSortBy,\n setTab,\n setFavFilter,\n setArchFilter,\n setAccessFilter,\n toggleCategory,\n toggleTag,\n setIncludedCats,\n setIncludedTags,\n toggleFavoritesFirst,\n loadMoreList,\n loadMoreShared,\n resetFilters,\n };\n}\n","/**\n * catalog/shared/useAgentListCore.ts — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/useAgentListCore.ts`.\n *\n * Seams inverted:\n * - Redux (`useAppSelector`/`useAppDispatch`/`createSelector`) → the catalog\n * store and the plain memoized selectors in `../selectors`.\n * - `useRouter().push` → the `navigate` port (default `window.location.assign`).\n *\n * TWO BEHAVIOURAL DELTAS, recorded in the CHANGELOG rather than hidden:\n * 1. There is no app-wide \"active agent\" store in this package (that is host\n * state by ruling D1 — the picker's contract is `onSelect(agentId)`), so\n * the pinned row comes from the `activeAgentId` PROP alone. The\n * frontend's fallback to a Redux `activeAgentId` has no package twin.\n * 2. For the same reason, a call site that passes NEITHER `onSelect` NOR\n * `navigateTo` gets a loud `errorSink` report instead of the frontend's\n * `dispatch(setActiveAgentId(...))`. A click that does nothing silently\n * is the exact failure this package exists to stop.\n */\n\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { useAgentCatalog, useAgentCatalogRows, useAgentCatalogState, useAgentCatalogUiPorts } from \"./context\";\nimport { useAgentConsumer } from \"./useAgentConsumer\";\nimport { agentListFooterLabel, shouldDefaultAgentListToPublicTab } from \"../labels\";\nimport {\n makeSelectFilteredAgents,\n selectAllAgentCategories,\n selectAllAgentTags,\n selectAllSystemAgentCategories,\n selectAllSystemAgentTags,\n selectAgentTabCounts,\n} from \"../selectors\";\nimport type { AgentCatalogState } from \"../store\";\nimport type { DefaultRowState } from \"../default-row-types\";\nimport type { AgentArchFilter, AgentSummary, AgentTab } from \"../types\";\n\n/**\n * The four ownership counts a tab strip prints. Declared HERE, beside the code\n * that computes them, so both the web tab strip and the native one name the\n * same shape (0.9.0 — it used to live in the web-only `AgentListTabs`).\n *\n * 🚨 These are the numbers on the BADGES, and since 0.9.1 they count exactly\n * the rows the tab renders under the consumer's own archive filter. A badge\n * that counted rows the list hid was the screen telling the user something\n * untrue about her own agents.\n */\nexport interface AgentListTabCounts {\n mine: number;\n shared: number;\n all: number;\n system: number;\n}\n\nexport interface AgentListCoreOptions {\n consumerId: string;\n onSelect?: (agentId: string) => void;\n navigateTo?: string;\n /** Route-scoped agent id (chat/builder headers). `undefined` = nothing pinned. */\n activeAgentIdOverride?: string | null;\n /**\n * Tab this surface opens on, applied once on first mount. Admin surfaces\n * that manage system agents pass `\"system\"`. When omitted the normal\n * user heuristic applies (a user with no agents of their own lands on the\n * public/system catalogue).\n */\n initialTab?: AgentTab;\n /**\n * ADMIN reading of the \"All\" tab: blend system agents into it instead of\n * keeping them to their own tab. See `makeSelectFilteredAgents`.\n */\n includeSystemInAll?: boolean;\n /**\n * 🚨 THE OWNERSHIP TABS THIS CALL SITE MAY REACH — a HARD restriction, not a\n * default.\n *\n * `AgentListTabs` already hides the buttons this list omits, but hiding a\n * button never emptied the list behind it: the active tab lives in the\n * consumer's REMEMBERED state, and `initialTab` is applied exactly once per\n * mount (`defaultTabAppliedRef`). So a person who had been on \"Mine\" and\n * then moved a control that narrows the picker got the personal catalogue\n * with the tab bar removed — the forbidden list, and no way to see that it\n * was forbidden. That is the defect Arman named on the mandate binding\n * screen's global rung (VISION-RECONCILIATION D2, 2026-08-31: the picker\n * opened on \"Mine · 40\").\n *\n * Given here, the tab is COERCED into the allowed set on every change of it,\n * not just at mount — so a restriction that arrives later is enforced later.\n */\n visibleTabs?: readonly AgentTab[];\n /**\n * THE ARCHIVED-ITEMS LAW's per-consumer override of the catalog-wide\n * `defaults.archiveFilter` knob, applied once at first registration. Almost\n * nothing should pass it: the platform answer is \"hide archived\", and the\n * person reveals the archive from the control on the filter bar.\n */\n initialArchFilter?: AgentArchFilter;\n /** Hide records that are invalid for this call site. */\n excludeAgentIds?: readonly string[];\n /**\n * Show the platform DEFAULT agent for this mandate key at the top of the\n * list, resolved live through the server (never a hardcoded name). Requires\n * the catalog to have been built with a `transport`.\n */\n defaultMandateKey?: string;\n}\n\n/**\n * How long the hover-preview detail panel stays open after the cursor leaves\n * an agent row (or the panel itself) before it closes. Generous on purpose:\n * the panel renders to the side of the list, so the user needs ample time to\n * travel the cursor across the gap to reach it without it vanishing. Paired\n * with a reserved, non-resizing popover width so the target never moves.\n */\nexport const HOVER_GRACE_MS = 900;\n\n/**\n * THE RULE, ALONE AND TESTABLE: which tab a restricted picker must land on.\n *\n * Returns `null` when the current tab is already allowed (nothing to do), and\n * otherwise the tab to switch to — `initialTab` when that is itself allowed,\n * else the first allowed tab.\n */\nexport function coerceVisibleTab(\n current: AgentTab,\n allowed: readonly AgentTab[],\n initialTab?: AgentTab,\n): AgentTab | null {\n if (allowed.length === 0) return null;\n if (allowed.includes(current)) return null;\n return initialTab && allowed.includes(initialTab)\n ? initialTab\n : (allowed[0] ?? null);\n}\n\nconst EMPTY_EXCLUDES: readonly string[] = [];\n\nexport function useAgentListCore({\n consumerId,\n onSelect,\n navigateTo,\n activeAgentIdOverride,\n initialTab,\n includeSystemInAll = false,\n visibleTabs,\n initialArchFilter,\n excludeAgentIds = EMPTY_EXCLUDES,\n defaultMandateKey,\n}: AgentListCoreOptions) {\n const catalog = useAgentCatalog();\n const { navigate } = useAgentCatalogUiPorts();\n\n const hasFetchedRef = useRef(false);\n const [hoveredAgent, setHoveredAgent] = useState<AgentSummary | null>(null);\n const hoverLeaveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const defaultTabAppliedRef = useRef(false);\n\n const consumer = useAgentConsumer(consumerId, {\n unregisterOnUnmount: true,\n ...(initialArchFilter ? { initialArchFilter } : {}),\n });\n const rows = useAgentCatalogRows();\n const userId = catalog.getUserIdOrNull();\n const tabCountsForFilter = selectAgentTabCounts(rows, consumer.state.archFilter);\n const ownedCount = tabCountsForFilter.mine;\n\n const selectFiltered = useMemo(\n () => makeSelectFilteredAgents(includeSystemInAll),\n [includeSystemInAll],\n );\n const filteredAgents = selectFiltered(rows, consumer.state);\n const excludedAgentIds = useMemo(\n () => new Set(excludeAgentIds),\n [excludeAgentIds],\n );\n const applyExcludes = useCallback(\n (list: AgentSummary[]): AgentSummary[] =>\n excludedAgentIds.size === 0\n ? list\n : list.filter((agent) => !excludedAgentIds.has(agent.id)),\n [excludedAgentIds],\n );\n const agents = applyExcludes(filteredAgents);\n\n // ── THE ARCHIVE PROBE — what the default state is keeping off the screen ──\n //\n // Clause 2 of THE ARCHIVED-ITEMS LAW: a footer counts what the list renders\n // and never implies the list is everything. So while archived rows are\n // hidden we also measure how many there ARE behind this exact tab, search,\n // category and tag selection — the same pipeline, one value changed — and\n // the footer says so. A second memoized selector instance keeps this off\n // the main one's memo slot, so the two never evict each other.\n const selectArchivedProbe = useMemo(\n () => makeSelectFilteredAgents(includeSystemInAll),\n [includeSystemInAll],\n );\n const archiveProbeState = useMemo(\n () => ({ ...consumer.state, archFilter: \"archived\" as const }),\n [consumer.state],\n );\n const archivedHiddenCount =\n consumer.archFilter === \"active\"\n ? applyExcludes(selectArchivedProbe(rows, archiveProbeState)).length\n : 0;\n\n const status = useAgentCatalogState(selectStatus);\n // `null` is an intentional \"nothing selected\" value for assignment\n // dropdowns. There is no app-wide active agent in this package (D1) — the\n // pinned row is whatever the host passes and nothing else.\n const activeAgentId = activeAgentIdOverride ?? null;\n const pinnedAgent = activeAgentId ? catalog.getAgent(activeAgentId) : undefined;\n\n // Category/tag options follow the ACTIVE TAB's population: user agents on\n // mine/shared/all, builtins on system. Same controls either way.\n const onSystemTab = consumer.tab === \"system\";\n const allCategories = onSystemTab\n ? selectAllSystemAgentCategories(rows)\n : selectAllAgentCategories(rows);\n const allTags = onSystemTab\n ? selectAllSystemAgentTags(rows)\n : selectAllAgentTags(rows);\n\n const tabCounts: AgentListTabCounts = tabCountsForFilter;\n\n const isLoading = status === \"loading\";\n const agentsLoaded = status === \"succeeded\" || status === \"failed\";\n\n const ensureLoaded = useCallback(() => {\n if (!hasFetchedRef.current) {\n hasFetchedRef.current = true;\n void catalog.ensureLoaded().catch(() => {\n // Already reported through the errorSink and reflected in `status`;\n // this catch only stops an unhandled rejection.\n });\n }\n }, [catalog]);\n\n // ── The mandate default row ─────────────────────────────────────────────\n const selectDefaultRow = useCallback(\n (state: AgentCatalogState): DefaultRowState | undefined =>\n defaultMandateKey ? state.defaultRows[defaultMandateKey] : undefined,\n [defaultMandateKey],\n );\n const defaultRow = useAgentCatalogState(selectDefaultRow);\n useEffect(() => {\n if (!defaultMandateKey) return;\n catalog.ensureDefaultRow(defaultMandateKey);\n }, [catalog, defaultMandateKey]);\n\n useEffect(() => {\n if (defaultTabAppliedRef.current) return;\n\n // An explicit surface default wins over the heuristic below, but only\n // once — after that the tab belongs to the user.\n if (initialTab) {\n defaultTabAppliedRef.current = true;\n if (consumer.tab !== initialTab) consumer.setTab(initialTab);\n return;\n }\n\n if (consumer.tab !== \"mine\") {\n defaultTabAppliedRef.current = true;\n return;\n }\n\n const wantsPublic = shouldDefaultAgentListToPublicTab({\n userId,\n ownedCount,\n agentsLoaded,\n });\n\n if (!wantsPublic) {\n if (!userId || agentsLoaded) {\n defaultTabAppliedRef.current = true;\n }\n return;\n }\n\n consumer.setTab(\"system\");\n defaultTabAppliedRef.current = true;\n }, [\n userId,\n ownedCount,\n agentsLoaded,\n initialTab,\n consumer.tab,\n consumer.setTab,\n ]);\n\n // 🚨 THE RESTRICTION IS ENFORCED, NOT DECORATED. A hidden tab whose rows are\n // still the ones being listed is worse than an offered one: the person sees a\n // catalogue this call site forbids and no control that explains why. The tab\n // is therefore coerced into the allowed set whenever it falls outside it —\n // including long after mount, when a control elsewhere on the page narrows\n // what this picker may reach. Keyed by the joined list so an inline array\n // literal does not re-fire this every render.\n const allowedTabsKey = visibleTabs ? visibleTabs.join(\",\") : \"\";\n useEffect(() => {\n if (!allowedTabsKey) return;\n const next = coerceVisibleTab(\n consumer.tab,\n allowedTabsKey.split(\",\") as AgentTab[],\n initialTab,\n );\n if (next) consumer.setTab(next);\n }, [allowedTabsKey, initialTab, consumer.tab, consumer.setTab]);\n\n useEffect(() => {\n ensureLoaded();\n }, [ensureLoaded]);\n\n const handleSelectAgent = useCallback(\n (agent: AgentSummary) => {\n if (onSelect) {\n onSelect(agent.id);\n } else if (navigateTo) {\n navigate(navigateTo.replace(\"{id}\", agent.id));\n } else {\n // Never a silent no-op — see the file header's delta 2.\n catalog.errorSink({\n code: \"select_has_nowhere_to_go\",\n message:\n \"an agent was chosen but this picker was given neither onSelect \" +\n \"nor navigateTo, so the choice went nowhere.\",\n context: { consumerId, agentId: agent.id },\n });\n }\n },\n [onSelect, navigateTo, navigate, catalog, consumerId],\n );\n\n const activeFilterCount =\n (consumer.sortBy !== \"updated-desc\" ? 1 : 0) +\n (consumer.includedCats.length > 0 ? 1 : 0) +\n (consumer.includedTags.length > 0 ? 1 : 0) +\n (consumer.favFilter !== \"all\" ? 1 : 0) +\n // The archive filter counts like every other filter, so a list showing\n // archived rows offers the reset control that puts them away again.\n (consumer.archFilter !== consumer.archFilterDefault ? 1 : 0);\n\n const handleAgentHover = useCallback(\n (agent: AgentSummary, panelOpen: boolean) => {\n if (panelOpen) return;\n if (hoverLeaveTimerRef.current) {\n clearTimeout(hoverLeaveTimerRef.current);\n hoverLeaveTimerRef.current = null;\n }\n setHoveredAgent(agent);\n },\n [],\n );\n\n const handleAgentHoverEnd = useCallback(\n (agent: AgentSummary, onClear: () => void) => {\n if (hoveredAgent?.id === agent.id) {\n hoverLeaveTimerRef.current = setTimeout(() => {\n setHoveredAgent(null);\n onClear();\n }, HOVER_GRACE_MS);\n }\n },\n [hoveredAgent],\n );\n\n const handleDetailPanelMouseEnter = useCallback(() => {\n if (hoverLeaveTimerRef.current) {\n clearTimeout(hoverLeaveTimerRef.current);\n hoverLeaveTimerRef.current = null;\n }\n }, []);\n\n const handleDetailPanelMouseLeave = useCallback((onClear: () => void) => {\n hoverLeaveTimerRef.current = setTimeout(() => {\n setHoveredAgent(null);\n onClear();\n }, HOVER_GRACE_MS);\n }, []);\n\n useEffect(\n () => () => {\n if (hoverLeaveTimerRef.current) clearTimeout(hoverLeaveTimerRef.current);\n },\n [],\n );\n\n /**\n * The footer's words, computed once from the numbers the list actually\n * rendered — identical on web and native because neither shell formats it\n * itself. See `agentListFooterLabel`.\n */\n const footerLabel = agentListFooterLabel({\n count: agents.length,\n archFilter: consumer.archFilter,\n archivedHiddenCount,\n });\n\n return {\n agents,\n archivedHiddenCount,\n footerLabel,\n isLoading,\n activeAgentId,\n pinnedAgent: pinnedAgent ?? null,\n defaultRow: defaultRow ?? null,\n allCategories,\n allTags,\n consumer,\n tabCounts,\n activeFilterCount,\n hoveredAgent,\n setHoveredAgent,\n ensureLoaded,\n handleSelectAgent,\n handleAgentHover,\n handleAgentHoverEnd,\n handleDetailPanelMouseEnter,\n handleDetailPanelMouseLeave,\n };\n}\n\nconst selectStatus = (state: AgentCatalogState) => state.status;\n","/**\n * `@ai-matrx/agents/catalog` — the row shape and the per-consumer view state.\n *\n * `AgentSummary` is the 19-column row `agx_get_list_full()` returns, camelCased.\n * It is deliberately NOT the editable agent record: dirty tracking, undo,\n * messages, tools and `_fetchStatus` stay in whichever host owns the editor.\n * A list row is a list row.\n *\n * The view-state types are a VERBATIM port of matrx-frontend\n * `features/agents/redux/agent-consumers/slice.ts` — only the coupling seam\n * inverts (Redux reducers become store actions in `./store`).\n */\n\n/**\n * A branded agent id. Every id that reaches `onSelect` is one of these:\n * either a `agent.definition` UUID, or the `mandate:<key>` reference a\n * default row carries (byte-identical to the ref shape matrx-extend\n * `src/lib/mandates.ts` and matrx-local `desktop/src/lib/mandates.ts`\n * already hand back to their hosts).\n *\n * 🚨 The brand is a STRING LITERAL, never `unique symbol`. This package emits\n * `./catalog` and `./catalog/react` as two separate bundles, so each `.d.ts`\n * carries its own copy of these declarations. A `unique symbol` brand is\n * NOMINAL: two copies of it are unrelated types, so `createAgentCatalog()`\n * from `./catalog` was not assignable to `<AgentCatalogProvider catalog=…>`\n * from `./catalog/react` — the exact two-import wiring the README, the\n * CHANGELOG and every consumer use. A literal brand is structural, so the two\n * copies unify, while a bare `string` still cannot be passed where an\n * `AgentId` is required (which is the whole point of branding). Any future\n * brand in this package follows the same rule.\n */\nexport type AgentId = string & { readonly __agentId: \"ai-matrx.agent-id\" };\n\n/** Brand a raw string as an `AgentId`. */\nexport function asAgentId(value: string): AgentId {\n return value as AgentId;\n}\n\n/** The `mandate:<key>` ref shape every client already speaks. */\nexport function mandateAgentId(mandateKey: string): AgentId {\n return `mandate:${mandateKey}` as AgentId;\n}\n\n/** True when an id is a mandate default row rather than a stored agent. */\nexport function isMandateAgentId(id: string): boolean {\n return id.startsWith(\"mandate:\");\n}\n\n/** `agent_type` verbatim. Only `builtin` changes how a row is grouped. */\nexport type AgentCatalogAgentType = \"user\" | \"builtin\";\n\n/**\n * `access_level` verbatim from `agx_get_list_full`. Widened over the raw\n * string because it is a DB-owned vocabulary: an unknown level renders as\n * itself rather than being coerced into a wrong one.\n */\nexport type AgentAccessLevel =\n | \"owner\"\n | \"admin\"\n | \"editor\"\n | \"viewer\"\n | \"system\"\n | (string & {});\n\n/**\n * Present on a catalog row ONLY when that agent is an **Orchestra** — a\n * conductor that delegates to member agents at run time. Choosing one for a\n * step, a chat or a workflow node runs the whole ensemble, so a person has to\n * be able to SEE that before choosing, not discover it from the run.\n *\n * The DB decides. `agx_get_list_full` / `agx_get_list` / `agx_search` build\n * this from `platform.associations` (the conductor self-edge plus its member\n * edges) in one `agx_orchestra_badges()` join — never a second fetch, and\n * never a per-row read. `null` for every ordinary agent.\n *\n * History: the badge lived only in the Python `GET /agents` route, so every\n * client lost it when the pickers moved to the RPC. It is a ROW FIELD now, in\n * the one read every client shares.\n */\nexport interface OrchestraBadge {\n /** How the ensemble runs: `supervisor` | `sequential` | `parallel` | `dag`, or a future mode verbatim. */\n mode: string;\n /** The composition's one-line description, when its author wrote one. */\n tagline: string | null;\n /**\n * The per-composition delegation-depth budget AS DECLARED, or `null` when\n * the composition declares none. Deliberately NOT defaulted here: the\n * platform's fallback ceiling is enforced by the server that runs the\n * ensemble, and a badge that invented a number would be reporting a promise\n * nobody made.\n */\n depthBudget: number | null;\n /** Member edges. From the ROW count, so an unlabelled ensemble still counts. */\n memberCount: number;\n /** Only REAL role titles — an ensemble with unlabelled edges yields `[]`. */\n memberTitles: string[];\n}\n\n/**\n * One `agx_get_list_full()` row, camelCased. Nineteen columns, no more:\n * anything richer needs a different read and is a different type.\n */\nexport interface AgentSummary {\n id: AgentId;\n name: string | null;\n description: string | null;\n category: string | null;\n tags: string[];\n agentType: AgentCatalogAgentType;\n modelId: string | null;\n /**\n * The agent's CLASS pin (`settings.offering_id` — which serving class of\n * the model runs, e.g. \"Matrx Lightning\"). `null` = no pin (the model's\n * preferred class runs). ABSENT = the read did not carry the column, so the\n * class is unknown and a display must name the model alone.\n */\n offeringId?: string | null;\n isActive: boolean;\n isArchived: boolean;\n isFavorite: boolean;\n createdBy: string | null;\n organizationId: string | null;\n taskId: string | null;\n sourceAgentId: string | null;\n createdAt: string | null;\n updatedAt: string | null;\n // Access metadata\n isOwner: boolean | null;\n accessLevel: AgentAccessLevel | null;\n sharedByEmail: string | null;\n /**\n * The Orchestra badge, or `null` for an ordinary agent. Strict: every row\n * carries the key, so a surface reads `agent.orchestra` and never has to ask\n * whether the column existed.\n */\n orchestra: OrchestraBadge | null;\n /**\n * Set only on a mandate default row — the key it resolved through, so a\n * host can tell \"the default\" from a stored agent without parsing the id.\n */\n mandateKey?: string;\n}\n\n// ── Per-consumer view state (verbatim port of the agent-consumers slice) ─────\n\nexport type AgentSortOption =\n | \"updated-desc\"\n | \"created-desc\"\n | \"name-asc\"\n | \"name-desc\"\n | \"category-asc\";\n\n/**\n * The sort choices a picker offers, in order. PURE DATA, so it lives in the\n * pure entry: a server-reachable manifest reads it at module scope, and\n * importing it from the client-stamped `./catalog/react` bundle dragged React\n * into a server graph for the sake of five string pairs. `./catalog/react`\n * re-exports it unchanged, so no consumer has to move.\n *\n * (Written \"client-stamped\", never with the literal directive: this comment is\n * emitted into `dist/catalog/index.d.ts`, and the tarball canary rightly\n * refuses that directive anywhere in a PURE entry.)\n */\nexport const SORT_OPTIONS: { value: AgentSortOption; label: string }[] = [\n { value: \"updated-desc\", label: \"Recent\" },\n { value: \"created-desc\", label: \"Created\" },\n { value: \"name-asc\", label: \"A → Z\" },\n { value: \"name-desc\", label: \"Z → A\" },\n { value: \"category-asc\", label: \"Category\" },\n];\n\n/** Which ownership tab is active in the agent list. */\nexport type AgentTab = \"mine\" | \"shared\" | \"all\" | \"system\";\n\n/** Favorite filter. */\nexport type AgentFavFilter = \"all\" | \"yes\" | \"no\";\n\n/**\n * The archive filter — THE ARCHIVED-ITEMS LAW's ONE control, in this\n * package's existing vocabulary.\n *\n * > \"everything should have an archive filter, and the default should always\n * > hide archived, but seeing archived items should be one or two clicks\n * > away.\" — Arman, 2026-09-09 (`common-docs/policies/archived-items.md`)\n *\n * Three states and no more, identical for every entity on the platform:\n *\n * | value | the platform's words | what the list shows |\n * |------------|----------------------|--------------------------|\n * | `active` | hide archived | only un-archived rows |\n * | `both` | show all | every row |\n * | `archived` | archived only | only archived rows |\n *\n * `active` is the platform default, and it is a KNOB — see\n * `AgentCatalogConfig.defaults.archiveFilter`.\n */\nexport type AgentArchFilter = \"active\" | \"archived\" | \"both\";\n\n/** Every legal archive-filter value, in the order the control cycles them. */\nexport const ARCHIVE_FILTER_ORDER: readonly AgentArchFilter[] = [\n \"active\",\n \"both\",\n \"archived\",\n];\n\nexport interface AgentArchFilterOption {\n value: AgentArchFilter;\n /** The platform's own words for the state — what a menu row would read. */\n label: string;\n /** What the filter-bar chip reads while this state is the active one. */\n chip: string;\n}\n\n/**\n * 🚨 ONE CONTROL, THREE STATES, SAME WORDS EVERYWHERE. A surface that invents\n * its own archive vocabulary breaks clause 3 of the law (\"the same primitive\n * everywhere … not a per-feature invention\").\n */\nexport const ARCHIVE_FILTER_OPTIONS: readonly AgentArchFilterOption[] = [\n { value: \"active\", label: \"Hide archived\", chip: \"Archive\" },\n { value: \"both\", label: \"Show all\", chip: \"All + archived\" },\n { value: \"archived\", label: \"Archived only\", chip: \"Archived only\" },\n];\n\n/**\n * The next state of the cycling control: hide archived → show all → archived\n * only → hide archived. Pure, so the web chip and the native chip cannot\n * drift apart, and so \"the control reveals archived rows in ONE action\" is a\n * testable claim rather than a UI opinion.\n */\nexport function nextArchFilter(current: AgentArchFilter): AgentArchFilter {\n const index = ARCHIVE_FILTER_ORDER.indexOf(current);\n if (index < 0) return ARCHIVE_FILTER_ORDER[0] as AgentArchFilter;\n return ARCHIVE_FILTER_ORDER[\n (index + 1) % ARCHIVE_FILTER_ORDER.length\n ] as AgentArchFilter;\n}\n\n/** True when `value` is one of the three legal states. */\nexport function isAgentArchFilter(value: unknown): value is AgentArchFilter {\n return value === \"active\" || value === \"archived\" || value === \"both\";\n}\n\n/**\n * Access level filter.\n * 'any' = no restriction (default).\n * 'owned' = only agents the user owns (isOwner = true).\n * 'shared' = only agents shared with the user (isOwner = false).\n * 'editable' = owner + admin + editor.\n */\nexport type AgentAccessFilter = \"any\" | \"owned\" | \"shared\" | \"editable\";\n\n/** Sentinel meaning \"include uncategorized / untagged\" items. */\nexport const AGENT_NONE_SENTINEL = \"__none__\";\n\nexport interface AgentConsumerState {\n tab: AgentTab;\n sortBy: AgentSortOption;\n searchTerm: string;\n\n /** INCLUSION model: empty = show all; non-empty = only matching. */\n includedCats: string[];\n\n /** INCLUSION model: empty = show all; non-empty = only matching. */\n includedTags: string[];\n\n favFilter: AgentFavFilter;\n archFilter: AgentArchFilter;\n accessFilter: AgentAccessFilter;\n favoritesFirst: boolean;\n\n /** Current page for owned-agent list items (after the card section). */\n listPage: number;\n\n /** Current page for shared-agent list items. */\n sharedPage: number;\n\n /**\n * Ids returned by the last server-side search (`agx_search`), in server rank\n * order. Additive: an agent in this list survives the search filter even\n * when the local scorer gives it 0.\n *\n * That is load-bearing for tier 2. A deep search matches an agent's prompt\n * content, which the client never loads — so the local scorer cannot see it.\n * Without this list the server would return prompt matches and the UI would\n * immediately filter them back out.\n *\n * Server-only matches sort BELOW every locally-scored match, in server rank\n * order, so obvious matches always come first.\n */\n serverMatchedIds: string[];\n\n /** True while a server search is in flight — drives the search spinner. */\n isServerSearching: boolean;\n\n /** Tier 2: also search agent prompt content. Opt-in, per consumer. */\n deepSearch: boolean;\n}\n\nexport const DEFAULT_AGENT_CONSUMER_STATE: AgentConsumerState = {\n tab: \"mine\",\n sortBy: \"updated-desc\",\n searchTerm: \"\",\n includedCats: [],\n includedTags: [],\n favFilter: \"all\",\n archFilter: \"active\",\n accessFilter: \"any\",\n favoritesFirst: true,\n listPage: 1,\n sharedPage: 1,\n serverMatchedIds: [],\n isServerSearching: false,\n deepSearch: false,\n};\n\n/** The subset of consumer state a caller may patch (paging is derived). */\nexport type AgentConsumerPatch = Partial<\n Omit<AgentConsumerState, \"listPage\" | \"sharedPage\">\n>;\n\n// ── Loud configuration failure ───────────────────────────────────────────────\n\n/**\n * Thrown by `createAgentCatalog` when a REQUIRED port is missing or an\n * optional feature was asked for without the port it needs. Never a warning,\n * never a degraded catalog: a picker that cannot read is not a picker.\n */\nexport class AgentCatalogConfigError extends Error {\n override readonly name = \"AgentCatalogConfigError\";\n /** Machine code, for a host that routes config failures. */\n readonly code: string;\n /** What the host must do, in a sentence a person can act on. */\n readonly remedy: string;\n\n constructor(args: { code: string; message: string; remedy: string }) {\n super(`${args.message} — ${args.remedy}`);\n this.code = args.code;\n this.remedy = args.remedy;\n }\n}\n","/**\n * catalog/labels.ts — @ai-matrx/agents/catalog\n *\n * VERBATIM port of matrx-frontend `features/agents/constants/agent-list-labels.ts`.\n * The only seam inverted: the two label constants moved into the `labels` port\n * (`DEFAULT_AGENT_CATALOG_LABELS.publicTab` / `.publicBadge`) so a host can\n * override them; the FUNCTIONS below keep their exact behaviour.\n */\n\nimport type { AgentCatalogLabels } from \"./ports\";\nimport { ARCHIVE_FILTER_OPTIONS, nextArchFilter } from \"./types\";\nimport type { AgentArchFilter, AgentTab } from \"./types\";\n\nexport function agentListEmptyLabel(\n tab: AgentTab,\n labels: AgentCatalogLabels,\n): string {\n switch (tab) {\n case \"system\":\n // 🚨 The tab IS the system tab, and the surfaces that mount this picker\n // call that rung \"System\" (V1 round 3). Saying \"public\" here made the\n // empty state name a different thing from the rung the person had just\n // chosen. The tab's own LABEL is a wider vocabulary question and is left\n // alone — this only stops the empty state contradicting its own case.\n return labels.emptySystem;\n case \"shared\":\n return labels.emptyShared;\n default:\n return labels.emptyDefault;\n }\n}\n\n/** Whether a list picker should default to the public (`system`) tab instead of Mine. */\nexport function shouldDefaultAgentListToPublicTab(args: {\n userId: string | null;\n ownedCount: number;\n agentsLoaded: boolean;\n}): boolean {\n if (!args.userId) return true;\n if (!args.agentsLoaded) return false;\n return args.ownedCount === 0;\n}\n\n// ── THE ARCHIVED-ITEMS LAW — the control's words, and the honest footer ─────\n//\n// `common-docs/policies/archived-items.md`, Arman 2026-09-09:\n//\n// \"everything should have an archive filter, and the default should always\n// hide archived, but seeing archived items should be one or two clicks\n// away.\"\n//\n// Clause 2 of that law is why these live here rather than inside a component:\n// \"Counts, badges, footers and pagination count what the list renders — a\n// screen never lies.\" The footer string is computed ONCE, from the same\n// numbers the list rendered, for both platforms.\n\n/** What the filter-bar chip reads in each state. */\nexport function agentArchiveFilterChipLabel(archFilter: AgentArchFilter): string {\n return (\n ARCHIVE_FILTER_OPTIONS.find((o) => o.value === archFilter)?.chip ?? \"Archive\"\n );\n}\n\n/** The platform's words for the state — menus, aria-labels, help text. */\nexport function agentArchiveFilterStateLabel(\n archFilter: AgentArchFilter,\n): string {\n return (\n ARCHIVE_FILTER_OPTIONS.find((o) => o.value === archFilter)?.label ??\n \"Hide archived\"\n );\n}\n\n/**\n * The accessible name of the ONE control, always naming the state it is IN\n * and the state one click moves it to. A control whose label does not say\n * what it currently does is the \"dead or dishonest\" shape the platform bans.\n */\nexport function agentArchiveFilterControlLabel(\n archFilter: AgentArchFilter,\n): string {\n return `Archive filter: ${agentArchiveFilterStateLabel(\n archFilter,\n ).toLowerCase()}. Click for ${agentArchiveFilterStateLabel(\n nextArchFilter(archFilter),\n ).toLowerCase()}`;\n}\n\n/**\n * THE FOOTER. It counts exactly what the list rendered and, whenever archived\n * rows are involved, says so — hidden ones included.\n *\n * hide archived, nothing archived behind it → \"412 agents\"\n * hide archived, 4 archived behind it → \"412 agents · 4 archived hidden\"\n * show all → \"416 agents · archived shown\"\n * archived only → \"4 archived shown\"\n */\nexport function agentListFooterLabel(args: {\n /** Rows actually rendered. */\n count: number;\n archFilter: AgentArchFilter;\n /**\n * Rows this view WOULD render if the filter were flipped to \"archived only\"\n * — exactly what the default state is keeping off the screen. Only ever\n * read in the `active` state.\n */\n archivedHiddenCount: number;\n}): string {\n const { count, archFilter, archivedHiddenCount } = args;\n if (archFilter === \"archived\") return `${count} archived shown`;\n const base = `${count} agent${count !== 1 ? \"s\" : \"\"}`;\n if (archFilter === \"both\") return `${base} · archived shown`;\n return archivedHiddenCount > 0\n ? `${base} · ${archivedHiddenCount} archived hidden`\n : base;\n}\n","// catalog/score.ts — @ai-matrx/agents/catalog\n//\n// THE canonical agent relevance scorer. One implementation, every surface,\n// every APP. Ported VERBATIM (behaviour byte-for-byte) from matrx-frontend\n// `features/agents/search/score.ts`; only the file header changed.\n//\n// This existed twice with drifted weights — the gallery copy in\n// `features/agents/redux/agent-consumers/selectors.ts` and a chat-side copy in\n// the (deleted 2026-08) legacy agentCache selectors. The chat copy scored an id\n// match at 50 with no exact-id bonus, so searching a chat-side picker by UUID\n// was effectively dead. Everything now delegates here.\n//\n// Pure: no Redux, no store types, no imports. Anything that can describe an\n// agent structurally can be scored.\n//\n// Adding a field? Add it here and it lights up on every surface at once.\n// Never fork this function.\n//\n// ── SQL PARITY (load-bearing) ───────────────────────────────────────────────\n// `public.agx_search_score` in migrations/agx_search_score.sql is the SQL\n// mirror of this function. Server-side paging FORCES a second implementation —\n// relevance has to be computed before LIMIT, which the browser cannot do — but\n// the two must stay in lockstep.\n//\n// CHANGE ONE, CHANGE THE OTHER IN THE SAME COMMIT, and keep the weights below\n// identical to the SQL constants. Guarded by score.parity.test.ts against the\n// shared fixture in __fixtures__/search-score-parity.json.\n//\n// This is not hypothetical: /agents/all shipped with a flat SQL `ILIKE OR` and\n// no ranking at all, so a description match tied with a name match and\n// searching \"image\" buried every image agent under unrelated ones.\n\n/**\n * The structural shape a record needs to be searchable. Every field except\n * `id` is optional so both the full gallery record and the slim chat record\n * satisfy it without adapters.\n */\nexport interface AgentSearchable {\n id: string;\n name?: string | null;\n description?: string | null;\n category?: string | null;\n tags?: string[] | null;\n modelId?: string | null;\n agentType?: string | null;\n outputFormat?: string | null;\n sharedByEmail?: string | null;\n}\n\n/**\n * Relevance score for an agent against a query. Higher = more relevant.\n * Returns 0 when nothing matches (0 is the \"no match\" contract — see\n * `agentMatchesSearch`).\n *\n * Scores only fields carried by the list-level fetches. Message content and\n * variable definitions are deliberately excluded: they are not loaded by the\n * list RPCs, so matching them here would be a false promise. Server-side\n * search owns deep content matching.\n */\nexport function computeAgentSearchScore(\n agent: AgentSearchable,\n query: string,\n): number {\n const q = query.trim().toLowerCase();\n if (!q) return 0;\n\n let score = 0;\n\n const name = (agent.name ?? \"\").toLowerCase();\n const desc = (agent.description ?? \"\").toLowerCase();\n\n if (name === q) score += 10000;\n else if (name.startsWith(q)) score += 5000;\n // Word-boundary beats a mid-word substring: \"image\" ranks\n // \"Basic Image Generator\" above \"Reimagine Helper\".\n else if (matchesWholeWord(name, q)) score += 3000;\n else if (name.includes(q)) score += 2000;\n\n if (desc === q) score += 1000;\n else if (desc.includes(q)) score += 500;\n\n if (agent.category?.toLowerCase().includes(q)) score += 300;\n if (agent.tags?.some((t) => t.toLowerCase().includes(q))) score += 300;\n if (agent.modelId?.toLowerCase().includes(q)) score += 100;\n if (agent.agentType?.toLowerCase().includes(q)) score += 100;\n if (agent.outputFormat?.toLowerCase().includes(q)) score += 100;\n\n // Id search — an exact UUID always wins outright so you can paste an id from\n // a URL or a log line and land on that agent, on any surface.\n const id = agent.id.toLowerCase();\n if (id === q) score += 100000;\n else if (id.includes(q)) score += 5000;\n\n // Helps find agents shared by a specific person.\n if (agent.sharedByEmail?.toLowerCase().includes(q)) score += 200;\n\n // Multi-term fallback: \"image gen\" matches nothing as a phrase. Score per\n // TERM, and only when EVERY term lands somewhere — so multi-word searches\n // work without degrading into a loose OR that matches half the list.\n if (score === 0 && q.includes(\" \")) {\n const terms = q.split(/\\s+/).filter(Boolean);\n let hits = 0;\n let termScore = 0;\n for (const term of terms) {\n const inName = name.includes(term);\n const matched =\n inName ||\n desc.includes(term) ||\n (agent.category?.toLowerCase().includes(term) ?? false) ||\n (agent.tags?.some((t) => t.toLowerCase().includes(term)) ?? false);\n if (matched) {\n hits += 1;\n termScore += inName ? 400 : 100;\n }\n }\n // All-or-nothing: a partial term match is not a match.\n if (hits === terms.length) score += termScore;\n }\n\n return score;\n}\n\n/** True when `q` appears in `haystack` on word boundaries. */\nfunction matchesWholeWord(haystack: string, q: string): boolean {\n const escaped = q.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`\\\\b${escaped}\\\\b`).test(haystack);\n}\n\n/** True when the agent matches the query at all. */\nexport function agentMatchesSearch(\n agent: AgentSearchable,\n query: string,\n): boolean {\n return computeAgentSearchScore(agent, query) > 0;\n}\n","/**\n * catalog/selectors.ts — @ai-matrx/agents/catalog\n *\n * VERBATIM port of matrx-frontend\n * `features/agents/redux/agent-consumers/selectors.ts`.\n *\n * ALL filter, sort, search-scoring, category/tag extraction and pagination\n * logic lives here — not in components. Two coupling seams inverted, nothing\n * else:\n *\n * 1. `createSelector` (reselect) → `memoize1`/`memoize2`/`memoize3` below,\n * the same last-arguments reference-equality memoization reselect\n * defaults to. No Redux, no store types.\n * 2. `AgentDefinitionRecord` → `AgentSummary`, the list-row shape\n * `agx_get_list_full` actually returns.\n *\n * One structural consequence of (2), recorded rather than hidden: the\n * frontend's `selectLiveAgents` filters `isVersion` snapshots out of a store\n * that also holds them. This catalog only ever holds list rows — a version\n * snapshot cannot enter it — so that filter is a no-op here and is not\n * ported.\n *\n * 🚨 TWO DELIBERATE DEPARTURES FROM THE ORIGINAL, both defects the port\n * inherited and 0.9.1 fixes at the class (see CHANGELOG 0.9.1):\n *\n * F1 — every sort now ends on `id` ASC, the same final key `agx_get_list`\n * ends on, so the order of TIED rows is defined by the rows instead of\n * by whichever transport the host used to fetch them.\n * F5 — the tab-badge counts honour the archive filter, so the badge, the\n * footer and the rendered rows are the same number.\n *\n * Everything else below is byte-identical to the original.\n */\n\nimport {\n agentMatchesSearch,\n computeAgentSearchScore,\n} from \"./score\";\nimport {\n AGENT_NONE_SENTINEL,\n type AgentArchFilter,\n type AgentConsumerState,\n type AgentSortOption,\n type AgentSummary,\n} from \"./types\";\n\nexport { computeAgentSearchScore, agentMatchesSearch };\nexport { AGENT_NONE_SENTINEL };\n\n// ── Constants (verbatim) ─────────────────────────────────────────────────────\n\nexport const AGENT_CARDS_LIMIT_DESKTOP = 8;\nexport const AGENT_CARDS_LIMIT_MOBILE = 4;\nexport const AGENT_LIST_ITEMS_PER_PAGE = 20;\n\n// ── Memoization (the reselect seam, inverted) ───────────────────────────────\n\n/**\n * Last-arguments memoization on reference equality — reselect's default\n * `defaultMemoize` behaviour, in eleven lines and with no dependency. A\n * selector built here is memoized PER INSTANCE, exactly like a\n * `createSelector` result, so the factories below keep their contract:\n * build the selector once per (consumerId, …) and reuse it.\n */\nexport function memoize1<A, R>(fn: (a: A) => R): (a: A) => R {\n let lastA: A | undefined;\n let last: R;\n let has = false;\n return (a: A): R => {\n if (!has || lastA !== a) {\n last = fn(a);\n lastA = a;\n has = true;\n }\n return last;\n };\n}\n\nexport function memoize2<A, B, R>(fn: (a: A, b: B) => R): (a: A, b: B) => R {\n let lastA: A | undefined;\n let lastB: B | undefined;\n let last: R;\n let has = false;\n return (a: A, b: B): R => {\n if (!has || lastA !== a || lastB !== b) {\n last = fn(a, b);\n lastA = a;\n lastB = b;\n has = true;\n }\n return last;\n };\n}\n\nexport function memoize3<A, B, C, R>(\n fn: (a: A, b: B, c: C) => R,\n): (a: A, b: B, c: C) => R {\n let lastA: A | undefined;\n let lastB: B | undefined;\n let lastC: C | undefined;\n let last: R;\n let has = false;\n return (a: A, b: B, c: C): R => {\n if (!has || lastA !== a || lastB !== b || lastC !== c) {\n last = fn(a, b, c);\n lastA = a;\n lastB = b;\n lastC = c;\n has = true;\n }\n return last;\n };\n}\n\n// ── Pure sort comparator ────────────────────────────────────────────────────\n\n/**\n * 🚨 THE FINAL TIEBREAKER. `agx_get_list` orders\n * `is_favorite DESC, updated_at DESC, id` — `id` ASCENDING is the unique key\n * that makes the SERVER's order TOTAL. Every sort in this file ends on the\n * same key, so the rendered order is a function of the ROWS and never of the\n * order they happened to arrive in.\n *\n * Why a raw `<` / `>` and not `localeCompare`: Postgres orders `uuid` by its\n * 16 raw bytes. The canonical text form is lowercase hex with dashes at fixed\n * positions, so a codepoint comparison of those strings reproduces the\n * database's order exactly. A locale collator does not — it is free to fold\n * case or ignore punctuation, and would silently diverge from the server on\n * precisely the ties this key exists to settle.\n */\nexport function compareAgentIds(a: AgentSummary, b: AgentSummary): number {\n const idA = a.id ?? \"\";\n const idB = b.id ?? \"\";\n if (idA < idB) return -1;\n if (idA > idB) return 1;\n return 0;\n}\n\n/**\n * The chosen sort key, then `id`. TOTAL for every option.\n *\n * Before 0.9.1 each branch below returned 0 for tied rows, which left their\n * relative order to whatever `Array.prototype.sort` had been handed — i.e. to\n * the transport. A host that fetched the RPC in one shot kept the server's\n * favourites-first/`updated_at DESC` order for ties; a host that paged it with\n * `order=id.asc` kept id-ASC. Same rows, same filters, two different screens.\n * The key below is the server's own, so both now render the server's answer.\n */\nexport function applyAgentSortComparator(\n a: AgentSummary,\n b: AgentSummary,\n sortBy: AgentSortOption,\n): number {\n const primary = compareAgentSortKey(a, b, sortBy);\n // An unparseable timestamp yields NaN, which `sort` reads as \"equal\" while\n // defeating `!== 0`. Collapse it to a tie so the id key still decides — a\n // total order must not depend on the data being clean.\n if (!Number.isFinite(primary) || primary === 0) return compareAgentIds(a, b);\n return primary;\n}\n\n/** The chosen key ALONE — no tiebreaker. Not total; not for rendering. */\nfunction compareAgentSortKey(\n a: AgentSummary,\n b: AgentSummary,\n sortBy: AgentSortOption,\n): number {\n switch (sortBy) {\n case \"name-asc\":\n return (a.name ?? \"\").localeCompare(b.name ?? \"\");\n case \"name-desc\":\n return (b.name ?? \"\").localeCompare(a.name ?? \"\");\n case \"created-desc\":\n return +new Date(b.createdAt ?? 0) - +new Date(a.createdAt ?? 0);\n case \"category-asc\":\n return (a.category ?? \"\").localeCompare(b.category ?? \"\");\n case \"updated-desc\":\n default:\n return +new Date(b.updatedAt ?? 0) - +new Date(a.updatedAt ?? 0);\n }\n}\n\n// ── Category / tag metadata (derived from live agents) ──────────────────────\n\n/** All unique categories across live USER agents, sorted alphabetically. */\nexport const selectAllAgentCategories = memoize1(\n (agents: readonly AgentSummary[]): string[] => {\n const cats = new Set<string>();\n for (const a of agents) {\n if (a.agentType === \"user\" && a.category) cats.add(a.category);\n }\n return Array.from(cats).sort();\n },\n);\n\n/**\n * All unique categories across live SYSTEM (builtin) agents. The system tab\n * gets the same category filter every other tab has — its options just come\n * from a different population.\n */\nexport const selectAllSystemAgentCategories = memoize1(\n (agents: readonly AgentSummary[]): string[] => {\n const cats = new Set<string>();\n for (const a of agents) {\n if (a.agentType === \"builtin\" && a.category) cats.add(a.category);\n }\n return Array.from(cats).sort();\n },\n);\n\n/** All unique tags across live user agents, sorted alphabetically. */\nexport const selectAllAgentTags = memoize1(\n (agents: readonly AgentSummary[]): string[] => {\n const tags = new Set<string>();\n for (const a of agents) {\n if (a.agentType === \"user\") a.tags?.forEach((t) => tags.add(t));\n }\n return Array.from(tags).sort();\n },\n);\n\n/** All unique tags across live SYSTEM (builtin) agents. */\nexport const selectAllSystemAgentTags = memoize1(\n (agents: readonly AgentSummary[]): string[] => {\n const tags = new Set<string>();\n for (const a of agents) {\n if (a.agentType === \"builtin\") a.tags?.forEach((t) => tags.add(t));\n }\n return Array.from(tags).sort();\n },\n);\n\n// ── User-owned + shared agents (excludes builtins) ─────────────────────────\n\n/** Live user-type agents (excludes builtins). */\nexport const selectUserTypeAgents = memoize1(\n (agents: readonly AgentSummary[]): AgentSummary[] =>\n agents.filter((a) => a.agentType === \"user\"),\n);\n\n/** Builtin/system agents only. For chat pickers and full catalogues. */\nexport const selectBuiltinTypeAgents = memoize1(\n (agents: readonly AgentSummary[]): AgentSummary[] =>\n agents.filter((a) => a.agentType === \"builtin\"),\n);\n\n// ── Pure filter pipelines (verbatim) ───────────────────────────────────────\n\n/**\n * The ONE ordering rule, and it is TOTAL on every path.\n *\n * searching: score DESC → server rank ASC → sort key → id ASC\n * not searching: favourites first (when asked) → sort key → id ASC\n *\n * `id` ASC is the final key `agx_get_list` itself ends on, so two hosts that\n * fetched the same rows through different transports render the same screen.\n */\nexport function sortFilteredAgents(\n filtered: AgentSummary[],\n consumer: AgentConsumerState,\n): AgentSummary[] {\n const { searchTerm, sortBy, favFilter, favoritesFirst } = consumer;\n\n if (searchTerm) {\n const scores = new Map<string, number>();\n filtered.forEach((a) => {\n scores.set(a.id, computeAgentSearchScore(a, searchTerm));\n });\n\n // Server rank, used only to order matches the local scorer cannot see\n // (tier-2 prompt hits). Locally-scored matches all have score > 0, so\n // they sort above this group unconditionally — obvious matches first.\n const serverRank = new Map<string, number>();\n consumer.serverMatchedIds.forEach((id, i) => serverRank.set(id, i));\n\n return [...filtered].sort((a, b) => {\n const sa = scores.get(a.id) ?? 0;\n const sb = scores.get(b.id) ?? 0;\n if (sb !== sa) return sb - sa;\n if (sa === 0) {\n const ra = serverRank.get(a.id);\n const rb = serverRank.get(b.id);\n if (ra !== undefined && rb !== undefined && ra !== rb) return ra - rb;\n }\n return applyAgentSortComparator(a, b, sortBy);\n });\n }\n\n return [...filtered].sort((a, b) => {\n if (favoritesFirst && favFilter === \"all\") {\n const aFav = a.isFavorite ? 1 : 0;\n const bFav = b.isFavorite ? 1 : 0;\n if (bFav !== aFav) return bFav - aFav;\n }\n return applyAgentSortComparator(a, b, sortBy);\n });\n}\n\n/** User-type agents — mine / shared / all tabs with full consumer filters. */\nexport function filterUserTypeAgents(\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n): AgentSummary[] {\n const {\n searchTerm,\n includedCats,\n includedTags,\n favFilter,\n archFilter,\n accessFilter,\n tab,\n } = consumer;\n\n // Built once, not per row — this runs on every keystroke over the full list.\n const serverMatched = new Set(consumer.serverMatchedIds);\n\n const filtered = agents.filter((agent) => {\n if (tab === \"mine\" && agent.isOwner !== true) return false;\n if (\n tab === \"shared\" &&\n !(agent.isOwner === false && agent.accessLevel != null)\n )\n return false;\n\n // THE ARCHIVED-ITEMS LAW, through the ONE predicate every tab, badge and\n // footer in this package shares.\n if (!agentMatchesArchiveFilter(agent, archFilter)) return false;\n\n if (favFilter === \"yes\" && !agent.isFavorite) return false;\n if (favFilter === \"no\" && agent.isFavorite) return false;\n\n if (accessFilter === \"owned\" && agent.isOwner !== true) return false;\n if (accessFilter === \"shared\" && agent.isOwner !== false) return false;\n if (\n accessFilter === \"editable\" &&\n agent.accessLevel !== \"owner\" &&\n agent.accessLevel !== \"admin\" &&\n agent.accessLevel !== \"editor\"\n )\n return false;\n\n if (includedCats.length > 0) {\n const category = agent.category;\n if (!category) {\n if (!includedCats.includes(AGENT_NONE_SENTINEL)) return false;\n } else if (!includedCats.includes(category)) {\n return false;\n }\n }\n\n if (includedTags.length > 0) {\n const isUntagged = !agent.tags?.length;\n if (isUntagged) {\n if (!includedTags.includes(AGENT_NONE_SENTINEL)) return false;\n } else if (!agent.tags?.some((t) => includedTags.includes(t))) {\n return false;\n }\n }\n\n // A server hit counts as a match even when the local scorer scores 0 —\n // that is the only way tier-2 prompt matches can reach the screen, since\n // the client never loads prompt content to score against.\n if (\n searchTerm &&\n !agentMatchesSearch(agent, searchTerm) &&\n !serverMatched.has(agent.id)\n )\n return false;\n\n return true;\n });\n\n return sortFilteredAgents(filtered, consumer);\n}\n\n/**\n * Builtin/system agents (tab === \"system\").\n *\n * Gets the SAME filter surface every other tab has — search, favorites,\n * category, tags, sort, AND THE ARCHIVE FILTER. Only the ownership/access\n * filters are skipped, because a builtin has no owner to filter on. A picker\n * that offers less on one tab than another is the exact half-built shape this\n * list exists to prevent.\n *\n * 🚨 0.9.2 — THE BUILTIN ARCHIVE EXEMPTION IS GONE, AND IT IS NOW ILLEGAL.\n *\n * Until 0.9.1 this function applied no archive filter, on the theory that \"a\n * builtin belongs to the platform and is never the user's to archive\". The\n * database disagreed: `Foundry Planner`\n * (`001b22f6-fa4d-40c6-a1a4-8575d4d04379`) is an ARCHIVED builtin, and it\n * rendered at Public index 216 and was pickable — while Mine / Shared / All\n * hid their archived rows. One picker, two rules, and a person could choose a\n * retired agent from the one tab that did not obey.\n *\n * THE ARCHIVED-ITEMS LAW (`common-docs/policies/archived-items.md`, Arman\n * 2026-09-09) closed the question for every entity at once: \"everything should\n * have an archive filter, and the default should always hide archived… all\n * archived items should always be treated the same.\" Clause 4 makes it a\n * class, not an instance — so there is no per-tab, per-entity or per-surface\n * exemption left to grant, here or anywhere.\n */\nexport function filterBuiltinTypeAgents(\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n): AgentSummary[] {\n const { searchTerm, favFilter, archFilter, includedCats, includedTags } =\n consumer;\n const serverMatched = new Set(consumer.serverMatchedIds);\n\n const filtered = agents.filter((agent) => {\n // THE LAW, first and unconditional — identical to the user-tab rule above.\n if (!agentMatchesArchiveFilter(agent, archFilter)) return false;\n\n if (favFilter === \"yes\" && !agent.isFavorite) return false;\n if (favFilter === \"no\" && agent.isFavorite) return false;\n\n if (includedCats.length > 0) {\n const category = agent.category;\n if (!category) {\n if (!includedCats.includes(AGENT_NONE_SENTINEL)) return false;\n } else if (!includedCats.includes(category)) {\n return false;\n }\n }\n\n if (includedTags.length > 0) {\n const isUntagged = !agent.tags?.length;\n if (isUntagged) {\n if (!includedTags.includes(AGENT_NONE_SENTINEL)) return false;\n } else if (!agent.tags?.some((t) => includedTags.includes(t))) {\n return false;\n }\n }\n\n if (\n searchTerm &&\n !agentMatchesSearch(agent, searchTerm) &&\n !serverMatched.has(agent.id)\n )\n return false;\n\n return true;\n });\n\n return sortFilteredAgents(filtered, consumer);\n}\n\n// ── Filtered agents (user + system tabs) ───────────────────────────────────\n\n/** Factory: owned user-type agents with consumer filters applied (ignores tab). */\nexport const makeSelectFilteredOwnedAgents = () =>\n memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] =>\n filterUserTypeAgents(selectUserTypeAgents(agents), {\n ...consumer,\n tab: \"mine\",\n }),\n );\n\n/** Factory: shared user-type agents with consumer filters applied (ignores tab). */\nexport const makeSelectFilteredSharedAgents = () =>\n memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] =>\n filterUserTypeAgents(selectUserTypeAgents(agents), {\n ...consumer,\n tab: \"shared\",\n }),\n );\n\n/**\n * Factory: filters and sorts agents for a consumer. User tabs (mine / shared /\n * all) draw from user-type agents; the system tab draws from builtins.\n *\n * `includeSystemInAll` is the ADMIN reading of the \"All\" tab. For a normal\n * user, system agents are a separate catalogue and \"All\" means \"all of MY\n * agents\". For an admin surface, system agents ARE their agents — so \"All\"\n * must be a single blended list, with each row still labelled (the `system`\n * badge on `AgentRow`) so the two are never confused.\n */\nexport const makeSelectFilteredAgents = (includeSystemInAll = false) =>\n memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] => {\n const userAgents = selectUserTypeAgents(agents);\n const builtinAgents = selectBuiltinTypeAgents(agents);\n if (consumer.tab === \"system\") {\n return filterBuiltinTypeAgents(builtinAgents, consumer);\n }\n if (includeSystemInAll && consumer.tab === \"all\") {\n return [\n ...filterUserTypeAgents(userAgents, consumer),\n ...filterBuiltinTypeAgents(builtinAgents, consumer),\n ];\n }\n return filterUserTypeAgents(userAgents, consumer);\n },\n );\n\n/** Factory: filters and sorts builtin agents for the chat agent picker. */\nexport const makeSelectFilteredBuiltinAgents = () =>\n memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] =>\n filterBuiltinTypeAgents(selectBuiltinTypeAgents(agents), consumer),\n );\n\n// ── Card / list split (verbatim) ───────────────────────────────────────────\n\nexport interface AgentListPage {\n items: AgentSummary[];\n hasMore: boolean;\n totalAfterCards: number;\n}\n\nfunction pageAfterCards(\n filtered: AgentSummary[],\n limit: number,\n page: number,\n): AgentListPage {\n const afterCards = filtered.slice(limit);\n const pageEnd = page * AGENT_LIST_ITEMS_PER_PAGE;\n const items = afterCards.slice(0, pageEnd);\n return {\n items,\n hasMore: items.length < afterCards.length,\n totalAfterCards: afterCards.length,\n };\n}\n\n/** Factory: slices filtered owned agents into the \"cards\" hero section. */\nexport const makeSelectOwnedAgentCards = (isMobile: boolean) => {\n const selectFiltered = makeSelectFilteredOwnedAgents();\n const limit = isMobile ? AGENT_CARDS_LIMIT_MOBILE : AGENT_CARDS_LIMIT_DESKTOP;\n return memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] => selectFiltered(agents, consumer).slice(0, limit),\n );\n};\n\n/** Factory: paginated list items for owned agents (everything after cards). */\nexport const makeSelectOwnedAgentListItems = (isMobile: boolean) => {\n const selectFiltered = makeSelectFilteredOwnedAgents();\n const limit = isMobile ? AGENT_CARDS_LIMIT_MOBILE : AGENT_CARDS_LIMIT_DESKTOP;\n return memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentListPage =>\n pageAfterCards(selectFiltered(agents, consumer), limit, consumer.listPage),\n );\n};\n\n/** Factory: slices filtered shared agents into the \"cards\" hero section. */\nexport const makeSelectSharedAgentCards = (isMobile: boolean) => {\n const selectFiltered = makeSelectFilteredSharedAgents();\n const limit = isMobile ? AGENT_CARDS_LIMIT_MOBILE : AGENT_CARDS_LIMIT_DESKTOP;\n return memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentSummary[] => selectFiltered(agents, consumer).slice(0, limit),\n );\n};\n\n/** Factory: paginated list items for shared agents (everything after cards). */\nexport const makeSelectSharedAgentListItems = (isMobile: boolean) => {\n const selectFiltered = makeSelectFilteredSharedAgents();\n const limit = isMobile ? AGENT_CARDS_LIMIT_MOBILE : AGENT_CARDS_LIMIT_DESKTOP;\n return memoize2(\n (\n agents: readonly AgentSummary[],\n consumer: AgentConsumerState,\n ): AgentListPage =>\n pageAfterCards(\n selectFiltered(agents, consumer),\n limit,\n consumer.sharedPage,\n ),\n );\n};\n\n// ── Convenience count selectors ────────────────────────────────────────────\n\n/** Factory: total count of filtered agents for a consumer. */\nexport const makeSelectFilteredAgentsCount = () => {\n const selectFiltered = makeSelectFilteredAgents();\n return memoize2(\n (agents: readonly AgentSummary[], consumer: AgentConsumerState): number =>\n selectFiltered(agents, consumer).length,\n );\n};\n\n/** Factory: total count of filtered builtin agents for a consumer. */\nexport const makeSelectFilteredBuiltinAgentsCount = () => {\n const selectFiltered = makeSelectFilteredBuiltinAgents();\n return memoize2(\n (agents: readonly AgentSummary[], consumer: AgentConsumerState): number =>\n selectFiltered(agents, consumer).length,\n );\n};\n\n// ── Consumer state convenience selectors ──────────────────────────────────\n\n/** Returns whether a consumer has any non-default filters active. */\nexport function agentConsumerHasActiveFilters(\n consumer: AgentConsumerState,\n defaults: AgentConsumerState,\n): boolean {\n return (\n consumer.tab !== defaults.tab ||\n consumer.sortBy !== defaults.sortBy ||\n consumer.searchTerm !== \"\" ||\n consumer.includedCats.length > 0 ||\n consumer.includedTags.length > 0 ||\n consumer.favFilter !== defaults.favFilter ||\n consumer.archFilter !== defaults.archFilter ||\n consumer.accessFilter !== defaults.accessFilter ||\n consumer.favoritesFirst !== defaults.favoritesFirst\n );\n}\n\n// ── Aggregate counts (for tab badges) ─────────────────────────────────────\n\n/**\n * 🚨 A BADGE COUNTS WHAT THE TAB RENDERS. Nothing else.\n *\n * Before 0.9.1 these five counted every user-type row, archived included,\n * while `filterUserTypeAgents` (archive filter `active`, the default) hid the\n * archived ones. The badge said \"Mine 416\", the list showed 412 rows and the\n * footer said \"412 agents\" — one screen, three numbers, one of them a lie\n * about agents the user cannot see or reach from there.\n *\n * `is_archived` is now honoured by the same rule the list uses, so the badge,\n * the footer and the rows agree on every tab and under every archive filter.\n *\n * 🚨 0.9.2 — AND THERE IS NO LONGER AN EXCEPTION. The system tab used to be\n * one (\"a builtin is never the user's to archive\"), which was false in the\n * database and illegal under THE ARCHIVED-ITEMS LAW. Its badge now counts\n * under the same archive rule its rows render under, so `Foundry Planner`\n * leaves the Public badge and the Public list together, or returns to both\n * together — never one without the other.\n */\nexport function agentMatchesArchiveFilter(\n agent: AgentSummary,\n archFilter: AgentArchFilter,\n): boolean {\n if (archFilter === \"active\") return !agent.isArchived;\n if (archFilter === \"archived\") return Boolean(agent.isArchived);\n return true;\n}\n\n/** Builtin rows matching an archive filter — the Public tab's badge. */\nfunction countBuiltinRows(\n agents: readonly AgentSummary[],\n archFilter: AgentArchFilter,\n): number {\n let n = 0;\n for (const a of agents) {\n if (a.agentType !== \"builtin\") continue;\n if (!agentMatchesArchiveFilter(a, archFilter)) continue;\n n += 1;\n }\n return n;\n}\n\nfunction countUserRows(\n agents: readonly AgentSummary[],\n archFilter: AgentArchFilter,\n predicate: (a: AgentSummary) => boolean,\n): number {\n let n = 0;\n for (const a of agents) {\n if (a.agentType !== \"user\") continue;\n if (!agentMatchesArchiveFilter(a, archFilter)) continue;\n if (predicate(a)) n += 1;\n }\n return n;\n}\n\nconst isOwned = (a: AgentSummary) => a.isOwner === true;\nconst isShared = (a: AgentSummary) =>\n a.isOwner === false && a.accessLevel != null;\nconst isAny = () => true;\nconst isFavorite = (a: AgentSummary) => Boolean(a.isFavorite);\n\n/**\n * The four tab badges for a consumer's CURRENT archive filter — the numbers\n * `useAgentListCore` puts on the tab strip. Flip the archive filter to\n * \"archived\" and the badges follow the list into the archive.\n */\nexport const selectAgentTabCounts = memoize2(\n (\n agents: readonly AgentSummary[],\n archFilter: AgentArchFilter,\n ): { mine: number; shared: number; all: number; system: number } => ({\n mine: countUserRows(agents, archFilter, isOwned),\n shared: countUserRows(agents, archFilter, isShared),\n all: countUserRows(agents, archFilter, isAny),\n system: countBuiltinRows(agents, archFilter),\n }),\n);\n\n/** Live user-type agents the default (`active`) list renders. */\nexport const selectTotalUserAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number =>\n countUserRows(agents, \"active\", isAny),\n);\n\nexport const selectTotalOwnedAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number =>\n countUserRows(agents, \"active\", isOwned),\n);\n\nexport const selectTotalSharedAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number =>\n countUserRows(agents, \"active\", isShared),\n);\n\n/**\n * Live builtin agents the DEFAULT (`active`) list renders — archived builtins\n * excluded, exactly like every other \"total\" beside it. Before 0.9.2 this\n * counted archived builtins too, which is how an archived `Foundry Planner`\n * reached the Public badge.\n */\nexport const selectTotalBuiltinAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number => countBuiltinRows(agents, \"active\"),\n);\n\nexport const selectTotalFavoriteAgentsCount = memoize1(\n (agents: readonly AgentSummary[]): number =>\n countUserRows(agents, \"active\", isFavorite),\n);\n","\"use client\";\n\n/**\n * catalog/react/AgentListDropdown.tsx — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/AgentListDropdown.tsx`.\n *\n * Seams inverted: every `@/components/ui/*` primitive → `@ai-matrx/design-system`\n * (Popover, Drawer, Tooltip); `useIsMobile` → design-system's; `useDialogContainer`\n * → the `popoverContainer` UI port; lucide → the package's inlined SVGs.\n *\n * The prop surface is unchanged, plus `defaultMandateKey`.\n */\n\nimport {\n cn,\n Drawer,\n DrawerContent,\n DrawerTitle,\n DrawerTrigger,\n Popover,\n PopoverContent,\n PopoverTrigger,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n useIsMobile,\n} from \"@ai-matrx/design-system\";\nimport { useMemo, useRef, useState } from \"react\";\n\nimport { AgentListPanelBody, PANEL_WIDTH } from \"./AgentListPanel\";\nimport { useAgentCatalog, useAgentCatalogUiPorts } from \"./context\";\nimport { ChevronDownIcon } from \"./icons\";\nimport { LIST_MAX_HEIGHT, PANEL_HEIGHT, panelHeightBelow, sideThatFits } from \"./types\";\nimport { useAgentListCore } from \"./useAgentListCore\";\nimport type { AgentSummary, AgentTab } from \"../types\";\n\nconst CONSUMER_ID = \"agent-list-dropdown\";\n\nexport interface AgentListDropdownProps {\n onSelect?: (agentId: string) => void;\n navigateTo?: string;\n className?: string;\n label?: string;\n /** Custom trigger element — replaces the default text button. */\n triggerSlot?: React.ReactNode;\n /** Remove the border from the default trigger button. */\n noBorder?: boolean;\n /** Use a compact (h-5) trigger instead of the default h-7. */\n compact?: boolean;\n /** Route-scoped agent id — highlights + pins the current agent in the list. */\n activeAgentId?: string | null;\n /**\n * Which side the desktop popover opens toward. Defaults to Radix's \"bottom\".\n * Pass \"right\" when the trigger lives in a narrow vertical rail so the panel\n * opens beside the rail instead of covering it. Ignored on mobile (Drawer).\n */\n contentSide?: \"top\" | \"right\" | \"bottom\" | \"left\";\n /**\n * Isolate this dropdown's filter/tab state under its own consumer id.\n * Defaults to the shared `agent-list-dropdown` consumer so ordinary chat\n * triggers keep one remembered set of filters across the app.\n */\n consumerId?: string;\n /** Tab to open on. Admin surfaces managing system agents pass `\"system\"`. */\n initialTab?: AgentTab;\n /** ADMIN variant: blend system agents into the \"All\" tab. */\n includeSystemInAll?: boolean;\n /** Restrict which ownership tabs are available for domain-constrained pickers. */\n visibleTabs?: readonly AgentTab[];\n /** Label override for the builtin-agent tab. Admin surfaces use \"System\". */\n systemTabLabel?: string;\n /** Resolve the route used by each named agent door. */\n resolveAgentHref?: (agent: AgentSummary) => string;\n /** Show the active agent above the filtered list. Default true. */\n showPinnedAgent?: boolean;\n /** Hide records that are invalid for this call site. */\n excludeAgentIds?: readonly string[];\n /**\n * Offer the platform DEFAULT agent for this mandate key at the top of the\n * list, named LIVE from the mandate's real Holder. `onSelect` receives\n * `mandate:<key>` for that row — the ref shape every client already speaks.\n */\n defaultMandateKey?: string;\n}\n\nexport function AgentListDropdown({\n onSelect,\n navigateTo,\n className,\n label,\n triggerSlot,\n noBorder = false,\n compact = false,\n activeAgentId: activeAgentIdProp,\n contentSide,\n consumerId = CONSUMER_ID,\n initialTab,\n includeSystemInAll = false,\n visibleTabs,\n systemTabLabel,\n resolveAgentHref: resolveAgentHrefProp,\n showPinnedAgent = true,\n excludeAgentIds,\n defaultMandateKey,\n}: AgentListDropdownProps) {\n const isMobile = useIsMobile();\n const { labels } = useAgentCatalog();\n const { popoverContainer } = useAgentCatalogUiPorts();\n const [open, setOpen] = useState(false);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [fitHeight, setFitHeight] = useState<string | null>(null);\n // The side actually used: the host's `contentSide`, re-chosen at open time\n // when the panel would not fit there (`sideThatFits`).\n const [openSide, setOpenSide] = useState(contentSide);\n\n const core = useAgentListCore({\n consumerId,\n ...(onSelect ? { onSelect } : {}),\n ...(navigateTo ? { navigateTo } : {}),\n ...(activeAgentIdProp !== undefined\n ? { activeAgentIdOverride: activeAgentIdProp }\n : {}),\n ...(initialTab ? { initialTab } : {}),\n includeSystemInAll,\n // The restriction has to reach the CORE, not just the tab strip — see\n // `AgentListCoreOptions.visibleTabs`.\n ...(visibleTabs ? { visibleTabs } : {}),\n ...(excludeAgentIds ? { excludeAgentIds } : {}),\n ...(defaultMandateKey ? { defaultMandateKey } : {}),\n });\n\n // 🚨 THE TRIGGER IS THE STATEMENT OF WHO IS ASSIGNED, so it never answers\n // \"Agents\" when an agent IS assigned — that reads as nothing selected. The\n // roster loads on mount (see `useAgentListCore`), so the interim is brief;\n // an id that never resolves says so rather than hiding behind the catalogue\n // label. Hosts that pass an explicit `label` are unaffected.\n // A mandate default's synthetic `mandate:<key>` id is intentionally absent\n // from the catalog's stored-agent map. Its resolved row is the one source\n // that can name that id, but only when it is the active id for this picker;\n // borrowing a different default row would misstate the assignment.\n const { pinnedAgent, defaultRow, activeAgentId, isLoading, activeFilterCount } =\n core;\n const activeDefaultRow =\n defaultRow?.row?.id === activeAgentId ? defaultRow.row : null;\n const displayLabel =\n label ??\n pinnedAgent?.name ??\n activeDefaultRow?.name ??\n (activeAgentId\n ? isLoading\n ? labels.triggerResolving\n : labels.triggerUnnameable\n : labels.triggerFallback);\n\n const showAssignedTooltip =\n Boolean(activeAgentId) &&\n displayLabel.trim().length > 0 &&\n displayLabel !== \"Select an agent\" &&\n displayLabel !== labels.triggerFallback;\n\n // Open-time behavior (load, pinned preview, focus) lives in the body, which\n // mounts with the popover/drawer; closing unmounts it and resets its panels.\n const handleOpen = (nextOpen: boolean) => {\n setOpen(nextOpen);\n if (nextOpen) {\n setFitHeight(contentSide || isMobile ? null : panelHeightBelow(triggerRef.current));\n setOpenSide(contentSide && !isMobile ? sideThatFits(triggerRef.current, contentSide) : contentSide);\n }\n };\n\n const resolveAgentHref = useMemo(() => {\n if (resolveAgentHrefProp) return resolveAgentHrefProp;\n if (!navigateTo) return undefined;\n return (agent: AgentSummary) => navigateTo.replace(\"{id}\", agent.id);\n }, [navigateTo, resolveAgentHrefProp]);\n\n\n const triggerButton = triggerSlot ?? (\n <button\n type=\"button\"\n className={cn(\n \"inline-flex items-center rounded-md text-xs font-medium transition-colors\",\n \"bg-background hover:bg-muted/50 text-foreground/80 hover:text-foreground\",\n compact ? \"h-5 gap-1 px-1.5\" : \"h-7 gap-1.5 px-2.5\",\n !noBorder && \"border border-border\",\n className,\n )}\n >\n <span className=\"min-w-0 max-w-[200px] flex-1 truncate text-left\">\n {displayLabel}\n </span>\n {activeFilterCount > 0 && (\n <span className=\"flex items-center justify-center w-4 h-4 rounded-md bg-primary text-primary-foreground text-[10px]\">\n {activeFilterCount}\n </span>\n )}\n <ChevronDownIcon className=\"w-3 h-3 text-muted-foreground/60\" />\n </button>\n );\n\n const wrapTrigger = (\n Trigger: typeof DrawerTrigger | typeof PopoverTrigger,\n ) => {\n if (!showAssignedTooltip) {\n return <Trigger asChild ref={triggerRef}>{triggerButton}</Trigger>;\n }\n return (\n <Tooltip {...(open ? { open: false } : {})}>\n <Trigger asChild ref={triggerRef}>\n <TooltipTrigger asChild>{triggerButton}</TooltipTrigger>\n </Trigger>\n <TooltipContent side=\"bottom\" className=\"max-w-xs\">\n {displayLabel}\n </TooltipContent>\n </Tooltip>\n );\n };\n\n const body = (\n <AgentListPanelBody\n core={core}\n includeSystemInAll={includeSystemInAll}\n showPinnedAgent={showPinnedAgent}\n onAfterSelect={() => setOpen(false)}\n {...(visibleTabs ? { visibleTabs } : {})}\n {...(systemTabLabel ? { systemTabLabel } : {})}\n {...(resolveAgentHref ? { resolveAgentHref } : {})}\n />\n );\n\n // ── Mobile ──\n if (isMobile) {\n return (\n <Drawer open={open} onOpenChange={handleOpen}>\n {wrapTrigger(DrawerTrigger)}\n <DrawerContent className=\"h-[85dvh]\">\n <DrawerTitle className=\"sr-only\">Select Agent</DrawerTitle>\n <div className=\"flex flex-col overflow-hidden flex-1 min-h-0\">\n {body}\n </div>\n </DrawerContent>\n </Drawer>\n );\n }\n\n // ── Desktop ──\n // The popover reserves its full two-column width for the entire time it is\n // open, so the hover-preview / filter panels toggle WITHOUT resizing or\n // repositioning the popover. A resizing popover in a narrow rail triggers\n // Radix collision-shifting that yanks the list out from under the cursor —\n // the panel \"appears, then runs away.\" A fixed footprint keeps the preview\n // a stationary, reachable target.\n return (\n <Popover open={open} onOpenChange={handleOpen} modal={false}>\n {wrapTrigger(PopoverTrigger)}\n {/* POPOVER-CENSUS 2026-09-22: sizing left \"fixed\" — fixed-shape two-column panel (340px list + 340px detail, fixed height) — not a single text label; sizing=content's 28rem ceiling would clip the panel layout, not fix clipped text. */}\n <PopoverContent\n {...(openSide ? { side: openSide } : fitHeight ? { side: \"bottom\" as const } : {})}\n align=\"start\"\n sideOffset={4}\n collisionPadding={12}\n sticky=\"always\"\n {...(popoverContainer ? { container: popoverContainer } : {})}\n className=\"p-0 overflow-hidden\"\n style={{ width: PANEL_WIDTH, height: fitHeight ?? PANEL_HEIGHT, maxHeight: fitHeight ?? LIST_MAX_HEIGHT }}\n >\n {body}\n </PopoverContent>\n </Popover>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentListPanel.tsx — THE agent picker body.\n *\n * The two-column picker a person sees when they open `AgentListDropdown`: the\n * list on the left (search, ownership tabs, filters, rows) and, on the right,\n * the hover peek (`AgentDetailCard`) or the sort / category / tag panel. On a\n * phone it is one column with the same detail and filter sub-views.\n *\n * It exists as its own component so every shell renders the SAME picker:\n * - `AgentListDropdown` puts it in a popover / drawer under a trigger;\n * - a host window (matrx-frontend's `agentPickerWindow`) puts it in a\n * floating window at the same 680 × 528 footprint.\n * Neither shell re-implements a row, a panel, or a hover rule.\n *\n * Two entry points:\n * - `AgentListPanel` — self-contained: owns its list core. Use it anywhere a\n * picker is a surface of its own (a window, a page region).\n * - `AgentListPanelBody` — takes a core the host already holds. The dropdown\n * uses it because its TRIGGER reads the same core (label, filter count)\n * and the core must outlive the popover closing.\n *\n * The body mounts when it is shown and unmounts when it is hidden, so \"open\"\n * behavior (load the roster, preview the pinned agent, focus search) runs on\n * mount and every transient panel resets by unmounting.\n */\n\nimport { cn, useIsMobile } from \"@ai-matrx/design-system\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { AgentCategoriesPanel } from \"./AgentCategoriesPanel\";\nimport { AgentDetailCard } from \"./AgentDetailCard\";\nimport { AgentListContent } from \"./AgentListContent\";\nimport { AgentMobileSubView } from \"./AgentMobileSubView\";\nimport { AgentSortPanel } from \"./AgentSortPanel\";\nimport { AgentTagsPanel } from \"./AgentTagsPanel\";\nimport { useAgentCatalog } from \"./context\";\nimport { ChevronRightIcon, MousePointerClickIcon } from \"./icons\";\nimport { PANEL_HEIGHT, type RightPanel } from \"./types\";\nimport { useAgentListCore } from \"./useAgentListCore\";\nimport type { AgentSummary, AgentTab } from \"../types\";\n\n/** The desktop picker's fixed footprint: a 340px list + a 340px peek. */\nexport const PANEL_WIDTH = \"680px\";\n\ntype AgentListCore = ReturnType<typeof useAgentListCore>;\n\ninterface AgentListPanelDisplayProps {\n /** Restrict which ownership tabs are available for domain-constrained pickers. */\n visibleTabs?: readonly AgentTab[];\n /** Label override for the builtin-agent tab. Admin surfaces use \"System\". */\n systemTabLabel?: string;\n /** ADMIN variant: blend system agents into the \"All\" tab (also labels it \"System\"). */\n includeSystemInAll?: boolean;\n /** Resolve the route used by each named agent door. */\n resolveAgentHref?: (agent: AgentSummary) => string;\n /** Show the active agent above the filtered list. Default true. */\n showPinnedAgent?: boolean;\n /** Focus the search field when the picker appears. Default true. */\n autoFocusSearch?: boolean;\n /** Runs after an agent is chosen (the core has already called `onSelect`). */\n onAfterSelect?: (agent: AgentSummary) => void;\n className?: string;\n}\n\nexport interface AgentListPanelBodyProps extends AgentListPanelDisplayProps {\n /** The list core the host holds (`useAgentListCore`). */\n core: AgentListCore;\n}\n\n/** The picker body over a core the host already holds. Fills its parent. */\nexport function AgentListPanelBody({\n core,\n visibleTabs,\n systemTabLabel,\n includeSystemInAll = false,\n resolveAgentHref,\n showPinnedAgent = true,\n autoFocusSearch = true,\n onAfterSelect,\n className,\n}: AgentListPanelBodyProps) {\n const isMobile = useIsMobile();\n const { labels } = useAgentCatalog();\n const [rightPanel, setRightPanel] = useState<RightPanel>(null);\n const [catSearch, setCatSearch] = useState(\"\");\n const [tagSearch, setTagSearch] = useState(\"\");\n const [mobileDetailAgent, setMobileDetailAgent] =\n useState<AgentSummary | null>(null);\n const [mobileSubView, setMobileSubView] = useState<\n \"sort\" | \"categories\" | \"tags\" | null\n >(null);\n const inputRef = useRef<HTMLInputElement>(null);\n\n const {\n agents,\n archivedHiddenCount,\n isLoading,\n activeAgentId,\n pinnedAgent,\n defaultRow,\n allCategories,\n allTags,\n consumer,\n tabCounts,\n activeFilterCount,\n hoveredAgent,\n setHoveredAgent,\n ensureLoaded,\n handleSelectAgent: coreSelectAgent,\n handleAgentHover: coreAgentHover,\n handleAgentHoverEnd: coreAgentHoverEnd,\n handleDetailPanelMouseEnter,\n handleDetailPanelMouseLeave: coreDetailMouseLeave,\n } = core;\n\n // \"Open\" = mount: load the roster and focus search.\n useEffect(() => {\n ensureLoaded();\n if (!autoFocusSearch) return undefined;\n const timer = setTimeout(() => inputRef.current?.focus(), 50);\n return () => clearTimeout(timer);\n }, [ensureLoaded, autoFocusSearch]);\n\n // Preview the pinned agent ONCE, as soon as it resolves — at mount when the\n // roster is already loaded (a dropdown re-opening), or when it lands (a\n // window opened cold). Never after the person has moved the peek themselves.\n const pinnedPreviewedRef = useRef(false);\n useEffect(() => {\n if (pinnedPreviewedRef.current || isMobile || !pinnedAgent) return;\n pinnedPreviewedRef.current = true;\n if (rightPanel !== null) return;\n setHoveredAgent(pinnedAgent);\n setRightPanel(\"detail\");\n }, [pinnedAgent, isMobile, rightPanel, setHoveredAgent]);\n\n const handleSelectAgent = (agent: AgentSummary) => {\n coreSelectAgent(agent);\n setMobileDetailAgent(null);\n setMobileSubView(null);\n onAfterSelect?.(agent);\n };\n\n const handleFilterChipClick = (panel: \"sort\" | \"categories\" | \"tags\") => {\n if (isMobile) {\n setMobileSubView(panel);\n } else {\n setRightPanel(rightPanel === panel ? null : panel);\n }\n };\n\n const handleAgentHover = useCallback(\n (agent: AgentSummary) => {\n if (isMobile) return;\n const filterPanelOpen =\n rightPanel === \"sort\" ||\n rightPanel === \"categories\" ||\n rightPanel === \"tags\";\n coreAgentHover(agent, filterPanelOpen);\n if (!filterPanelOpen) setRightPanel(\"detail\");\n },\n [isMobile, rightPanel, coreAgentHover],\n );\n\n const handleAgentHoverEnd = useCallback(\n (agent: AgentSummary) => {\n if (isMobile) return;\n if (rightPanel !== \"detail\") return;\n coreAgentHoverEnd(agent, () => setRightPanel(null));\n },\n [isMobile, rightPanel, coreAgentHoverEnd],\n );\n\n const handleDetailPanelMouseLeave = useCallback(() => {\n coreDetailMouseLeave(() => setRightPanel(null));\n }, [coreDetailMouseLeave]);\n\n const effectiveSystemTabLabel =\n systemTabLabel ?? (includeSystemInAll ? \"System\" : undefined);\n\n const listPanel = (\n <AgentListContent\n agents={agents}\n isLoading={isLoading}\n consumer={consumer}\n activeAgentId={activeAgentId}\n allCategories={allCategories}\n allTags={allTags}\n inputRef={inputRef}\n onSelectAgent={handleSelectAgent}\n {...(resolveAgentHref ? { resolveAgentHref } : {})}\n onReset={consumer.resetFilters}\n activeFilterCount={activeFilterCount}\n isMobile={isMobile}\n hoveredAgent={hoveredAgent}\n onAgentHover={handleAgentHover}\n onAgentHoverEnd={handleAgentHoverEnd}\n onDetailPress={setMobileDetailAgent}\n onFilterChipClick={handleFilterChipClick}\n rightPanel={rightPanel}\n tabCounts={tabCounts}\n archivedHiddenCount={archivedHiddenCount}\n {...(visibleTabs ? { visibleTabs } : {})}\n {...(effectiveSystemTabLabel\n ? { systemTabLabel: effectiveSystemTabLabel }\n : {})}\n pinnedAgent={showPinnedAgent ? pinnedAgent : null}\n defaultRow={defaultRow}\n listOpen\n />\n );\n\n // ── Mobile: one column, detail and filter panels as sub-views ──\n if (isMobile) {\n return (\n <div className={cn(\"flex min-h-0 flex-1 flex-col overflow-hidden\", className)}>\n {mobileDetailAgent ? (\n <div className=\"flex flex-col overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => setMobileDetailAgent(null)}\n className=\"flex items-center gap-1.5 px-3 py-2.5 text-sm font-medium text-primary hover:bg-muted/30 transition-colors border-b border-border shrink-0\"\n >\n <ChevronRightIcon className=\"w-4 h-4 rotate-180\" />\n Back\n </button>\n <div className=\"overflow-y-auto\">\n <AgentDetailCard\n agent={mobileDetailAgent}\n onSelect={() => handleSelectAgent(mobileDetailAgent)}\n />\n </div>\n </div>\n ) : mobileSubView ? (\n <AgentMobileSubView\n view={mobileSubView}\n consumer={consumer}\n allCategories={allCategories}\n allTags={allTags}\n catSearch={catSearch}\n setCatSearch={setCatSearch}\n tagSearch={tagSearch}\n setTagSearch={setTagSearch}\n onBack={() => {\n setMobileSubView(null);\n setCatSearch(\"\");\n setTagSearch(\"\");\n }}\n />\n ) : (\n listPanel\n )}\n </div>\n );\n }\n\n // ── Desktop: a fixed two-column footprint ──\n // Both columns are reserved for the whole time the picker is shown, so the\n // hover preview and filter panels toggle WITHOUT resizing anything. A\n // resizing panel in a narrow rail triggers collision-shifting that yanks the\n // list out from under the cursor; a fixed footprint keeps the preview a\n // stationary, reachable target.\n return (\n <div className={cn(\"flex h-full\", className)}>\n <div className=\"flex flex-col min-w-[340px] flex-1 border-r border-border\">\n {listPanel}\n </div>\n <div\n className=\"h-full w-[340px] shrink-0 overflow-hidden flex flex-col\"\n onMouseEnter={\n rightPanel === \"detail\" ? handleDetailPanelMouseEnter : undefined\n }\n onMouseLeave={\n rightPanel === \"detail\" ? handleDetailPanelMouseLeave : undefined\n }\n >\n {rightPanel === \"detail\" && hoveredAgent && (\n <div key={hoveredAgent.id} className=\"h-full matrx-agent-fade-in\">\n <AgentDetailCard\n agent={hoveredAgent}\n onSelect={() => handleSelectAgent(hoveredAgent)}\n />\n </div>\n )}\n {rightPanel === \"sort\" && (\n <AgentSortPanel\n consumer={consumer}\n onClose={() => setRightPanel(null)}\n />\n )}\n {rightPanel === \"categories\" && (\n <AgentCategoriesPanel\n consumer={consumer}\n allCategories={allCategories}\n search={catSearch}\n setSearch={setCatSearch}\n onClose={() => {\n setRightPanel(null);\n setCatSearch(\"\");\n }}\n />\n )}\n {rightPanel === \"tags\" && (\n <AgentTagsPanel\n consumer={consumer}\n allTags={allTags}\n search={tagSearch}\n setSearch={setTagSearch}\n onClose={() => {\n setRightPanel(null);\n setTagSearch(\"\");\n }}\n />\n )}\n {rightPanel === null && (\n <div className=\"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center\">\n <MousePointerClickIcon className=\"h-6 w-6 text-muted-foreground/40\" />\n <p className=\"text-xs text-muted-foreground/70 leading-relaxed\">\n {labels.hoverHint}\n </p>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nexport interface AgentListPanelProps extends AgentListPanelDisplayProps {\n /**\n * Fill the parent instead of the fixed `PANEL_WIDTH` × `PANEL_HEIGHT`\n * footprint — for a resizable host (a window). The list column takes the\n * extra width; the peek column stays 340px.\n */\n fill?: boolean;\n /** Unique consumer id for this picker's filter/tab state. */\n consumerId: string;\n /** The chosen agent's id (`mandate:<key>` for a mandate default row). */\n onSelect?: (agentId: string) => void;\n /** Navigate on select instead of (or besides) `onSelect`; `{id}` is replaced. */\n navigateTo?: string;\n /** Highlights + pins this agent in the list. */\n activeAgentId?: string | null;\n /** Tab to open on. Admin surfaces managing system agents pass `\"system\"`. */\n initialTab?: AgentTab;\n /** Hide records that are invalid for this call site. */\n excludeAgentIds?: readonly string[];\n /** Offer the mandate's live-resolved default agent at the top of the list. */\n defaultMandateKey?: string;\n}\n\n/**\n * The self-contained picker: owns its list core. Desktop renders at the fixed\n * `PANEL_WIDTH` × `PANEL_HEIGHT` footprint (or fills its parent with `fill`);\n * mobile fills its parent.\n */\nexport function AgentListPanel({\n consumerId,\n onSelect,\n navigateTo,\n activeAgentId,\n initialTab,\n includeSystemInAll = false,\n visibleTabs,\n excludeAgentIds,\n defaultMandateKey,\n resolveAgentHref: resolveAgentHrefProp,\n className,\n fill = false,\n ...display\n}: AgentListPanelProps) {\n const isMobile = useIsMobile();\n const core = useAgentListCore({\n consumerId,\n ...(onSelect ? { onSelect } : {}),\n ...(navigateTo ? { navigateTo } : {}),\n ...(activeAgentId !== undefined\n ? { activeAgentIdOverride: activeAgentId }\n : {}),\n ...(initialTab ? { initialTab } : {}),\n includeSystemInAll,\n ...(visibleTabs ? { visibleTabs } : {}),\n ...(excludeAgentIds ? { excludeAgentIds } : {}),\n ...(defaultMandateKey ? { defaultMandateKey } : {}),\n });\n const resolveAgentHref = useMemo(() => {\n if (resolveAgentHrefProp) return resolveAgentHrefProp;\n if (!navigateTo) return undefined;\n return (agent: AgentSummary) => navigateTo.replace(\"{id}\", agent.id);\n }, [navigateTo, resolveAgentHrefProp]);\n\n return (\n <div\n className={cn(\"flex min-h-0 flex-col overflow-hidden\", (isMobile || fill) && \"h-full w-full\", className)}\n style={isMobile || fill ? undefined : { width: PANEL_WIDTH, height: PANEL_HEIGHT }}\n >\n <AgentListPanelBody\n core={core}\n includeSystemInAll={includeSystemInAll}\n {...(visibleTabs ? { visibleTabs } : {})}\n {...(resolveAgentHref ? { resolveAgentHref } : {})}\n {...display}\n />\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/primitives.tsx — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/core/primitives.tsx`.\n * Seams: lucide icons → the package's own inlined SVGs (C19); `cn` from\n * `@ai-matrx/design-system`.\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\nimport type { ComponentType, Ref } from \"react\";\n\nimport { CheckIcon, SearchIcon, XIcon } from \"./icons\";\n\nexport const SearchInput = ({\n ref,\n value,\n onChange,\n placeholder,\n}: {\n ref?: Ref<HTMLInputElement>;\n value: string;\n onChange: (v: string) => void;\n placeholder: string;\n}) => (\n <div className=\"flex items-center gap-1.5 h-7 px-2 rounded-md bg-muted/40 border border-border/50\">\n <SearchIcon className=\"w-3 h-3 text-muted-foreground shrink-0\" />\n <input\n ref={ref}\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder}\n className=\"flex-1 bg-transparent text-xs text-foreground placeholder:text-muted-foreground/50 outline-none min-w-0\"\n style={{ fontSize: \"16px\" }}\n />\n {value && (\n <button\n type=\"button\"\n onClick={() => onChange(\"\")}\n className=\"text-muted-foreground hover:text-foreground\"\n aria-label=\"Clear search\"\n >\n <XIcon className=\"w-3 h-3\" />\n </button>\n )}\n </div>\n);\n\nexport function FilterChip({\n icon: Icon,\n label,\n active,\n focused,\n onClick,\n ariaLabel,\n testId,\n}: {\n icon: ComponentType<{ className?: string }>;\n label: string;\n active: boolean;\n focused?: boolean;\n onClick: () => void;\n /** Accessible name when the visible label alone would not say the state. */\n ariaLabel?: string;\n /** Stable hook so a shell test can measure the control, not a class name. */\n testId?: string;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n {...(testId ? { \"data-testid\": testId } : {})}\n className={cn(\n \"inline-flex items-center gap-1 h-6 px-1.5 rounded text-[11px] font-medium shrink-0 transition-colors\",\n focused\n ? \"bg-primary/15 text-primary border border-primary/30 ring-1 ring-primary/20\"\n : active\n ? \"bg-primary/10 text-primary border border-primary/20\"\n : \"text-muted-foreground hover:text-foreground hover:bg-muted/50 border border-transparent\",\n )}\n >\n <Icon className=\"w-3 h-3\" />\n <span>{label}</span>\n </button>\n );\n}\n\nexport function OptionRow({\n label,\n selected,\n onClick,\n}: {\n label: string;\n selected: boolean;\n onClick: () => void;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={cn(\n \"flex items-center w-full px-3 py-2 text-xs transition-colors\",\n \"hover:bg-muted/50 active:bg-muted/70\",\n selected && \"text-primary font-medium\",\n )}\n >\n <span className=\"flex-1 text-left\">{label}</span>\n {selected && <CheckIcon className=\"w-3.5 h-3.5 text-primary shrink-0\" />}\n </button>\n );\n}\n\nexport function CheckRow({\n label,\n checked,\n onClick,\n}: {\n label: string;\n checked: boolean;\n onClick: () => void;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className=\"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-muted/50 active:bg-muted/70 transition-colors\"\n >\n <div\n className={cn(\n \"w-3.5 h-3.5 rounded-sm border flex items-center justify-center shrink-0 transition-colors\",\n checked ? \"bg-primary border-primary\" : \"border-muted-foreground/30\",\n )}\n >\n {checked && <CheckIcon className=\"w-2.5 h-2.5 text-primary-foreground\" />}\n </div>\n <span className=\"flex-1 text-left truncate\">{label}</span>\n </button>\n );\n}\n\nexport function SidePanelHeader({\n title,\n onClose,\n}: {\n title: string;\n onClose: () => void;\n}) {\n return (\n <div className=\"flex items-center justify-between px-3 py-2 border-b border-border shrink-0\">\n <span className=\"text-xs font-semibold text-foreground\">{title}</span>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"w-5 h-5 rounded flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors\"\n aria-label=\"Close\"\n >\n <XIcon className=\"w-3.5 h-3.5\" />\n </button>\n </div>\n );\n}\n","/**\n * catalog/shared/icon-paths.ts — THE picker's glyph geometry, once.\n *\n * 🚨 C19: the package ships its OWN inlined SVGs (adapted from the Lucide\n * shapes the matrx-frontend originals used — same 24×24 grid, same 2px\n * stroke) rather than depending on an icon library. 0.9.0 lifted the path\n * data out of `catalog/react/icons.tsx` into this pure module so the React\n * Native entry draws the IDENTICAL shapes through `react-native-svg`: an\n * agent row wears the same star, and an Orchestra the same conductor mark, in\n * every Matrx client. A glyph added here appears on both platforms or on\n * neither; there is no way to give one platform a shape the other lacks.\n *\n * Pure data — no React, no DOM, no react-native.\n */\n\nexport interface AgentCatalogIconCircle {\n cx: number;\n cy: number;\n r: number;\n /** Painted with `currentColor` regardless of the icon's `filled` state. */\n filled?: boolean;\n}\n\nexport interface AgentCatalogIconShape {\n paths: readonly string[];\n circles?: readonly AgentCatalogIconCircle[];\n /** True when the icon supports a `filled` variant (only the star does). */\n fillable?: boolean;\n}\n\nconst SHAPES = {\n star: {\n paths: [\n \"M11.5 3.2a.6.6 0 0 1 1 0l2.3 4.7 5.2.8a.6.6 0 0 1 .3 1l-3.8 3.7.9 5.2a.6.6 0 0 1-.9.6L12 16.8l-4.6 2.4a.6.6 0 0 1-.9-.6l.9-5.2-3.8-3.7a.6.6 0 0 1 .3-1l5.2-.8Z\",\n ],\n fillable: true,\n },\n chevronRight: { paths: [\"m9 18 6-6-6-6\"] },\n chevronDown: { paths: [\"m6 9 6 6 6-6\"] },\n search: {\n paths: [\"m21 21-4.3-4.3\"],\n circles: [{ cx: 11, cy: 11, r: 8 }],\n },\n x: { paths: [\"M18 6 6 18\", \"m6 6 12 12\"] },\n check: { paths: [\"M20 6 9 17l-5-5\"] },\n arrowUpDown: {\n paths: [\"m21 16-4 4-4-4\", \"M17 20V4\", \"m3 8 4-4 4 4\", \"M7 4v16\"],\n },\n folder: {\n paths: [\n \"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z\",\n ],\n },\n tag: {\n paths: [\n \"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z\",\n ],\n circles: [{ cx: 7.5, cy: 7.5, r: 0.5, filled: true }],\n },\n rotateCcw: {\n paths: [\n \"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\",\n \"M3 3v5h5\",\n ],\n },\n loader: { paths: [\"M21 12a9 9 0 1 1-6.219-8.56\"] },\n alertTriangle: {\n paths: [\n \"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\",\n \"M12 9v4\",\n \"M12 17h.01\",\n ],\n },\n /**\n * The Orchestra marker (Lucide `music-4`): the glyph the Workflow Studio's\n * picker used for a conductor, kept identical so the same agent wears the\n * same mark in every client.\n */\n music4: {\n paths: [\"M9 18V5l12-2v13\", \"m9 9 12-2\"],\n circles: [\n { cx: 6, cy: 18, r: 3 },\n { cx: 18, cy: 16, r: 3 },\n ],\n },\n clock: {\n paths: [\"M12 6v6l4 2\"],\n circles: [{ cx: 12, cy: 12, r: 10 }],\n },\n globe: {\n paths: [\"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20\", \"M2 12h20\"],\n circles: [{ cx: 12, cy: 12, r: 10 }],\n },\n users: {\n paths: [\n \"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\",\n \"M22 21v-2a4 4 0 0 0-3-3.87\",\n \"M16 3.13a4 4 0 0 1 0 7.75\",\n ],\n circles: [{ cx: 9, cy: 7, r: 4 }],\n },\n externalLink: {\n paths: [\n \"M15 3h6v6\",\n \"M10 14 21 3\",\n \"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\",\n ],\n },\n messageCircle: { paths: [\"M7.9 20A9 9 0 1 0 4 16.1L2 22Z\"] },\n rocket: {\n paths: [\n \"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91 0\",\n \"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2\",\n \"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0\",\n \"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5\",\n ],\n },\n /**\n * THE ARCHIVE GLYPH (Lucide `archive`) — the ONE mark of the platform\n * archive filter, drawn identically in every Matrx client so the control a\n * person learns on one surface is recognisable on all of them.\n */\n archive: {\n paths: [\n \"M3 3h18a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z\",\n \"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8\",\n \"M10 12h4\",\n ],\n },\n circleCheck: {\n paths: [\"m9 12 2 2 4-4\"],\n circles: [{ cx: 12, cy: 12, r: 10 }],\n },\n} satisfies Record<string, AgentCatalogIconShape>;\n\nexport type AgentCatalogIconName = keyof typeof SHAPES;\n\n/** The glyph table, widened so every shape reads uniformly at a call site. */\nexport const ICON_PATHS: Record<AgentCatalogIconName, AgentCatalogIconShape> =\n SHAPES;\n\n/** Every glyph the picker can draw. Both entries must cover all of them. */\nexport const ICON_NAMES = Object.keys(ICON_PATHS) as AgentCatalogIconName[];\n","\"use client\";\n\n/**\n * catalog/react/icons.tsx — @ai-matrx/agents/catalog/react\n *\n * 🚨 C19 — NO ICON-LIBRARY DEPENDENCY, EVER. The picker's glyphs ship as\n * inlined SVGs (adapted from the Lucide shapes the matrx-frontend originals\n * used, same 24×24 grid, same 2px stroke), exactly as `@ai-matrx/tap-target`\n * does for its ~60 buttons. A dependency on `lucide-react` would cost every\n * consumer a version-skew risk for a fraction of a percent of bytes.\n *\n * 0.9.0: the PATH DATA moved to `../shared/icon-paths`, which the React Native\n * entry draws through `react-native-svg`. The components below are unchanged\n * in name, props and output — they now read their geometry from the shared\n * table instead of holding a private copy, so a glyph can never differ between\n * the web picker and the native one.\n *\n * Colour comes from `currentColor` only — no hardcoded fill anywhere.\n */\n\nimport type { SVGProps } from \"react\";\n\nimport { ICON_PATHS, type AgentCatalogIconName } from \"../shared/icon-paths\";\n\nexport type IconProps = SVGProps<SVGSVGElement> & { className?: string };\n\nfunction Svg({ children, ...props }: IconProps & { children: React.ReactNode }) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n {...props}\n >\n {children}\n </svg>\n );\n}\n\n/** Draw one shared shape. `filled` only affects the icons that declare it. */\nfunction Shape({ name, filled }: { name: AgentCatalogIconName; filled: boolean }) {\n const shape = ICON_PATHS[name];\n return (\n <>\n {shape.paths.map((d, index) => (\n <path\n key={`p${index}`}\n d={d}\n {...(filled && shape.fillable ? { fill: \"currentColor\" } : {})}\n />\n ))}\n {(shape.circles ?? []).map((circle, index) => (\n <circle\n key={`c${index}`}\n cx={circle.cx}\n cy={circle.cy}\n r={circle.r}\n {...(circle.filled ? { fill: \"currentColor\" } : {})}\n />\n ))}\n </>\n );\n}\n\nfunction makeIcon(name: AgentCatalogIconName) {\n return function Icon(props: IconProps) {\n return (\n <Svg {...props}>\n <Shape name={name} filled={false} />\n </Svg>\n );\n };\n}\n\n/** The favourite star. `filled` paints it with `currentColor`. */\nexport function StarIcon({\n filled = false,\n ...props\n}: IconProps & { filled?: boolean }) {\n return (\n <Svg {...props} fill={filled ? \"currentColor\" : \"none\"}>\n <Shape name=\"star\" filled={filled} />\n </Svg>\n );\n}\n\nexport const ChevronRightIcon = makeIcon(\"chevronRight\");\nexport const ChevronDownIcon = makeIcon(\"chevronDown\");\nexport const SearchIcon = makeIcon(\"search\");\nexport const XIcon = makeIcon(\"x\");\nexport const CheckIcon = makeIcon(\"check\");\nexport const ArrowUpDownIcon = makeIcon(\"arrowUpDown\");\nexport const FolderIcon = makeIcon(\"folder\");\nexport const TagIcon = makeIcon(\"tag\");\nexport const RotateCcwIcon = makeIcon(\"rotateCcw\");\nexport const ArchiveIcon = makeIcon(\"archive\");\nexport const LoaderIcon = makeIcon(\"loader\");\nexport const UsersIcon = makeIcon(\"users\");\nexport const ClockIcon = makeIcon(\"clock\");\nexport const GlobeIcon = makeIcon(\"globe\");\nexport const ExternalLinkIcon = makeIcon(\"externalLink\");\nexport const MessageCircleIcon = makeIcon(\"messageCircle\");\nexport const RocketIcon = makeIcon(\"rocket\");\nexport const CircleCheckIcon = makeIcon(\"circleCheck\");\n/** The drift banner's glyph. */\nexport const AlertTriangleIcon = makeIcon(\"alertTriangle\");\n/**\n * The Orchestra marker (Lucide `music-4`): the glyph the Workflow Studio's\n * picker used for a conductor, kept identical so the same agent wears the same\n * mark in every client.\n */\nexport const Music4Icon = makeIcon(\"music4\");\n\n/**\n * The empty-hover-panel hint glyph. Web-only: the native picker has no hover\n * panel, so this shape has no native twin and stays local to this file.\n */\nexport function MousePointerClickIcon(props: IconProps) {\n return (\n <Svg {...props}>\n <path d=\"M14 4.1 12 6\" />\n <path d=\"m5.1 8-2.9-.8\" />\n <path d=\"m6 12-1.9 2\" />\n <path d=\"M7.2 2.2 8 5.1\" />\n <path d=\"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z\" />\n </Svg>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentCategoriesPanel.tsx — port of `.../core/AgentCategoriesPanel.tsx`.\n *\n * 🚨 ONE DEFECT FIXED, NOT PRESERVED (C22 — a real defect found in the original\n * is fixed in the package AND recorded in the CHANGELOG). The original's\n * \"Clear (n)\" ran `consumer.includedCats.forEach(consumer.toggleCategory)`,\n * and `toggleCategory` computes its next array from the `includedCats`\n * captured in the CURRENT render — so three toggles fired in one tick all\n * start from the same snapshot and the last write wins: clicking Clear with\n * three categories active removed exactly ONE. matrx-frontend's own\n * `useAgentConsumer` documents this hazard and names `setIncludedCats` as the\n * fix; the call site never adopted it. It does here.\n */\n\nimport { CheckRow, SearchInput, SidePanelHeader } from \"./primitives\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\n\nexport interface AgentCategoriesPanelProps {\n consumer: UseAgentConsumerReturn;\n allCategories: string[];\n search: string;\n setSearch: (v: string) => void;\n onClose: () => void;\n}\n\nexport function AgentCategoriesPanel({\n consumer,\n allCategories,\n search,\n setSearch,\n onClose,\n}: AgentCategoriesPanelProps) {\n const filtered = allCategories.filter(\n (c) => !search || c.toLowerCase().includes(search.toLowerCase()),\n );\n return (\n <div className=\"flex flex-col h-full\">\n <SidePanelHeader title=\"Categories\" onClose={onClose} />\n <div className=\"px-2 pt-2 pb-1 shrink-0\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"Filter categories...\"\n />\n </div>\n {consumer.includedCats.length > 0 && (\n <button\n type=\"button\"\n onClick={() => consumer.setIncludedCats([])}\n className=\"mx-2 mb-1 h-6 rounded text-[11px] font-medium text-primary hover:bg-muted/50 transition-colors text-left shrink-0\"\n >\n Clear ({consumer.includedCats.length})\n </button>\n )}\n <div className=\"overflow-y-auto flex-1\">\n {filtered.length === 0 ? (\n <p className=\"text-xs text-muted-foreground text-center py-6\">\n No categories\n </p>\n ) : (\n filtered.map((cat) => (\n <CheckRow\n key={cat}\n label={cat}\n checked={consumer.includedCats.includes(cat)}\n onClick={() => consumer.toggleCategory(cat)}\n />\n ))\n )}\n </div>\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentDetailCard.tsx — VERBATIM port of matrx-frontend\n * `.../core/AgentDetailCard.tsx`. Seams:\n * - `HoverCard` + `Button` from `@/components/ui/*` → `@ai-matrx/design-system`.\n * - `AgentSneakPeekContent`/`AgentSneakPeekCopyMenu` → the `openPeek` port.\n * ABSENT → the peek affordance is HIDDEN. Never a dead button.\n * - `AiModelRef` → the `renderModelRef` port (default: the model id as text).\n * - `next/link` → the `LinkComponent` port.\n * - lucide icons → the package's inlined SVGs (C19).\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\n\nimport { FavoriteAgentButton } from \"./FavoriteAgentButton\";\nimport { useAgentCatalogUiPorts } from \"./context\";\nimport {\n ClockIcon,\n ExternalLinkIcon,\n FolderIcon,\n GlobeIcon,\n MessageCircleIcon,\n Music4Icon,\n RocketIcon,\n TagIcon,\n UsersIcon,\n} from \"./icons\";\nimport {\n orchestraDelegatesLine,\n orchestraDepthLine,\n orchestraLabel,\n} from \"../orchestra\";\nimport { isMandateAgentId, type AgentSummary } from \"../types\";\n\nexport interface AgentDetailCardProps {\n agent: AgentSummary;\n onSelect: () => void;\n}\n\nexport function AgentDetailCard({ agent, onSelect }: AgentDetailCardProps) {\n const { LinkComponent, renderModelRef, openPeek } = useAgentCatalogUiPorts();\n const updatedDate = agent.updatedAt ? new Date(agent.updatedAt) : null;\n const createdDate = agent.createdAt ? new Date(agent.createdAt) : null;\n // A mandate default row is a live reference, not a stored agent — it has no\n // agent door and no favorite. Its actions are the ones that make sense.\n const isDefaultRow = isMandateAgentId(agent.id);\n\n const formatDate = (d: Date | null) => {\n if (!d) return null;\n return d.toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n });\n };\n\n return (\n <div className=\"flex flex-col h-full\">\n <div className=\"px-4 pt-4 pb-3\">\n <div className=\"flex items-start gap-3\">\n <div className=\"w-9 h-9 rounded-lg bg-primary/10 flex items-center justify-center shrink-0\" />\n <div className=\"flex-1 min-w-0\">\n <h3 className=\"text-sm font-semibold text-foreground leading-tight truncate\">\n {agent.name || \"Untitled\"}\n </h3>\n {agent.isFavorite && (\n <div className=\"flex items-center gap-1 mt-0.5\">\n <span className=\"text-[11px] matrx-agent-star-on\">\n Pinned to favorites\n </span>\n </div>\n )}\n </div>\n {!isDefaultRow && <FavoriteAgentButton id={agent.id} variant=\"list\" />}\n </div>\n </div>\n\n <div className=\"h-px bg-border mx-3\" />\n\n <div className=\"flex-1 overflow-y-auto px-4 py-3 space-y-3\">\n {/* THE ORCHESTRA BLOCK COMES FIRST. Everything below describes an\n agent; this says the choice runs an ENSEMBLE, which changes what\n selecting it means. Ported from the Workflow Studio picker's\n selected-agent lines, which were the only place this ever showed. */}\n {agent.orchestra && (\n <div className=\"rounded-md border border-primary/20 bg-primary/5 px-2.5 py-2\">\n <div className=\"flex items-center gap-1.5\">\n <Music4Icon className=\"w-3.5 h-3.5 text-primary shrink-0\" />\n <span className=\"text-[11px] font-medium text-primary\">\n {orchestraLabel(agent.orchestra)}\n </span>\n </div>\n {agent.orchestra.tagline && (\n <p className=\"mt-1 text-xs text-foreground/80 leading-relaxed\">\n {agent.orchestra.tagline}\n </p>\n )}\n {orchestraDelegatesLine(agent.orchestra) && (\n <p\n className=\"mt-1 text-[11px] text-muted-foreground\"\n title={`Delegates to: ${agent.orchestra.memberTitles.join(\", \")}`}\n >\n {orchestraDelegatesLine(agent.orchestra)}\n </p>\n )}\n {orchestraDepthLine(agent.orchestra) && (\n <p className=\"mt-0.5 text-[11px] text-muted-foreground\">\n {orchestraDepthLine(agent.orchestra)}\n </p>\n )}\n </div>\n )}\n\n {agent.description && (\n <div>\n <p className=\"text-[11px] font-medium text-muted-foreground uppercase tracking-wider mb-1\">\n Description\n </p>\n <p className=\"text-xs text-foreground/80 leading-relaxed\">\n {agent.description}\n </p>\n </div>\n )}\n\n {agent.category && (\n <div className=\"flex items-center gap-2\">\n <FolderIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n <span className=\"text-xs text-foreground/80\">{agent.category}</span>\n </div>\n )}\n\n {agent.tags && agent.tags.length > 0 && (\n <div>\n <div className=\"flex items-center gap-1.5 mb-1.5\">\n <TagIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n <span className=\"text-[11px] font-medium text-muted-foreground\">\n Tags\n </span>\n </div>\n <div className=\"flex flex-wrap gap-1\">\n {agent.tags.map((tag) => (\n <span\n key={tag}\n className=\"inline-flex items-center h-5 px-1.5 rounded text-[10px] font-medium bg-muted text-muted-foreground\"\n >\n {tag}\n </span>\n ))}\n </div>\n </div>\n )}\n\n {agent.accessLevel && (\n <div className=\"flex items-center gap-2\">\n {agent.isOwner === false ? (\n <UsersIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n ) : (\n <GlobeIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n )}\n <div className=\"flex flex-col\">\n <span className=\"text-xs text-foreground/80 capitalize\">\n {agent.accessLevel === \"owner\"\n ? \"You own this\"\n : `Shared — ${agent.accessLevel}`}\n </span>\n {agent.sharedByEmail && (\n <span className=\"text-[10px] text-muted-foreground\">\n by {agent.sharedByEmail}\n </span>\n )}\n </div>\n </div>\n )}\n\n {agent.modelId && (\n <div className=\"flex items-center gap-2\">\n {renderModelRef({\n modelId: agent.modelId,\n ...(agent.offeringId !== undefined\n ? { offeringId: agent.offeringId }\n : {}),\n className: \"max-w-full text-xs text-foreground/80\",\n })}\n </div>\n )}\n\n {(updatedDate || createdDate) && (\n <div className=\"pt-1 space-y-1\">\n {updatedDate && (\n <div className=\"flex items-center gap-2\">\n <ClockIcon className=\"w-3.5 h-3.5 text-muted-foreground shrink-0\" />\n <span className=\"text-[11px] text-muted-foreground\">\n Updated {formatDate(updatedDate)}\n </span>\n </div>\n )}\n {createdDate && (\n <div className=\"flex items-center gap-2\">\n <ClockIcon className=\"w-3.5 h-3.5 text-muted-foreground/50 shrink-0\" />\n <span className=\"text-[11px] text-muted-foreground/70\">\n Created {formatDate(createdDate)}\n </span>\n </div>\n )}\n </div>\n )}\n </div>\n\n <div className=\"h-px bg-border mx-3 mt-auto\" />\n <div className=\"px-3 py-2 shrink-0 flex items-center gap-1.5\">\n <button\n type=\"button\"\n onClick={onSelect}\n className=\"flex-1 h-7 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 active:bg-primary/80 transition-colors\"\n >\n Select\n </button>\n {openPeek && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n openPeek(agent);\n }}\n title=\"Sneak Peek\"\n aria-label=\"Sneak Peek\"\n className={iconButtonClass}\n >\n <RocketIcon className=\"w-3.5 h-3.5\" />\n </button>\n )}\n {!isDefaultRow && (\n <>\n <LinkComponent\n href={`/chat/a/${agent.id}`}\n onClick={(e) => e.stopPropagation()}\n title=\"Open in chat\"\n aria-label=\"Open in chat\"\n className={iconButtonClass}\n >\n <MessageCircleIcon className=\"w-3.5 h-3.5\" />\n </LinkComponent>\n <LinkComponent\n href={`/agents/go/${agent.id}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={(e) => e.stopPropagation()}\n title=\"Open in new tab\"\n aria-label=\"Open in new tab\"\n className={cn(\n iconButtonClass,\n \"hover:text-foreground\",\n )}\n >\n <ExternalLinkIcon className=\"w-3.5 h-3.5\" />\n </LinkComponent>\n </>\n )}\n </div>\n </div>\n );\n}\n\nconst iconButtonClass =\n \"flex items-center justify-center h-7 w-7 rounded-md border border-border bg-background text-muted-foreground hover:text-primary hover:bg-muted/50 transition-colors shrink-0\";\n","\"use client\";\n\n/**\n * catalog/react/FavoriteAgentButton.tsx — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/FavoriteAgentButton.tsx`.\n * Seams: Redux (`selectAgentById` + `saveAgentField`) → the catalog store's\n * `getAgent` + `setFavorite`; lucide `Star` → the inlined SVG; the amber\n * literal → the `--matrx-agent-favorite` token (C26 — no hardcoded colour in\n * package components).\n *\n * A star is PER-PERSON (`platform.user_entity_state`), so every agent the\n * caller can see is starrable — shared and system agents included. The old\n * \"Shared — cannot favorite\" gate existed only because the retired\n * `agent.definition.is_favorite` flag lived on the OWNER's row.\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\nimport { useCallback } from \"react\";\n\nimport { useAgentCatalog, useAgentCatalogState } from \"./context\";\nimport { StarIcon } from \"./icons\";\nimport type { AgentCatalogState } from \"../store\";\n\ninterface FavoriteAgentButtonProps {\n id: string;\n /** \"card\" = absolute-positioned corner star, \"list\" = inline icon button */\n variant?: \"card\" | \"list\";\n disabled?: boolean;\n}\n\nexport function FavoriteAgentButton({\n id,\n variant = \"card\",\n disabled,\n}: FavoriteAgentButtonProps) {\n const catalog = useAgentCatalog();\n const select = useCallback(\n (state: AgentCatalogState) => state.byId[id],\n [id],\n );\n const record = useAgentCatalogState(select);\n const isFavorite = record?.isFavorite ?? false;\n\n const handleClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (disabled) return;\n void catalog.setFavorite(id, !isFavorite).catch(() => {\n // Already rolled back and screamed by the store.\n });\n };\n\n const title = isFavorite ? \"Remove from favorites\" : \"Add to favorites\";\n\n if (variant === \"list\") {\n return (\n <button\n type=\"button\"\n className={cn(\n \"flex-shrink-0 p-0.5 rounded transition-all duration-150\",\n \"focus:outline-none focus-visible:ring-2 focus-visible:ring-primary\",\n disabled\n ? \"cursor-not-allowed\"\n : \"hover:scale-110 cursor-pointer\",\n )}\n onClick={handleClick}\n disabled={disabled}\n title={title}\n aria-label={isFavorite ? \"Remove from favorites\" : \"Add to favorites\"}\n >\n <StarIcon\n filled={isFavorite}\n className={cn(\n \"h-3.5 w-3.5 transition-all duration-150\",\n isFavorite\n ? \"matrx-agent-star-on\"\n : \"text-muted-foreground/40 hover:matrx-agent-star-on\",\n )}\n />\n </button>\n );\n }\n\n return (\n <button\n type=\"button\"\n className={cn(\n \"absolute top-2.5 right-2.5 z-10 p-0.5 rounded transition-all duration-150\",\n \"focus:outline-none focus-visible:ring-2 focus-visible:ring-primary\",\n disabled\n ? \"cursor-not-allowed\"\n : \"hover:scale-110 cursor-pointer\",\n isFavorite\n ? \"matrx-agent-star-on\"\n : \"text-muted-foreground/40 hover:matrx-agent-star-on\",\n )}\n onClick={handleClick}\n disabled={disabled}\n title={title}\n aria-label={isFavorite ? \"Remove from favorites\" : \"Add to favorites\"}\n >\n <StarIcon filled={isFavorite} className=\"w-4 h-4 transition-all duration-150\" />\n </button>\n );\n}\n","/**\n * catalog/orchestra.ts — @ai-matrx/agents/catalog\n *\n * Creator words for an Orchestra badge. A VERBATIM port of the helpers the\n * Workflow Studio's hand-rolled picker carried (`apps/workflow-studio/src/\n * hooks/use-agents.ts` before `c0f958b43`), lifted here so every client says\n * the same sentence about the same ensemble.\n *\n * Pure — no React, no DOM. The row shape is `OrchestraBadge` in `./types`.\n */\n\nimport type { OrchestraBadge } from \"./types\";\n\n/**\n * Creator words for an Orchestra's run mode. \"supervisor\" is already plain\n * English; the structural modes get humanized (never \"sequential/parallel/dag\"\n * at eye level). An unknown future mode falls through as its own word rather\n * than hiding — visible-but-unpolished beats invisible.\n */\nconst ORCHESTRA_MODE_LABEL: Record<string, string> = {\n supervisor: \"supervisor\",\n sequential: \"in order\",\n parallel: \"together\",\n dag: \"custom flow\",\n};\n\nexport function orchestraModeLabel(mode: string): string {\n return ORCHESTRA_MODE_LABEL[mode] ?? mode;\n}\n\n/** Human label for a badge: \"Orchestra · supervisor · 3 members\" (singular-safe). */\nexport function orchestraLabel(badge: OrchestraBadge): string {\n const n = badge.memberCount;\n return `Orchestra · ${orchestraModeLabel(badge.mode)} · ${n} ${\n n === 1 ? \"member\" : \"members\"\n }`;\n}\n\n/**\n * The member-call ceiling in Creator language (\"Team members can call helpers\n * up to 2 levels deep\"), or `null` when the composition declared none. A badge\n * never invents the platform default: the server that runs the ensemble owns\n * that number, and printing a promise nobody made is worse than printing\n * nothing.\n */\nexport function orchestraDepthLine(badge: OrchestraBadge): string | null {\n const n = badge.depthBudget;\n if (typeof n !== \"number\" || n <= 0) return null;\n return `Team members can call helpers up to ${n} ${\n n === 1 ? \"level\" : \"levels\"\n } deep`;\n}\n\n/**\n * One visible line naming who the Orchestra delegates to, collapsing past\n * `limit` into \"+N more\". `null` when no member carries a real role title —\n * \"Member, Member, Member\" is noise that reads like data.\n */\nexport function orchestraDelegatesLine(\n badge: OrchestraBadge,\n limit = 3,\n): string | null {\n const titles = badge.memberTitles;\n if (titles.length === 0) return null;\n const shown = titles.slice(0, limit);\n const extra = titles.length - shown.length;\n return `Delegates to: ${shown.join(\", \")}${\n extra > 0 ? ` +${extra} more` : \"\"\n }`;\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentListContent.tsx — port of `.../core/AgentListContent.tsx`.\n *\n * Additive to the original: the MANDATE DEFAULT ROW and its DRIFT BANNER. The\n * banner is the primary scream and it is PERSISTENT — it does not auto-dismiss\n * and it is not a console line (design D3). The `notifier` port fires beside\n * it, never instead of it.\n */\n\nimport { ErrorBox } from \"@ai-matrx/design-system\";\nimport { useEffect, useRef } from \"react\";\n\nimport { AgentFilterBar } from \"./AgentFilterBar\";\nimport { AgentListTabs, type AgentListTabCounts } from \"./AgentListTabs\";\nimport { AgentRow } from \"./AgentRow\";\nimport { useAgentCatalog } from \"./context\";\nimport { AlertTriangleIcon, LoaderIcon, XIcon } from \"./icons\";\nimport { SearchInput } from \"./primitives\";\nimport type { RightPanel } from \"./types\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\nimport type { DefaultRowState } from \"../default-row-types\";\nimport { agentListEmptyLabel, agentListFooterLabel } from \"../labels\";\nimport type { AgentSummary, AgentTab } from \"../types\";\n\nexport interface AgentListContentProps {\n agents: AgentSummary[];\n isLoading: boolean;\n consumer: UseAgentConsumerReturn;\n activeAgentId: string | null;\n allCategories: string[];\n allTags: string[];\n inputRef: React.RefObject<HTMLInputElement | null>;\n onSelectAgent: (a: AgentSummary) => void;\n /** Per-row href for cmd/ctrl+click. Defaults to `/agents/go/[id]`. */\n resolveAgentHref?: ((agent: AgentSummary) => string) | undefined;\n onReset: () => void;\n activeFilterCount: number;\n isMobile: boolean;\n hoveredAgent: AgentSummary | null;\n onAgentHover: (a: AgentSummary) => void;\n onAgentHoverEnd: (a: AgentSummary) => void;\n onDetailPress: (a: AgentSummary) => void;\n onFilterChipClick: (panel: \"sort\" | \"categories\" | \"tags\") => void;\n rightPanel: RightPanel;\n tabCounts: AgentListTabCounts;\n /** Limit the ownership tabs shown by this picker. */\n visibleTabs?: readonly AgentTab[] | undefined;\n /** Label override for the builtin tab — admin surfaces pass \"System\". */\n systemTabLabel?: string | undefined;\n /** Resolved current agent — pinned at the top when the list opens. */\n pinnedAgent?: AgentSummary | null | undefined;\n /** The mandate default row, when this picker was given a `defaultMandateKey`. */\n defaultRow?: DefaultRowState | null | undefined;\n /** When true, scroll the list to the pinned row (top). */\n listOpen?: boolean | undefined;\n /**\n * Rows the ARCHIVE FILTER is currently keeping off this screen — from\n * `useAgentListCore`. The footer names them (clause 2 of THE ARCHIVED-ITEMS\n * LAW: a screen never implies the list is everything). 0 means \"nothing\n * archived is hidden behind this view\", which is also what a host that\n * mounts this component directly and passes nothing gets.\n */\n archivedHiddenCount?: number | undefined;\n}\n\nexport function AgentListContent({\n agents,\n isLoading,\n consumer,\n activeAgentId,\n allCategories,\n allTags,\n inputRef,\n onSelectAgent,\n resolveAgentHref,\n onReset,\n activeFilterCount,\n isMobile,\n hoveredAgent,\n onAgentHover,\n onAgentHoverEnd,\n onDetailPress,\n onFilterChipClick,\n rightPanel,\n tabCounts,\n visibleTabs,\n systemTabLabel,\n pinnedAgent = null,\n defaultRow = null,\n listOpen = false,\n archivedHiddenCount = 0,\n}: AgentListContentProps) {\n const catalog = useAgentCatalog();\n const listScrollRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (listOpen && pinnedAgent) {\n listScrollRef.current?.scrollTo({ top: 0 });\n }\n }, [listOpen, pinnedAgent?.id]);\n\n const { labels } = catalog;\n const emptyLabel =\n catalog.getUserIdOrNull() === null\n ? labels.emptySignedOut\n : agentListEmptyLabel(consumer.tab, labels);\n const defaultAgent = defaultRow?.row ?? null;\n\n return (\n <div className=\"flex flex-col h-full\">\n {/* Search */}\n <div className=\"px-2 pt-2 pb-1 shrink-0\">\n <SearchInput\n ref={inputRef}\n value={consumer.searchTerm}\n onChange={consumer.setSearchTerm}\n placeholder={labels.searchPlaceholder}\n />\n </div>\n\n <AgentListTabs\n consumer={consumer}\n tabCounts={tabCounts}\n systemTabLabel={systemTabLabel}\n visibleTabs={visibleTabs}\n />\n\n {/* Filter bar */}\n <AgentFilterBar\n consumer={consumer}\n allCategories={allCategories}\n allTags={allTags}\n activeFilterCount={activeFilterCount}\n isMobile={isMobile}\n rightPanel={rightPanel}\n onFilterChipClick={onFilterChipClick}\n onReset={onReset}\n />\n\n {/* 🚨 THE DRIFT SCREAM — persistent, in the picker, never console-only. */}\n {defaultRow?.drift && (\n <div\n role=\"status\"\n className=\"matrx-agent-drift-banner mx-2 mb-1.5 flex items-start gap-2 rounded-md px-2 py-1.5 shrink-0\"\n >\n <AlertTriangleIcon className=\"w-3.5 h-3.5 shrink-0 mt-px\" />\n <span className=\"text-[11px] leading-snug flex-1\">\n {defaultRow.drift}\n </span>\n <button\n type=\"button\"\n aria-label=\"Dismiss\"\n onClick={() => catalog.dismissDefaultRowDrift(defaultRow.mandateKey)}\n className=\"shrink-0 opacity-70 hover:opacity-100\"\n >\n <XIcon className=\"w-3 h-3\" />\n </button>\n </div>\n )}\n {defaultRow?.error && (\n <ErrorBox\n as=\"div\"\n className=\"matrx-agent-drift-banner mx-2 mb-1.5 flex items-start gap-2 rounded-md px-2 py-1.5 shrink-0\"\n message={defaultRow.error}\n operation={`Load the default agent for ${defaultRow.mandateKey}`}\n origin=\"agents/AgentListContent\"\n >\n <AlertTriangleIcon className=\"w-3.5 h-3.5 shrink-0 mt-px\" />\n <span className=\"text-[11px] leading-snug flex-1\">\n {defaultRow.error}\n </span>\n <button\n type=\"button\"\n onClick={() => catalog.retryDefaultRow(defaultRow.mandateKey)}\n className=\"shrink-0 text-[11px] font-medium underline underline-offset-2 opacity-80 hover:opacity-100\"\n >\n Try again\n </button>\n </ErrorBox>\n )}\n\n <div className=\"h-px bg-border shrink-0\" />\n\n {/* Agent list */}\n <div ref={listScrollRef} className=\"overflow-y-auto flex-1 min-h-0\">\n {isLoading ? (\n <div className=\"flex items-center justify-center py-8 gap-2 text-muted-foreground\">\n <LoaderIcon className=\"w-4 h-4 matrx-agent-spin\" />\n <span className=\"text-xs\">{labels.loading}</span>\n </div>\n ) : agents.length === 0 && !pinnedAgent && !defaultAgent ? (\n <div className=\"flex flex-col items-center py-8 text-muted-foreground\">\n <span className=\"text-xs\">{emptyLabel}</span>\n </div>\n ) : (\n <div className=\"py-0.5\">\n {defaultAgent && (\n <>\n <div className=\"px-3 pt-1.5 pb-0.5\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n Default\n </span>\n </div>\n <AgentRow\n key={`default-${defaultAgent.id}`}\n agent={defaultAgent}\n isActive={defaultAgent.id === activeAgentId}\n isHovered={hoveredAgent?.id === defaultAgent.id}\n isMobile={isMobile}\n onClick={() => onSelectAgent(defaultAgent)}\n href={resolveAgentHref?.(defaultAgent)}\n onHover={() => onAgentHover(defaultAgent)}\n onHoverEnd={() => onAgentHoverEnd(defaultAgent)}\n onDetailPress={() => onDetailPress(defaultAgent)}\n />\n <div className=\"mx-2 my-0.5 h-px bg-border\" />\n </>\n )}\n {pinnedAgent && (\n <>\n <div className=\"px-3 pt-1.5 pb-0.5\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n {labels.currentAgentHeading}\n </span>\n </div>\n <AgentRow\n key={`pinned-${pinnedAgent.id}`}\n agent={pinnedAgent}\n isActive\n isHovered={hoveredAgent?.id === pinnedAgent.id}\n isMobile={isMobile}\n onClick={() => onSelectAgent(pinnedAgent)}\n href={resolveAgentHref?.(pinnedAgent)}\n onHover={() => onAgentHover(pinnedAgent)}\n onHoverEnd={() => onAgentHoverEnd(pinnedAgent)}\n onDetailPress={() => onDetailPress(pinnedAgent)}\n />\n <div className=\"mx-2 my-0.5 h-px bg-border\" />\n </>\n )}\n {agents.map((agent) => (\n <AgentRow\n key={agent.id}\n agent={agent}\n isActive={agent.id === activeAgentId}\n isHovered={hoveredAgent?.id === agent.id}\n isMobile={isMobile}\n onClick={() => onSelectAgent(agent)}\n href={resolveAgentHref?.(agent)}\n onHover={() => onAgentHover(agent)}\n onHoverEnd={() => onAgentHoverEnd(agent)}\n onDetailPress={() => onDetailPress(agent)}\n />\n ))}\n {agents.length === 0 && (pinnedAgent || defaultAgent) && (\n <div className=\"flex flex-col items-center py-4 text-muted-foreground\">\n <span className=\"text-xs\">{emptyLabel}</span>\n </div>\n )}\n </div>\n )}\n </div>\n\n {/* Footer count */}\n <div className=\"h-px bg-border shrink-0\" />\n <div className=\"flex items-center justify-between px-2.5 py-1.5 shrink-0\">\n <span\n data-testid=\"agent-list-footer\"\n className=\"text-[10px] text-muted-foreground tabular-nums\"\n >\n {agentListFooterLabel({\n count: agents.length,\n archFilter: consumer.archFilter,\n archivedHiddenCount,\n })}\n </span>\n {consumer.searchTerm && (\n <button\n type=\"button\"\n onClick={() => consumer.setSearchTerm(\"\")}\n className=\"text-[10px] text-muted-foreground hover:text-foreground transition-colors\"\n >\n Clear search\n </button>\n )}\n </div>\n </div>\n );\n}\n","/**\n * catalog/react/types.ts — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/core/types.ts`.\n */\n\nexport type RightPanel = \"detail\" | \"sort\" | \"categories\" | \"tags\" | null;\n\n/**\n * `SORT_OPTIONS` MOVED to the pure `@ai-matrx/agents/catalog` entry in 0.8.0 —\n * it is five string pairs, and importing it from this `\"use client\"` bundle\n * pulled React into server graphs that only wanted the labels. Re-exported here\n * unchanged so every existing import keeps working; prefer the pure entry.\n */\nexport { SORT_OPTIONS } from \"../types\";\n\nexport const PANEL_HEIGHT = \"528px\";\n\n/**\n * 🚨 THE PANEL NEVER OUTGROWS THE SPACE IT HAS.\n *\n * The popover reserves a FIXED footprint on purpose (a resizing panel in a\n * narrow rail gets collision-shifted out from under the cursor). But a flat\n * 528px is taller than the room above a trigger sitting mid-page on a laptop,\n * and Radix cannot shift what does not fit either way — so the top of the\n * panel, which is the SEARCH BOX, was rendered off-screen. Measured 2026-09-08\n * on the mandate Holder screen at 1280x900: the popover sat at `top: -76`.\n *\n * Clamping to Radix's own measurement keeps the footprint fixed whenever there\n * IS room and merely shortens the list when there is not — the panel still\n * never resizes while open, because the available height does not change while\n * the popover is open.\n */\nexport const LIST_MAX_HEIGHT =\n \"min(528px, var(--radix-popper-available-height, 528px))\";\n\n/**\n * 🚨 OPEN BELOW THE CONTROL WHENEVER THERE IS ROOM TO USE IT.\n *\n * Radix flips a popover to the side with more room using the panel's FULL\n * height, so a trigger in the middle of a dialog (the mandate \"Use my own\"\n * picker on a 1280x900 screen: 418px below, 528px panel) sent the whole panel\n * ABOVE it — over the dialog's own title and controls, reading as a list\n * floating at the top of the screen (2026-09-26). This measures the room\n * below at open time: when a usable list fits there, the panel is sized to it\n * and pinned to `side=\"bottom\"`; only when it does not is Radix left to flip.\n * The height is fixed for the whole time the panel is open, so nothing moves\n * under the cursor (the reason the footprint is fixed at all).\n *\n * Returns a px height, or `null` for \"use the default footprint and placement\".\n */\nexport function panelHeightBelow(\n trigger: Element | null,\n options: { full?: number; minUsable?: number; gap?: number } = {},\n): string | null {\n if (!trigger || typeof window === \"undefined\") return null;\n const full = options.full ?? 528;\n const minUsable = options.minUsable ?? 300;\n const gap = options.gap ?? 16; // sideOffset 4 + collisionPadding 12\n const below = window.innerHeight - trigger.getBoundingClientRect().bottom - gap;\n if (below >= full) return null;\n return below >= minUsable ? `${Math.floor(below)}px` : null;\n}\n\n/**\n * 🚨 A SIDE-OPENING PANEL NEVER LEAVES THE SCREEN.\n *\n * A host may ask for `side=\"left\"` / `\"right\"` (the chat composer's presets\n * panel opens \"All agents\" to its left). Radix shifts a side-placed popover\n * only VERTICALLY, so when the 680px panel does not fit on that side it runs\n * off the screen edge and the search box, tabs and names are cut off (blind run\n * PB-03, /chat/new in an 800px pane, 2026-10-01). Measured at open time: keep\n * the asked side when the panel fits there, else the opposite side when it\n * fits, else open below, where Radix can shift it horizontally into view.\n * Vertical sides pass through unchanged.\n */\nexport function sideThatFits(\n trigger: Element | null,\n side: \"top\" | \"right\" | \"bottom\" | \"left\",\n options: { width?: number; gap?: number } = {},\n): \"top\" | \"right\" | \"bottom\" | \"left\" {\n if (!trigger || typeof window === \"undefined\" || (side !== \"left\" && side !== \"right\")) return side;\n const width = options.width ?? 680;\n const gap = options.gap ?? 16; // sideOffset 4 + collisionPadding 12\n const rect = trigger.getBoundingClientRect();\n const room = { left: rect.left - gap, right: window.innerWidth - rect.right - gap };\n if (room[side] >= width) return side;\n const other = side === \"left\" ? \"right\" : \"left\";\n if (room[other] >= width) return other;\n return \"bottom\";\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentFilterBar.tsx — VERBATIM port of matrx-frontend\n * `.../core/AgentFilterBar.tsx`. Seams: lucide icons → inlined SVGs (C19);\n * `scrollbar-none` → the package's own class.\n */\n\nimport { FilterChip } from \"./primitives\";\nimport {\n ArchiveIcon,\n ArrowUpDownIcon,\n FolderIcon,\n RotateCcwIcon,\n StarIcon,\n TagIcon,\n} from \"./icons\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\nimport { SORT_OPTIONS, type RightPanel } from \"./types\";\nimport {\n agentArchiveFilterChipLabel,\n agentArchiveFilterControlLabel,\n} from \"../labels\";\nimport { nextArchFilter } from \"../types\";\n\nexport interface AgentFilterBarProps {\n consumer: UseAgentConsumerReturn;\n allCategories: string[];\n allTags: string[];\n activeFilterCount: number;\n isMobile: boolean;\n rightPanel: RightPanel;\n onFilterChipClick: (panel: \"sort\" | \"categories\" | \"tags\") => void;\n onReset: () => void;\n}\n\n/**\n * The filter bar is IDENTICAL on every tab, system included. A tab that offers\n * fewer controls than its neighbour is the half-built shape this list exists\n * to prevent — the system tab's category/tag options simply come from the\n * builtin population (see `selectAllSystemAgentCategories`).\n *\n * 🚨 THE ARCHIVE CONTROL IS NOT OPTIONAL (0.9.2). It renders here, on every\n * tab, for every consumer — including one whose `visibleTabs` removes the tab\n * strip above it, since this bar is mounted unconditionally by\n * `AgentListContent`. THE ARCHIVED-ITEMS LAW clause 3: revealing archived\n * items is one or two clicks away, \"on the surface itself — never zero\n * (impossible) and never buried in another page\". One click of this chip\n * shows all; a second shows archived only; a third hides them again.\n */\nexport function AgentFilterBar({\n consumer,\n allCategories,\n allTags,\n activeFilterCount,\n isMobile,\n rightPanel,\n onFilterChipClick,\n onReset,\n}: AgentFilterBarProps) {\n return (\n <div className=\"flex items-center gap-1 px-2 pb-1.5 overflow-x-auto matrx-agent-scrollbar-none shrink-0\">\n <FilterChip\n icon={ArrowUpDownIcon}\n label={\n SORT_OPTIONS.find((o) => o.value === consumer.sortBy)?.label ?? \"Sort\"\n }\n active={consumer.sortBy !== \"updated-desc\"}\n focused={!isMobile && rightPanel === \"sort\"}\n onClick={() => onFilterChipClick(\"sort\")}\n />\n <FilterChip\n icon={StarIcon}\n label={consumer.favFilter === \"no\" ? \"No Favs\" : \"Favs\"}\n active={consumer.favFilter !== \"all\"}\n onClick={() => {\n const next =\n consumer.favFilter === \"all\"\n ? \"yes\"\n : consumer.favFilter === \"yes\"\n ? \"no\"\n : \"all\";\n consumer.setFavFilter(next);\n }}\n />\n <FilterChip\n icon={ArchiveIcon}\n label={agentArchiveFilterChipLabel(consumer.archFilter)}\n active={consumer.archFilter !== consumer.archFilterDefault}\n ariaLabel={agentArchiveFilterControlLabel(consumer.archFilter)}\n testId=\"agent-archive-filter\"\n onClick={() => consumer.setArchFilter(nextArchFilter(consumer.archFilter))}\n />\n {allCategories.length > 0 && (\n <FilterChip\n icon={FolderIcon}\n label={\n consumer.includedCats.length > 0\n ? `${consumer.includedCats.length}`\n : \"Category\"\n }\n active={consumer.includedCats.length > 0}\n focused={!isMobile && rightPanel === \"categories\"}\n onClick={() => onFilterChipClick(\"categories\")}\n />\n )}\n {allTags.length > 0 && (\n <FilterChip\n icon={TagIcon}\n label={\n consumer.includedTags.length > 0\n ? `${consumer.includedTags.length}`\n : \"Tags\"\n }\n active={consumer.includedTags.length > 0}\n focused={!isMobile && rightPanel === \"tags\"}\n onClick={() => onFilterChipClick(\"tags\")}\n />\n )}\n {activeFilterCount > 0 && (\n <button\n type=\"button\"\n onClick={onReset}\n aria-label=\"Reset filters\"\n className=\"flex items-center gap-0.5 h-6 px-1.5 rounded text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors shrink-0\"\n >\n <RotateCcwIcon className=\"w-3 h-3\" />\n </button>\n )}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentListTabs.tsx — VERBATIM port of matrx-frontend\n * `.../core/AgentListTabs.tsx`. Seams: `cn` from design-system; the \"Public\"\n * literal → the `labels` port; `scrollbar-none` → the package's own\n * `matrx-agent-scrollbar-none` (a package never invents a Tailwind class name\n * and expects the consumer's `@source` scan to generate it — THE GENERATION\n * HAZARD).\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\n\nimport { useAgentCatalog } from \"./context\";\nimport type { AgentListTabCounts } from \"../shared/useAgentListCore\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\nimport type { AgentTab } from \"../types\";\n\nexport type { AgentListTabCounts } from \"../shared/useAgentListCore\";\n\ninterface AgentListTabsProps {\n consumer: UseAgentConsumerReturn;\n tabCounts: AgentListTabCounts;\n /** Limit the ownership tabs for constrained pickers. */\n visibleTabs?: readonly AgentTab[] | undefined;\n /**\n * Label for the builtin-agent tab. Users see \"Public\" (that is what a\n * platform agent is to them); ADMIN surfaces pass \"System\", because there\n * these are the agents they own and maintain.\n */\n systemTabLabel?: string | undefined;\n}\n\nexport function AgentListTabs({\n consumer,\n tabCounts,\n systemTabLabel,\n visibleTabs,\n}: AgentListTabsProps) {\n const { labels } = useAgentCatalog();\n const tabs: {\n value: AgentTab;\n label: string;\n countKey: keyof AgentListTabCounts;\n }[] = [\n { value: \"mine\", label: \"Mine\", countKey: \"mine\" },\n { value: \"shared\", label: \"Shared\", countKey: \"shared\" },\n { value: \"all\", label: \"All\", countKey: \"all\" },\n { value: \"system\", label: labels.publicTab, countKey: \"system\" },\n ];\n\n return (\n <div\n className=\"flex items-center gap-0.5 px-2 pb-1 overflow-x-auto matrx-agent-scrollbar-none shrink-0\"\n role=\"tablist\"\n aria-label=\"Agent ownership\"\n >\n {tabs\n .filter(({ value }) => !visibleTabs || visibleTabs.includes(value))\n .map(({ value, label: baseLabel, countKey }) => {\n const label =\n value === \"system\" ? (systemTabLabel ?? baseLabel) : baseLabel;\n const active = consumer.tab === value;\n const count = tabCounts[countKey];\n return (\n <button\n key={value}\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => consumer.setTab(value)}\n className={cn(\n \"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium transition-colors shrink-0\",\n active\n ? \"bg-primary text-primary-foreground\"\n : \"text-muted-foreground hover:text-foreground hover:bg-muted/50\",\n )}\n >\n <span>{label}</span>\n <span\n className={cn(\"tabular-nums opacity-70\", active && \"opacity-90\")}\n >\n {count}\n </span>\n </button>\n );\n })}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentRow.tsx — VERBATIM port of matrx-frontend\n * `.../core/AgentRow.tsx`. Seams: `next/link` → the `LinkComponent` port\n * (default a plain `<a>`, so cmd-click works with no host wiring); lucide →\n * inlined SVGs; the amber star literal → the `--matrx-agent-favorite` token.\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\n\nimport { useAgentCatalog, useAgentCatalogUiPorts } from \"./context\";\nimport { ChevronRightIcon, Music4Icon, StarIcon } from \"./icons\";\nimport {\n orchestraDelegatesLine,\n orchestraLabel,\n} from \"../orchestra\";\nimport type { AgentSummary } from \"../types\";\n\nexport interface AgentRowProps {\n agent: AgentSummary;\n isActive: boolean;\n isHovered: boolean;\n isMobile: boolean;\n /** Row href. Defaults to `/agents/go/[id]`. */\n href?: string | undefined;\n onClick: () => void;\n onHover: () => void;\n onHoverEnd: () => void;\n onDetailPress: () => void;\n}\n\nexport function AgentRow({\n agent,\n isActive,\n isHovered,\n isMobile,\n href,\n onClick,\n onHover,\n onHoverEnd,\n onDetailPress,\n}: AgentRowProps) {\n const { LinkComponent } = useAgentCatalogUiPorts();\n const { labels } = useAgentCatalog();\n const rowHref = href ?? `/agents/go/${agent.id}`;\n\n return (\n <div\n // Parity hook with the native row's `testID`. It is what lets the web\n // shell's ordering be MEASURED rather than asserted about — see\n // `catalog/react/total-order.test.tsx`.\n data-testid={`agent-row-${agent.id}`}\n className={cn(\n \"flex items-center w-full text-left transition-colors group\",\n \"hover:bg-muted/50 active:bg-muted/70\",\n isActive && \"bg-primary/5\",\n !isMobile && isHovered && \"bg-muted/40\",\n )}\n onMouseEnter={isMobile ? undefined : onHover}\n onMouseLeave={isMobile ? undefined : onHoverEnd}\n >\n <LinkComponent\n href={rowHref}\n onClick={(e) => {\n if (e.metaKey || e.ctrlKey) return;\n e.preventDefault();\n onClick();\n }}\n className=\"flex items-center gap-2 flex-1 min-w-0 px-3 py-2\"\n >\n {agent.isFavorite && (\n <StarIcon filled className=\"w-3 h-3 matrx-agent-star-on shrink-0\" />\n )}\n <span\n className={cn(\n \"text-[13px] font-medium truncate\",\n isActive ? \"text-primary\" : \"text-foreground\",\n )}\n >\n {agent.name || \"Untitled\"}\n </span>\n {/* Conductor marker. An Orchestra runs its WHOLE ensemble from this\n one choice, so the row says so where the choice is made — not in a\n run log afterwards. Icon + member count only: the row is a name,\n and the mode, tagline and member titles are one hover away in the\n detail card. Ported from the Workflow Studio picker this replaced. */}\n {agent.orchestra && (\n <span\n className=\"flex shrink-0 items-center gap-0.5 rounded-sm bg-primary/10 px-1 py-px text-[9px] font-medium text-primary\"\n title={\n orchestraDelegatesLine(agent.orchestra) ??\n orchestraLabel(agent.orchestra)\n }\n >\n <Music4Icon className=\"w-2.5 h-2.5\" />\n {agent.orchestra.memberCount}\n </span>\n )}\n {/* ARCHIVED rows stay offered (the archived-items law) and say so. */}\n {agent.isArchived ? (\n <span\n data-testid={`agent-archived-badge-${agent.id}`}\n className=\"text-[9px] font-medium text-muted-foreground bg-muted px-1 py-px rounded shrink-0 ml-auto\"\n >\n {labels.archivedBadge}\n </span>\n ) : null}\n {/* Origin badge. On a blended list (admin \"All\", search results) this\n is the only thing that tells a system agent from your own. */}\n {agent.agentType === \"builtin\" ? (\n <span className={cn(\"text-[9px] font-medium text-primary bg-primary/10 px-1 py-px rounded shrink-0\", !agent.isArchived && \"ml-auto\")}>\n {labels.systemBadge}\n </span>\n ) : agent.isOwner === false ? (\n <span className={cn(\"text-[9px] text-muted-foreground bg-muted px-1 py-px rounded shrink-0\", !agent.isArchived && \"ml-auto\")}>\n shared\n </span>\n ) : null}\n </LinkComponent>\n {isMobile && (\n <button\n type=\"button\"\n aria-label=\"Show details\"\n onClick={(e) => {\n e.stopPropagation();\n onDetailPress();\n }}\n className=\"flex items-center justify-center w-10 h-full shrink-0 text-muted-foreground/40 active:text-muted-foreground\"\n >\n <ChevronRightIcon className=\"w-4 h-4\" />\n </button>\n )}\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentMobileSubView.tsx — port of `.../core/AgentMobileSubView.tsx`.\n * Carries the same \"Clear (n)\" fix as `AgentCategoriesPanel` — see its header.\n */\n\nimport { CheckRow, OptionRow, SearchInput } from \"./primitives\";\nimport { ChevronRightIcon } from \"./icons\";\nimport { SORT_OPTIONS } from \"./types\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\n\nexport interface AgentMobileSubViewProps {\n view: \"sort\" | \"categories\" | \"tags\";\n consumer: UseAgentConsumerReturn;\n allCategories: string[];\n allTags: string[];\n catSearch: string;\n setCatSearch: (v: string) => void;\n tagSearch: string;\n setTagSearch: (v: string) => void;\n onBack: () => void;\n}\n\nexport function AgentMobileSubView({\n view,\n consumer,\n allCategories,\n allTags,\n catSearch,\n setCatSearch,\n tagSearch,\n setTagSearch,\n onBack,\n}: AgentMobileSubViewProps) {\n const title =\n view === \"sort\" ? \"Sort\" : view === \"categories\" ? \"Categories\" : \"Tags\";\n\n return (\n <div className=\"flex flex-col\">\n <button\n type=\"button\"\n onClick={onBack}\n className=\"flex items-center gap-1.5 px-3 py-2.5 text-sm font-medium text-primary hover:bg-muted/30 transition-colors border-b border-border shrink-0\"\n >\n <ChevronRightIcon className=\"w-4 h-4 rotate-180\" />\n {title}\n </button>\n {view === \"sort\" &&\n SORT_OPTIONS.map((opt) => (\n <OptionRow\n key={opt.value}\n label={opt.label}\n selected={consumer.sortBy === opt.value}\n onClick={() => {\n consumer.setSortBy(opt.value);\n onBack();\n }}\n />\n ))}\n {view === \"categories\" && (\n <>\n <div className=\"px-2 pt-2 pb-1\">\n <SearchInput\n value={catSearch}\n onChange={setCatSearch}\n placeholder=\"Filter categories...\"\n />\n </div>\n {consumer.includedCats.length > 0 && (\n <button\n type=\"button\"\n onClick={() => consumer.setIncludedCats([])}\n className=\"mx-2 mb-1 h-6 rounded text-[11px] font-medium text-primary hover:bg-muted/50 transition-colors text-left\"\n >\n Clear ({consumer.includedCats.length})\n </button>\n )}\n <div className=\"overflow-y-auto max-h-[300px]\">\n {allCategories\n .filter(\n (c) =>\n !catSearch ||\n c.toLowerCase().includes(catSearch.toLowerCase()),\n )\n .map((cat) => (\n <CheckRow\n key={cat}\n label={cat}\n checked={consumer.includedCats.includes(cat)}\n onClick={() => consumer.toggleCategory(cat)}\n />\n ))}\n </div>\n </>\n )}\n {view === \"tags\" && (\n <>\n <div className=\"px-2 pt-2 pb-1\">\n <SearchInput\n value={tagSearch}\n onChange={setTagSearch}\n placeholder=\"Filter tags...\"\n />\n </div>\n {consumer.includedTags.length > 0 && (\n <button\n type=\"button\"\n onClick={() => consumer.setIncludedTags([])}\n className=\"mx-2 mb-1 h-6 rounded text-[11px] font-medium text-primary hover:bg-muted/50 transition-colors text-left\"\n >\n Clear ({consumer.includedTags.length})\n </button>\n )}\n <div className=\"overflow-y-auto max-h-[300px]\">\n {allTags\n .filter(\n (t) =>\n !tagSearch ||\n t.toLowerCase().includes(tagSearch.toLowerCase()),\n )\n .map((tag) => (\n <CheckRow\n key={tag}\n label={tag}\n checked={consumer.includedTags.includes(tag)}\n onClick={() => consumer.toggleTag(tag)}\n />\n ))}\n </div>\n </>\n )}\n </div>\n );\n}\n","\"use client\";\n\n/** catalog/react/AgentSortPanel.tsx — VERBATIM port of `.../core/AgentSortPanel.tsx`. */\n\nimport { OptionRow, SidePanelHeader } from \"./primitives\";\nimport { SORT_OPTIONS } from \"./types\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\n\nexport interface AgentSortPanelProps {\n consumer: UseAgentConsumerReturn;\n onClose: () => void;\n}\n\nexport function AgentSortPanel({ consumer, onClose }: AgentSortPanelProps) {\n return (\n <div className=\"flex flex-col h-full\">\n <SidePanelHeader title=\"Sort By\" onClose={onClose} />\n <div className=\"overflow-y-auto flex-1\">\n {SORT_OPTIONS.map((opt) => (\n <OptionRow\n key={opt.value}\n label={opt.label}\n selected={consumer.sortBy === opt.value}\n onClick={() => consumer.setSortBy(opt.value)}\n />\n ))}\n </div>\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentTagsPanel.tsx — port of `.../core/AgentTagsPanel.tsx`.\n * Carries the same \"Clear (n)\" fix as `AgentCategoriesPanel` — see its header.\n */\n\nimport { CheckRow, SearchInput, SidePanelHeader } from \"./primitives\";\nimport type { UseAgentConsumerReturn } from \"./useAgentConsumer\";\n\nexport interface AgentTagsPanelProps {\n consumer: UseAgentConsumerReturn;\n allTags: string[];\n search: string;\n setSearch: (v: string) => void;\n onClose: () => void;\n}\n\nexport function AgentTagsPanel({\n consumer,\n allTags,\n search,\n setSearch,\n onClose,\n}: AgentTagsPanelProps) {\n const filtered = allTags.filter(\n (t) => !search || t.toLowerCase().includes(search.toLowerCase()),\n );\n return (\n <div className=\"flex flex-col h-full\">\n <SidePanelHeader title=\"Tags\" onClose={onClose} />\n <div className=\"px-2 pt-2 pb-1 shrink-0\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"Filter tags...\"\n />\n </div>\n {consumer.includedTags.length > 0 && (\n <button\n type=\"button\"\n onClick={() => consumer.setIncludedTags([])}\n className=\"mx-2 mb-1 h-6 rounded text-[11px] font-medium text-primary hover:bg-muted/50 transition-colors text-left shrink-0\"\n >\n Clear ({consumer.includedTags.length})\n </button>\n )}\n <div className=\"overflow-y-auto flex-1\">\n {filtered.length === 0 ? (\n <p className=\"text-xs text-muted-foreground text-center py-6\">\n No tags\n </p>\n ) : (\n filtered.map((tag) => (\n <CheckRow\n key={tag}\n label={tag}\n checked={consumer.includedTags.includes(tag)}\n onClick={() => consumer.toggleTag(tag)}\n />\n ))\n )}\n </div>\n </div>\n );\n}\n","\"use client\";\n\n/**\n * catalog/react/AgentListInlinePicker.tsx — VERBATIM port of matrx-frontend\n * `features/agents/components/agent-listings/AgentListInlinePicker.tsx`.\n *\n * Embeddable agent browser with configurable ownership tabs. Reuses the same\n * core as `AgentListDropdown` (`useAgentListCore` + `AgentListContent`)\n * without a popover/drawer shell. Intended for surfaces that dedicate a panel\n * region to agent selection.\n */\n\nimport { cn } from \"@ai-matrx/design-system\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { AgentDetailCard } from \"./AgentDetailCard\";\nimport { AgentListContent } from \"./AgentListContent\";\nimport { AgentMobileSubView } from \"./AgentMobileSubView\";\nimport { ChevronRightIcon } from \"./icons\";\nimport { useAgentListCore } from \"./useAgentListCore\";\nimport type { AgentSummary, AgentTab } from \"../types\";\n\nexport interface AgentListInlinePickerProps {\n /** Unique consumer id for filter/tab state (see `useAgentConsumer`). */\n consumerId: string;\n onSelect: (agentId: string) => void;\n activeAgentId?: string | null;\n className?: string;\n /** Auto-focus the search field on mount. Default true. */\n autoFocusSearch?: boolean;\n /** Tab to open on. Admin surfaces that manage system agents pass `\"system\"`. */\n initialTab?: AgentTab;\n /** ADMIN variant: blend system agents into the \"All\" tab. */\n includeSystemInAll?: boolean;\n /** Restrict which ownership tabs are available for domain-constrained pickers. */\n visibleTabs?: readonly AgentTab[];\n /** Label override for the builtin-agent tab. Admin surfaces use \"System\". */\n systemTabLabel?: string;\n /** Resolve the route used by each named agent door. */\n resolveAgentHref?: (agent: AgentSummary) => string;\n /** Show the globally active agent above the filtered list. Default true. */\n showPinnedAgent?: boolean;\n /** Hide records that are invalid for this call site. */\n excludeAgentIds?: readonly string[];\n /** Offer the mandate's live-resolved default agent at the top of the list. */\n defaultMandateKey?: string;\n}\n\nexport function AgentListInlinePicker({\n consumerId,\n onSelect,\n activeAgentId = null,\n className,\n autoFocusSearch = true,\n initialTab,\n includeSystemInAll = false,\n visibleTabs,\n systemTabLabel,\n resolveAgentHref,\n showPinnedAgent = true,\n excludeAgentIds,\n defaultMandateKey,\n}: AgentListInlinePickerProps) {\n const inputRef = useRef<HTMLInputElement>(null);\n const [catSearch, setCatSearch] = useState(\"\");\n const [tagSearch, setTagSearch] = useState(\"\");\n const [mobileDetailAgent, setMobileDetailAgent] =\n useState<AgentSummary | null>(null);\n const [mobileSubView, setMobileSubView] = useState<\n \"sort\" | \"categories\" | \"tags\" | null\n >(null);\n\n const {\n agents,\n archivedHiddenCount,\n isLoading,\n allCategories,\n allTags,\n consumer,\n tabCounts,\n activeFilterCount,\n hoveredAgent,\n pinnedAgent,\n defaultRow,\n ensureLoaded,\n handleSelectAgent: coreSelectAgent,\n handleAgentHover,\n handleAgentHoverEnd,\n } = useAgentListCore({\n consumerId,\n onSelect,\n activeAgentIdOverride: activeAgentId,\n ...(initialTab ? { initialTab } : {}),\n includeSystemInAll,\n // The restriction has to reach the CORE, not just the tab strip — see\n // `AgentListCoreOptions.visibleTabs`.\n ...(visibleTabs ? { visibleTabs } : {}),\n ...(excludeAgentIds ? { excludeAgentIds } : {}),\n ...(defaultMandateKey ? { defaultMandateKey } : {}),\n });\n\n useEffect(() => {\n ensureLoaded();\n if (!autoFocusSearch) return undefined;\n const timer = setTimeout(() => inputRef.current?.focus(), 50);\n return () => clearTimeout(timer);\n }, [ensureLoaded, autoFocusSearch]);\n\n const handleSelectAgent = (agent: AgentSummary) => {\n coreSelectAgent(agent);\n setMobileDetailAgent(null);\n setMobileSubView(null);\n };\n\n const handleFilterChipClick = (panel: \"sort\" | \"categories\" | \"tags\") => {\n setMobileSubView(panel);\n };\n\n // Single-column layout — no hover side panel (same as mobile drawer).\n const isMobile = true;\n\n if (mobileDetailAgent) {\n return (\n <div className={cn(\"flex h-full min-h-0 flex-col\", className)}>\n <button\n type=\"button\"\n onClick={() => setMobileDetailAgent(null)}\n className=\"flex shrink-0 items-center gap-1.5 border-b border-border px-3 py-2 text-sm font-medium text-primary transition-colors hover:bg-muted/30\"\n >\n <ChevronRightIcon className=\"h-4 w-4 rotate-180\" />\n Back\n </button>\n <div className=\"min-h-0 flex-1 overflow-y-auto\">\n <AgentDetailCard\n agent={mobileDetailAgent}\n onSelect={() => handleSelectAgent(mobileDetailAgent)}\n />\n </div>\n </div>\n );\n }\n\n if (mobileSubView) {\n return (\n <div className={cn(\"flex h-full min-h-0 flex-col\", className)}>\n <AgentMobileSubView\n view={mobileSubView}\n consumer={consumer}\n allCategories={allCategories}\n allTags={allTags}\n catSearch={catSearch}\n setCatSearch={setCatSearch}\n tagSearch={tagSearch}\n setTagSearch={setTagSearch}\n onBack={() => {\n setMobileSubView(null);\n setCatSearch(\"\");\n setTagSearch(\"\");\n }}\n />\n </div>\n );\n }\n\n return (\n <div className={cn(\"flex h-full min-h-0 flex-col\", className)}>\n <AgentListContent\n agents={agents}\n isLoading={isLoading}\n consumer={consumer}\n activeAgentId={activeAgentId}\n allCategories={allCategories}\n allTags={allTags}\n inputRef={inputRef}\n onSelectAgent={handleSelectAgent}\n {...(resolveAgentHref ? { resolveAgentHref } : {})}\n onReset={consumer.resetFilters}\n activeFilterCount={activeFilterCount}\n isMobile={isMobile}\n hoveredAgent={hoveredAgent}\n onAgentHover={(agent) => handleAgentHover(agent, false)}\n onAgentHoverEnd={(agent) => handleAgentHoverEnd(agent, () => {})}\n onDetailPress={setMobileDetailAgent}\n onFilterChipClick={handleFilterChipClick}\n rightPanel={null}\n tabCounts={tabCounts}\n archivedHiddenCount={archivedHiddenCount}\n {...(visibleTabs ? { visibleTabs } : {})}\n {...(systemTabLabel ?? (includeSystemInAll ? \"System\" : undefined)\n ? {\n systemTabLabel:\n systemTabLabel ?? (includeSystemInAll ? \"System\" : undefined),\n }\n : {})}\n pinnedAgent={showPinnedAgent ? pinnedAgent : null}\n defaultRow={defaultRow}\n listOpen\n />\n </div>\n );\n}\n"],"mappings":";;;;AAeA,SAAS,WAAAA,gBAA+B;;;ACMxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAoHH;AAjCJ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AA,MACC,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;AAAA,MACrC,GAAI,mBAAmB,qBAAqB,WAAW,UACpD;AAAA,QACE,gBACE,mBAAmB,qBAAqB,WAAW;AAAA,MACvD,IACA,CAAC;AAAA,MACL,aAAa,kBAAkB,cAAc;AAAA,MAC7C;AAAA,MACA,UAAQ;AAAA;AAAA,EACV,GACF;AAEJ;","names":["useMemo","jsx","useMemo","useCallback","useCallback","useCallback","useEffect","useMemo","useRef","useState","useRef","useState","useMemo","useCallback","useEffect","cn","useIsMobile","useMemo","useRef","useState","cn","useCallback","useEffect","useMemo","useRef","useState","jsx","jsx","jsxs","jsx","jsxs","cn","cn","useCallback","jsx","useCallback","isFavorite","cn","Fragment","jsx","jsxs","cn","useEffect","useRef","jsx","jsxs","cn","jsx","jsxs","cn","cn","jsx","jsxs","cn","Fragment","jsx","jsxs","useRef","useEffect","Fragment","jsx","jsxs","jsx","jsxs","jsx","jsxs","jsx","jsxs","useState","useRef","useEffect","useCallback","cn","useMemo","jsx","jsxs","useIsMobile","useState","useRef","useMemo","cn","cn","useEffect","useRef","useState","jsx","jsxs","useRef","useState","useEffect","cn"]}
|