@erdoai/ui 0.1.23 → 0.1.25

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.
package/dist/index.d.cts CHANGED
@@ -7,6 +7,13 @@ import * as RechartsPrimitive from 'recharts';
7
7
  import { UseQueryResult } from '@tanstack/react-query';
8
8
  import { ClassValue } from 'clsx';
9
9
 
10
+ /**
11
+ * Dataset details returned by getDatasetDetails
12
+ */
13
+ interface DatasetDetails {
14
+ id: string;
15
+ name: string;
16
+ }
10
17
  /**
11
18
  * Interface for custom data fetching implementations.
12
19
  * Use this when you need to override the default REST API behavior,
@@ -17,6 +24,16 @@ import { ClassValue } from 'clsx';
17
24
  */
18
25
  interface DataFetcher {
19
26
  fetchDatasetContents: (slug: string, invocationId: string) => Promise<any[]>;
27
+ /**
28
+ * Get dataset details (id and name) by slug.
29
+ * Used by DatasetDownload component to resolve slug to downloadable dataset.
30
+ */
31
+ getDatasetDetails?: (slug: string, threadId: string) => Promise<DatasetDetails | null>;
32
+ /**
33
+ * Download a dataset file by ID.
34
+ * Returns a Blob that can be saved as a file.
35
+ */
36
+ downloadDataset?: (datasetId: string) => Promise<Blob>;
20
37
  }
21
38
  /**
22
39
  * Configuration for the ErdoProvider.
@@ -27,6 +44,11 @@ interface ErdoProviderConfig {
27
44
  * Used by default REST implementation in hooks.
28
45
  */
29
46
  baseUrl: string;
47
+ /**
48
+ * Optional thread ID for dataset operations.
49
+ * Used by DatasetDownload to resolve dataset slugs.
50
+ */
51
+ threadId?: string;
30
52
  /**
31
53
  * Optional auth token for API calls.
32
54
  * Will be sent as Bearer token in Authorization header.
@@ -1151,6 +1173,29 @@ interface StatusSpinnerProps {
1151
1173
  */
1152
1174
  declare function StatusSpinner({ status, color, size, className }: StatusSpinnerProps): react_jsx_runtime.JSX.Element;
1153
1175
 
1176
+ interface DatasetDownloadProps {
1177
+ /** Dataset slug to download */
1178
+ slug: string;
1179
+ /** Invocation ID (used for context, may be needed by some backends) */
1180
+ invocationId?: string;
1181
+ /** Optional thread ID override (falls back to provider's threadId) */
1182
+ threadId?: string;
1183
+ /** Optional class name for styling */
1184
+ className?: string;
1185
+ }
1186
+ /**
1187
+ * A download button component for datasets.
1188
+ *
1189
+ * Uses the DataFetcher from ErdoProvider if available, otherwise falls back
1190
+ * to REST API calls using baseUrl and auth tokens.
1191
+ *
1192
+ * @example
1193
+ * ```tsx
1194
+ * <DatasetDownload slug="my-dataset" invocationId="abc123" />
1195
+ * ```
1196
+ */
1197
+ declare function DatasetDownload({ slug, invocationId: _invocationId, threadId: threadIdProp, className, }: DatasetDownloadProps): react_jsx_runtime.JSX.Element | null;
1198
+
1154
1199
  interface ZoomState {
1155
1200
  refAreaLeft: number | null;
1156
1201
  refAreaRight: number | null;
@@ -1268,11 +1313,30 @@ interface UseThreadReturn {
1268
1313
  * For server-side processing where you don't need React rendering,
1269
1314
  * use `ErdoClient.invoke()` or `ErdoClient.invokeStream()` directly.
1270
1315
  *
1271
- * ## Loading message history
1316
+ * ## Persisting message history
1317
+ *
1318
+ * This hook focuses on streaming new messages. For chat history, we recommend
1319
+ * storing messages in your own database as they complete:
1320
+ *
1321
+ * ```tsx
1322
+ * const { streamingContents, sendMessage } = useThread({
1323
+ * botKey: 'org.my-bot',
1324
+ * onFinish: () => {
1325
+ * // Save to your database when message completes
1326
+ * await saveMessageToDb(threadId, streamingContents);
1327
+ * },
1328
+ * });
1329
+ *
1330
+ * // Load history from your database
1331
+ * const { data: history } = useQuery({
1332
+ * queryKey: ['messages', threadId],
1333
+ * queryFn: () => fetchMessagesFromDb(threadId),
1334
+ * });
1335
+ * ```
1336
+ *
1337
+ * This gives you full control over your data and avoids extra API calls.
1272
1338
  *
1273
- * This hook focuses on streaming new messages. To load existing thread messages
1274
- * (chat history), use `client.getThreadMessages(threadId)` with React Query or
1275
- * your preferred data fetching solution:
1339
+ * Alternatively, you can fetch history from Erdo using `client.getThreadMessages()`:
1276
1340
  *
1277
1341
  * ```tsx
1278
1342
  * const { data: history } = useQuery({
@@ -1404,4 +1468,4 @@ declare function handleIncrementalMixedJsonParsing(outputContent: MessageContent
1404
1468
  */
1405
1469
  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;
1406
1470
 
1407
- 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, DatasetTable, type DatasetTableProps, type Entity, type EntityType, ErdoProvider, type ErdoProviderConfig, type ErdoProviderProps, ErdoUI, type ErdoUIProps, ErrorBoundary, ExecutionStatus, ExpandableOutputContent, type ExpandableOutputContentProps, HeatmapChart, InvocationEvent, type InvocationEventProps, InvocationEvents, type InvocationEventsProps, 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, Output, type OutputContent, type OutputProps, 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, StepInvocation, type StepInvocationProps, StepInvocationStatus, type StepInvocationStatusProps, StreamingLoader, TableContent, type TableContentProps, TextContent, type TextContentProps, ThinkingContent, type ThinkingContentProps, ToolGroupContent, type ToolGroupContentProps, type UseThreadOptions, type UseThreadReturn, WebParseContent, type WebParseContentProps, WebSearchContent, type WebSearchContentProps, type WrapperType, WritingLoader, cn, extractContentItems, formatValue, handleIncrementalMixedJsonParsing, handleSSEEvent, isJsonLike, isParsingComplete, isParsingInProgress, isWhitespaceChar, parseCompleteJson, parseMixedJson, parseToDate, resolveKeyFromData, toSnakeCase, useChartZoom, useDatasetContents, useErdoConfig, useErdoConfigOptional, useMultipleDatasetContents, useThread };
1471
+ 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 DatasetDetails, DatasetDownload, type DatasetDownloadProps, DatasetTable, type DatasetTableProps, type Entity, type EntityType, ErdoProvider, type ErdoProviderConfig, type ErdoProviderProps, ErdoUI, type ErdoUIProps, ErrorBoundary, ExecutionStatus, ExpandableOutputContent, type ExpandableOutputContentProps, HeatmapChart, InvocationEvent, type InvocationEventProps, InvocationEvents, type InvocationEventsProps, 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, Output, type OutputContent, type OutputProps, 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, StepInvocation, type StepInvocationProps, StepInvocationStatus, type StepInvocationStatusProps, StreamingLoader, TableContent, type TableContentProps, TextContent, type TextContentProps, ThinkingContent, type ThinkingContentProps, ToolGroupContent, type ToolGroupContentProps, type UseThreadOptions, type UseThreadReturn, WebParseContent, type WebParseContentProps, WebSearchContent, type WebSearchContentProps, type WrapperType, WritingLoader, cn, extractContentItems, formatValue, handleIncrementalMixedJsonParsing, handleSSEEvent, isJsonLike, isParsingComplete, isParsingInProgress, isWhitespaceChar, parseCompleteJson, parseMixedJson, parseToDate, resolveKeyFromData, toSnakeCase, useChartZoom, useDatasetContents, useErdoConfig, useErdoConfigOptional, useMultipleDatasetContents, useThread };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,13 @@ import * as RechartsPrimitive from 'recharts';
7
7
  import { UseQueryResult } from '@tanstack/react-query';
8
8
  import { ClassValue } from 'clsx';
9
9
 
10
+ /**
11
+ * Dataset details returned by getDatasetDetails
12
+ */
13
+ interface DatasetDetails {
14
+ id: string;
15
+ name: string;
16
+ }
10
17
  /**
11
18
  * Interface for custom data fetching implementations.
12
19
  * Use this when you need to override the default REST API behavior,
@@ -17,6 +24,16 @@ import { ClassValue } from 'clsx';
17
24
  */
18
25
  interface DataFetcher {
19
26
  fetchDatasetContents: (slug: string, invocationId: string) => Promise<any[]>;
27
+ /**
28
+ * Get dataset details (id and name) by slug.
29
+ * Used by DatasetDownload component to resolve slug to downloadable dataset.
30
+ */
31
+ getDatasetDetails?: (slug: string, threadId: string) => Promise<DatasetDetails | null>;
32
+ /**
33
+ * Download a dataset file by ID.
34
+ * Returns a Blob that can be saved as a file.
35
+ */
36
+ downloadDataset?: (datasetId: string) => Promise<Blob>;
20
37
  }
21
38
  /**
22
39
  * Configuration for the ErdoProvider.
@@ -27,6 +44,11 @@ interface ErdoProviderConfig {
27
44
  * Used by default REST implementation in hooks.
28
45
  */
29
46
  baseUrl: string;
47
+ /**
48
+ * Optional thread ID for dataset operations.
49
+ * Used by DatasetDownload to resolve dataset slugs.
50
+ */
51
+ threadId?: string;
30
52
  /**
31
53
  * Optional auth token for API calls.
32
54
  * Will be sent as Bearer token in Authorization header.
@@ -1151,6 +1173,29 @@ interface StatusSpinnerProps {
1151
1173
  */
1152
1174
  declare function StatusSpinner({ status, color, size, className }: StatusSpinnerProps): react_jsx_runtime.JSX.Element;
1153
1175
 
1176
+ interface DatasetDownloadProps {
1177
+ /** Dataset slug to download */
1178
+ slug: string;
1179
+ /** Invocation ID (used for context, may be needed by some backends) */
1180
+ invocationId?: string;
1181
+ /** Optional thread ID override (falls back to provider's threadId) */
1182
+ threadId?: string;
1183
+ /** Optional class name for styling */
1184
+ className?: string;
1185
+ }
1186
+ /**
1187
+ * A download button component for datasets.
1188
+ *
1189
+ * Uses the DataFetcher from ErdoProvider if available, otherwise falls back
1190
+ * to REST API calls using baseUrl and auth tokens.
1191
+ *
1192
+ * @example
1193
+ * ```tsx
1194
+ * <DatasetDownload slug="my-dataset" invocationId="abc123" />
1195
+ * ```
1196
+ */
1197
+ declare function DatasetDownload({ slug, invocationId: _invocationId, threadId: threadIdProp, className, }: DatasetDownloadProps): react_jsx_runtime.JSX.Element | null;
1198
+
1154
1199
  interface ZoomState {
1155
1200
  refAreaLeft: number | null;
1156
1201
  refAreaRight: number | null;
@@ -1268,11 +1313,30 @@ interface UseThreadReturn {
1268
1313
  * For server-side processing where you don't need React rendering,
1269
1314
  * use `ErdoClient.invoke()` or `ErdoClient.invokeStream()` directly.
1270
1315
  *
1271
- * ## Loading message history
1316
+ * ## Persisting message history
1317
+ *
1318
+ * This hook focuses on streaming new messages. For chat history, we recommend
1319
+ * storing messages in your own database as they complete:
1320
+ *
1321
+ * ```tsx
1322
+ * const { streamingContents, sendMessage } = useThread({
1323
+ * botKey: 'org.my-bot',
1324
+ * onFinish: () => {
1325
+ * // Save to your database when message completes
1326
+ * await saveMessageToDb(threadId, streamingContents);
1327
+ * },
1328
+ * });
1329
+ *
1330
+ * // Load history from your database
1331
+ * const { data: history } = useQuery({
1332
+ * queryKey: ['messages', threadId],
1333
+ * queryFn: () => fetchMessagesFromDb(threadId),
1334
+ * });
1335
+ * ```
1336
+ *
1337
+ * This gives you full control over your data and avoids extra API calls.
1272
1338
  *
1273
- * This hook focuses on streaming new messages. To load existing thread messages
1274
- * (chat history), use `client.getThreadMessages(threadId)` with React Query or
1275
- * your preferred data fetching solution:
1339
+ * Alternatively, you can fetch history from Erdo using `client.getThreadMessages()`:
1276
1340
  *
1277
1341
  * ```tsx
1278
1342
  * const { data: history } = useQuery({
@@ -1404,4 +1468,4 @@ declare function handleIncrementalMixedJsonParsing(outputContent: MessageContent
1404
1468
  */
1405
1469
  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;
1406
1470
 
1407
- 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, DatasetTable, type DatasetTableProps, type Entity, type EntityType, ErdoProvider, type ErdoProviderConfig, type ErdoProviderProps, ErdoUI, type ErdoUIProps, ErrorBoundary, ExecutionStatus, ExpandableOutputContent, type ExpandableOutputContentProps, HeatmapChart, InvocationEvent, type InvocationEventProps, InvocationEvents, type InvocationEventsProps, 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, Output, type OutputContent, type OutputProps, 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, StepInvocation, type StepInvocationProps, StepInvocationStatus, type StepInvocationStatusProps, StreamingLoader, TableContent, type TableContentProps, TextContent, type TextContentProps, ThinkingContent, type ThinkingContentProps, ToolGroupContent, type ToolGroupContentProps, type UseThreadOptions, type UseThreadReturn, WebParseContent, type WebParseContentProps, WebSearchContent, type WebSearchContentProps, type WrapperType, WritingLoader, cn, extractContentItems, formatValue, handleIncrementalMixedJsonParsing, handleSSEEvent, isJsonLike, isParsingComplete, isParsingInProgress, isWhitespaceChar, parseCompleteJson, parseMixedJson, parseToDate, resolveKeyFromData, toSnakeCase, useChartZoom, useDatasetContents, useErdoConfig, useErdoConfigOptional, useMultipleDatasetContents, useThread };
1471
+ 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 DatasetDetails, DatasetDownload, type DatasetDownloadProps, DatasetTable, type DatasetTableProps, type Entity, type EntityType, ErdoProvider, type ErdoProviderConfig, type ErdoProviderProps, ErdoUI, type ErdoUIProps, ErrorBoundary, ExecutionStatus, ExpandableOutputContent, type ExpandableOutputContentProps, HeatmapChart, InvocationEvent, type InvocationEventProps, InvocationEvents, type InvocationEventsProps, 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, Output, type OutputContent, type OutputProps, 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, StepInvocation, type StepInvocationProps, StepInvocationStatus, type StepInvocationStatusProps, StreamingLoader, TableContent, type TableContentProps, TextContent, type TextContentProps, ThinkingContent, type ThinkingContentProps, ToolGroupContent, type ToolGroupContentProps, type UseThreadOptions, type UseThreadReturn, WebParseContent, type WebParseContentProps, WebSearchContent, type WebSearchContentProps, type WrapperType, WritingLoader, cn, extractContentItems, formatValue, handleIncrementalMixedJsonParsing, handleSSEEvent, isJsonLike, isParsingComplete, isParsingInProgress, isWhitespaceChar, parseCompleteJson, parseMixedJson, parseToDate, resolveKeyFromData, toSnakeCase, useChartZoom, useDatasetContents, useErdoConfig, useErdoConfigOptional, useMultipleDatasetContents, useThread };