<!-- GENERATED by scripts/build-llms.mjs from llms/retrieval.md — do not edit this file. -->

# `lr-knowledge-base`

- **Import** `import '@aceshooting/lyra-ui/components/lr-knowledge-base.js';` (stable tag alias; registers the tag)
- **Class** `LyraKnowledgeBase`, also available unregistered from `@aceshooting/lyra-ui/components/retrieval/knowledge-base/knowledge-base.class.js`
- **Family** `components/retrieval/` — see `llms/index.md` for its siblings
- **Status** `stable` since `4.1.0` — see the maturity and deprecation policy in `llms/shared.md`
- **Release history** [CHANGELOG.md](../../CHANGELOG.md); family-wide breaking-change summaries: [llms-full.txt](../../llms-full.txt)
- **Deprecations** none
- **Optional peers** none
- **Themeable via** 29 parts, 0 custom properties — see this component's own `@csspart`/`@cssprop` list below
- **Library-wide behavior** (events, form association, `locale`/`strings`, tokens, TS types): `llms/shared.md`

---

## `lr-knowledge-base`

Controlled source list for a retrieval knowledge base: sync status, indexing health, permissions, and
per-row create/sync/pause/delete requests. Composes `lr-table`, `lr-badge`, `lr-stat`, and a per-row
`lr-dropdown` containing `lr-menu`. Never syncs or indexes anything itself.

**Properties:**

- `sources: KnowledgeSource[] = []` (attribute: false) — `KnowledgeSource { id: string; name: string;
type?: string; syncStatus: KnowledgeSourceSyncStatus; indexingHealth?: KnowledgeSourceIndexingHealth;
permission?: KnowledgeSourcePermission; documentCount?: number; lastSyncedAt?: Date | string;
errorMessage?: string }` (all four types exported here), where
  `KnowledgeSourceSyncStatus = 'idle' | 'syncing' | 'paused' | 'synced' | 'error'`,
  `KnowledgeSourceIndexingHealth = 'healthy' | 'degraded' | 'failed' | 'unknown'` (absent is treated
  as `'unknown'`), and `KnowledgeSourcePermission = 'owner' | 'editor' | 'viewer' | 'restricted'`.
  `type` is a free-form connector kind (`'drive'`, `'notion'`, `'upload'`, `'url'`, …) rendered
  as-is. `lastSyncedAt` follows this library's `Date | string` timestamp convention (epoch ms Date or
  ISO-8601); absent/unparseable renders "never synced". `errorMessage` shows only while
  `syncStatus === 'error'`. `id`/`name` follow `DocumentRef`'s spirit, but a source is a _connector
  feeding_ documents, not a document, so the rest of the fields are its own
- `label?: string` — heading text and the table's accessible name; omission uses the localized
  knowledge-base label. An explicit empty string keeps the visible heading empty while the nested
  table still takes the localized default as its accessible name
- `hideSummary: boolean = false` (attribute `hide-summary`, reflected) — hides the aggregate
  total/synced/syncing/needs-attention row
- `hideCreate: boolean = false` (attribute `hide-create`, reflected) — hides the "Add source"
  affordance, e.g. for a read-only or permission-gated view
- `error: boolean = false` (reflected) — reports a failed source-list load. Forwarded to the nested
  `lr-table`, whose own built-in failed-load state (with retry button) replaces the source rows
  while it's set; `error` beats the empty state, matching `lr-table`'s own precedence
- `errorHeading?: string` (attribute `error-heading`) — failed-load heading override, forwarded to
  the nested table. Omitted localizes the table's own `tableLoadFailed` default
- `errorDescription: string = ''` (attribute `error-description`) — failed-load supporting copy,
  forwarded to the nested table

Source ids must be nonblank and unique. Malformed rows and later duplicates are omitted first-wins
before summary totals, empty state, table rows, or source actions. A retained source whose `name` is
missing, blank, or nonstring uses the localized “untitled source” label in both the row and its action
names.

**Events:** `lr-source-create` (`detail: null` — nothing exists yet to reference),
`lr-source-sync` (`detail: { sourceId: string }`), `lr-source-pause` (`detail: { sourceId: string }`),
`lr-source-delete` (`detail: { sourceId: string }`, no built-in confirmation, matching
`lr-thread-list`'s `lr-thread-delete`). These were spelled `lr-kb-create`/`-sync`/`-pause`/`-delete`
before 9.0.0 — the library's only abbreviated event prefix. `<lr-knowledge-base-admin>` already
re-emitted them under the `lr-source-*` names, so a host listening on the admin shell needs no
change; a host listening directly on `<lr-knowledge-base>` renames its four listeners.
`lr-retry` (`detail: null`, cancelable) — the nested table's built-in retry button was activated,
only rendered while `error` is set; the default action clears `error`, `preventDefault()` leaves it
set. This component intercepts the nested table's own `lr-retry` and re-proposes its own, so the
outer `error` property never drifts out of sync with the table's internal state.

**Slots:** `error` — replaces the nested table's built-in failed-load state, including its retry
button, while `error` is set.

**CSS parts:** `base`, `toolbar` (heading + "Add source" row), `heading` (the heading text),
`create-button` (omitted while `hideCreate`), `summary` (omitted while `hideSummary` or `sources` is
empty), `summary-stat`, `table`, `name-cell`, `source-name`, `source-type` (omitted when `type` is
unset), `sync-cell`, `sync-badge`, `sync-timestamp`, `sync-error`, `health-cell`, `health-badge`,
`document-count` (omitted when unset), `permission-badge` (omitted when `permission` is unset),
`actions-menu`, `actions-trigger` (the kebab `<button>`), `error-row`, `error-cell`, `error` (the
nested table's built-in `lr-empty` host), `error-base`, `error-icon`, `error-heading`,
`error-description`, `error-actions`, `retry-button`.

The row and error-state parts — `name-cell`, `source-name`, `source-type`, `sync-cell`, `sync-badge`,
`sync-timestamp`, `sync-error`, `health-cell`, `health-badge`, `document-count`,
`permission-badge`, `actions-menu`, `actions-trigger`, `error-row`, `error-cell`, `error`,
`error-base`, `error-icon`, `error-heading`, `error-description`, `error-actions`, and
`retry-button` — are forwarded from the composed table through `[part="table"]`/`exportparts`, so
they are styleable as `lr-knowledge-base::part(actions-trigger)`. `actions-trigger` is the forwarded
kebab button: it inherits the row font, has the shared `--lr-icon-button-size` minimum hit area
(40px by default), and keeps independent hover, pressed, and focus treatment.

**Themeable custom properties:** shared tokens only.

**Optional peer deps:** none.

**Known gotchas:**

- `permission` is rendered informationally only — the per-row action menu is never gated by it.
  Authorization enforcement is the host's concern.
- "Sync now" is disabled only while `syncStatus === 'syncing'` (including on `'error'` rows, so
  re-running a failed sync is one click); "Pause sync" is enabled only while `'syncing'`.
- The inner `lr-table`'s own `lr-row-click` is deliberately stopped from propagating — this component
  exposes no row-click/selection semantics, only the per-row action menu.

---
