import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{ToolInvocation,ToolApprovalEventDetail}from'../../../ai/types.js';import type{ApprovalAction}from'../approval-state.js'; /** * One entry in a ``. Extends `ToolInvocation` (`src/ai/types.ts`) with the * timeline-specific fields a bare invocation record doesn't carry on its own: when the call ran * (`startedAt`/`endedAt`, from which duration is derived), how many * times it was retried before landing on its current `status`, which of its `args`/`result`/ * `error` fields should render masked, and a human-in-the-loop approval decision. The inherited * `ToolInvocation` fields still assign directly onto ``/`` * with no adapter, exactly as `ToolInvocation` itself already does. */ export interface ToolTimelineEntry extends ToolInvocation{ /** Stable identity for the owning run/source generation. Supply this when invocation ids can be * reused; when an identity repeats, its first occurrence wins deterministically. */ sourceKey?:string; /** Literal icon hint forwarded to the composed ``. */ icon?:string; /** Epoch milliseconds the call started. Entries are ordered by this field (ascending); an entry * with no `startedAt` sorts after every timed entry, keeping its relative position among any * other untimed entries, and renders with no visible timestamp. */ startedAt?:number; /** Epoch milliseconds the call reached a terminal state. Paired with `startedAt` to derive the * duration handed to ``'s own `durationMs` -- omitted (or paired with no * `startedAt`) while still pending/running, or whenever the duration isn't known. */ endedAt?:number; /** Number of retry attempts before this entry's current `status` -- `2` means the call reached * its current state on its third try. Omitted or `0` renders no retry indicator. */ retryCount?:number; /** Dotted field paths within `args`/`result`/`error` to mask in the rendered detail view, e.g. * `['args.apiKey', 'result.rows.0.ssn']`, or the bare `'args'`/`'result'`/`'error'` to mask an * entire branch. A path with no matching field is a no-op, never a thrown error. Never applied * to the copy of `args` handed to the approval dialog -- see the class doc's approval note. */ redactedFields?:readonly string[]; /** Whether this call is gated behind a human approval decision. While `true` and `approved` is * still `undefined`, activating the entry's chip opens the shared approval dialog instead of * merely firing the chip's own selection event. */ needsApproval?:boolean; /** The approval decision, once made. `undefined` means still pending a decision. */ approved?:boolean;} /** * `detail` for `lr-tool-approval-decide` -- extends the shared `ToolApprovalEventDetail` * (`src/ai/types.ts`) with the (possibly host-edited) `args` the approval dialog produced, * present only when `approved` is `true`. A listener that only cares about the shared * `{ invocationId, approved }` shape can ignore `args` entirely; one driving actual tool * execution needs it, since the dialog's optional inline editing step can hand back different * arguments than the entry originally proposed. */ export interface ToolTimelineApprovalDetail extends ToolApprovalEventDetail{args?:unknown;sourceKey?:string;}export interface ToolTimelineActivateDetail{invocationId:string;sourceKey?:string;}export interface ToolTimelineRenderErrorDetail extends ToolTimelineActivateDetail{toolName:string;error:unknown;} /** Which approval action is waiting for a host that vetoed `lr-tool-approval-decide` to settle it. */ export type ToolTimelineApprovalPending=ApprovalAction|null;export interface LyraToolTimelineEventMap{'lr-tool-approval-decide':CustomEvent;'lr-tool-activate':CustomEvent;'lr-tool-render-error':CustomEvent;} /** * `` — a chronological list of an agent run's tool/function calls, each * rendered through `` (name/status/duration) and `` * (args/result), with per-entry retry counts, sensitive-field redaction, and a shared * `` for entries gated behind a human approval decision. This component * owns none of the actual per-call rendering -- that is entirely those three existing * primitives -- its own job is ordering `entries` chronologically, computing each entry's * duration from `startedAt`/`endedAt`, masking `redactedFields` before handing `args`/`result` to * ``, and opening/closing the one shared approval dialog for whichever entry * is currently pending a decision. * * Ordering: `entries` is sorted ascending by `startedAt`; an entry with no `startedAt` sorts after * every timed entry, keeping its position relative to any other untimed entries stable (input * order is preserved among ties) — a still-pending call with no timestamp yet naturally lands at * the end without needing to be pre-sorted by the host. * Rendering is bounded to 500 unique source entries before sorting. Duplicate `(sourceKey,id)` * identities use a deterministic first-wins policy. Entries already open or under approval * review are reserved inside that budget when new history would otherwise push them past the * ceiling, and a localized notice exposes truncation instead of silently hiding it. Foreign * runtime statuses normalize once to `pending` before both row and child presentation. * * Redaction work is deferred until a detail row opens and memoized while its payload/path inputs * remain unchanged. It is bounded to 100 paths, 64 levels, and 10,000 visited nodes; exceeding a * ceiling masks the affected branch rather than exposing data or exhausting the page. Redaction * only ever affects the read-only detail view: the copy of `args` handed to the * approval dialog is always the entry's real, unmasked value. Approving a masked-args call must * let the reviewer see (and, if `approvalEditable`, edit) what will actually be sent — handing the * dialog a placeholder string in place of a real field would silently corrupt the decision. * * Approval: activating the chip (`lr-tool-call-chip-select`) of an entry with `needsApproval` and * an undecided `approved` opens the shared dialog for that entry; approving or denying emits this * component's own `lr-tool-approval-decide` and closes the dialog. This component never mutates * `entries` itself — a host applies the decision (and any resulting status change) and re-assigns * `entries`; if the entry currently under review disappears or no longer qualifies as pending * (its `approved` was resolved some other way) by the time `entries` changes, the dialog closes on * its own rather than staying open over stale data. If a host cancels `lr-tool-approval-decide` to * persist it asynchronously, `pendingApproval` identifies the held action. After success, update * the controlled entries and call `finalizePendingApproval()`; after failure, call * `revertPendingApproval()` to restore the same open dialog and its draft for retry. A host that * instead resolves the decision synchronously by reassigning `entries` from within the same * `preventDefault()`ed listener wins outright: the entry's live state is re-checked immediately * after dispatch, so the shared dialog's `pending` flag is never parked on an entry the host already * finalized. A chip * belonging to an entry that isn't pending approval emits the timeline-owned, correlated * `lr-tool-activate`; raw child selection and disclosure lifecycle events are contained. * * Public collection properties take bounded readonly snapshots. `entries` retains each source * object and its opaque `args`/`result` payloads by identity only while a closed descriptor-safe * projection copies the fields this component uses; later rendering never re-reads an admitted * source record. Create a new collection and reassign it after changes; mutating the assigned * array does not update the view. * * @customElement lr-tool-timeline * @event lr-tool-approval-decide - A pending entry's approval dialog was resolved. * `detail: { invocationId, approved, args? }` — `args` (the dialog's current, possibly * host-edited arguments) is present only when `approved` is `true`. Cancelable; preventing it * preserves the pending dialog and its current argument edits, sets `pendingApproval`, and * requires `finalizePendingApproval()` or `revertPendingApproval()` to settle the held action. * @event lr-tool-activate - A non-approval entry was activated. `detail: { invocationId, * sourceKey? }`. * @event lr-tool-render-error - A nested result renderer failed. `detail: { invocationId, * sourceKey?, toolName, error }`. * @csspart base - The root `
    `. * @csspart entry - One entry's `
  1. `; carries `data-status` (the entry's `status`) and * `data-pending-approval` (`"true"`/`"false"`). * @csspart entry-marker - The decorative rail dot/connector for one entry. * @csspart entry-body - Wrapper around one entry's header and details. * @csspart entry-header - Wrapper around the timestamp, chip, retry badge, and approval status. * @csspart entry-timestamp - The formatted `startedAt`, only rendered while it's set. * @csspart entry-retries - The retry-count badge, only rendered while `retryCount > 0`. * @csspart entry-retries-label - The localized "Retry" text within the retry badge. * @csspart entry-retries-count - The formatted retry count within the retry badge. * @csspart entry-approval-status - The "Approved"/"Denied" badge, only rendered once `approved` * is set; carries `data-decision` (`"approved"`/`"denied"`). * @csspart entry-redacted-indicator - A decorative marker shown when `redactedFields` is * non-empty for that entry; the glyph is decorative and localized hidden-state text remains in * the accessibility tree. * @csspart entry-details - The `` disclosure wrapping the entry's result view. * @csspart entry-result - The entry's ``. * @csspart entry-error - The entry's `error` text, only rendered when set. * @csspart approval-dialog - The single shared `` instance. * @csspart empty - Localized empty state shown when no entries are available. * @csspart limit - Localized resource-ceiling notice. * @cssprop [--lr-tool-timeline-gap=var(--lr-space-l)] - Vertical gap between entries. * @cssprop [--lr-tool-timeline-marker-size=var(--lr-size-0-625rem)] - Diameter of an entry's rail * dot; also the width of the marker gutter column. * @cssprop [--lr-tool-timeline-denied-marker-color=var(--lr-color-warning)] - Rail-dot color for a * `status="denied"` entry, decoupled from the pending-approval border below so a consumer can * retint either independently. * @cssprop [--lr-tool-timeline-pending-marker-color=var(--lr-color-text-quiet)] - Rail-dot color * for a `status="pending"` entry. * @cssprop [--lr-tool-timeline-pending-approval-border-color=var(--lr-color-warning)] - Color of * the entry body's leading border while `data-pending-approval="true"`. * @cssprop [--lr-tool-timeline-running-marker-color=var(--lr-color-brand)] - Running rail dot. * @cssprop [--lr-tool-timeline-success-marker-color=var(--lr-color-success)] - Success rail dot. * @cssprop [--lr-tool-timeline-error-marker-color=var(--lr-color-danger)] - Error rail dot. * @cssprop [--lr-tool-timeline-approved-bg=var(--lr-color-success-quiet)] - Approved badge background. * @cssprop [--lr-tool-timeline-approved-color=var(--lr-color-success)] - Approved badge foreground. * @cssprop [--lr-tool-timeline-denied-bg=var(--lr-color-danger-quiet)] - Denied badge background. * @cssprop [--lr-tool-timeline-denied-color=var(--lr-color-danger)] - Denied badge foreground. * @cssprop [--lr-tool-timeline-error-color=var(--lr-color-danger)] - Expanded error text. * @status stable * @since 4.1.0 */ export declare class LyraToolTimeline extends LyraElement{protected static readonly ownedCollectionProperties:readonly string[]; /** Provider tool payloads can be opaque objects. Preserve row identity at the array boundary, * then admit only one descriptor-safe canonical record for every rendering path. */ protected static readonly identityCollectionProperties:readonly string[];static styles:import("lit").CSSResultGroup[]; /** The calls to render, in any order — see the class doc's ordering note. Entries with empty * invocation ids are omitted; duplicate `(sourceKey, id)` identities normalize first-wins. */ entries:readonly ToolTimelineEntry[]; /** Forwarded to the shared approval dialog's own `editable` — whether a reviewer can edit an * entry's arguments before approving it. */ approvalEditable:boolean; /** Overrides the default `hour:minute` rendering of every entry's `startedAt`. */ formatTimestamp?:(date:Date)=>string; /** The `(sourceKey,id)` identity of the entry currently under review, or `undefined` while the * shared dialog is closed. */ private reviewingEntryKey?;private approvalPending;private openedEntryIds;private projectedEntriesCache;private projectionTruncated;private redactionCache;private limitAnnouncementSink?;private limitAnnouncementInitialized;private previouslyTruncated;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private syncLimitAnnouncementSink; /** The approval/denial action held after a listener vetoes `lr-tool-approval-decide`, or `null` * otherwise. Read-only: call `finalizePendingApproval()` after persisting the controlled entry, * or `revertPendingApproval()` to release the same dialog and draft for another attempt. */ get pendingApproval():ToolTimelineApprovalPending;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private rebuildProjection;private get sortedEntries();private get reviewingEntry();private durationFor;private normalizedDate;private onChipSelect; /** Re-derives, directly from the live `entries` prop, whether the entry identified by `key` still * needs a decision. Used right after dispatching `lr-tool-approval-decide`, whose listener runs * synchronously inside `emit()` -- a host resolving the decision by reassigning `entries` (rather * than calling `finalizePendingApproval()`/`revertPendingApproval()`) has already done so by the * time control returns, and `this.projectedEntriesCache` is not rebuilt until the next `willUpdate` * pass, so it cannot be trusted here either. */ private entryStillNeedsApproval;private onDialogApprove;private onDialogDeny;private onDialogClose; /** Completes a vetoed approval/denial after the host has persisted the controlled entry. Closes * the review dialog without changing `entries`; no-op when no approval action is pending. */ finalizePendingApproval():void; /** Releases a vetoed approval/denial after host persistence fails. Keeps the same dialog open * and retains any edited arguments so the reviewer can retry; no-op when nothing is pending. */ revertPendingApproval():void;private onDetailsToggle;private stopOwnedEvent;private onRenderError;private redactedEntry;private openedDetailsTemplate;private entryTemplate;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-tool-timeline':LyraToolTimeline;}}