@usetheo/ui 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/components/composites/attributes-table/attributes-table.d.ts +20 -0
  2. package/dist/components/composites/attributes-table/index.d.ts +1 -0
  3. package/dist/components/composites/io-cards/index.d.ts +2 -0
  4. package/dist/components/composites/io-cards/io-cards.d.ts +17 -0
  5. package/dist/components/composites/io-cards/message-card.d.ts +21 -0
  6. package/dist/components/composites/span-graph/index.d.ts +1 -0
  7. package/dist/components/composites/span-graph/span-graph.d.ts +19 -0
  8. package/dist/components/composites/span-tree/index.d.ts +2 -0
  9. package/dist/components/composites/span-tree/span-tree-row.d.ts +22 -0
  10. package/dist/components/composites/span-tree/span-tree-virtual.d.ts +7 -0
  11. package/dist/components/composites/span-tree/span-tree.d.ts +34 -0
  12. package/dist/components/composites/span-waterfall/index.d.ts +1 -0
  13. package/dist/components/composites/span-waterfall/span-waterfall.d.ts +28 -0
  14. package/dist/components/composites/trace-compare/index.d.ts +1 -0
  15. package/dist/components/composites/trace-compare/trace-compare.d.ts +27 -0
  16. package/dist/components/composites/trace-transcript/index.d.ts +1 -0
  17. package/dist/components/composites/trace-transcript/trace-transcript.d.ts +26 -0
  18. package/dist/components/primitives/action-bar/action-bar.d.ts +2 -0
  19. package/dist/components/primitives/combobox/combobox.d.ts +3 -3
  20. package/dist/index.d.ts +16 -0
  21. package/dist/index.js +1565 -1
  22. package/dist/lib/trace/align.d.ts +41 -0
  23. package/dist/lib/trace/attributes.d.ts +11 -0
  24. package/dist/lib/trace/bar-layout.d.ts +52 -0
  25. package/dist/lib/trace/chat.d.ts +14 -0
  26. package/dist/lib/trace/cost.d.ts +16 -0
  27. package/dist/lib/trace/duration.d.ts +18 -0
  28. package/dist/lib/trace/flatten.d.ts +28 -0
  29. package/dist/lib/trace/graph-layout.d.ts +52 -0
  30. package/dist/lib/trace/index.d.ts +9 -0
  31. package/dist/lib/trace/types.d.ts +80 -0
  32. package/dist/test/fixtures/trace.d.ts +19 -0
  33. package/package.json +3 -1
@@ -0,0 +1,20 @@
1
+ export interface AttributesTableProps {
2
+ attrs?: Record<string, unknown>;
3
+ /** Predicate marking a key's value as sensitive (masked fail-closed). Default: nothing masked. */
4
+ maskedKeys?: (key: string) => boolean;
5
+ /** Whether the viewer is authorized to reveal masked values. Default false (fail-closed). */
6
+ canReveal?: boolean;
7
+ /** Keys promoted to a badge header above the namespace cards. */
8
+ promoted?: string[];
9
+ /** Namespace cards start expanded. Default true. */
10
+ defaultOpen?: boolean;
11
+ }
12
+ /**
13
+ * AttributesTable — namespace-grouped OTel span attributes with fail-closed
14
+ * PII masking. A `maskedKeys`-flagged value renders as `•••`; its raw string
15
+ * NEVER enters the DOM (no text node, no title/aria/data) until Reveal is
16
+ * clicked AND `canReveal` is true, and its CopyButton is withheld until then.
17
+ * When `!canReveal` the reveal control is a quiet "masked" hint, not an inert
18
+ * button. Object values fall back to the dependency-free `JsonViewer`.
19
+ */
20
+ export declare function AttributesTable({ attrs, maskedKeys, canReveal, promoted, defaultOpen, }: AttributesTableProps): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export { AttributesTable, type AttributesTableProps } from "./attributes-table.js";
@@ -0,0 +1,2 @@
1
+ export { IOCards, type IOCardsProps } from "./io-cards.js";
2
+ export { MessageCard, MessageItem, type RenderMarkdown } from "./message-card.js";
@@ -0,0 +1,17 @@
1
+ import { type RenderMarkdown } from "./message-card.js";
2
+ export interface IOCardsProps {
3
+ /** Raw payload string: a chat-message-array JSON, other JSON, or plain text. */
4
+ value?: string;
5
+ /** Optional slot for rendering markdown bodies (e.g. react-markdown + sanitize). Default: plain text. */
6
+ renderMarkdown?: RenderMarkdown;
7
+ "data-testid"?: string;
8
+ }
9
+ /**
10
+ * IOCards — renders a span's input/output value. A chat-message array becomes
11
+ * role-labeled cards (with tool-call/result linkage and long-history
12
+ * collapse); a redacted marker and non-chat payloads fall back to a plain
13
+ * message or the dependency-free `JsonViewer`. Markdown bodies go through the
14
+ * optional `renderMarkdown` slot — the default renderer NEVER interprets HTML
15
+ * (XSS-safe by construction; no `dangerouslySetInnerHTML` anywhere).
16
+ */
17
+ export declare function IOCards({ value, renderMarkdown, "data-testid": testId }: IOCardsProps): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ChatMessage, ToolCall } from "../../../lib/trace/types.js";
3
+ export type RenderMarkdown = (text: string) => ReactNode;
4
+ /** Props shared by the message-rendering components (kills the repeated `{message, renderMarkdown}` shape). */
5
+ interface MessageProps {
6
+ message: ChatMessage;
7
+ renderMarkdown?: RenderMarkdown;
8
+ }
9
+ /** A bordered, role-labeled Card: role Badge + body (markdown slot or plain text) + raw-JSON toggle. */
10
+ export declare function MessageCard({ message, renderMarkdown }: MessageProps): import("react").JSX.Element;
11
+ /** A dedicated tool-call card: function name + call-id + JSON arguments. Linked to its result by id. */
12
+ export declare function ToolCallCard({ call }: {
13
+ call: ToolCall;
14
+ }): import("react").JSX.Element;
15
+ /** A tool-result card, linked to its originating call by `tool_call_id`. */
16
+ export declare function ToolResultCard({ message }: {
17
+ message: ChatMessage;
18
+ }): import("react").JSX.Element;
19
+ /** Render one chat message as its appropriate card kind (tool-result → tool-calls → plain message). */
20
+ export declare function MessageItem({ message, renderMarkdown }: MessageProps): import("react").JSX.Element;
21
+ export {};
@@ -0,0 +1 @@
1
+ export { SpanGraph, type SpanGraphProps } from "./span-graph.js";
@@ -0,0 +1,19 @@
1
+ import type { TraceSpan } from "../../../lib/trace/types.js";
2
+ export interface SpanGraphProps {
3
+ root: TraceSpan;
4
+ selectedId: string | null;
5
+ onSelect: (id: string) => void;
6
+ /** Max spans before the honest "too large" state renders. Default 200. */
7
+ nodeCap?: number;
8
+ className?: string;
9
+ "aria-label"?: string;
10
+ }
11
+ /**
12
+ * SpanGraph — a deterministic, dependency-free SVG rendering of the trace as a
13
+ * layered agent graph (depth = distance from root, order = index within
14
+ * depth). Edges follow parent/call order; the root→selected path is
15
+ * highlighted. Over `nodeCap` spans it renders an honest "too large" state
16
+ * instead of an unreadable hairball. No layout lib (elkjs/d3) — SVG-pure by
17
+ * ADR D4. Nodes are focusable buttons; selection is controlled.
18
+ */
19
+ export declare function SpanGraph({ root, selectedId, onSelect, nodeCap, className, "aria-label": ariaLabel, }: SpanGraphProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { SpanTree, type SpanTreeProps, type SpanTreeRenderCtx } from "./span-tree.js";
2
+ export { SpanTreeRow, type SpanTreeRowProps } from "./span-tree-row.js";
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from "react";
2
+ import type { TraceSpan } from "../../../lib/trace/types.js";
3
+ export interface SpanTreeRowProps {
4
+ span: TraceSpan;
5
+ depth: number;
6
+ selected: boolean;
7
+ collapsed: boolean;
8
+ hasChildren: boolean;
9
+ posinset: number;
10
+ setsize: number;
11
+ showMetrics?: boolean;
12
+ /** Optional trace window for the inline timeline bar. */
13
+ bounds?: {
14
+ startNs: bigint;
15
+ endNs: bigint;
16
+ };
17
+ onSelect: (id: string) => void;
18
+ onToggle: (id: string) => void;
19
+ renderBadge?: (span: TraceSpan) => ReactNode;
20
+ }
21
+ /** The single clickable row for a span — shared by the recursive and virtualized paths. */
22
+ export declare function SpanTreeRow({ span, depth, selected, collapsed, hasChildren, posinset, setsize, showMetrics, bounds, onSelect, onToggle, renderBadge, }: SpanTreeRowProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { FlatSpan } from "../../../lib/trace/types.js";
2
+ import type { SpanTreeRenderCtx } from "./span-tree.js";
3
+ export interface SpanTreeVirtualProps extends SpanTreeRenderCtx {
4
+ flat: FlatSpan[];
5
+ }
6
+ /** Virtualized flat-list tree (large traces at/above the threshold), reusing @tanstack/react-virtual. */
7
+ export declare function SpanTreeVirtual({ flat, selectedId, collapsed, showMetrics, bounds, onSelect, onToggle, renderBadge, }: SpanTreeVirtualProps): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import { type ReactNode } from "react";
2
+ import type { TraceSpan } from "../../../lib/trace/types.js";
3
+ /** Shared render context threaded to every row (kills per-node prop duplication). */
4
+ export interface SpanTreeRenderCtx {
5
+ selectedId: string | null;
6
+ collapsed: Set<string>;
7
+ showMetrics?: boolean;
8
+ bounds?: {
9
+ startNs: bigint;
10
+ endNs: bigint;
11
+ };
12
+ onSelect: (id: string) => void;
13
+ onToggle: (id: string) => void;
14
+ renderBadge?: (span: TraceSpan) => ReactNode;
15
+ }
16
+ export interface SpanTreeProps extends Omit<SpanTreeRenderCtx, "onToggle"> {
17
+ /** Root span of the trace. */
18
+ root: TraceSpan;
19
+ /** Collapse toggle (controlled). */
20
+ onToggleCollapse: (id: string) => void;
21
+ /** Visible-row count at/above which the virtualized path engages. Default 200. */
22
+ virtualizeThreshold?: number;
23
+ className?: string;
24
+ "aria-label"?: string;
25
+ }
26
+ /**
27
+ * SpanTree — an accessible, controllable tree of trace spans with full
28
+ * WAI-ARIA APG TreeView semantics (treeitem / level / posinset / setsize /
29
+ * selected / expanded / group). Renders recursively for small traces and
30
+ * switches to a virtualized flat-list at/above `virtualizeThreshold`. The
31
+ * container is keyboard-navigable (↑/↓ move, Home/End jump, Enter/Space
32
+ * select). Fully controlled: selection + collapse live in the consumer.
33
+ */
34
+ export declare function SpanTree({ root, selectedId, onSelect, collapsed, onToggleCollapse, showMetrics, bounds, virtualizeThreshold, renderBadge, className, "aria-label": ariaLabel, }: SpanTreeProps): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export { SpanWaterfall, type SpanWaterfallProps } from "./span-waterfall.js";
@@ -0,0 +1,28 @@
1
+ import type { TraceSpan } from "../../../lib/trace/types.js";
2
+ type Bounds = {
3
+ startNs: bigint;
4
+ endNs: bigint;
5
+ };
6
+ export interface SpanWaterfallProps {
7
+ root: TraceSpan;
8
+ /** Trace window; defaults to the honest min-start/max-end envelope of the whole tree. */
9
+ bounds?: Bounds;
10
+ selectedId: string | null;
11
+ onSelect: (id: string) => void;
12
+ collapsed: Set<string>;
13
+ /** ns → label for the hover-needle. Default ISO datetime. */
14
+ formatTimestamp?: (ns: bigint) => string;
15
+ /** USD cost formatter for the ∑ rollup badge. Default `$0.0000`. */
16
+ formatCostUsd?: (usd: number) => string;
17
+ className?: string;
18
+ "aria-label"?: string;
19
+ }
20
+ /**
21
+ * SpanWaterfall — a nice-interval time axis over row-packed span bars, a
22
+ * hover-needle reading the absolute wall-clock time under the pointer, and a
23
+ * `∑` rollup-cost badge on parent rows. Bars are percentage-positioned via
24
+ * `computeBarLayout` (clock-skew / in-flight → dashed unbounded). Controlled:
25
+ * selection lives in the consumer. Escaped text only — no HTML injection.
26
+ */
27
+ export declare function SpanWaterfall({ root, bounds, selectedId, onSelect, collapsed, formatTimestamp, formatCostUsd, className, "aria-label": ariaLabel, }: SpanWaterfallProps): import("react").JSX.Element;
28
+ export {};
@@ -0,0 +1 @@
1
+ export { TraceCompare, type TraceCompareProps, type CompareLane } from "./trace-compare.js";
@@ -0,0 +1,27 @@
1
+ import { type AlignRow } from "../../../lib/trace/align.js";
2
+ import type { TraceSpan } from "../../../lib/trace/types.js";
3
+ export interface CompareLane {
4
+ /** Display label (e.g. a trace id). */
5
+ id: string;
6
+ root: TraceSpan;
7
+ /** Data still loading — the lane renders a skeleton and no deltas compute. */
8
+ pending?: boolean;
9
+ }
10
+ export interface TraceCompareProps {
11
+ /** Baseline lane. */
12
+ laneA: CompareLane;
13
+ /** Compared lane (B vs A). */
14
+ laneB: CompareLane;
15
+ /** Custom aligner (default: structural `alignSpanTrees`). */
16
+ align?: (a: TraceSpan, b: TraceSpan) => AlignRow[];
17
+ /** USD cost formatter. Default `$0.0000`. */
18
+ formatCostUsd?: (usd: number) => string;
19
+ className?: string;
20
+ }
21
+ /**
22
+ * TraceCompare — two traces side by side (B vs A baseline): a metrics header
23
+ * per lane and a structural diff table. Deltas are honest — a span present in
24
+ * only one trace is marked `only in A/B` with no fabricated delta. The
25
+ * component receives DATA (lanes); fetching/URL live in the consumer.
26
+ */
27
+ export declare function TraceCompare({ laneA, laneB, align, formatCostUsd, className, }: TraceCompareProps): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export { TraceTranscript, type TraceTranscriptProps } from "./trace-transcript.js";
@@ -0,0 +1,26 @@
1
+ import type { TraceSpan, TranscriptRow } from "../../../lib/trace/types.js";
2
+ export interface TraceTranscriptProps {
3
+ /** Trace root — the row model is derived via `toTranscriptRows`. */
4
+ root: TraceSpan;
5
+ /** Pre-computed rows (overrides `root` derivation — mainly for tests / custom row models). */
6
+ rows?: TranscriptRow[];
7
+ selectedId: string | null;
8
+ onSelect: (id: string) => void;
9
+ /** Collapsed group ids (subagent subtrees). Uncontrolled-friendly: omit to keep all expanded. */
10
+ collapsedGroups?: Set<string>;
11
+ onToggleGroup?: (groupId: string) => void;
12
+ /** USD cost formatter for per-row stats. Default `$0.0000`. */
13
+ formatCostUsd?: (usd: number) => string;
14
+ /** Row count at/above which the virtualized path engages. Default 200. */
15
+ virtualizeThreshold?: number;
16
+ className?: string;
17
+ "aria-label"?: string;
18
+ }
19
+ /**
20
+ * TraceTranscript — a reader-mode feed of a trace: one card per span (role
21
+ * badge + name + output preview + micro-stats), with collapsible group
22
+ * headers for subagent subtrees. Virtualizes at/above `virtualizeThreshold`.
23
+ * Controlled selection; group collapse is controlled when `collapsedGroups`
24
+ * is supplied. Escaped text only.
25
+ */
26
+ export declare function TraceTranscript({ root, rows: rowsProp, selectedId, onSelect, collapsedGroups, onToggleGroup, formatCostUsd, virtualizeThreshold, className, "aria-label": ariaLabel, }: TraceTranscriptProps): import("react").JSX.Element;
@@ -19,6 +19,8 @@ import type { ElementType, HTMLAttributes, ReactNode } from "react";
19
19
  export interface ActionBarProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
20
20
  search?: {
21
21
  placeholder: string;
22
+ /** Accessible name; defaults to the placeholder with trailing ellipsis stripped (issue #8). */
23
+ "aria-label"?: string;
22
24
  value: string;
23
25
  onChange: (value: string) => void;
24
26
  };
@@ -23,7 +23,7 @@ declare const Combobox: import("react").ForwardRefExoticComponent<ComboboxProps
23
23
  ref?: React.Ref<HTMLInputElement>;
24
24
  } & {
25
25
  asChild?: boolean;
26
- }, "asChild" | "key" | keyof import("react").InputHTMLAttributes<HTMLInputElement>>, "type" | "value" | "onChange"> & {
26
+ }, "key" | "asChild" | keyof import("react").InputHTMLAttributes<HTMLInputElement>>, "type" | "value" | "onChange"> & {
27
27
  value?: string;
28
28
  onValueChange?: (search: string) => void;
29
29
  } & import("react").RefAttributes<HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -34,7 +34,7 @@ declare const Combobox: import("react").ForwardRefExoticComponent<ComboboxProps
34
34
  ref?: React.Ref<HTMLDivElement>;
35
35
  } & {
36
36
  asChild?: boolean;
37
- }, "asChild" | "key" | keyof HTMLAttributes<HTMLDivElement>>, "disabled" | "value" | "onSelect"> & {
37
+ }, "key" | "asChild" | keyof HTMLAttributes<HTMLDivElement>>, "value" | "disabled" | "onSelect"> & {
38
38
  disabled?: boolean;
39
39
  onSelect?: (value: string) => void;
40
40
  value?: string;
@@ -47,7 +47,7 @@ declare const Combobox: import("react").ForwardRefExoticComponent<ComboboxProps
47
47
  ref?: React.Ref<HTMLDivElement>;
48
48
  } & {
49
49
  asChild?: boolean;
50
- }, "asChild" | "key" | keyof HTMLAttributes<HTMLDivElement>> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
50
+ }, "key" | "asChild" | keyof HTMLAttributes<HTMLDivElement>> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
51
51
  };
52
52
  export { Combobox };
53
53
  export type { ComboboxProps, ComboboxContentProps, ComboboxInputProps, ComboboxItemProps };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { cn } from "./lib/cn.js";
2
+ export { aggregateCost, asChat, contentText, isRedactedThinking, buildLayeredGraph, computeBarLayout, computeTraceBounds, deriveSpanKind, durationMs, flattenAll, flattenVisible, GRAPH_NODE_CAP, isSpanError, KIND_LABEL, niceAxisTicks, packRows, prettyValue, spanCostUsd, toNs, alignSpanTrees, groupByNamespace, traceMetrics, toTranscriptRows, VIRTUALIZE_THRESHOLD, } from "./lib/trace/index.js";
3
+ export type { AlignDelta, AlignRow, AttributeGroup, AxisTick, BarLayout, ChatMessage, FlatSpan, GraphEdge, GraphNode, LayeredGraph, SpanKind, SpanStatus, ToolCall, TraceSpan, TranscriptRow, TranscriptRowStats, } from "./lib/trace/index.js";
2
4
  export { Button, buttonVariants, type ButtonProps } from "./components/primitives/button/index.js";
3
5
  export { Badge, badgeVariants, type BadgeProps } from "./components/primitives/badge/index.js";
4
6
  export { Breadcrumb, type BreadcrumbLinkProps, } from "./components/primitives/breadcrumb/index.js";
@@ -61,3 +63,17 @@ export { PreviewEnvCard, type PreviewEnv, type PreviewService, } from "./compone
61
63
  export { DomainConfig, type Domain, type DomainStatus, } from "./components/composites/domain-config/index.js";
62
64
  export { RollbackUI, type RollbackTarget, } from "./components/composites/rollback-ui/index.js";
63
65
  export { CommandPalette, type CommandItem, } from "./components/composites/command-palette/index.js";
66
+ export { SpanTree, SpanTreeRow } from "./components/composites/span-tree/index.js";
67
+ export type { SpanTreeProps, SpanTreeRowProps, SpanTreeRenderCtx, } from "./components/composites/span-tree/index.js";
68
+ export { SpanWaterfall } from "./components/composites/span-waterfall/index.js";
69
+ export type { SpanWaterfallProps } from "./components/composites/span-waterfall/index.js";
70
+ export { AttributesTable } from "./components/composites/attributes-table/index.js";
71
+ export type { AttributesTableProps } from "./components/composites/attributes-table/index.js";
72
+ export { IOCards, MessageCard, MessageItem } from "./components/composites/io-cards/index.js";
73
+ export type { IOCardsProps, RenderMarkdown } from "./components/composites/io-cards/index.js";
74
+ export { TraceTranscript } from "./components/composites/trace-transcript/index.js";
75
+ export type { TraceTranscriptProps } from "./components/composites/trace-transcript/index.js";
76
+ export { SpanGraph } from "./components/composites/span-graph/index.js";
77
+ export type { SpanGraphProps } from "./components/composites/span-graph/index.js";
78
+ export { TraceCompare } from "./components/composites/trace-compare/index.js";
79
+ export type { TraceCompareProps, CompareLane, } from "./components/composites/trace-compare/index.js";