import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraProvenance}from'../provenance-panel/provenance-panel.class.js';import'../provenance-panel/provenance-panel.class.js';import'../../agent-tools/confirm-bar/confirm-bar.class.js';import'../../overlays/empty/empty.class.js';import type{LyraNodeTypeStyle}from'../../../internal/node-type-style.js';export type{LyraNodeTypeStyle}from'../../../internal/node-type-style.js';import type{LyraScoreThresholds}from'../graph/graph.class.js'; /** * One item held in a memory panel's short-term or long-term list. `provenance` reuses * `lr-provenance-panel`'s own `LyraProvenance` shape verbatim -- assigning `item.provenance` onto * that component's `provenance` property needs no adapter. */ export interface LyraMemoryItem{id:string; /** The memory's content, rendered as plain text. */ text:string; /** 0-1 confidence that this memory is accurate/current. Omit when confidence isn't tracked for * this item -- the confidence indicator is omitted entirely rather than rendering a 0%/unknown * placeholder. */ confidence?:number; /** What grounded this memory (entities/relationships/communities/source chunks), rendered * through `lr-provenance-panel` behind a per-item disclosure toggle. Omit when this memory * carries no traceable grounding -- the toggle is omitted entirely in that case. */ provenance?:LyraProvenance;}type MemoryScope='short-term'|'long-term';export interface LyraMemoryAddDetail{memory:LyraMemoryItem;}export interface LyraMemoryRemoveDetail{memoryId:string;scope:MemoryScope;}export interface LyraMemoryExpandDetail{memoryId:string;scope:MemoryScope;expanded:boolean;}export interface LyraMemoryPanelEventMap{'lr-add':CustomEvent>;'lr-remove':CustomEvent;'lr-forget':CustomEvent;'lr-expand':CustomEvent;} /** * `` — an agent's working memory surface: short-term context and long-term * memories, each item's confidence and (optional) grounding provenance, and add/remove/forget * actions gated behind an explicit confirmation step before anything is reported as decided. * * Composes `lr-provenance-panel` for a per-item's provenance breakdown (revealed behind a * disclosure toggle, only rendered when `item.provenance` is set) and `lr-confirm-bar` for every * add/remove/forget confirmation -- this component never re-implements a new inline-confirmation * pattern of its own. A memory item's confidence reuses `lr-citation-badge`'s own confidence * vocabulary (`citationHighConfidence`/`citationMediumConfidence`/`citationLowConfidence`), tiered * against `thresholds` the same way `lr-chunk-inspector` tiers a chunk's relevance score. * * `shortTerm`/`longTerm` are controlled and never mutated by this component -- approving a pending * action only fires the matching event; the host applies the resulting state change (adding to * `longTerm`, removing an item, clearing `longTerm`) and passes new arrays back down. At most one * confirmation is ever pending at a time: starting a new action (on the same item or a different * one) silently cancels whichever confirmation was already open, the same way only one row can be * mid-edit in a list at once. * If a controlled collection replacement removes the row containing focus, focus moves to the * closest surviving memory row, or to the stable root when no row survives. * * Focus follows the confirmation rather than being dropped: activating an action replaces the * button that had focus, so focus moves into the freshly rendered `lr-confirm-bar` (its Deny * control -- the safe action -- or the bar's own status element) instead of falling back to * ``. Resolving or cancelling hands focus back: to the row for a per-item decision, to the * "Forget all" control for the bulk one. Escape while the confirmation holds focus cancels it * exactly like Deny -- no event, same focus return -- and does not propagate, so an enclosing * dialog or popover still sees its own Escape when no confirmation is open. * * Three distinct, non-overlapping actions: `add` promotes a short-term item into long-term memory * (only offered on short-term items -- long-term items are already there); `remove` deletes one * specific item from whichever list it's in (offered on every item); `forget` is deliberately * scoped to the whole long-term list at once (a single "Forget all" control in that section's * header, only rendered while `longTerm` is non-empty) -- a bulk, more consequential action kept * distinct from the per-item `remove`. * * Public collection sequences are bounded, frozen snapshots. Admitted memory source identities * and provenance remain opaque while descriptor-safe projections copy display and action fields * once; later rendering, event emission, and controlled-focus recovery never reread a source row. * Create a new collection and reassign it after changes; mutating the assigned array does not * update the view. Blank memory ids and later duplicates within each scope are ignored before * rendering, counts, focus recovery, confirmation state, or actions. The first item for an id * wins in that scope. * * @customElement lr-memory-panel * @event lr-add - A pending "add to long-term memory" action was approved. `detail: { memory }` -- * the short-term item as-is; the host decides how/whether to persist it. * @event lr-remove - A pending "remove" action was approved. `detail: { memoryId, scope }`. * @event lr-forget - The pending "forget all long-term memories" action was approved. No detail. * @event lr-expand - A memory item's provenance disclosure was toggled. * `detail: { memoryId, scope, expanded }`. * @csspart base - The root wrapper. * @csspart empty - The all-empty `lr-empty` state, shown when both lists are empty. * @csspart section - One of the two (short-term/long-term) sections; carries `data-scope`. * @csspart section-header - A section's heading + (long-term only) "Forget all" control row. * @csspart heading - A section's visible heading text. * @csspart section-empty - A section's "no items" text, shown when that section's own list is empty. * @csspart list - A section's `role="list"` wrapper, omitted while that section is empty. * @csspart item - One memory item row (`role="listitem"`); carries `data-id`/`data-scope` and a * stable `tabindex="-1"` so focus has somewhere to land after a pending confirmation on this row * resolves. * @csspart item-row - The wrapper around an item's text and confidence indicator. * @csspart item-text - The item's `text`. * @csspart confidence - The item's confidence tier text, carrying `data-tone`. Omitted when * `confidence` is unset. * @csspart expand-toggle - The provenance disclosure toggle. Omitted when `provenance` is unset. * @csspart item-body - The disclosed `lr-provenance-panel` wrapper, `hidden` while collapsed. * Omitted when `provenance` is unset. * @csspart item-actions - The wrapper around an item's action row (or its pending `lr-confirm-bar`). * @csspart add-button - The "Add to long-term memory" action. Only rendered on short-term items. * @csspart remove-button - The "Remove" action. Rendered on every item. * @csspart forget-all-button - The long-term section's bulk "Forget all" action. Only rendered * while `longTerm` is non-empty. * @csspart forget-all-confirm - The `` shown in place of the "Forget all" * action while that bulk confirmation is pending. * @cssprop [--lr-memory-panel-confidence-success-color=var(--lr-color-success)] - Text color for a * high-confidence item's confidence indicator. * @cssprop [--lr-memory-panel-confidence-warning-color=var(--lr-color-warning)] - Text color for a * medium-confidence item's confidence indicator. * @cssprop [--lr-memory-panel-confidence-danger-color=var(--lr-color-danger)] - Text color for a * low-confidence item's confidence indicator. * @status stable * @since 4.1.0 */ export declare class LyraMemoryPanel extends LyraElement{protected static readonly ownedCollectionProperties:readonly string[]; /** Memory source records can contain opaque provenance retained for the public add event. */ protected static readonly identityCollectionProperties:readonly string[];static styles:import("lit").CSSResultGroup[];protected static readonly immutableEventDetails:readonly string[]; /** The admitted memory is opaque caller state inside the otherwise frozen add envelope. */ protected static readonly identityEventDetailProperties:Readonly<{'lr-add':readonly string[];}>; /** Ephemeral, working-context items. Controlled and never mutated by this component. */ shortTerm:readonly LyraMemoryItem[]; /** Persisted memories. Controlled and never mutated by this component. */ longTerm:readonly LyraMemoryItem[]; /** `lr-provenance-panel` `types` pass-through, forwarded verbatim to every expanded item's panel. */ types:readonly LyraNodeTypeStyle[]; /** Confidence-tier and (forwarded) provenance relevance-tier boundaries. */ thresholds:LyraScoreThresholds; /** Fallback overall group name. A non-empty host `aria-label` makes the host the sole owner; an * explicitly empty host label stays empty on the group, and so does an explicitly empty * `label`. */ label?:string;private expandedIds;private pending;private readonly idBase;private readonly canonicalMemoriesBySource;private pendingControlledFocus;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private captureControlledFocus;private canonicalMemoriesFor; /** Never reproject a prior retained collection during controlled focus recovery. */ private cachedCanonicalMemoriesFor;private get normalizedShortTerm();private get normalizedLongTerm();private memoriesForScope;private itemKey;private itemBodyId;private tier;private toggleExpand;private startItemPending;private startForgetAllPending; /** * The action button that opens a confirmation is destroyed by the very render that opens it, so a * keyboard user who activated it would be dropped back onto `` -- top of the page, nothing * announced. Move focus into the confirmation's own Deny control instead (`lr-confirm-bar` orders * the safe action first), falling back to that bar's always-present `[part="status"]`. * * The bar -- and the `lr-button` inside it -- run their own first Lit update *after* this * component's, so both are awaited before the focus call; `pending` is re-checked afterwards so a * confirmation that was resolved or cancelled in the meantime never steals focus back. */ private focusPendingConfirmation; /** Escape cancels the open confirmation exactly like pressing its Deny control -- same event * (none), same focus return. Scoped to the bar rather than the document: this is an inline, * non-modal confirmation, so it must not swallow Escape for an enclosing dialog or popover. */ private onConfirmKeyDown;private refocusItem;private resolveItemDecision;private resolveForgetAllDecision;private renderConfidence;private renderItemConfirm;private renderItem;private renderForgetAllControl;private renderSection;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-memory-panel':LyraMemoryPanel;}}