@mastra/playground-ui 23.0.2 → 24.0.0-alpha.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 (85) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/index.cjs.js +4254 -13
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.css +354 -84
  5. package/dist/index.es.js +4137 -16
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/src/domains/logs/components/index.d.ts +6 -0
  8. package/dist/src/domains/logs/components/log-details-view.d.ts +12 -0
  9. package/dist/src/domains/logs/components/logs-error-content.d.ts +14 -0
  10. package/dist/src/domains/logs/components/logs-layout.d.ts +19 -0
  11. package/dist/src/domains/logs/components/logs-list-view.d.ts +20 -0
  12. package/dist/src/domains/logs/components/logs-toolbar.d.ts +13 -0
  13. package/dist/src/domains/logs/components/no-logs-info.d.ts +1 -0
  14. package/dist/src/domains/logs/hooks/index.d.ts +4 -0
  15. package/dist/src/domains/logs/hooks/use-logs-filter-persistence.d.ts +22 -0
  16. package/dist/src/domains/logs/hooks/use-logs-list-navigation.d.ts +22 -0
  17. package/dist/src/domains/logs/hooks/use-logs-url-state.d.ts +38 -0
  18. package/dist/src/domains/logs/hooks/use-logs.d.ts +1271 -0
  19. package/dist/src/domains/logs/index.d.ts +4 -0
  20. package/dist/src/domains/logs/log-filters.d.ts +109 -0
  21. package/dist/src/domains/logs/types.d.ts +35 -0
  22. package/dist/src/domains/metrics/components/bar-list.d.ts +21 -0
  23. package/dist/src/domains/metrics/components/date-range-selector.d.ts +1 -0
  24. package/dist/src/domains/metrics/components/index.d.ts +9 -0
  25. package/dist/src/domains/metrics/components/kpi-card-view.d.ts +9 -0
  26. package/dist/src/domains/metrics/components/latency-card-view.d.ts +11 -0
  27. package/dist/src/domains/metrics/components/metrics-utils.d.ts +15 -0
  28. package/dist/src/domains/metrics/components/model-usage-cost-card-view.d.ts +7 -0
  29. package/dist/src/domains/metrics/components/scores-card-view.d.ts +12 -0
  30. package/dist/src/domains/metrics/components/token-usage-by-agent-card-view.d.ts +7 -0
  31. package/dist/src/domains/metrics/components/traces-volume-card-view.d.ts +11 -0
  32. package/dist/src/domains/metrics/hooks/index.d.ts +12 -0
  33. package/dist/src/domains/metrics/hooks/use-agent-runs-kpi-metrics.d.ts +10 -0
  34. package/dist/src/domains/metrics/hooks/use-avg-score-kpi-metrics.d.ts +10 -0
  35. package/dist/src/domains/metrics/hooks/use-latency-metrics.d.ts +11 -0
  36. package/dist/src/domains/metrics/hooks/use-metrics-filters.d.ts +9 -0
  37. package/dist/src/domains/metrics/hooks/use-metrics.d.ts +43 -0
  38. package/dist/src/domains/metrics/hooks/use-model-cost-kpi-metrics.d.ts +7 -0
  39. package/dist/src/domains/metrics/hooks/use-model-usage-cost-metrics.d.ts +10 -0
  40. package/dist/src/domains/metrics/hooks/use-scores-metrics.d.ts +22 -0
  41. package/dist/src/domains/metrics/hooks/use-token-usage-by-agent-metrics.d.ts +9 -0
  42. package/dist/src/domains/metrics/hooks/use-total-tokens-kpi-metrics.d.ts +6 -0
  43. package/dist/src/domains/metrics/hooks/use-trace-volume-metrics.d.ts +10 -0
  44. package/dist/src/domains/metrics/index.d.ts +2 -0
  45. package/dist/src/domains/traces/components/format-hierarchical-spans.d.ts +12 -0
  46. package/dist/src/domains/traces/components/index.d.ts +18 -0
  47. package/dist/src/domains/traces/components/shared.d.ts +3 -0
  48. package/dist/src/domains/traces/components/span-data-panel-view.d.ts +26 -0
  49. package/dist/src/domains/traces/components/span-details-view.d.ts +14 -0
  50. package/dist/src/domains/traces/components/span-token-usage.d.ts +22 -0
  51. package/dist/src/domains/traces/components/timeline-expand-col.d.ts +12 -0
  52. package/dist/src/domains/traces/components/timeline-name-col.d.ts +15 -0
  53. package/dist/src/domains/traces/components/timeline-structure-sign.d.ts +5 -0
  54. package/dist/src/domains/traces/components/timeline-timing-col.d.ts +12 -0
  55. package/dist/src/domains/traces/components/trace-data-panel-view.d.ts +28 -0
  56. package/dist/src/domains/traces/components/trace-details-view.d.ts +18 -0
  57. package/dist/src/domains/traces/components/trace-keys-and-values.d.ts +16 -0
  58. package/dist/src/domains/traces/components/trace-timeline-span.d.ts +18 -0
  59. package/dist/src/domains/traces/components/trace-timeline.d.ts +15 -0
  60. package/dist/src/domains/traces/components/traces-error-content.d.ts +16 -0
  61. package/dist/src/domains/traces/components/traces-layout.d.ts +18 -0
  62. package/dist/src/domains/traces/components/traces-list-view.d.ts +39 -0
  63. package/dist/src/domains/traces/components/traces-toolbar.d.ts +19 -0
  64. package/dist/src/domains/traces/hooks/get-all-span-ids.d.ts +3 -0
  65. package/dist/src/domains/traces/hooks/index.d.ts +13 -0
  66. package/dist/src/domains/traces/hooks/use-entity-names.d.ts +7 -0
  67. package/dist/src/domains/traces/hooks/use-environments.d.ts +1 -0
  68. package/dist/src/domains/traces/hooks/use-service-names.d.ts +1 -0
  69. package/dist/src/domains/traces/hooks/use-span-detail.d.ts +46 -0
  70. package/dist/src/domains/traces/hooks/use-tags.d.ts +1 -0
  71. package/dist/src/domains/traces/hooks/use-trace-filter-persistence.d.ts +31 -0
  72. package/dist/src/domains/traces/hooks/use-trace-light-spans.d.ts +19 -0
  73. package/dist/src/domains/traces/hooks/use-trace-list-navigation.d.ts +12 -0
  74. package/dist/src/domains/traces/hooks/use-trace-span-navigation.d.ts +10 -0
  75. package/dist/src/domains/traces/hooks/use-trace-spans.d.ts +47 -0
  76. package/dist/src/domains/traces/hooks/use-trace-url-state.d.ts +53 -0
  77. package/dist/src/domains/traces/hooks/use-traces.d.ts +1549 -0
  78. package/dist/src/domains/traces/index.d.ts +8 -0
  79. package/dist/src/domains/traces/trace-filters.d.ts +121 -0
  80. package/dist/src/domains/traces/types.d.ts +35 -0
  81. package/dist/src/domains/traces/utils/group-traces-by-thread.d.ts +20 -0
  82. package/dist/src/domains/traces/utils/index.d.ts +2 -0
  83. package/dist/src/domains/traces/utils/span-utils.d.ts +15 -0
  84. package/dist/src/index.d.ts +3 -0
  85. package/package.json +12 -9
@@ -0,0 +1,18 @@
1
+ import { LightSpanRecord } from '@mastra/core/storage';
2
+ export interface TraceDetailsViewProps {
3
+ traceId: string;
4
+ /** Lightweight spans for the trace. Caller fetches via useTraceLightSpans. */
5
+ spans: LightSpanRecord[] | undefined;
6
+ isLoading?: boolean;
7
+ onClose: () => void;
8
+ /** Called when the user clicks a span in the timeline. Toggling a selected span off passes undefined. */
9
+ onSpanSelect?: (spanId: string | undefined) => void;
10
+ /** Fully controlled selection — the span to highlight. Pass whatever the parent's source of truth is. */
11
+ selectedSpanId?: string | null;
12
+ }
13
+ /**
14
+ * Compact trace panel using `DataDetailsPanel` (popover-style). Renders the timeline only —
15
+ * no trace header KV, no evaluate/save actions. Use this for inline trace inspection from a
16
+ * list page (e.g. the Logs page). For the full-width trace view, use `TraceDataPanelView`.
17
+ */
18
+ export declare function TraceDetailsView({ traceId, spans, isLoading, onClose, onSpanSelect, selectedSpanId, }: TraceDetailsViewProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ /** Lightweight root-span fields available from `useTraceLightSpans`. */
2
+ type RootSpanSummary = {
3
+ entityId?: string | null;
4
+ entityName?: string | null;
5
+ entityType?: string | null;
6
+ startedAt: Date | string;
7
+ endedAt?: Date | string | null;
8
+ error?: unknown;
9
+ };
10
+ export interface TraceKeysAndValuesProps {
11
+ rootSpan: RootSpanSummary;
12
+ numOfCol?: 1 | 2 | 3;
13
+ className?: string;
14
+ }
15
+ export declare function TraceKeysAndValues({ rootSpan, numOfCol, className }: TraceKeysAndValuesProps): import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,18 @@
1
+ import { UISpan } from '../types';
2
+ type TraceTimelineSpanProps = {
3
+ span: UISpan;
4
+ depth?: number;
5
+ onSpanClick?: (id: string) => void;
6
+ selectedSpanId?: string;
7
+ isLastChild?: boolean;
8
+ overallLatency?: number;
9
+ overallStartTime?: string;
10
+ fadedTypes?: string[];
11
+ searchPhrase?: string;
12
+ featuredSpanIds?: string[];
13
+ expandedSpanIds?: string[];
14
+ setExpandedSpanIds?: React.Dispatch<React.SetStateAction<string[]>>;
15
+ chartWidth?: 'wide' | 'default';
16
+ };
17
+ export declare function TraceTimelineSpan({ span, depth, onSpanClick, selectedSpanId, isLastChild, overallLatency, overallStartTime, fadedTypes, searchPhrase, featuredSpanIds, expandedSpanIds, setExpandedSpanIds, chartWidth, }: TraceTimelineSpanProps): import("react/jsx-runtime").JSX.Element;
18
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Dispatch, SetStateAction } from '../../../../node_modules/@types/react';
2
+ import { UISpan } from '../types';
3
+ type TraceTimelineProps = {
4
+ hierarchicalSpans: UISpan[];
5
+ onSpanClick: (id: string) => void;
6
+ selectedSpanId?: string;
7
+ isLoading?: boolean;
8
+ fadedTypes?: string[];
9
+ expandedSpanIds?: string[];
10
+ setExpandedSpanIds?: Dispatch<SetStateAction<string[]>>;
11
+ featuredSpanIds?: string[];
12
+ chartWidth?: 'wide' | 'default';
13
+ };
14
+ export declare function TraceTimeline({ hierarchicalSpans, onSpanClick, selectedSpanId, isLoading, fadedTypes, expandedSpanIds, setExpandedSpanIds, featuredSpanIds, chartWidth, }: TraceTimelineProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,16 @@
1
+ export interface TracesErrorContentProps {
2
+ /** The error from a useTraces / useTraceLightSpans / etc. query. */
3
+ error: unknown;
4
+ /** Passed to PermissionDenied (e.g. 'traces' / 'trace'). */
5
+ resource: string;
6
+ /** Title shown on the generic ErrorState fallback. */
7
+ errorTitle: string;
8
+ }
9
+ /**
10
+ * Renders the appropriate fallback content for a traces-related query error:
11
+ * `<SessionExpired />` for 401, `<PermissionDenied />` for 403, otherwise `<ErrorState />`.
12
+ *
13
+ * The consumer wraps it in whatever layout they want (NoDataPageLayout for the list page,
14
+ * PageLayout.MainArea for the detail page, etc.) — this component only owns the 3-branch decision.
15
+ */
16
+ export declare function TracesErrorContent({ error, resource, errorTitle }: TracesErrorContentProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from '../../../../node_modules/@types/react';
2
+ export interface TracesLayoutProps {
3
+ /** The trace list (left column). */
4
+ listSlot: ReactNode;
5
+ /** The trace data panel (right column, top). When null/undefined, the whole right column collapses. */
6
+ tracePanelSlot?: ReactNode;
7
+ /** The span data panel (right column, middle). Only rendered when truthy. */
8
+ spanPanelSlot?: ReactNode;
9
+ /** The score data panel (right column, bottom). Only rendered when truthy. */
10
+ scorePanelSlot?: ReactNode;
11
+ /** When the trace panel is collapsed, the right column's grid-rows squash the trace row to `auto`. */
12
+ traceCollapsed?: boolean;
13
+ }
14
+ /**
15
+ * Pure 2-column layout shell for the traces page. Owns no state and fetches no data — pass slots in.
16
+ * Right-column row template adapts based on which panels are present.
17
+ */
18
+ export declare function TracesLayout({ listSlot, tracePanelSlot, spanPanelSlot, scorePanelSlot, traceCollapsed, }: TracesLayoutProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ /** Span attributes fields the list view reads directly. Extra unknown keys are allowed so callers
2
+ * can pass the full attributes record from @mastra/core/storage without mapping. */
3
+ export type TraceAttributes = {
4
+ status?: string | null;
5
+ agentId?: string | null;
6
+ workflowId?: string | null;
7
+ [key: string]: unknown;
8
+ };
9
+ export type TracesListViewTrace = {
10
+ traceId: string;
11
+ name: string;
12
+ entityType?: string | null;
13
+ entityId?: string | null;
14
+ entityName?: string | null;
15
+ attributes?: TraceAttributes | null;
16
+ input?: unknown;
17
+ startedAt?: Date | string | null;
18
+ createdAt: Date | string;
19
+ threadId?: string | null;
20
+ };
21
+ export type TracesListViewProps = {
22
+ traces: TracesListViewTrace[];
23
+ isLoading?: boolean;
24
+ isFetchingNextPage?: boolean;
25
+ hasNextPage?: boolean;
26
+ setEndOfListElement?: (element: HTMLDivElement | null) => void;
27
+ filtersApplied?: boolean;
28
+ /** Currently featured/selected trace — its row gets the highlighted background. */
29
+ featuredTraceId?: string | null;
30
+ /** Called when a row is clicked. The current selection logic (toggle on same id) is the consumer's call. */
31
+ onTraceClick: (trace: TracesListViewTrace) => void;
32
+ groupByThread?: boolean;
33
+ threadTitles?: Record<string, string>;
34
+ };
35
+ /**
36
+ * Pure presentational list. Renders the TracesDataList primitive with rows, optional thread grouping,
37
+ * empty state, and infinite-paging loader. Owns no state.
38
+ */
39
+ export declare function TracesListView({ traces, isLoading, isFetchingNextPage, hasNextPage, setEndOfListElement, filtersApplied, featuredTraceId, onTraceClick, groupByThread, threadTitles, }: TracesListViewProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { PropertyFilterField, PropertyFilterToken } from '../../../ds/components/PropertyFilter/types';
2
+ type TracesToolbarProps = {
3
+ /** Keep all filter pills but reset each value to its neutral state
4
+ * ('' for text, 'Any' for single-select, [] for multi-select). */
5
+ onClear?: () => void;
6
+ /** Fully remove all filter pills. */
7
+ onRemoveAll?: () => void;
8
+ onSave?: () => void;
9
+ /** When provided, an extra "Remove saved filters" option is shown —
10
+ * wire it up only when there is actually a saved set to remove. */
11
+ onRemoveSaved?: () => void;
12
+ isLoading?: boolean;
13
+ filterFields: PropertyFilterField[];
14
+ filterTokens: PropertyFilterToken[];
15
+ onFilterTokensChange: (tokens: PropertyFilterToken[]) => void;
16
+ autoFocusFilterFieldId?: string;
17
+ };
18
+ export declare function TracesToolbar({ onClear, onRemoveAll, onSave, onRemoveSaved, isLoading, filterFields, filterTokens, onFilterTokensChange, autoFocusFilterFieldId, }: TracesToolbarProps): import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,3 @@
1
+ import { UISpan } from '../types';
2
+ export declare function getSpanDescendantIds(span: UISpan): string[];
3
+ export declare function getAllSpanIds(spans: UISpan[]): string[];
@@ -0,0 +1,13 @@
1
+ export { getAllSpanIds, getSpanDescendantIds } from './get-all-span-ids';
2
+ export { useSpanDetail } from './use-span-detail';
3
+ export { useTraceLightSpans } from './use-trace-light-spans';
4
+ export { useTraceSpans } from './use-trace-spans';
5
+ export { useTraces } from './use-traces';
6
+ export { useTags } from './use-tags';
7
+ export { useEntityNames } from './use-entity-names';
8
+ export { useEnvironments } from './use-environments';
9
+ export { useServiceNames } from './use-service-names';
10
+ export { useTraceSpanNavigation } from './use-trace-span-navigation';
11
+ export { useTraceListNavigation } from './use-trace-list-navigation';
12
+ export { useTraceUrlState, type UseTraceUrlStateResult, type UseTraceUrlStateOptions, type SetURLSearchParamsLike, } from './use-trace-url-state';
13
+ export { useTraceFilterPersistence, type UseTraceFilterPersistenceResult, type TraceFilterPersistenceOptions, } from './use-trace-filter-persistence';
@@ -0,0 +1,7 @@
1
+ import { EntityType } from '@mastra/core/observability';
2
+ type UseEntityNamesOptions = {
3
+ entityType?: EntityType;
4
+ rootOnly?: boolean;
5
+ };
6
+ export declare const useEntityNames: ({ entityType, rootOnly }?: UseEntityNamesOptions) => import('@tanstack/react-query').UseQueryResult<string[], Error>;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useEnvironments: () => import('@tanstack/react-query').UseQueryResult<string[], Error>;
@@ -0,0 +1 @@
1
+ export declare const useServiceNames: () => import('@tanstack/react-query').UseQueryResult<string[], Error>;
@@ -0,0 +1,46 @@
1
+ export declare function useSpanDetail(traceId: string | null | undefined, spanId: string | null | undefined): import('@tanstack/react-query').UseQueryResult<{
2
+ span: {
3
+ createdAt: Date;
4
+ updatedAt: Date | null;
5
+ name: string;
6
+ spanType: import('@mastra/core/observability').SpanType;
7
+ isEvent: boolean;
8
+ startedAt: Date;
9
+ traceId: string;
10
+ spanId: string;
11
+ experimentId?: string | null | undefined;
12
+ attributes?: Record<string, unknown> | null | undefined;
13
+ links?: unknown[] | null | undefined;
14
+ input?: unknown;
15
+ output?: unknown;
16
+ error?: unknown;
17
+ endedAt?: Date | null | undefined;
18
+ requestContext?: Record<string, unknown> | null | undefined;
19
+ metadata?: Record<string, unknown> | null | undefined;
20
+ tags?: string[] | null | undefined;
21
+ source?: string | null | undefined;
22
+ entityType?: import('@mastra/core/storage').EntityType | null | undefined;
23
+ entityId?: string | null | undefined;
24
+ entityName?: string | null | undefined;
25
+ parentEntityType?: import('@mastra/core/storage').EntityType | null | undefined;
26
+ parentEntityId?: string | null | undefined;
27
+ parentEntityName?: string | null | undefined;
28
+ rootEntityType?: import('@mastra/core/storage').EntityType | null | undefined;
29
+ rootEntityId?: string | null | undefined;
30
+ rootEntityName?: string | null | undefined;
31
+ userId?: string | null | undefined;
32
+ organizationId?: string | null | undefined;
33
+ resourceId?: string | null | undefined;
34
+ runId?: string | null | undefined;
35
+ sessionId?: string | null | undefined;
36
+ threadId?: string | null | undefined;
37
+ requestId?: string | null | undefined;
38
+ environment?: string | null | undefined;
39
+ serviceName?: string | null | undefined;
40
+ scope?: Record<string, unknown> | null | undefined;
41
+ entityVersionId?: string | null | undefined;
42
+ parentEntityVersionId?: string | null | undefined;
43
+ rootEntityVersionId?: string | null | undefined;
44
+ parentSpanId?: string | null | undefined;
45
+ };
46
+ }, Error>;
@@ -0,0 +1 @@
1
+ export declare const useTags: () => import('@tanstack/react-query').UseQueryResult<string[], Error>;
@@ -0,0 +1,31 @@
1
+ import { SetURLSearchParamsLike } from './use-trace-url-state';
2
+ export interface TraceFilterPersistenceOptions {
3
+ /** Override the localStorage key. Default: 'mastra:traces:saved-filters'. */
4
+ storageKey?: string;
5
+ /** Toast text overrides; pass `false` to suppress the toast entirely. */
6
+ messages?: {
7
+ saved?: string | false;
8
+ cleared?: string | false;
9
+ };
10
+ /** Skip the once-on-mount hydration from localStorage. Default: false (hydration runs). */
11
+ skipHydration?: boolean;
12
+ }
13
+ export interface UseTraceFilterPersistenceResult {
14
+ /** True when localStorage has a previously saved filter set. */
15
+ hasSavedFilters: boolean;
16
+ /** Persist the current URL filter params to localStorage. */
17
+ handleSave: () => void;
18
+ /** Forget the saved filter set. */
19
+ handleRemoveSaved: () => void;
20
+ }
21
+ /**
22
+ * Owns the localStorage save/restore lifecycle for trace filters:
23
+ * - tracks `hasSavedFilters`
24
+ * - exposes `handleSave` / `handleRemoveSaved` (with toast feedback)
25
+ * - hydrates the URL from saved filters once on mount, but only if the URL is filter-clean
26
+ * (so a shared link / direct nav with explicit filters wins over the saved set)
27
+ *
28
+ * Pass `storageKey` to scope persistence (e.g. per-project). Pass `messages.{saved,cleared} = false`
29
+ * to suppress the toast.
30
+ */
31
+ export declare function useTraceFilterPersistence(searchParams: URLSearchParams, setSearchParams: SetURLSearchParamsLike, options?: TraceFilterPersistenceOptions): UseTraceFilterPersistenceResult;
@@ -0,0 +1,19 @@
1
+ export declare function useTraceLightSpans(traceId: string | null | undefined): import('@tanstack/react-query').UseQueryResult<{
2
+ traceId: string;
3
+ spans: {
4
+ createdAt: Date;
5
+ updatedAt: Date | null;
6
+ name: string;
7
+ spanType: import('@mastra/core/observability').SpanType;
8
+ isEvent: boolean;
9
+ startedAt: Date;
10
+ traceId: string;
11
+ spanId: string;
12
+ parentSpanId?: string | null | undefined;
13
+ endedAt?: Date | null | undefined;
14
+ error?: unknown;
15
+ entityType?: import('@mastra/core/storage').EntityType | null | undefined;
16
+ entityId?: string | null | undefined;
17
+ entityName?: string | null | undefined;
18
+ }[];
19
+ }, Error>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Derives previous/next *trace* navigation handlers from the current traces list and the featured
3
+ * trace id. Returns undefined for handlers that are out of bounds so the consumer can render
4
+ * disabled UI. Mirrors the shape of `useTraceSpanNavigation`.
5
+ */
6
+ export declare function useTraceListNavigation<T extends {
7
+ traceId: string;
8
+ }>(traces: T[], featuredTraceId: string | undefined, onTraceChange: (traceId: string) => void): {
9
+ featuredTraceIdx: number;
10
+ handlePreviousTrace: (() => void) | undefined;
11
+ handleNextTrace: (() => void) | undefined;
12
+ };
@@ -0,0 +1,10 @@
1
+ import { LightSpanRecord } from '@mastra/core/storage';
2
+ /**
3
+ * Derives previous/next span navigation handlers from a trace's lightweight spans.
4
+ * Returns undefined for handlers that are out of bounds so the consumer can render disabled UI.
5
+ */
6
+ export declare function useTraceSpanNavigation(lightSpans: LightSpanRecord[] | undefined, featuredSpanId: string | null | undefined, onSpanChange: (spanId: string) => void): {
7
+ handlePreviousSpan: (() => void) | undefined;
8
+ handleNextSpan: (() => void) | undefined;
9
+ timelineSpanIds: string[];
10
+ };
@@ -0,0 +1,47 @@
1
+ export declare function useTraceSpans(traceId: string | null | undefined): import('@tanstack/react-query').UseQueryResult<{
2
+ traceId: string;
3
+ spans: {
4
+ createdAt: Date;
5
+ updatedAt: Date | null;
6
+ name: string;
7
+ spanType: import('@mastra/core/observability').SpanType;
8
+ isEvent: boolean;
9
+ startedAt: Date;
10
+ traceId: string;
11
+ spanId: string;
12
+ experimentId?: string | null | undefined;
13
+ attributes?: Record<string, unknown> | null | undefined;
14
+ links?: unknown[] | null | undefined;
15
+ input?: unknown;
16
+ output?: unknown;
17
+ error?: unknown;
18
+ endedAt?: Date | null | undefined;
19
+ requestContext?: Record<string, unknown> | null | undefined;
20
+ metadata?: Record<string, unknown> | null | undefined;
21
+ tags?: string[] | null | undefined;
22
+ source?: string | null | undefined;
23
+ entityType?: import('@mastra/core/storage').EntityType | null | undefined;
24
+ entityId?: string | null | undefined;
25
+ entityName?: string | null | undefined;
26
+ parentEntityType?: import('@mastra/core/storage').EntityType | null | undefined;
27
+ parentEntityId?: string | null | undefined;
28
+ parentEntityName?: string | null | undefined;
29
+ rootEntityType?: import('@mastra/core/storage').EntityType | null | undefined;
30
+ rootEntityId?: string | null | undefined;
31
+ rootEntityName?: string | null | undefined;
32
+ userId?: string | null | undefined;
33
+ organizationId?: string | null | undefined;
34
+ resourceId?: string | null | undefined;
35
+ runId?: string | null | undefined;
36
+ sessionId?: string | null | undefined;
37
+ threadId?: string | null | undefined;
38
+ requestId?: string | null | undefined;
39
+ environment?: string | null | undefined;
40
+ serviceName?: string | null | undefined;
41
+ scope?: Record<string, unknown> | null | undefined;
42
+ entityVersionId?: string | null | undefined;
43
+ parentEntityVersionId?: string | null | undefined;
44
+ rootEntityVersionId?: string | null | undefined;
45
+ parentSpanId?: string | null | undefined;
46
+ }[];
47
+ }, Error>;
@@ -0,0 +1,53 @@
1
+ import { SpanTab, TraceDatePreset } from '../index';
2
+ import { EntityOptions, TraceStatusFilter } from '../trace-filters';
3
+ import { PropertyFilterToken } from '../../../ds/components/PropertyFilter/types';
4
+ /** Minimal interface compatible with react-router's `setSearchParams`. */
5
+ export type SetURLSearchParamsLike = (next: URLSearchParams | ((prev: URLSearchParams) => URLSearchParams), options?: {
6
+ replace?: boolean;
7
+ preventScrollReset?: boolean;
8
+ state?: unknown;
9
+ }) => void;
10
+ export interface UseTraceUrlStateOptions {
11
+ /** Called after `handleRemoveAll` clears all filter URL params. Use this to reset page-local
12
+ * UI state (e.g. a "group by thread" toggle) without wrapping the handler. */
13
+ onRemoveAll?: () => void;
14
+ }
15
+ export interface UseTraceUrlStateResult {
16
+ searchParams: URLSearchParams;
17
+ setSearchParams: SetURLSearchParamsLike;
18
+ datePreset: TraceDatePreset;
19
+ selectedDateFrom: Date | undefined;
20
+ selectedDateTo: Date | undefined;
21
+ /** Synchronously-updated ref of the latest preset. Used to ignore onDateChange callbacks
22
+ * the date picker fires after a non-custom preset switch. */
23
+ datePresetRef: React.MutableRefObject<TraceDatePreset>;
24
+ traceIdParam: string | undefined;
25
+ spanIdParam: string | undefined;
26
+ spanTabParam: SpanTab | undefined;
27
+ scoreIdParam: string | undefined;
28
+ selectedEntityOption: EntityOptions | undefined;
29
+ selectedStatus: TraceStatusFilter | undefined;
30
+ filterTokens: PropertyFilterToken[];
31
+ handleTraceClick: (traceId: string) => void;
32
+ /** Convenience: clears the featured trace selection. Equivalent to `handleTraceClick('')`. */
33
+ handleTraceClose: () => void;
34
+ handleSpanChange: (spanId: string | null) => void;
35
+ /** Convenience: clears the featured span selection. Equivalent to `handleSpanChange(null)`. */
36
+ handleSpanClose: () => void;
37
+ handleSpanTabChange: (tab: SpanTab) => void;
38
+ handleScoreChange: (scoreId: string | null) => void;
39
+ handleFilterTokensChange: (nextTokens: PropertyFilterToken[]) => void;
40
+ handleDateChange: (value: Date | undefined, type: 'from' | 'to') => void;
41
+ handleDatePresetChange: (preset: TraceDatePreset) => void;
42
+ handleRemoveAll: () => void;
43
+ /** Lower-level helper used by `handleClear`: writes a token set and clears the trace/span selection. */
44
+ applyFilterTokens: (tokens: PropertyFilterToken[]) => void;
45
+ }
46
+ /**
47
+ * Owns all URL-derived state and URL-modifying handlers for the traces page. Routing-agnostic —
48
+ * pass `searchParams` and `setSearchParams` from whichever router the consumer uses.
49
+ *
50
+ * Stays focused on URL state: localStorage save/restore, filter discovery, and the error-view
51
+ * short-circuit are intentionally NOT part of this hook so consumers can swap them independently.
52
+ */
53
+ export declare function useTraceUrlState(searchParams: URLSearchParams, setSearchParams: SetURLSearchParamsLike, options?: UseTraceUrlStateOptions): UseTraceUrlStateResult;