import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraFrame}from'../../../internal/variants.js';import type{AgentRun,CancelEventDetail,RetryEventDetail}from'../../../ai/types.js';import type{BadgeVariant}from'../../overlays/badge/badge.class.js';export interface AgentRunMetric{id:string;label:string;value:string|number;variant?:BadgeVariant;} /** Visual chrome for ``'s root — the library's shared container-frame vocabulary. */ export type AgentRunAppearance=LyraFrame;export interface LyraAgentRunEventMap{'lr-cancel':CustomEvent;'lr-run-retry':CustomEvent;} /** * `` — the top-level shell for one `AgentRun`: lifecycle-status badge, elapsed * time, current step, model/cost summary, and built-in Cancel/Retry controls in a header, plus * four named composition slots (`tasks`/`tools`/`reasoning`/`output`) for the run's actual * content. This is deliberately a SHELL, not a new step-rendering surface — every piece of * per-step or per-invocation rendering routes through an existing primitive: * * - **Elapsed time**: composes `` (`status`/`started-at`, its own built-in * Stop button hidden via `show-stop="false"` since this component renders its own Cancel/Retry * pair instead) for the *live, ticking* readout while the run is genuinely in progress * (`running`/`collecting`/`waiting-input`/`waiting-approval`). `` doesn't fit: * its `phase` vocabulary * (`idle`/`connecting`/`streaming`/`stalled`) models transport/connection health, not an agent * run's nine built-in lifecycle statuses (plus application-defined extensions), and it exposes no elapsed-time readout at all — exactly the * distinction ``'s own class doc already draws between the two. Once the * run reaches a terminal state (`done`/`error`/`cancelled`) with both a `startedAt` and an * `endedAt`, this component instead renders a small locally-formatted static duration * (`endedAt - startedAt`): ``'s `status="complete"` semantics only * ever freeze at whatever it last computed *live*, so mounting it directly against a completed * run loaded from history (e.g. `startedAt` yesterday, `endedAt` five minutes later, loaded * today) would either show a stale zero or the wrong multi-hour span — it has no way to render a * fixed historical span on demand. That static fallback reuses the side-effect-free duration * value model shared by the run/tool surfaces while retaining this component's own localized * message interpolation. * - **Model + cost summary**: composes ``, fed `run.costEstimate` (formatted via * `formatCost`, or a plain `Intl.NumberFormat` by default — this library never assumes a * currency, see ``'s own explicit `currency` prop) as its `cost-text`. * `run.model` (a plain string with no analogous `` property) renders alongside * as plain text. * - **Current step**: a single-line summary of whichever `run.steps` entry currently has * `status.kind === 'running'` (the last such entry, if more than one) — a plain text line, not a * list, so it doesn't duplicate ``'s own per-item rendering. * - **Tasks slot default content**: when the host doesn't slot anything into `tasks` and * `run.steps` is non-empty, this component's own `` fallback renders a `` * populated by mapping every `AgentStep` to a `TaskItem` (see `toTaskItem()`) — a plain data * adapter between the two existing shapes, not new rendering. * - **Status badge**: composes ``. **Empty state**: composes `` when `run` is * `null`. * * `tools`/`reasoning`/`output` are plain named slots with no default content — entirely the * host's own composition (typically ``/`` rows, * reasoning/streaming text, and final output respectively). An `actions` slot adds extra header * controls alongside the built-in Cancel/Retry pair. The `header` and `summary` slots replace the * built-in lifecycle header and model/usage/metrics summary respectively. `statusLabels` and * `statusVariants` make application-defined lifecycle kinds first-class, while `metrics` renders * arbitrary labeled values such as prompt and completion token counts. * * The built-in Cancel button renders while `showCancel` is true and the run's status is one of * `TICKING_KINDS` (still genuinely in progress); Retry renders while `showRetry` is true and the * status is `error` or `cancelled`. Clicking either fires `lr-cancel`/`lr-run-retry` with * `CancelEventDetail`/`RetryEventDetail` from `src/ai/types.ts` — this component never cancels or * retries anything itself, it only requests. `RetryEventDetail.attempt` is a 1-based counter * local to this component, incremented on every `lr-run-retry` click and reset to `0` whenever * `run.id` changes (a genuinely new run replacing the old one, as opposed to the same run's status * merely updating in place). * * Lifecycle transitions into an attention-needing or terminal state (`waiting-input`, * `waiting-approval`, `done`, `error`, `cancelled`) are announced through an internal * ``, mirroring ``'s own stall/recover announcements — * `running`/`idle` transitions are frequent and not independently actionable, so they stay * silent, and whatever status a freshly-assigned `run` (a new `run.id`) happens to already carry * is never itself treated as an eventful transition, only a later in-place change is. * * Public collection and status-map properties take bounded, clone-owned readonly snapshots. * Create and reassign a new array or record after changes; mutating the assigned value does not * update the view. * * @customElement lr-agent-run * @slot tasks - Task/plan content. Falls back to a `` built from `run.steps` when * nothing is slotted and `run.steps` is non-empty. * @slot header - Replaces the built-in lifecycle header and its built-in actions. * @slot summary - Replaces the built-in model, usage, and metrics summary. * @slot tools - Tool-call content (e.g. ``/`` rows). No * default content. * @slot reasoning - Reasoning/thinking content. No default content. * @slot output - The run's final output content. No default content. * @slot actions - Extra header actions alongside the built-in Cancel/Retry buttons. * @event lr-cancel - The built-in Cancel button was activated. `detail: CancelEventDetail` * (`{ reason }`, always `undefined` from the built-in button itself). * @event lr-run-retry - The built-in Retry button was activated. `detail: RetryEventDetail` * (`{ attempt }`, a 1-based counter reset per `run.id`). * @csspart base - The root container. * @csspart empty - The `` shown when `run` is `null`. * @csspart header - The header row wrapping status, elapsed time, current step, summary, and actions. * @csspart status - Wrapper around the status badge and optional status message. * @csspart status-badge - The resolved `` lifecycle-status pill. * @csspart status-message - `run.status.message`, when set. * @csspart elapsed - The composed ``, only rendered while the run is * actively ticking (see the class doc). * @csspart elapsed-static - The static formatted duration for a terminal run with both * `startedAt` and `endedAt`. * @csspart current-step - Wrapper around the current-step icon and label. Only rendered while a * step has `status.kind === 'running'`. * @csspart current-step-icon - The spinning current-step icon. * @csspart current-step-label - The current step's `label` text. * @csspart summary - Wrapper around the model text and the composed ``. Only * rendered while `run.model` or a valid `run.costEstimate` is present. * @csspart model - `run.model`, when set. * @csspart usage - The composed ``. * @csspart metric - One arbitrary metric in the built-in summary. * @csspart metric-label - The metric's label. * @csspart metric-value - The metric's value. * @csspart actions - Wrapper around the `actions` slot and the built-in Cancel/Retry buttons. * @csspart cancel-button - The built-in Cancel button. Only rendered while cancelable (see the * class doc). * @csspart retry-button - The built-in Retry button. Only rendered while retryable. * @csspart body - Wrapper around the four composition slots. * @csspart tasks - The `tasks` slot. * @csspart tools - The `tools` slot. * @csspart reasoning - The `reasoning` slot. * @csspart output - The `output` slot. * @cssprop [--lr-agent-run-spin=var(--lr-transition-ambient)] - Current-step icon spin animation. * @cssprop [--lr-agent-run-metric-brand-color=var(--lr-color-brand)] - Brand metric value. * @cssprop [--lr-agent-run-metric-danger-color=var(--lr-color-danger)] - Danger metric value. * @cssprop [--lr-agent-run-metric-success-color=var(--lr-color-success)] - Success metric value. * @cssprop [--lr-agent-run-metric-warning-color=var(--lr-color-warning)] - Warning metric value. * @cssprop [--lr-agent-run-compact-padding=var(--lr-space-s)] - `[part="base"]` padding while * `compact`. * @cssprop [--lr-agent-run-compact-gap=var(--lr-space-s)] - Gap between `[part="base"]`'s header * and body while `compact`. * @cssprop [--lr-agent-run-background=var(--lr-color-surface)] - Fill of the outer card * (`[part="base"]`) while `frame="card"`. `frame="plain"` still removes the fill entirely. * @cssprop [--lr-agent-run-border-color=var(--lr-color-border)] - Colour of the outer card's * border. * @cssprop [--lr-agent-run-radius=var(--lr-radius)] - Corner radius of the outer card. * `frame="plain"` still squares the corners. * @status stable * @since 4.1.0 */ export declare class LyraAgentRun extends LyraElement{protected static readonly ownedCollectionProperties:readonly string[];static styles:import("lit").CSSResultGroup[]; /** The run to display. Controlled and never mutated by this component -- pass a new object to * update it. `null` renders the shared `` `noData` state. A runtime summary record * without `steps` renders an empty task slot, and a step without a status renders as pending. */ run:AgentRun|null; /** Overrides the default plain `Intl.NumberFormat` rendering of `run.costEstimate` fed to the * composed ``'s `cost-text` -- e.g. to add a currency symbol/code, which this * library never assumes on a host's behalf. */ formatCost?:(cost:number)=>string; /** Clone-owned labels for application-defined lifecycle kinds. Built-in kinds remain localized * by Lyra. Reassign a new record after changes. */ statusLabels:Readonly>; /** Clone-owned badge variants for application-defined lifecycle kinds. Unknown kinds default to * `neutral`. Reassign a new record after changes. */ statusVariants:Readonly>; /** Additional run metrics such as prompt/completion token counts. Empty/blank ids are omitted * and duplicates normalize first-wins before summary visibility and rendering. */ metrics:readonly AgentRunMetric[];private get normalizedMetrics(); /** Whether the built-in Cancel button can render at all -- still gated by the run's own status * being cancelable (`running`/`collecting`/`waiting-input`/`waiting-approval`). Set `false` for a read-only * viewer. */ showCancel:boolean; /** Whether the built-in Retry button can render at all -- still gated by the run's own status * being retryable (`error`/`cancelled`). */ showRetry:boolean; /** Tighter root padding and header/body gap for dense contexts (a run rendered as a row in a * list, a side panel) -- same convention as `lr-empty`'s `compact`. Defaults to `false`, i.e. * the full card padding. Purely a density knob: the border and background stay, so use * `frame="plain"` instead to drop the chrome entirely. */ compact:boolean; /** Visual chrome, in the library's shared container-frame vocabulary. `'card'` (the default) * keeps the bordered, filled, padded box. `'plain'` removes the border, background, padding and * corner radius, so a run nested inside a host container that already draws a border doesn't * double it. `plain` wins over `compact` when both are set (nothing left to tighten). The * built-in Cancel/Retry buttons draw their own border/background and stay visibly interactive * either way. */ frame:LyraFrame;private retryAttempt;private hasHeaderSlot;private hasSummarySlot;private liveRegion?;private previousRunId?;private previousStatusKind?;protected willUpdate(changed:PropertyValues):void;private hasSlotted;private onHeaderSlotChange;private onSummarySlotChange;protected updated(changed:PropertyValues):void;private handleRunChange;private isAttentionKind;private announceStatus;private statusLabel;private get currentStep();private get isTicking(); /** The static formatted duration for a terminal run with both `startedAt` and `endedAt` -- * `undefined` while ticking, not yet terminal, or missing either timestamp (see the class * doc's "elapsed time" section for why a terminal run doesn't reuse the live ticker). */ private get staticElapsedText();private get costText();private get canCancel();private get canRetry();private onCancelClick;private onRetryClick;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-agent-run':LyraAgentRun;}}