@erdoai/ui 0.1.9 → 0.1.10

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.
@@ -0,0 +1,1174 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import React__default from 'react';
4
+ import { ErdoClient, ContentItem, LogEntry, ToolGroup, InvocationStatus as InvocationStatus$1, SSEEvent, InvokeResult, InvokeParams } from '@erdoai/types';
5
+ export { ContentItem } from '@erdoai/types';
6
+ import * as RechartsPrimitive from 'recharts';
7
+ import { UseQueryResult } from '@tanstack/react-query';
8
+ import { ClassValue } from 'clsx';
9
+
10
+ /**
11
+ * Interface for custom data fetching implementations.
12
+ * Use this when you need to override the default REST API behavior,
13
+ * e.g., when using an Encore client or custom backend.
14
+ *
15
+ * Must be a STABLE object reference - create outside components to avoid
16
+ * recreating on every render.
17
+ */
18
+ interface DataFetcher {
19
+ fetchDatasetContents: (slug: string, invocationId: string) => Promise<any[]>;
20
+ }
21
+ /**
22
+ * Configuration for the ErdoProvider.
23
+ */
24
+ interface ErdoProviderConfig {
25
+ /**
26
+ * Base URL for API calls (e.g., 'https://api.erdo.ai')
27
+ * Used by default REST implementation in hooks.
28
+ */
29
+ baseUrl: string;
30
+ /**
31
+ * Optional auth token for API calls.
32
+ * Will be sent as Bearer token in Authorization header.
33
+ * Use this for long-lived API keys (B2B backend-to-backend).
34
+ */
35
+ authToken?: string;
36
+ /**
37
+ * Optional session token for B2B2C use cases.
38
+ * When provided, uses the session-authenticated endpoint for dataset queries.
39
+ * Session tokens are short-lived, scoped to specific datasets, and created
40
+ * by B2B customers for their end users.
41
+ *
42
+ * Example B2B2C flow:
43
+ * 1. B2B backend creates session token via POST /dataset-sessions
44
+ * 2. B2B frontend passes session token to ErdoProvider
45
+ * 3. End user can query only the datasets scoped to that session
46
+ */
47
+ sessionToken?: string;
48
+ /**
49
+ * Optional ErdoClient for invoking bots.
50
+ * Required if using useInvocation hook.
51
+ */
52
+ client?: ErdoClient;
53
+ /**
54
+ * Optional custom data fetcher for non-standard backends.
55
+ * When provided, hooks will use this instead of the default REST implementation.
56
+ *
57
+ * Example usage with Encore client:
58
+ * ```typescript
59
+ * // lib/erdo-fetcher.ts - Create ONCE outside components
60
+ * export const erdoDataFetcher: DataFetcher = {
61
+ * fetchDatasetContents: async (slug, invocationId) => {
62
+ * const client = await getRequestClient();
63
+ * return client.dataset.GetDatasetContents({ slug, invocationId });
64
+ * },
65
+ * };
66
+ * ```
67
+ */
68
+ dataFetcher?: DataFetcher;
69
+ }
70
+ interface ErdoProviderProps {
71
+ children: React__default.ReactNode;
72
+ config: ErdoProviderConfig;
73
+ }
74
+ /**
75
+ * Provider component that configures data fetching for Erdo UI components.
76
+ *
77
+ * @example Simple usage with baseUrl (B2B customers):
78
+ * ```tsx
79
+ * <ErdoProvider config={{ baseUrl: 'https://api.erdo.ai', authToken: 'xxx' }}>
80
+ * <App />
81
+ * </ErdoProvider>
82
+ * ```
83
+ *
84
+ * @example With custom data fetcher (Erdo frontend):
85
+ * ```tsx
86
+ * <ErdoProvider config={{ baseUrl: '', dataFetcher: erdoDataFetcher }}>
87
+ * <App />
88
+ * </ErdoProvider>
89
+ * ```
90
+ */
91
+ declare function ErdoProvider({ children, config }: ErdoProviderProps): react_jsx_runtime.JSX.Element;
92
+ /**
93
+ * Hook to access the Erdo provider configuration.
94
+ * Must be used within an ErdoProvider.
95
+ */
96
+ declare function useErdoConfig(): ErdoProviderConfig;
97
+ /**
98
+ * Hook to check if we're inside an ErdoProvider.
99
+ * Returns the config if available, null otherwise.
100
+ */
101
+ declare function useErdoConfigOptional(): ErdoProviderConfig | null;
102
+
103
+ declare const THEMES: {
104
+ readonly light: "";
105
+ readonly dark: ".dark";
106
+ };
107
+ type ChartConfig = {
108
+ [k in string]: {
109
+ label?: React.ReactNode;
110
+ icon?: React.ComponentType;
111
+ } & ({
112
+ color?: string;
113
+ theme?: never;
114
+ } | {
115
+ color?: never;
116
+ theme: Record<keyof typeof THEMES, string>;
117
+ });
118
+ };
119
+ declare function ChartContainer({ id, className, children, config, debounceResize, ...props }: React.ComponentProps<'div'> & {
120
+ config: ChartConfig;
121
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
122
+ /** Debounce resize events by 200ms to prevent animation restarts during streaming */
123
+ debounceResize?: boolean;
124
+ }): react_jsx_runtime.JSX.Element;
125
+ declare const ChartStyle: ({ id, config }: {
126
+ id: string;
127
+ config: ChartConfig;
128
+ }) => react_jsx_runtime.JSX.Element | null;
129
+ declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
130
+ interface ChartTooltipContentProps {
131
+ active?: boolean;
132
+ payload?: ReadonlyArray<{
133
+ dataKey?: string;
134
+ name?: string;
135
+ value?: any;
136
+ color?: string;
137
+ payload?: any;
138
+ [key: string]: any;
139
+ }>;
140
+ label?: string | number;
141
+ className?: string;
142
+ indicator?: 'line' | 'dot' | 'dashed';
143
+ hideLabel?: boolean;
144
+ hideIndicator?: boolean;
145
+ labelFormatter?: (label: any, payload: any) => React.ReactNode;
146
+ labelClassName?: string;
147
+ formatter?: (value: any, name: any, item: any, index: number, payload: any) => React.ReactNode;
148
+ color?: string;
149
+ nameKey?: string;
150
+ labelKey?: string;
151
+ }
152
+ declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: ChartTooltipContentProps): react_jsx_runtime.JSX.Element | null;
153
+ declare const ChartLegend: typeof RechartsPrimitive.Legend;
154
+ interface ChartLegendContentProps {
155
+ className?: string;
156
+ hideIcon?: boolean;
157
+ payload?: ReadonlyArray<{
158
+ value?: string;
159
+ color?: string;
160
+ dataKey?: any;
161
+ [key: string]: any;
162
+ }>;
163
+ verticalAlign?: 'top' | 'bottom' | 'middle';
164
+ nameKey?: string;
165
+ }
166
+ declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: ChartLegendContentProps): react_jsx_runtime.JSX.Element | null;
167
+
168
+ interface Axis$2 {
169
+ label: string;
170
+ key: string;
171
+ maxValue?: string | null;
172
+ minValue?: string | null;
173
+ format?: string | null;
174
+ type?: 'number' | 'category' | 'date' | null;
175
+ }
176
+ interface DataConfig {
177
+ chartType: 'bar' | 'line' | 'pie' | 'histogram' | 'scatter' | 'heatmap';
178
+ xAxis: Axis$2;
179
+ yAxes: Array<Axis$2>;
180
+ series: Array<{
181
+ key: string;
182
+ name: string;
183
+ color: string;
184
+ axisIndex?: number;
185
+ }>;
186
+ }
187
+ interface BaseChartProps {
188
+ title: string;
189
+ subtitle?: string | null;
190
+ data: any[];
191
+ displayConfig: ChartConfig;
192
+ dataConfig: DataConfig;
193
+ disableAnimation?: boolean;
194
+ onZoomChange?: (domain: {
195
+ x: [number | null, number | null];
196
+ y: [number | null, number | null];
197
+ }) => void;
198
+ stacked?: boolean;
199
+ /** Enable download button (default: true) */
200
+ enableDownload?: boolean;
201
+ /** Callback when download succeeds */
202
+ onDownloadSuccess?: (fileName: string) => void;
203
+ /** Callback when download fails */
204
+ onDownloadError?: (error: string) => void;
205
+ }
206
+ interface ChartProps extends BaseChartProps {
207
+ ChartComponent: React__default.ComponentType<any>;
208
+ PointComponent: React__default.ComponentType<any>;
209
+ }
210
+ declare function Chart(props: ChartProps): react_jsx_runtime.JSX.Element;
211
+
212
+ declare function BarChart(props: any): react_jsx_runtime.JSX.Element;
213
+
214
+ declare function LineChart(props: any): react_jsx_runtime.JSX.Element;
215
+
216
+ declare function PieChart(props: BaseChartProps): react_jsx_runtime.JSX.Element;
217
+
218
+ declare function ScatterChart(props: any): react_jsx_runtime.JSX.Element;
219
+
220
+ declare function HeatmapChart(props: any): react_jsx_runtime.JSX.Element;
221
+
222
+ interface Axis$1 {
223
+ label: string;
224
+ key: string;
225
+ type?: 'number' | 'category' | 'date' | null;
226
+ format?: string | null;
227
+ maxValue?: string | null;
228
+ minValue?: string | null;
229
+ }
230
+ interface Series$1 {
231
+ name: string;
232
+ key: string;
233
+ color: string;
234
+ datasetSlug: string;
235
+ axisIndex?: number;
236
+ filters?: Filter$1[];
237
+ }
238
+ interface Filter$1 {
239
+ key: string;
240
+ operator: 'equals' | 'not_equals' | 'greater_than' | 'less_than' | 'contains' | 'between';
241
+ value: string[];
242
+ }
243
+ interface SortCondition$1 {
244
+ key: string;
245
+ direction: 'asc' | 'desc';
246
+ }
247
+ interface DatasetChartProps {
248
+ chartType: 'bar' | 'line' | 'pie' | 'histogram' | 'scatter' | 'heatmap';
249
+ title: string;
250
+ invocationId: string;
251
+ datasetSlugs: string[];
252
+ xAxis: Axis$1;
253
+ yAxes: Axis$1[];
254
+ series: Series$1[];
255
+ dataReduction?: {
256
+ strategy: 'none' | 'sample' | 'aggregate' | 'bin';
257
+ target_points: number;
258
+ };
259
+ stacked?: boolean;
260
+ sort?: SortCondition$1[];
261
+ /** Optional callback for scroll updates when chart loads */
262
+ onScrollUpdate?: () => void;
263
+ }
264
+ declare const DatasetChart: React__default.NamedExoticComponent<DatasetChartProps>;
265
+
266
+ declare class ErrorBoundary extends React__default.Component<{
267
+ fallback: React__default.ReactNode;
268
+ children: React__default.ReactNode;
269
+ }, {
270
+ hasError: boolean;
271
+ }> {
272
+ constructor(props: {
273
+ fallback: React__default.ReactNode;
274
+ children: React__default.ReactNode;
275
+ });
276
+ static getDerivedStateFromError(_: Error): {
277
+ hasError: boolean;
278
+ };
279
+ componentDidCatch(error: Error, errorInfo: React__default.ErrorInfo): void;
280
+ render(): React__default.ReactNode;
281
+ }
282
+
283
+ /** Props passed to all content components */
284
+ interface ContentComponentProps {
285
+ content: ContentItem;
286
+ className?: string;
287
+ }
288
+ interface ContentProps {
289
+ content: ContentItem;
290
+ className?: string;
291
+ /**
292
+ * Override renderers for specific content types.
293
+ * Key is the content_type or ui_content_type string.
294
+ * Component receives { content, className, ...otherProps } props.
295
+ * Components can accept additional props beyond ContentComponentProps.
296
+ *
297
+ * @example
298
+ * ```tsx
299
+ * <Content
300
+ * content={contentItem}
301
+ * components={{
302
+ * 'bot_invocation': MyBotInvocation,
303
+ * 'authorize_integration': AuthorizeIntegration,
304
+ * 'my_custom_type': MyCustomRenderer,
305
+ * }}
306
+ * />
307
+ * ```
308
+ */
309
+ components?: Record<string, React__default.ComponentType<any>>;
310
+ }
311
+ /**
312
+ * Routes content to the appropriate renderer based on content_type and ui_content_type.
313
+ *
314
+ * This is the main entry point for rendering content items from Erdo bot invocations.
315
+ * It checks for custom component overrides first, then falls back to built-in renderers.
316
+ *
317
+ * @example
318
+ * ```tsx
319
+ * // Basic usage - uses built-in renderers
320
+ * <Content content={contentItem} />
321
+ *
322
+ * // With custom overrides
323
+ * <Content
324
+ * content={contentItem}
325
+ * components={{
326
+ * 'bot_invocation': MyBotInvocation,
327
+ * 'authorize_integration': AuthorizeIntegration,
328
+ * }}
329
+ * />
330
+ * ```
331
+ */
332
+ declare function Content({ content, className, components }: ContentProps): react_jsx_runtime.JSX.Element | null;
333
+
334
+ interface TextContentProps {
335
+ content: string;
336
+ className?: string;
337
+ }
338
+ declare function TextContent({ content, className }: TextContentProps): react_jsx_runtime.JSX.Element | null;
339
+
340
+ interface JsonContentProps {
341
+ content: unknown;
342
+ className?: string;
343
+ }
344
+ declare function JsonContent({ content, className }: JsonContentProps): react_jsx_runtime.JSX.Element | null;
345
+
346
+ interface MarkdownContentProps {
347
+ /** The markdown content to render */
348
+ content: string;
349
+ /** Additional CSS class names */
350
+ className?: string;
351
+ }
352
+ /**
353
+ * Renders markdown content with GitHub Flavored Markdown support.
354
+ *
355
+ * @example
356
+ * ```tsx
357
+ * <MarkdownContent content="# Hello\n\nThis is **bold** text." />
358
+ * ```
359
+ */
360
+ declare function MarkdownContent({ content, className }: MarkdownContentProps): react_jsx_runtime.JSX.Element | null;
361
+
362
+ interface TableColumn {
363
+ column_name: string;
364
+ key: string;
365
+ format?: string;
366
+ value_type?: 'number' | 'category' | 'date';
367
+ }
368
+ interface TableContentProps {
369
+ title?: string;
370
+ columns: TableColumn[];
371
+ data: any[];
372
+ className?: string;
373
+ maxRows?: number;
374
+ }
375
+ declare function TableContent({ title, columns, data, className, maxRows }: TableContentProps): react_jsx_runtime.JSX.Element;
376
+
377
+ interface Axis {
378
+ axis_label: string;
379
+ key: string;
380
+ max_value?: string | null;
381
+ min_value?: string | null;
382
+ value_type?: 'number' | 'category' | 'date' | null;
383
+ format?: string | null;
384
+ }
385
+ interface Series {
386
+ series_name: string;
387
+ key: string;
388
+ color: string;
389
+ dataset_slug?: string;
390
+ axis_index?: number;
391
+ filters?: Filter[];
392
+ }
393
+ interface Filter {
394
+ key: string;
395
+ operator: 'equals' | 'not_equals' | 'greater_than' | 'less_than' | 'contains' | 'between';
396
+ value: string[];
397
+ }
398
+ interface SortCondition {
399
+ key: string;
400
+ direction: 'asc' | 'desc';
401
+ }
402
+ interface ContentChartConfig {
403
+ chart_type: 'bar' | 'line' | 'pie' | 'histogram' | 'scatter' | 'heatmap';
404
+ chart_title: string;
405
+ x_axis: Axis;
406
+ y_axes: Axis[];
407
+ series: Series[];
408
+ data_reduction?: {
409
+ strategy: 'none' | 'sample' | 'aggregate' | 'bin';
410
+ target_points: number;
411
+ };
412
+ stacked?: boolean;
413
+ sort?: SortCondition[];
414
+ }
415
+ interface ChartContentProps {
416
+ config: ContentChartConfig;
417
+ data: any[];
418
+ className?: string;
419
+ }
420
+ declare function ChartContent({ config, data, className }: ChartContentProps): react_jsx_runtime.JSX.Element;
421
+
422
+ interface ThinkingContentProps {
423
+ item: ContentItem;
424
+ className?: string;
425
+ }
426
+ /**
427
+ * Renders Claude's thinking/reasoning content in a collapsible panel.
428
+ * Handles both regular thinking and redacted (encrypted) thinking.
429
+ */
430
+ declare function ThinkingContent({ item, className }: ThinkingContentProps): react_jsx_runtime.JSX.Element;
431
+
432
+ interface LogContentProps {
433
+ item: ContentItem;
434
+ className?: string;
435
+ }
436
+ interface LogProps {
437
+ log: LogEntry;
438
+ }
439
+ declare function Log({ log }: LogProps): react_jsx_runtime.JSX.Element;
440
+ /**
441
+ * Renders log entries with level-based styling (info, error, requires_info).
442
+ */
443
+ declare function LogContent({ item, className }: LogContentProps): react_jsx_runtime.JSX.Element;
444
+
445
+ interface WebSearchContentProps {
446
+ item: ContentItem;
447
+ className?: string;
448
+ }
449
+ /**
450
+ * Renders web search results as a list of clickable cards.
451
+ */
452
+ declare function WebSearchContent({ item, className }: WebSearchContentProps): react_jsx_runtime.JSX.Element | null;
453
+
454
+ interface WebParseContentProps {
455
+ item: ContentItem;
456
+ className?: string;
457
+ }
458
+ /**
459
+ * Renders parsed web page content with title, description, and markdown body.
460
+ */
461
+ declare function WebParseContent({ item, className }: WebParseContentProps): react_jsx_runtime.JSX.Element | null;
462
+
463
+ type WrapperType = 'standard' | 'info' | 'warning';
464
+ interface ExpandableOutputContentProps {
465
+ children: React__default.ReactNode;
466
+ defaultOpen?: boolean;
467
+ wrapperType?: WrapperType;
468
+ compact?: boolean;
469
+ className?: string;
470
+ }
471
+ /**
472
+ * An expandable container for code output with max-height and scroll.
473
+ */
474
+ declare function ExpandableOutputContent({ children, defaultOpen, wrapperType, compact, className, }: ExpandableOutputContentProps): react_jsx_runtime.JSX.Element;
475
+ interface OutputLineProps {
476
+ children: React__default.ReactNode;
477
+ timestamp?: string;
478
+ }
479
+ /**
480
+ * Standard output text line with optional timestamp.
481
+ */
482
+ declare function StdoutText({ children, timestamp }: OutputLineProps): react_jsx_runtime.JSX.Element;
483
+ /**
484
+ * Error/stderr output text line with info styling.
485
+ */
486
+ declare function StderrText({ children, timestamp }: OutputLineProps): react_jsx_runtime.JSX.Element;
487
+ /**
488
+ * Warning output text line with warning styling.
489
+ */
490
+ declare function StdwarnText({ children, timestamp }: OutputLineProps): react_jsx_runtime.JSX.Element;
491
+
492
+ interface CollapsibleCodeBlockProps {
493
+ language: string;
494
+ value: string;
495
+ defaultOpen?: boolean;
496
+ title?: string;
497
+ closeTitle?: string;
498
+ className?: string;
499
+ /** Theme: 'dark' | 'light' | 'auto'. Auto uses prefers-color-scheme. Default: 'auto' */
500
+ theme?: 'dark' | 'light' | 'auto';
501
+ }
502
+ /**
503
+ * A collapsible code block with syntax highlighting.
504
+ */
505
+ declare function CollapsibleCodeBlock({ language, value, defaultOpen, title, closeTitle, className, theme, }: CollapsibleCodeBlockProps): react_jsx_runtime.JSX.Element;
506
+
507
+ interface SqlContentProps {
508
+ item: ContentItem;
509
+ className?: string;
510
+ }
511
+ /**
512
+ * Renders SQL generation content with thinking text and collapsible SQL code.
513
+ */
514
+ declare function SqlContent({ item, className }: SqlContentProps): react_jsx_runtime.JSX.Element | null;
515
+
516
+ interface CodegenContentProps {
517
+ item: ContentItem;
518
+ className?: string;
519
+ }
520
+ /**
521
+ * Renders code generation content with step-by-step explanation, code, and warnings.
522
+ */
523
+ declare function CodegenContent({ item, className }: CodegenContentProps): react_jsx_runtime.JSX.Element | null;
524
+
525
+ interface CodeexecContentProps {
526
+ item: ContentItem;
527
+ className?: string;
528
+ }
529
+ /**
530
+ * Renders code execution output (stdout, stderr, warnings).
531
+ */
532
+ declare function CodeexecContent({ item, className }: CodeexecContentProps): react_jsx_runtime.JSX.Element | null;
533
+
534
+ interface ToolGroupContentProps {
535
+ /** The tool group data */
536
+ toolGroup: ToolGroup;
537
+ /** Optional Content component for rendering nested results (avoids circular imports) */
538
+ ContentComponent?: React__default.ComponentType<{
539
+ content: ContentItem;
540
+ className?: string;
541
+ }>;
542
+ className?: string;
543
+ }
544
+ /**
545
+ * Renders tool invocations and their results in a collapsible format.
546
+ */
547
+ declare function ToolGroupContent({ toolGroup, ContentComponent, className, }: ToolGroupContentProps): react_jsx_runtime.JSX.Element;
548
+
549
+ /** Content data for a bot invocation (passed in ContentItem.content) */
550
+ interface BotInvocationContentData {
551
+ /** Unique invocation ID */
552
+ invocation_id: string;
553
+ /** Bot ID */
554
+ bot_id: string;
555
+ /** Bot display name */
556
+ bot_name: string;
557
+ /** Whether this invocation is transparent (embedded) */
558
+ transparent?: boolean;
559
+ }
560
+ /** Status information for a bot invocation */
561
+ interface BotInvocationStatusInfo {
562
+ /** Current status of the invocation */
563
+ status: InvocationStatus$1 | string;
564
+ /** Optional status message */
565
+ message?: string | {
566
+ Valid: boolean;
567
+ String: string;
568
+ };
569
+ }
570
+ /** Event within a bot invocation */
571
+ interface BotInvocationEventInfo {
572
+ /** Unique event ID */
573
+ id: string;
574
+ /** Event type (output, step, etc.) */
575
+ type: string;
576
+ /** When the event was created */
577
+ created_at?: string;
578
+ /** Event data - structure depends on type */
579
+ data?: unknown;
580
+ }
581
+ /** Resolved bot invocation with status and events */
582
+ interface ResolvedBotInvocation {
583
+ /** Current status of the invocation */
584
+ currentStatus?: BotInvocationStatusInfo | null;
585
+ /** Map of events by ID */
586
+ eventsByID?: Record<string, BotInvocationEventInfo>;
587
+ /** Additional invocation details */
588
+ [key: string]: unknown;
589
+ }
590
+ interface BotInvocationContentProps {
591
+ /** The content data containing invocation_id, bot_id, bot_name */
592
+ content: BotInvocationContentData;
593
+ /** Resolved bot invocation data with events and status */
594
+ botInvocation?: ResolvedBotInvocation | null;
595
+ /** Whether the invocation is still loading */
596
+ isLoading?: boolean;
597
+ /** Whether this should be open by default */
598
+ defaultOpen?: boolean;
599
+ /** Optional admin link href (e.g., to agent designer) */
600
+ adminLinkHref?: string;
601
+ /** Optional admin link text */
602
+ adminLinkText?: string;
603
+ /** Whether to show the admin link */
604
+ showAdminLink?: boolean;
605
+ /** Callback when admin link is clicked */
606
+ onAdminClick?: (invocationId: string, botId: string) => void;
607
+ /** Callback when invocation is expanded */
608
+ onExpand?: (invocationId: string, botId: string, botName: string) => void;
609
+ /** Component for rendering nested events */
610
+ EventsComponent?: React__default.ComponentType<{
611
+ eventsByID: Record<string, BotInvocationEventInfo>;
612
+ defaultOpen?: boolean;
613
+ }>;
614
+ /** Component for rendering individual content items */
615
+ ContentComponent?: React__default.ComponentType<{
616
+ content: ContentItem;
617
+ className?: string;
618
+ }>;
619
+ className?: string;
620
+ }
621
+ /**
622
+ * Renders a bot invocation with status, collapsible events, and optional admin link.
623
+ *
624
+ * This component is designed to receive already-processed invocation data.
625
+ * Data fetching should be handled by the consuming application.
626
+ */
627
+ declare function BotInvocationContent({ content, botInvocation, isLoading, defaultOpen, adminLinkHref, adminLinkText, showAdminLink, onAdminClick, onExpand, EventsComponent, ContentComponent: _ContentComponent, className, }: BotInvocationContentProps): react_jsx_runtime.JSX.Element | null;
628
+
629
+ type SpinnerStatus = 'loading' | 'finished' | 'failed';
630
+ interface StatusSpinnerProps {
631
+ status: SpinnerStatus;
632
+ /** Icon color - if not provided, auto-detects from theme (white for dark, black for light) */
633
+ color?: string;
634
+ /** Size in pixels - defaults to 16 */
635
+ size?: number;
636
+ className?: string;
637
+ }
638
+ /**
639
+ * Animated status spinner using Lordicon/Lottie animations.
640
+ * Shows a spinning loader when loading, checkmark when finished, and alert when failed.
641
+ */
642
+ declare function StatusSpinner({ status, color, size, className }: StatusSpinnerProps): react_jsx_runtime.JSX.Element;
643
+
644
+ interface ZoomState {
645
+ refAreaLeft: number | null;
646
+ refAreaRight: number | null;
647
+ refAreaTop: number | null;
648
+ refAreaBottom: number | null;
649
+ zooming: boolean;
650
+ }
651
+ interface Domain {
652
+ x: [number | string | null, number | string | null];
653
+ y: [number | string | null, number | string | null];
654
+ }
655
+ interface ZoomEvent {
656
+ chartX: number;
657
+ chartY: number;
658
+ xValue: number;
659
+ yValue: number;
660
+ }
661
+ interface UseChartZoomProps {
662
+ onZoomChange?: (domain: {
663
+ x: [number | null, number | null];
664
+ y: [number | null, number | null];
665
+ }) => void;
666
+ }
667
+ declare function useChartZoom({ onZoomChange }?: UseChartZoomProps): {
668
+ zoomState: ZoomState;
669
+ customDomain: Domain;
670
+ handlers: {
671
+ onZoomStart: (e: ZoomEvent) => void;
672
+ onZoomMove: (e: ZoomEvent) => void;
673
+ onZoomEnd: () => void;
674
+ onResetZoom: () => void;
675
+ };
676
+ };
677
+
678
+ /**
679
+ * Hook to fetch contents of a single dataset.
680
+ *
681
+ * @param datasetSlug - The slug/identifier of the dataset
682
+ * @param invocationId - The invocation ID context
683
+ * @returns React Query result with dataset contents
684
+ *
685
+ * @example
686
+ * ```tsx
687
+ * const { data, isLoading, error } = useDatasetContents('my-dataset', invocationId);
688
+ * ```
689
+ */
690
+ declare function useDatasetContents(datasetSlug: string, invocationId: string): UseQueryResult<any[], Error>;
691
+ /**
692
+ * Hook to fetch contents of multiple datasets in parallel.
693
+ *
694
+ * @param datasetSlugs - Array of dataset slugs/identifiers
695
+ * @param invocationId - The invocation ID context
696
+ * @returns Array of React Query results, one per dataset
697
+ *
698
+ * @example
699
+ * ```tsx
700
+ * const results = useMultipleDatasetContents(['dataset-1', 'dataset-2'], invocationId);
701
+ * const isLoading = results.some(r => r.isLoading);
702
+ * const allData = results.map(r => r.data || []);
703
+ * ```
704
+ */
705
+ declare function useMultipleDatasetContents(datasetSlugs: string[], invocationId: string): UseQueryResult<any[], Error>[];
706
+
707
+ interface UseInvocationOptions {
708
+ /** Called for each SSE event received during streaming */
709
+ onEvent?: (event: SSEEvent) => void;
710
+ /** Called when invocation completes successfully */
711
+ onFinish?: (result: InvokeResult) => void;
712
+ /** Called if an error occurs */
713
+ onError?: (error: Error) => void;
714
+ }
715
+ interface UseInvocationReturn {
716
+ /** Current invocation result (updates during streaming) */
717
+ result: InvokeResult | null;
718
+ /** Whether an invocation is currently in progress */
719
+ isStreaming: boolean;
720
+ /** Error if the last invocation failed */
721
+ error: Error | null;
722
+ /** Function to start a new invocation */
723
+ invoke: (botKey: string, params: InvokeParams) => Promise<InvokeResult>;
724
+ /** Function to cancel the current invocation */
725
+ cancel: () => void;
726
+ }
727
+ /**
728
+ * Hook for invoking Erdo bots and streaming results.
729
+ *
730
+ * Requires ErdoProvider with a client configured.
731
+ *
732
+ * @example
733
+ * ```tsx
734
+ * function MyComponent() {
735
+ * const { result, isStreaming, invoke } = useInvocation({
736
+ * onEvent: (event) => console.log('Event:', event),
737
+ * onFinish: (result) => console.log('Done:', result),
738
+ * });
739
+ *
740
+ * const handleAnalyze = async () => {
741
+ * await invoke('org.my-bot', {
742
+ * messages: [{ role: 'user', content: 'Analyze sales data' }],
743
+ * datasets: ['sales-2024'],
744
+ * });
745
+ * };
746
+ *
747
+ * return (
748
+ * <div>
749
+ * <button onClick={handleAnalyze} disabled={isStreaming}>
750
+ * {isStreaming ? 'Analyzing...' : 'Analyze'}
751
+ * </button>
752
+ * {result && <div>Result: {JSON.stringify(result)}</div>}
753
+ * </div>
754
+ * );
755
+ * }
756
+ * ```
757
+ */
758
+ declare function useInvocation(options?: UseInvocationOptions): UseInvocationReturn;
759
+
760
+ /**
761
+ * Format a value based on its type and specified format pattern
762
+ */
763
+ declare function formatValue(value: any, format?: string | null, valueType?: 'number' | 'category' | 'date' | null): string;
764
+ /**
765
+ * Parse a value to a Date object
766
+ */
767
+ declare function parseToDate(value: any): Date | null;
768
+
769
+ declare function cn(...inputs: ClassValue[]): string;
770
+
771
+ /**
772
+ * Utility functions for resolving data keys across different naming conventions.
773
+ * Used by dataset visualization components (charts, tables, etc.) to handle
774
+ * mismatches between config keys and actual data keys.
775
+ */
776
+ /**
777
+ * Convert PascalCase or camelCase to snake_case
778
+ * Examples: ActiveUsers -> active_users, userName -> user_name
779
+ */
780
+ declare function toSnakeCase(str: string): string;
781
+ /**
782
+ * Resolve the actual key from data objects by trying multiple patterns.
783
+ * This handles common naming convention mismatches between config and data.
784
+ *
785
+ * Tries in order:
786
+ * 1. Exact match
787
+ * 2. Lowercase (Date -> date)
788
+ * 3. Snake case (ActiveUsers -> active_users)
789
+ * 4. Normalized (case-insensitive, underscore-insensitive)
790
+ *
791
+ * @param dataRows - Array of data objects to search
792
+ * @param configKey - The key from the configuration
793
+ * @returns The resolved key that exists in the data, or the original key if not found
794
+ */
795
+ declare function resolveKeyFromData(dataRows: any[], configKey: string): string;
796
+
797
+ /**
798
+ * JSON streaming parser utilities.
799
+ * Used for parsing potentially incomplete JSON during SSE streaming.
800
+ */
801
+ type JSONValue = string | number | boolean | null | {
802
+ [key: string]: JSONValue;
803
+ [parsingSymbol]?: boolean;
804
+ } | (JSONValue[] & {
805
+ [parsingSymbol]?: boolean;
806
+ });
807
+ type ParserState = 'START' | 'IN_OBJECT' | 'IN_ARRAY' | 'IN_OBJECT_KEY' | 'AFTER_KEY' | 'IN_OBJECT_VALUE' | 'IN_STRING' | 'IN_NUMBER' | 'IN_TRUE' | 'IN_FALSE' | 'IN_NULL' | 'IN_UNICODE' | 'END';
808
+ declare const parsingSymbol: unique symbol;
809
+ declare class JSONStreamParser {
810
+ result: JSONValue | undefined;
811
+ private stack;
812
+ private key;
813
+ state: ParserState;
814
+ private stringBuffer;
815
+ private numberBuffer;
816
+ private quoteBuffer;
817
+ private escapeNext;
818
+ private unicode;
819
+ private isInTripleQuotes;
820
+ constructor();
821
+ private reset;
822
+ parse(jsonString: string): JSONValue | undefined;
823
+ add(chunk: string): JSONValue | undefined;
824
+ private processChar;
825
+ private handleStartState;
826
+ private error;
827
+ private handleObjectState;
828
+ private handleArrayState;
829
+ private handleObjectKeyState;
830
+ private handleAfterKeyState;
831
+ private handleObjectValueState;
832
+ private handleStringState;
833
+ private handleNumberState;
834
+ private handleLiteralState;
835
+ private handleUnicodeState;
836
+ private handleEscapeChar;
837
+ private startObject;
838
+ private endObject;
839
+ private startArray;
840
+ private endArray;
841
+ private startValue;
842
+ private endString;
843
+ private endNumber;
844
+ private endLiteral;
845
+ private addValueToParent;
846
+ private updateValueInParent;
847
+ private isWhitespace;
848
+ private getParentState;
849
+ }
850
+ /**
851
+ * Parse a complete JSON string, with fallback to streaming parser for malformed JSON.
852
+ */
853
+ declare function parseCompleteJson(content: string): any;
854
+ type ContentChunk = {
855
+ content: string | Record<string, any>;
856
+ type: 'json' | 'text';
857
+ };
858
+ declare function isWhitespaceChar(char: string): boolean;
859
+ /**
860
+ * Parse mixed content that may contain JSON objects embedded in text.
861
+ * Handles both markdown code blocks (```json...```) and inline JSON.
862
+ */
863
+ declare function parseMixedJson(content: string | any[] | Record<string, any>): ContentChunk[] | any[] | Record<string, any>;
864
+ declare function isParsingComplete(value: any): boolean;
865
+ declare function isParsingInProgress(value: any): boolean;
866
+
867
+ /**
868
+ * SSE Event Types for parsing streaming invocation results.
869
+ *
870
+ * These types are standalone and don't depend on any generated client types.
871
+ * They represent the structure of entities that can be built from SSE events.
872
+ */
873
+
874
+ type ContentType = 'text' | 'json' | 'xml' | 'thinking' | 'redacted_thinking';
875
+ declare function isJsonLike(contentType: ContentType, uiContentType: string): boolean;
876
+ type EntityType = 'message' | 'message_content' | 'invocation' | 'output' | 'output_content' | 'step' | 'result_handler' | 'status' | 'log';
877
+ type MessageStreamingState = 'in_progress' | 'completed';
878
+ interface SSEEventData {
879
+ payload: Record<string, any> | string;
880
+ metadata: {
881
+ path: string;
882
+ content_type?: ContentType;
883
+ history_content_type?: string;
884
+ ui_content_type?: string;
885
+ invocation_id?: string;
886
+ message_id?: string;
887
+ message_content_id?: string;
888
+ user_visibility?: string;
889
+ bot_visibility?: string;
890
+ visibility?: string;
891
+ output_id?: string;
892
+ output_content_id?: string;
893
+ step_id?: string;
894
+ result_handler_id?: string;
895
+ status_id?: string;
896
+ [key: string]: any;
897
+ };
898
+ }
899
+ interface BaseContentFields {
900
+ botInvocation?: BotInvocation;
901
+ parsedJson?: ContentChunk[];
902
+ _currentContent?: ContentChunk;
903
+ _jsonParser?: JSONStreamParser;
904
+ _isInJson?: boolean;
905
+ _charBuffer?: string;
906
+ state: MessageStreamingState;
907
+ invocation_id: string;
908
+ }
909
+ interface Message {
910
+ id: string;
911
+ thread_id: string;
912
+ author_id: string;
913
+ author_entity_type: string;
914
+ created_at: string;
915
+ updated_at: string;
916
+ role: string;
917
+ avatar?: string;
918
+ }
919
+ interface MessageContent extends BaseContentFields {
920
+ _type: 'message_content';
921
+ id: string;
922
+ message_id: string;
923
+ content_type: ContentType;
924
+ content: string;
925
+ created_by_invocation_id?: string;
926
+ user_visibility: string;
927
+ bot_visibility: string;
928
+ created_at: string;
929
+ updated_at: string;
930
+ content_params: {
931
+ RawMessage: any;
932
+ Valid: boolean;
933
+ };
934
+ history_content_type: {
935
+ String: string;
936
+ Valid: boolean;
937
+ };
938
+ ui_content_type: {
939
+ String: string;
940
+ Valid: boolean;
941
+ };
942
+ }
943
+ interface MessageWithContents {
944
+ _type: 'message';
945
+ message: Message;
946
+ state: MessageStreamingState;
947
+ contents: MessageContent[];
948
+ contentsByID: Record<string, MessageContent>;
949
+ contentIDToIdx: Record<string, number>;
950
+ }
951
+ interface Output {
952
+ id: string;
953
+ invocation_id?: string;
954
+ path?: string;
955
+ created_at: string;
956
+ updated_at: string;
957
+ }
958
+ interface OutputContent extends BaseContentFields {
959
+ _type: 'output_content';
960
+ id: string;
961
+ output_id: string;
962
+ content: string;
963
+ content_type: ContentType;
964
+ user_visibility: string;
965
+ bot_visibility: string;
966
+ created_at: string;
967
+ updated_at: string;
968
+ content_params: {
969
+ RawMessage: any;
970
+ Valid: boolean;
971
+ };
972
+ history_content_type: {
973
+ String: string;
974
+ Valid: boolean;
975
+ };
976
+ ui_content_type: {
977
+ String: string;
978
+ Valid: boolean;
979
+ };
980
+ output: OutputWithContents | null;
981
+ }
982
+ interface OutputWithContents {
983
+ _type: 'output';
984
+ id: string;
985
+ step_id?: string;
986
+ output: Output;
987
+ state: MessageStreamingState;
988
+ contents: OutputContent[];
989
+ contentsByID: Record<string, OutputContent>;
990
+ contentIDToIdx: Record<string, number>;
991
+ }
992
+ interface Step {
993
+ _type: 'step';
994
+ id: string;
995
+ invocation_id: string;
996
+ step_id: string;
997
+ created_at: string;
998
+ updated_at: string;
999
+ current_status_id: string;
1000
+ path: {
1001
+ String: string;
1002
+ Valid: boolean;
1003
+ };
1004
+ action_type: {
1005
+ String: string;
1006
+ Valid: boolean;
1007
+ };
1008
+ key: {
1009
+ String: string;
1010
+ Valid: boolean;
1011
+ };
1012
+ bot_id?: string;
1013
+ result_handler_id: string;
1014
+ step_order: {
1015
+ Int32: number;
1016
+ Valid: boolean;
1017
+ };
1018
+ output_content_type: {
1019
+ String: string;
1020
+ Valid: boolean;
1021
+ };
1022
+ execution_mode: {
1023
+ String: string;
1024
+ Valid: boolean;
1025
+ };
1026
+ output_behaviour: {
1027
+ String: string;
1028
+ Valid: boolean;
1029
+ };
1030
+ user_output_visibility: {
1031
+ String: string;
1032
+ Valid: boolean;
1033
+ };
1034
+ output_channels: string[];
1035
+ running_message: {
1036
+ String: string;
1037
+ Valid: boolean;
1038
+ };
1039
+ finished_message: {
1040
+ String: string;
1041
+ Valid: boolean;
1042
+ };
1043
+ depends_on: string[];
1044
+ eventsByID: Record<string, InvocationEvent>;
1045
+ currentStatus: Status | null;
1046
+ }
1047
+ interface ResultHandler {
1048
+ _type: 'result_handler';
1049
+ id: string;
1050
+ invocation_id: string;
1051
+ result_handler_id: string;
1052
+ step_invocation_id: string;
1053
+ type: string;
1054
+ if_conditions: Record<string, any>;
1055
+ created_at: string;
1056
+ updated_at: string;
1057
+ output_content_type: string;
1058
+ result_handler_order: number;
1059
+ eventsByID: Record<string, InvocationEvent>;
1060
+ }
1061
+ declare enum InvocationStatus {
1062
+ Pending = "pending",
1063
+ Running = "running",
1064
+ Success = "success",
1065
+ Error = "error",
1066
+ RequiresInfo = "requires info",
1067
+ GoToStep = "go to step",
1068
+ Skipped = "skipped",
1069
+ Break = "break"
1070
+ }
1071
+ declare enum ExecutionStatus {
1072
+ Initializing = "initializing",
1073
+ Running = "running",
1074
+ ProcessingDatasets = "processing datasets",
1075
+ Completed = "completed",
1076
+ Failed = "failed"
1077
+ }
1078
+ interface StatusEvent {
1079
+ status: ExecutionStatus | InvocationStatus | string;
1080
+ message?: string;
1081
+ details?: Record<string, any>;
1082
+ }
1083
+ interface Status {
1084
+ _type: 'status';
1085
+ id: string;
1086
+ status: string;
1087
+ message: {
1088
+ String: string;
1089
+ Valid: boolean;
1090
+ };
1091
+ Details: StatusEvent;
1092
+ created_at?: string;
1093
+ }
1094
+ interface BotInvocationData {
1095
+ id: string;
1096
+ bot_id: string;
1097
+ bot_name?: string;
1098
+ created_by_user_id?: string;
1099
+ current_state_id: string;
1100
+ parent_invocation_id: string;
1101
+ branch_init_state_id: string;
1102
+ current_status_id: string;
1103
+ organization_id: string;
1104
+ created_at: string;
1105
+ updated_at: string;
1106
+ }
1107
+ interface BotInvocation {
1108
+ _type: 'invocation';
1109
+ bot_invocation: BotInvocationData;
1110
+ eventsByID: Record<string, InvocationEvent>;
1111
+ currentStatus: Status | null;
1112
+ current_status: Status | null;
1113
+ step_invocations: any[];
1114
+ step_invocation_states: any[];
1115
+ resources: any[];
1116
+ outputs: any[];
1117
+ statuses: any[];
1118
+ }
1119
+ interface InvocationEvent {
1120
+ id?: string;
1121
+ type?: EntityType;
1122
+ created_at?: string;
1123
+ _type: 'invocation_event';
1124
+ Output: OutputWithContents | null;
1125
+ Message: MessageWithContents | null;
1126
+ Status: Status | null;
1127
+ ResultHandler: ResultHandler | null;
1128
+ Step: Step | null;
1129
+ }
1130
+ type Entity = MessageWithContents | MessageContent | BotInvocation | OutputWithContents | OutputContent | Step | ResultHandler | Status;
1131
+
1132
+ /**
1133
+ * SSE Event Handler
1134
+ *
1135
+ * Handles Server-Sent Events from Erdo invocations and builds up the
1136
+ * message/invocation tree structure for rendering.
1137
+ */
1138
+
1139
+ /**
1140
+ * Handles incremental parsing of mixed JSON/text content as it streams in.
1141
+ *
1142
+ * This function is called each time new content arrives during streaming.
1143
+ * It parses the content to detect JSON blocks interspersed with text,
1144
+ * updating the outputContent's parsed_blocks array as complete JSON
1145
+ * objects are detected.
1146
+ *
1147
+ * @param outputContent - The message or output content to update
1148
+ * @param content - The full accumulated content string so far
1149
+ * @returns The updated content object with parsed_blocks populated
1150
+ */
1151
+ declare function handleIncrementalMixedJsonParsing(outputContent: MessageContent | OutputContent, content: string): MessageContent | OutputContent;
1152
+ /**
1153
+ * Handles different types of SSE events and updates the message tree accordingly.
1154
+ *
1155
+ * Returns the updated entity at the root level (typically a message or message_content),
1156
+ * or null if no update was performed (e.g., for message finished events).
1157
+ *
1158
+ * Note: Only message or message_content types can be returned as root objects.
1159
+ * Other entity types like invocation, step, output, etc. will be nested inside
1160
+ * a message_content entity.
1161
+ *
1162
+ * @param eventType - The type of SSE event (e.g., 'bot started', 'message content delta')
1163
+ * @param event - The SSE event data
1164
+ * @param path - The path to the entity being updated
1165
+ * @param threadID - The thread ID for creating messages
1166
+ * @param activeMessagesByID - Map of active messages by ID
1167
+ * @param currentEntity - The current entity being processed
1168
+ * @param parents - Parent entities in the tree
1169
+ * @param entityIds - Map of entity type to ID for context
1170
+ * @returns The updated entity or null if no update was performed
1171
+ */
1172
+ declare function handleSSEEvent(eventType: string, event: SSEEventData, path: string[], threadID: string, activeMessagesByID: Record<string, MessageWithContents>, currentEntity?: Entity | null, parents?: Entity[], entityIds?: Record<string, string>): Entity | null;
1173
+
1174
+ export { BarChart, type BaseChartProps, type BotInvocation, BotInvocationContent, type BotInvocationContentData, type BotInvocationContentProps, type BotInvocationData, type BotInvocationEventInfo, type BotInvocationStatusInfo, Chart, type ChartConfig, ChartContainer, ChartContent, type ChartContentProps, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, CodeexecContent, type CodeexecContentProps, CodegenContent, type CodegenContentProps, CollapsibleCodeBlock, type CollapsibleCodeBlockProps, Content, type ContentChartConfig, type ContentChunk, type ContentComponentProps, type ContentProps, type ContentType, type DataFetcher, DatasetChart, type DatasetChartProps, type Entity, type EntityType, ErdoProvider, type ErdoProviderConfig, type ErdoProviderProps, ErrorBoundary, ExecutionStatus, ExpandableOutputContent, type ExpandableOutputContentProps, HeatmapChart, type InvocationEvent, InvocationStatus, JSONStreamParser, type JSONValue, JsonContent, type JsonContentProps, LineChart, Log, LogContent, type LogContentProps, type LogProps, MarkdownContent, type MarkdownContentProps, type Message, type MessageContent, type MessageStreamingState, type MessageWithContents, type Output, type OutputContent, type OutputWithContents, PieChart, type ResolvedBotInvocation, type ResultHandler, type SSEEventData, ScatterChart, type SpinnerStatus, SqlContent, type SqlContentProps, type Status, type StatusEvent, StatusSpinner, type StatusSpinnerProps, StderrText, StdoutText, StdwarnText, type Step, TableContent, type TableContentProps, TextContent, type TextContentProps, ThinkingContent, type ThinkingContentProps, ToolGroupContent, type ToolGroupContentProps, type UseInvocationOptions, type UseInvocationReturn, WebParseContent, type WebParseContentProps, WebSearchContent, type WebSearchContentProps, type WrapperType, cn, formatValue, handleIncrementalMixedJsonParsing, handleSSEEvent, isJsonLike, isParsingComplete, isParsingInProgress, isWhitespaceChar, parseCompleteJson, parseMixedJson, parseToDate, resolveKeyFromData, toSnakeCase, useChartZoom, useDatasetContents, useErdoConfig, useErdoConfigOptional, useInvocation, useMultipleDatasetContents };