import{type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{Citation}from'../../../ai/types.js';import type{ContextMeterTone}from'../../data/context-meter/context-meter.class.js';import type{LyraCitationBadgeEventMap}from'../../retrieval/citation-badge/citation-badge.class.js';import type{LyraCopyButtonEventMap}from'../../utility/copy-button/copy-button.class.js';import type{LyraExportFormatOption,LyraExportButtonEventMap}from'../../utility/export-button/export-button.class.js';import'../../data/context-meter/context-meter.class.js';import'../../utility/copy-button/copy-button.class.js';import'../../utility/export-button/export-button.class.js';import'../../retrieval/citation-badge/citation-badge.class.js';import'../../overlays/empty/empty.class.js'; /** * One redacted character range within a `ContextInspectorSegment.text`. `start`/`end` are plain * UTF-16 offsets, matching `Citation['span']`'s own `{ start; end }` shape (`ai/types.ts`). `text` * is expected to already carry a redaction placeholder in that range (e.g. `[REDACTED]`) -- this * component only visually/accessibly marks the range, it never receives, un-redacts, or renders * the original sensitive content. */ export interface ContextInspectorRedaction{start:number;end:number; /** Shown as the marker's `title`/accessible reason. Falls back to a generic localized "Redacted" when unset. */ reason?:string;} /** One piece of the assembled final prompt context, e.g. a system prompt, a retrieved chunk, or one chat-history turn. */ export interface ContextInspectorSegment{id:string; /** Short heading, e.g. "System prompt", "Retrieved chunk 2". Feeds both this segment's own heading and its `` segment label. */ label:string; /** The segment's final text, exactly as sent to the model (post-redaction/post-truncation). */ text:string; /** Estimated token count. Feeds ``'s segment `value` directly. */ tokens:number;tone?:ContextMeterTone; /** Source attribution -- renders a `` carrying `citation.sourceId`/`citation.label`. */ citation?:Citation; /** True when `text` was cut short of the segment's original content. */ truncated?:boolean; /** Tokens omitted by truncation, shown in the truncation-boundary marker's text when set. */ omittedTokens?:number; /** Character ranges within `text` that are redaction placeholders (see `ContextInspectorRedaction`). */ redactions?:readonly ContextInspectorRedaction[];}export interface LyraContextInspectorEventMap extends LyraCitationBadgeEventMap,LyraCopyButtonEventMap,LyraExportButtonEventMap{} /** * `` — an inspection view of the exact context assembled for a model call: * per-segment token estimates via ``, source attribution via * ``, and copy/export affordances via ``/``. * Truncation-boundary and redaction-marker rendering are this component's own minimal * presentational logic (see `ContextInspectorSegment`'s `truncated`/`omittedTokens`/`redactions` * fields) — no existing primitive covers "show where this got cut off / redacted", so this stays a * small, purpose-built rendering step rather than a general text-annotation system. * * Pure projection: never fetches, estimates tokens, or performs redaction itself — `segments` is * expected to already carry each field's final, already-processed value (e.g. `text` already has * any redaction placeholders substituted in; this component never sees or renders the original * unredacted content). Duplicate segment ids normalize before totals, exports, rendering, and * citation events; the first occurrence wins. * * Public collection properties take bounded, clone-owned readonly snapshots. Create a new * collection and reassign it after changes; mutating the assigned array does not update the view. * * @customElement lr-context-inspector * @event lr-copy - `detail: { ok: true, text }`, surfaced by the embedded `lr-copy-button` copying the * assembled context text (every segment's `label` + `text`, in order). Bubbles + composed * already; not re-emitted, so exactly one event reaches a host listener. * @event lr-error - A clipboard write failed in the embedded copy control. * @event lr-copy-error - The embedded copy control's compatibility error event for the same * clipboard failure. * @event lr-toolbar-actions-change - No-detail coordination event surfaced unchanged from the * embedded copy button when its logical toolbar action changes availability or backing trigger. * @event lr-export - `detail: { format }`, surfaced by the embedded `lr-export-button`, one row * per segment. Cancelable — see that component's own contract for substituting a * server-generated export. * @event lr-export-complete - `detail: { format }`, fired after a non-cancelled export completes. * @event lr-export-error - The embedded export control could not complete the requested export. * @event lr-show - The embedded export format menu opened. * @event lr-hide - The embedded export format menu closed. * @event lr-citation-activate - `detail: { sourceId, index }`, surfaced by a segment's embedded * `lr-citation-badge` — the "jump to this source" signal a host wires to scrolling/highlighting * the matching `lr-source-card`. * @event lr-citation-open - `detail: { sourceId, index, href }`, this component's "full preview" * signal, surfaced the same way. * @csspart base - The `role="group"` wrapper. * @csspart meter - The embedded `lr-context-meter`. Omitted (replaced by `empty`) when `segments` is empty. * @csspart toolbar - The wrapper around the copy/export affordances. Omitted when `segments` is empty. * @csspart copy-button - The embedded `lr-copy-button`. * @csspart export-button - The embedded `lr-export-button`. * @csspart segments - The `role="list"` wrapper around all segments. Omitted (replaced by `empty`) when `segments` is empty. * @csspart segment - One segment's wrapper (`role="listitem"`). * @csspart segment-header - A segment's label/token-count/citation row. * @csspart segment-label - A segment's visible label text. * @csspart segment-tokens - A segment's visible token-estimate text. * @csspart citation - A segment's embedded `lr-citation-badge`, rendered only when it carries a `citation`. * @csspart segment-text - A segment's text body, carrying any `redaction` marks and its own trailing `truncation-boundary` marker. * @csspart redaction - One redacted range within a segment's text (a ``). * @csspart truncation-boundary - The marker appended after a `truncated` segment's text. * @csspart empty - The empty state, shown when `segments` is empty. * @status stable * @since 4.1.0 */ export declare class LyraContextInspector extends LyraElement{protected static readonly ownedCollectionProperties:readonly string[];static styles:import("lit").CSSResultGroup[]; /** The assembled context, one entry per piece (system prompt, retrieved chunk, history turn, * ...). Empty/blank ids are omitted and duplicates normalize first-wins before metering, * rendering, export, and events. A valid-id streaming row whose text has not arrived yet is * retained with an empty text body. */ segments:readonly ContextInspectorSegment[]; /** The full token budget `segments` are measured against — passed straight through to ``'s own `total`. */ total:number; /** Accessible group name, and the embedded ``'s own visible caption, e.g. "128K context window". */ label:string; /** Export format(s) offered by the embedded `` — a single id renders a plain button, more than one a format-choice menu. */ exportFormats:readonly LyraExportFormatOption[]; /** Download filename (no extension) passed through to ``. */ exportFilename:string;private get normalizedSegments();private get meterSegments();private get safeTotal(); /** Every segment's `label` + `text`, in order — the ``'s `value`. */ private get assembledText(); /** One flat row per segment for `` — `redactions` is summarized as a count * rather than carried in full, keeping every export format (including CSV) well-formed. */ private get exportRows();private renderSegmentText;private renderTruncationBoundary;private renderSegment;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-context-inspector':LyraContextInspector;}}