@ash-cloud/ash-ui 0.0.3 → 0.0.5

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
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { NormalizedToolCall, NormalizedEntry, ToolDisplayConfig, LogEntry, ToolDisplayMode, TodoItem, ToolStatus, ActionType } from './types.cjs';
3
- export { AssistantMessageEntry, CommandRunAction, CommandRunResult, DEFAULT_DISPLAY_CONFIG, ErrorEntry, FileAttachment, FileEditAction, FileReadAction, FileWriteAction, GenericToolAction, GlobAction, LogCategory, LogLevel, McpToolAction, NormalizedEntryType, SearchAction, ThinkingEntry, TodoStatus, TodoWriteAction, ToolCallEntry, ToolExecutionGroup as ToolExecutionGroupType, ToolResult, UserMessageEntry, WebFetchAction, WebSearchAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction } from './types.cjs';
2
+ import { NormalizedToolCall, NormalizedEntry, ToolDisplayConfig, WidgetRenderFunction, WidgetAction, LogEntry, ToolDisplayMode, TodoItem, ToolStatus, ActionType } from './types.cjs';
3
+ export { AssistantMessageEntry, CommandRunAction, CommandRunResult, DEFAULT_DISPLAY_CONFIG, ErrorEntry, FileAttachment, FileEditAction, FileReadAction, FileWriteAction, GenericToolAction, GlobAction, LogCategory, LogLevel, McpToolAction, NormalizedEntryType, SearchAction, ThinkingEntry, TodoStatus, TodoWriteAction, ToolCallEntry, ToolExecutionGroup as ToolExecutionGroupType, ToolResult, UserMessageEntry, WebFetchAction, WebSearchAction, WidgetEntry, WidgetRenderProps, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry } from './types.cjs';
4
4
  import { ReactNode, DragEvent, ChangeEvent } from 'react';
5
5
  import { ParsedOption } from './utils.cjs';
6
6
  export { GroupedEntry, ParsedOptionsResult, ToolUseInput, cn, createToolCall, extractTextContent, extractToolCallsFromGroup, formatFileSize, formatTimestamp, formatToolName, generateToolSummary, getActionIcon, getActionLabel, groupEntriesForCompactMode, mapToolToActionType, normalizeToolResult, parseCommandResult, parseMcpToolName, parseOptionsFromContent, truncate, updateToolCallWithResult } from './utils.cjs';
7
- export { AlertCircleIcon, AlertTriangleIcon, BotIcon, BrainIcon, BugIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, ClipboardListIcon, CodeIcon, CopyIcon, EditIcon, FileIcon, FilePlusIcon, FolderSearchIcon, GlobeIcon, IconProps, InfoIcon, ListChecksIcon, LoaderIcon, MessageSquareIcon, MoonIcon, PaperclipIcon, PlugIcon, SearchIcon, SendIcon, SparklesIcon, StopCircleIcon, SunIcon, TerminalIcon, ToolIcon, UserIcon, XCircleIcon, XIcon } from './icons.cjs';
7
+ export { AlertCircleIcon, AlertTriangleIcon, BotIcon, BrainIcon, BugIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, ClipboardListIcon, CodeIcon, CopyIcon, EditIcon, ErrorIcon, FileIcon, FilePlusIcon, FolderSearchIcon, GlobeIcon, IconProps, InfoIcon, ListChecksIcon, LoaderIcon, MessageSquareIcon, MoonIcon, PaperclipIcon, PlugIcon, SearchIcon, SendIcon, SparklesIcon, SpinnerIcon, StopCircleIcon, SunIcon, TerminalIcon, ToolIcon, UserIcon, XCircleIcon, XIcon } from './icons.cjs';
8
8
  export { BorderRadius, Colors, Keyframes, Shadows, Spacing, Transitions, Typography, Widget, ZIndex, allKeyframesCss, borderRadius, colors, inlineStyles, keyframes, keyframesCss, shadows, spacing, tokensToCssVariables, transitions, typography, widget, zIndex } from './design-tokens.cjs';
9
9
 
10
10
  interface ToolCallCardProps {
@@ -41,6 +41,29 @@ interface MessageListProps {
41
41
  displayConfig?: ToolDisplayConfig;
42
42
  /** Callback when user selects an option from assistant message */
43
43
  onOptionSelect?: (optionText: string) => void;
44
+ /**
45
+ * Custom render function for widget entries.
46
+ * When provided, widget entries will be rendered using this function.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * <MessageList
51
+ * entries={entries}
52
+ * renderWidget={({ widgetType, widgetData, onAction }) => {
53
+ * if (widgetType === 'image-grid') {
54
+ * return <ImageGrid data={widgetData} onSelect={onAction} />;
55
+ * }
56
+ * return null;
57
+ * }}
58
+ * />
59
+ * ```
60
+ */
61
+ renderWidget?: WidgetRenderFunction;
62
+ /**
63
+ * Callback for widget interactions (e.g., selection, submit).
64
+ * Called when widgets dispatch actions via their onAction callback.
65
+ */
66
+ onWidgetAction?: (action: WidgetAction) => void;
44
67
  /** Additional class names */
45
68
  className?: string;
46
69
  }
@@ -64,7 +87,7 @@ interface MessageListProps {
64
87
  * <MessageList entries={entries} displayConfig={{ mode: 'compact' }} />
65
88
  * ```
66
89
  */
67
- declare function MessageList({ entries, loading, streamingContent, displayConfig: displayConfigProp, onOptionSelect, className, }: MessageListProps): react_jsx_runtime.JSX.Element;
90
+ declare function MessageList({ entries, loading, streamingContent, displayConfig: displayConfigProp, onOptionSelect, renderWidget, onWidgetAction, className, }: MessageListProps): react_jsx_runtime.JSX.Element;
68
91
 
69
92
  interface UserMessageProps {
70
93
  entry: NormalizedEntry;
@@ -382,12 +405,15 @@ interface DisplayModeToggleProps {
382
405
  labels?: {
383
406
  inline?: string;
384
407
  compact?: string;
408
+ accordion?: string;
385
409
  };
410
+ /** Which modes to cycle through (default: all three) */
411
+ modes?: ToolDisplayMode[];
386
412
  }
387
413
  /**
388
- * DisplayModeToggle - Button to toggle between inline and compact display modes
414
+ * DisplayModeToggle - Button to cycle through display modes
389
415
  *
390
- * Uses the DisplayModeContext to toggle between 'inline' and 'compact' modes.
416
+ * Uses the DisplayModeContext to cycle through 'inline', 'compact', and 'accordion' modes.
391
417
  * Must be used within a DisplayModeProvider.
392
418
  *
393
419
  * @example
@@ -411,7 +437,39 @@ interface DisplayModeToggleProps {
411
437
  * }
412
438
  * ```
413
439
  */
414
- declare function DisplayModeToggle({ className, showLabel, labels, }: DisplayModeToggleProps): react_jsx_runtime.JSX.Element;
440
+ declare function DisplayModeToggle({ className, showLabel, labels, modes, }: DisplayModeToggleProps): react_jsx_runtime.JSX.Element;
441
+
442
+ type StepStatus = 'pending' | 'running' | 'success' | 'error';
443
+ interface StepAccordionProps {
444
+ /** Tool calls to display as steps */
445
+ toolCalls: NormalizedToolCall[];
446
+ /** Whether the accordion starts expanded */
447
+ defaultExpanded?: boolean;
448
+ /** Controlled expanded state */
449
+ isExpanded?: boolean;
450
+ /** Callback when expanded state changes */
451
+ onToggle?: () => void;
452
+ /** Additional class names */
453
+ className?: string;
454
+ }
455
+ /**
456
+ * StepAccordion - Simpler accordion that shows tool calls as numbered steps
457
+ *
458
+ * Features:
459
+ * - Collapsed header shows current running step or completion status
460
+ * - Expanded view shows all steps as a numbered list
461
+ * - Shows step duration for completed steps
462
+ * - Compact design suitable for embedding in chat
463
+ *
464
+ * @example
465
+ * ```tsx
466
+ * <StepAccordion
467
+ * toolCalls={normalizedToolCalls}
468
+ * defaultExpanded={false}
469
+ * />
470
+ * ```
471
+ */
472
+ declare function StepAccordion({ toolCalls, defaultExpanded, isExpanded: controlledExpanded, onToggle, className, }: StepAccordionProps): react_jsx_runtime.JSX.Element | null;
415
473
 
416
474
  interface StatusIndicatorProps {
417
475
  status: ToolStatus;
@@ -840,4 +898,4 @@ interface UseFileUploadReturn {
840
898
  declare function useFileUpload({ maxFileSize, // 100MB
841
899
  maxFiles, onValidationError, }?: UseFileUploadOptions): UseFileUploadReturn;
842
900
 
843
- export { ActionIcon, type ActionIconProps, ActionType, AssistantMessage, type AssistantMessageProps, type FileAttachment as ChatFileAttachment, CodeBlock, type CodeBlockProps, CompactToolStatusLine, type CompactToolStatusLineProps, type DisplayModeContextType, DisplayModeProvider, type DisplayModeProviderProps, DisplayModeToggle, type DisplayModeToggleProps, EnvVarsPanel, type EnvVarsPanelProps, ErrorMessage, type ErrorMessageProps, JsonDisplay, type JsonDisplayProps, LoadingIndicator, type LoadingIndicatorProps, LogEntry, LogsPanel, type LogsPanelProps, MessageEntry, type MessageEntryProps, MessageList, type MessageListProps, NormalizedEntry, NormalizedToolCall, OptionCards, type OptionCardsProps, ParsedOption, type QueuedMessage, StatusIndicator, type StatusIndicatorProps, StreamingText, type StreamingTextProps, type Theme, type ThemeContextType, ThemeProvider, type ThemeProviderProps, ThinkingMessage, type ThinkingMessageProps, TodoItem, TodoPanel, type TodoPanelProps, ToolCallCard, type ToolCallCardProps, ToolCallMessage, type ToolCallMessageProps, ToolDisplayConfig, ToolDisplayMode, ToolExecutionGroup, type ToolExecutionGroupProps, ToolStatus, TypewriterText, type TypewriterTextProps, type UseFileUploadOptions, type UseFileUploadReturn, type UseMessageQueueOptions, type UseMessageQueueReturn, type UseStopExecutionOptions, type UseStopExecutionReturn, UserMessage, type UserMessageProps, useDisplayConfig, useDisplayMode, useFileUpload, useMessageQueue, useStopExecution, useTheme };
901
+ export { ActionIcon, type ActionIconProps, ActionType, AssistantMessage, type AssistantMessageProps, type FileAttachment as ChatFileAttachment, CodeBlock, type CodeBlockProps, CompactToolStatusLine, type CompactToolStatusLineProps, type DisplayModeContextType, DisplayModeProvider, type DisplayModeProviderProps, DisplayModeToggle, type DisplayModeToggleProps, EnvVarsPanel, type EnvVarsPanelProps, ErrorMessage, type ErrorMessageProps, JsonDisplay, type JsonDisplayProps, LoadingIndicator, type LoadingIndicatorProps, LogEntry, LogsPanel, type LogsPanelProps, MessageEntry, type MessageEntryProps, MessageList, type MessageListProps, NormalizedEntry, NormalizedToolCall, OptionCards, type OptionCardsProps, ParsedOption, type QueuedMessage, StatusIndicator, type StatusIndicatorProps, StepAccordion, type StepAccordionProps, type StepStatus, StreamingText, type StreamingTextProps, type Theme, type ThemeContextType, ThemeProvider, type ThemeProviderProps, ThinkingMessage, type ThinkingMessageProps, TodoItem, TodoPanel, type TodoPanelProps, ToolCallCard, type ToolCallCardProps, ToolCallMessage, type ToolCallMessageProps, ToolDisplayConfig, ToolDisplayMode, ToolExecutionGroup, type ToolExecutionGroupProps, ToolStatus, TypewriterText, type TypewriterTextProps, type UseFileUploadOptions, type UseFileUploadReturn, type UseMessageQueueOptions, type UseMessageQueueReturn, type UseStopExecutionOptions, type UseStopExecutionReturn, UserMessage, type UserMessageProps, WidgetAction, WidgetRenderFunction, useDisplayConfig, useDisplayMode, useFileUpload, useMessageQueue, useStopExecution, useTheme };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { NormalizedToolCall, NormalizedEntry, ToolDisplayConfig, LogEntry, ToolDisplayMode, TodoItem, ToolStatus, ActionType } from './types.js';
3
- export { AssistantMessageEntry, CommandRunAction, CommandRunResult, DEFAULT_DISPLAY_CONFIG, ErrorEntry, FileAttachment, FileEditAction, FileReadAction, FileWriteAction, GenericToolAction, GlobAction, LogCategory, LogLevel, McpToolAction, NormalizedEntryType, SearchAction, ThinkingEntry, TodoStatus, TodoWriteAction, ToolCallEntry, ToolExecutionGroup as ToolExecutionGroupType, ToolResult, UserMessageEntry, WebFetchAction, WebSearchAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction } from './types.js';
2
+ import { NormalizedToolCall, NormalizedEntry, ToolDisplayConfig, WidgetRenderFunction, WidgetAction, LogEntry, ToolDisplayMode, TodoItem, ToolStatus, ActionType } from './types.js';
3
+ export { AssistantMessageEntry, CommandRunAction, CommandRunResult, DEFAULT_DISPLAY_CONFIG, ErrorEntry, FileAttachment, FileEditAction, FileReadAction, FileWriteAction, GenericToolAction, GlobAction, LogCategory, LogLevel, McpToolAction, NormalizedEntryType, SearchAction, ThinkingEntry, TodoStatus, TodoWriteAction, ToolCallEntry, ToolExecutionGroup as ToolExecutionGroupType, ToolResult, UserMessageEntry, WebFetchAction, WebSearchAction, WidgetEntry, WidgetRenderProps, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry } from './types.js';
4
4
  import { ReactNode, DragEvent, ChangeEvent } from 'react';
5
5
  import { ParsedOption } from './utils.js';
6
6
  export { GroupedEntry, ParsedOptionsResult, ToolUseInput, cn, createToolCall, extractTextContent, extractToolCallsFromGroup, formatFileSize, formatTimestamp, formatToolName, generateToolSummary, getActionIcon, getActionLabel, groupEntriesForCompactMode, mapToolToActionType, normalizeToolResult, parseCommandResult, parseMcpToolName, parseOptionsFromContent, truncate, updateToolCallWithResult } from './utils.js';
7
- export { AlertCircleIcon, AlertTriangleIcon, BotIcon, BrainIcon, BugIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, ClipboardListIcon, CodeIcon, CopyIcon, EditIcon, FileIcon, FilePlusIcon, FolderSearchIcon, GlobeIcon, IconProps, InfoIcon, ListChecksIcon, LoaderIcon, MessageSquareIcon, MoonIcon, PaperclipIcon, PlugIcon, SearchIcon, SendIcon, SparklesIcon, StopCircleIcon, SunIcon, TerminalIcon, ToolIcon, UserIcon, XCircleIcon, XIcon } from './icons.js';
7
+ export { AlertCircleIcon, AlertTriangleIcon, BotIcon, BrainIcon, BugIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, ClipboardListIcon, CodeIcon, CopyIcon, EditIcon, ErrorIcon, FileIcon, FilePlusIcon, FolderSearchIcon, GlobeIcon, IconProps, InfoIcon, ListChecksIcon, LoaderIcon, MessageSquareIcon, MoonIcon, PaperclipIcon, PlugIcon, SearchIcon, SendIcon, SparklesIcon, SpinnerIcon, StopCircleIcon, SunIcon, TerminalIcon, ToolIcon, UserIcon, XCircleIcon, XIcon } from './icons.js';
8
8
  export { BorderRadius, Colors, Keyframes, Shadows, Spacing, Transitions, Typography, Widget, ZIndex, allKeyframesCss, borderRadius, colors, inlineStyles, keyframes, keyframesCss, shadows, spacing, tokensToCssVariables, transitions, typography, widget, zIndex } from './design-tokens.js';
9
9
 
10
10
  interface ToolCallCardProps {
@@ -41,6 +41,29 @@ interface MessageListProps {
41
41
  displayConfig?: ToolDisplayConfig;
42
42
  /** Callback when user selects an option from assistant message */
43
43
  onOptionSelect?: (optionText: string) => void;
44
+ /**
45
+ * Custom render function for widget entries.
46
+ * When provided, widget entries will be rendered using this function.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * <MessageList
51
+ * entries={entries}
52
+ * renderWidget={({ widgetType, widgetData, onAction }) => {
53
+ * if (widgetType === 'image-grid') {
54
+ * return <ImageGrid data={widgetData} onSelect={onAction} />;
55
+ * }
56
+ * return null;
57
+ * }}
58
+ * />
59
+ * ```
60
+ */
61
+ renderWidget?: WidgetRenderFunction;
62
+ /**
63
+ * Callback for widget interactions (e.g., selection, submit).
64
+ * Called when widgets dispatch actions via their onAction callback.
65
+ */
66
+ onWidgetAction?: (action: WidgetAction) => void;
44
67
  /** Additional class names */
45
68
  className?: string;
46
69
  }
@@ -64,7 +87,7 @@ interface MessageListProps {
64
87
  * <MessageList entries={entries} displayConfig={{ mode: 'compact' }} />
65
88
  * ```
66
89
  */
67
- declare function MessageList({ entries, loading, streamingContent, displayConfig: displayConfigProp, onOptionSelect, className, }: MessageListProps): react_jsx_runtime.JSX.Element;
90
+ declare function MessageList({ entries, loading, streamingContent, displayConfig: displayConfigProp, onOptionSelect, renderWidget, onWidgetAction, className, }: MessageListProps): react_jsx_runtime.JSX.Element;
68
91
 
69
92
  interface UserMessageProps {
70
93
  entry: NormalizedEntry;
@@ -382,12 +405,15 @@ interface DisplayModeToggleProps {
382
405
  labels?: {
383
406
  inline?: string;
384
407
  compact?: string;
408
+ accordion?: string;
385
409
  };
410
+ /** Which modes to cycle through (default: all three) */
411
+ modes?: ToolDisplayMode[];
386
412
  }
387
413
  /**
388
- * DisplayModeToggle - Button to toggle between inline and compact display modes
414
+ * DisplayModeToggle - Button to cycle through display modes
389
415
  *
390
- * Uses the DisplayModeContext to toggle between 'inline' and 'compact' modes.
416
+ * Uses the DisplayModeContext to cycle through 'inline', 'compact', and 'accordion' modes.
391
417
  * Must be used within a DisplayModeProvider.
392
418
  *
393
419
  * @example
@@ -411,7 +437,39 @@ interface DisplayModeToggleProps {
411
437
  * }
412
438
  * ```
413
439
  */
414
- declare function DisplayModeToggle({ className, showLabel, labels, }: DisplayModeToggleProps): react_jsx_runtime.JSX.Element;
440
+ declare function DisplayModeToggle({ className, showLabel, labels, modes, }: DisplayModeToggleProps): react_jsx_runtime.JSX.Element;
441
+
442
+ type StepStatus = 'pending' | 'running' | 'success' | 'error';
443
+ interface StepAccordionProps {
444
+ /** Tool calls to display as steps */
445
+ toolCalls: NormalizedToolCall[];
446
+ /** Whether the accordion starts expanded */
447
+ defaultExpanded?: boolean;
448
+ /** Controlled expanded state */
449
+ isExpanded?: boolean;
450
+ /** Callback when expanded state changes */
451
+ onToggle?: () => void;
452
+ /** Additional class names */
453
+ className?: string;
454
+ }
455
+ /**
456
+ * StepAccordion - Simpler accordion that shows tool calls as numbered steps
457
+ *
458
+ * Features:
459
+ * - Collapsed header shows current running step or completion status
460
+ * - Expanded view shows all steps as a numbered list
461
+ * - Shows step duration for completed steps
462
+ * - Compact design suitable for embedding in chat
463
+ *
464
+ * @example
465
+ * ```tsx
466
+ * <StepAccordion
467
+ * toolCalls={normalizedToolCalls}
468
+ * defaultExpanded={false}
469
+ * />
470
+ * ```
471
+ */
472
+ declare function StepAccordion({ toolCalls, defaultExpanded, isExpanded: controlledExpanded, onToggle, className, }: StepAccordionProps): react_jsx_runtime.JSX.Element | null;
415
473
 
416
474
  interface StatusIndicatorProps {
417
475
  status: ToolStatus;
@@ -840,4 +898,4 @@ interface UseFileUploadReturn {
840
898
  declare function useFileUpload({ maxFileSize, // 100MB
841
899
  maxFiles, onValidationError, }?: UseFileUploadOptions): UseFileUploadReturn;
842
900
 
843
- export { ActionIcon, type ActionIconProps, ActionType, AssistantMessage, type AssistantMessageProps, type FileAttachment as ChatFileAttachment, CodeBlock, type CodeBlockProps, CompactToolStatusLine, type CompactToolStatusLineProps, type DisplayModeContextType, DisplayModeProvider, type DisplayModeProviderProps, DisplayModeToggle, type DisplayModeToggleProps, EnvVarsPanel, type EnvVarsPanelProps, ErrorMessage, type ErrorMessageProps, JsonDisplay, type JsonDisplayProps, LoadingIndicator, type LoadingIndicatorProps, LogEntry, LogsPanel, type LogsPanelProps, MessageEntry, type MessageEntryProps, MessageList, type MessageListProps, NormalizedEntry, NormalizedToolCall, OptionCards, type OptionCardsProps, ParsedOption, type QueuedMessage, StatusIndicator, type StatusIndicatorProps, StreamingText, type StreamingTextProps, type Theme, type ThemeContextType, ThemeProvider, type ThemeProviderProps, ThinkingMessage, type ThinkingMessageProps, TodoItem, TodoPanel, type TodoPanelProps, ToolCallCard, type ToolCallCardProps, ToolCallMessage, type ToolCallMessageProps, ToolDisplayConfig, ToolDisplayMode, ToolExecutionGroup, type ToolExecutionGroupProps, ToolStatus, TypewriterText, type TypewriterTextProps, type UseFileUploadOptions, type UseFileUploadReturn, type UseMessageQueueOptions, type UseMessageQueueReturn, type UseStopExecutionOptions, type UseStopExecutionReturn, UserMessage, type UserMessageProps, useDisplayConfig, useDisplayMode, useFileUpload, useMessageQueue, useStopExecution, useTheme };
901
+ export { ActionIcon, type ActionIconProps, ActionType, AssistantMessage, type AssistantMessageProps, type FileAttachment as ChatFileAttachment, CodeBlock, type CodeBlockProps, CompactToolStatusLine, type CompactToolStatusLineProps, type DisplayModeContextType, DisplayModeProvider, type DisplayModeProviderProps, DisplayModeToggle, type DisplayModeToggleProps, EnvVarsPanel, type EnvVarsPanelProps, ErrorMessage, type ErrorMessageProps, JsonDisplay, type JsonDisplayProps, LoadingIndicator, type LoadingIndicatorProps, LogEntry, LogsPanel, type LogsPanelProps, MessageEntry, type MessageEntryProps, MessageList, type MessageListProps, NormalizedEntry, NormalizedToolCall, OptionCards, type OptionCardsProps, ParsedOption, type QueuedMessage, StatusIndicator, type StatusIndicatorProps, StepAccordion, type StepAccordionProps, type StepStatus, StreamingText, type StreamingTextProps, type Theme, type ThemeContextType, ThemeProvider, type ThemeProviderProps, ThinkingMessage, type ThinkingMessageProps, TodoItem, TodoPanel, type TodoPanelProps, ToolCallCard, type ToolCallCardProps, ToolCallMessage, type ToolCallMessageProps, ToolDisplayConfig, ToolDisplayMode, ToolExecutionGroup, type ToolExecutionGroupProps, ToolStatus, TypewriterText, type TypewriterTextProps, type UseFileUploadOptions, type UseFileUploadReturn, type UseMessageQueueOptions, type UseMessageQueueReturn, type UseStopExecutionOptions, type UseStopExecutionReturn, UserMessage, type UserMessageProps, WidgetAction, WidgetRenderFunction, useDisplayConfig, useDisplayMode, useFileUpload, useMessageQueue, useStopExecution, useTheme };
package/dist/index.js CHANGED
@@ -630,6 +630,16 @@ function ClipboardListIcon({ className }) {
630
630
  /* @__PURE__ */ jsx("path", { d: "M8 16h.01" })
631
631
  ] });
632
632
  }
633
+ function SpinnerIcon({ className }) {
634
+ return /* @__PURE__ */ jsx("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) });
635
+ }
636
+ function ErrorIcon({ className }) {
637
+ return /* @__PURE__ */ jsxs("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
638
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
639
+ /* @__PURE__ */ jsx("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
640
+ /* @__PURE__ */ jsx("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
641
+ ] });
642
+ }
633
643
  function StatusIndicator({ status, size = "sm", className }) {
634
644
  const sizeClasses = {
635
645
  sm: "w-2 h-2",
@@ -1528,6 +1538,163 @@ function ToolExecutionGroup({
1528
1538
  }
1529
1539
  );
1530
1540
  }
1541
+ function formatDuration(startMs, endMs) {
1542
+ const duration = endMs - startMs;
1543
+ if (duration < 1e3) return `${duration}ms`;
1544
+ return `${(duration / 1e3).toFixed(1)}s`;
1545
+ }
1546
+ function getToolLabel(toolName, summary) {
1547
+ if (summary && summary.length > 0 && summary.length < 50) {
1548
+ return summary;
1549
+ }
1550
+ const cleaned = toolName.replace(/^mcp__[^_]+__/, "").replace(/Tool$/, "").replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2");
1551
+ return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
1552
+ }
1553
+ function toStepStatus(status) {
1554
+ switch (status) {
1555
+ case "pending":
1556
+ return "running";
1557
+ case "success":
1558
+ return "success";
1559
+ case "failed":
1560
+ return "error";
1561
+ default:
1562
+ return "pending";
1563
+ }
1564
+ }
1565
+ function StepIcon({ status }) {
1566
+ const iconClass = "w-3.5 h-3.5";
1567
+ switch (status) {
1568
+ case "running":
1569
+ return /* @__PURE__ */ jsx(SpinnerIcon, { className: cn(iconClass, "animate-spin text-[var(--ash-accent)]") });
1570
+ case "success":
1571
+ return /* @__PURE__ */ jsx(CheckIcon, { className: cn(iconClass, "text-[var(--ash-accent)]") });
1572
+ case "error":
1573
+ return /* @__PURE__ */ jsx(ErrorIcon, { className: cn(iconClass, "text-red-500") });
1574
+ default:
1575
+ return /* @__PURE__ */ jsx(ToolIcon, { className: cn(iconClass, "text-white/40") });
1576
+ }
1577
+ }
1578
+ function StepAccordion({
1579
+ toolCalls,
1580
+ defaultExpanded = false,
1581
+ isExpanded: controlledExpanded,
1582
+ onToggle,
1583
+ className
1584
+ }) {
1585
+ const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
1586
+ const isExpanded = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
1587
+ const handleToggle = useCallback(() => {
1588
+ if (onToggle) {
1589
+ onToggle();
1590
+ } else {
1591
+ setInternalExpanded((prev) => !prev);
1592
+ }
1593
+ }, [onToggle]);
1594
+ if (toolCalls.length === 0) {
1595
+ return null;
1596
+ }
1597
+ const completedSteps = toolCalls.filter((tc) => tc.status === "success" || tc.status === "failed").length;
1598
+ const runningStep = toolCalls.find((tc) => tc.status === "pending");
1599
+ const hasError = toolCalls.some((tc) => tc.status === "failed");
1600
+ const allComplete = completedSteps === toolCalls.length;
1601
+ return /* @__PURE__ */ jsxs(
1602
+ "div",
1603
+ {
1604
+ className: cn(
1605
+ "rounded-xl border overflow-hidden",
1606
+ hasError ? "border-red-500/30" : allComplete ? "border-[var(--ash-accent)]/30" : "border-yellow-500/30",
1607
+ className
1608
+ ),
1609
+ children: [
1610
+ /* @__PURE__ */ jsxs(
1611
+ "button",
1612
+ {
1613
+ type: "button",
1614
+ onClick: handleToggle,
1615
+ className: "w-full flex items-center gap-2 px-3 py-2 bg-white/5 hover:bg-white/10 transition-colors text-left cursor-pointer",
1616
+ children: [
1617
+ /* @__PURE__ */ jsx(
1618
+ ChevronDownIcon,
1619
+ {
1620
+ className: cn(
1621
+ "w-4 h-4 text-white/40 transition-transform duration-200 flex-shrink-0",
1622
+ !isExpanded && "-rotate-90"
1623
+ )
1624
+ }
1625
+ ),
1626
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0 flex items-center gap-2", children: runningStep ? /* @__PURE__ */ jsxs(Fragment, { children: [
1627
+ /* @__PURE__ */ jsx(SpinnerIcon, { className: "w-3.5 h-3.5 animate-spin text-[var(--ash-accent)] flex-shrink-0" }),
1628
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-white/80 truncate", children: getToolLabel(runningStep.toolName, runningStep.summary) })
1629
+ ] }) : hasError ? /* @__PURE__ */ jsxs(Fragment, { children: [
1630
+ /* @__PURE__ */ jsx(ErrorIcon, { className: "w-3.5 h-3.5 text-red-500 flex-shrink-0" }),
1631
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-red-400 truncate", children: "Completed with errors" })
1632
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1633
+ /* @__PURE__ */ jsx(CheckIcon, { className: "w-3.5 h-3.5 text-[var(--ash-accent)] flex-shrink-0" }),
1634
+ /* @__PURE__ */ jsxs("span", { className: "text-sm text-white/70 truncate", children: [
1635
+ completedSteps,
1636
+ " step",
1637
+ completedSteps !== 1 ? "s" : "",
1638
+ " completed"
1639
+ ] })
1640
+ ] }) }),
1641
+ /* @__PURE__ */ jsxs("span", { className: "text-xs px-1.5 py-0.5 rounded-full bg-white/10 text-white/50 flex-shrink-0", children: [
1642
+ completedSteps,
1643
+ "/",
1644
+ toolCalls.length
1645
+ ] })
1646
+ ]
1647
+ }
1648
+ ),
1649
+ isExpanded && /* @__PURE__ */ jsx("div", { className: "border-t border-white/10 ash-accordion-content", children: /* @__PURE__ */ jsx("div", { className: "divide-y divide-white/5", children: toolCalls.map((toolCall, index) => {
1650
+ const stepStatus = toStepStatus(toolCall.status);
1651
+ const startTime = toolCall.startedAt ? new Date(toolCall.startedAt).getTime() : 0;
1652
+ const endTime = toolCall.completedAt ? new Date(toolCall.completedAt).getTime() : 0;
1653
+ const hasDuration = startTime > 0 && endTime > 0;
1654
+ return /* @__PURE__ */ jsxs(
1655
+ "div",
1656
+ {
1657
+ className: cn(
1658
+ "px-3 py-2 flex items-start gap-2",
1659
+ stepStatus === "running" && "bg-[var(--ash-accent)]/5",
1660
+ stepStatus === "error" && "bg-red-500/5"
1661
+ ),
1662
+ children: [
1663
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 flex-shrink-0 pt-0.5", children: [
1664
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-white/40 w-4 text-right", children: [
1665
+ index + 1,
1666
+ "."
1667
+ ] }),
1668
+ /* @__PURE__ */ jsx(StepIcon, { status: stepStatus })
1669
+ ] }),
1670
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
1671
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1672
+ /* @__PURE__ */ jsx(
1673
+ "span",
1674
+ {
1675
+ className: cn(
1676
+ "text-sm",
1677
+ stepStatus === "running" && "text-[var(--ash-accent)]",
1678
+ stepStatus === "success" && "text-white/70",
1679
+ stepStatus === "error" && "text-red-400",
1680
+ stepStatus === "pending" && "text-white/40"
1681
+ ),
1682
+ children: getToolLabel(toolCall.toolName, toolCall.summary)
1683
+ }
1684
+ ),
1685
+ hasDuration && (stepStatus === "success" || stepStatus === "error") && /* @__PURE__ */ jsx("span", { className: "text-xs text-white/40", children: formatDuration(startTime, endTime) })
1686
+ ] }),
1687
+ toolCall.isError && toolCall.actionType && "result" in toolCall.actionType && /* @__PURE__ */ jsx("p", { className: "text-xs mt-1 text-red-400/80 truncate", children: String(toolCall.actionType.result?.value || "Error") })
1688
+ ] })
1689
+ ]
1690
+ },
1691
+ toolCall.id
1692
+ );
1693
+ }) }) })
1694
+ ]
1695
+ }
1696
+ );
1697
+ }
1531
1698
 
1532
1699
  // src/types.ts
1533
1700
  function isCommandRunAction(action) {
@@ -1569,6 +1736,9 @@ function isToolCallEntry(entry) {
1569
1736
  function isErrorEntry(entry) {
1570
1737
  return entry.type === "error";
1571
1738
  }
1739
+ function isWidgetEntry(entry) {
1740
+ return entry.type === "widget";
1741
+ }
1572
1742
  var DEFAULT_DISPLAY_CONFIG = {
1573
1743
  mode: "inline",
1574
1744
  breakEveryNToolCalls: 0,
@@ -1624,10 +1794,25 @@ function MessageList({
1624
1794
  streamingContent,
1625
1795
  displayConfig: displayConfigProp,
1626
1796
  onOptionSelect,
1797
+ renderWidget,
1798
+ onWidgetAction,
1627
1799
  className
1628
1800
  }) {
1629
1801
  const contextConfig = useDisplayConfig();
1630
1802
  const config = displayConfigProp || contextConfig;
1803
+ const createWidgetActionHandler = useCallback(
1804
+ (entryId, widgetType) => {
1805
+ if (!onWidgetAction) return void 0;
1806
+ return (action) => {
1807
+ onWidgetAction({
1808
+ ...action,
1809
+ entryId,
1810
+ widgetType
1811
+ });
1812
+ };
1813
+ },
1814
+ [onWidgetAction]
1815
+ );
1631
1816
  const groupedEntries = useMemo(() => {
1632
1817
  if (config.mode === "inline") {
1633
1818
  return entries.map((entry) => ({
@@ -1641,12 +1826,31 @@ function MessageList({
1641
1826
  return /* @__PURE__ */ jsxs("div", { className: cn("flex-1 overflow-y-auto p-4 space-y-4 ash-scrollbar", className), children: [
1642
1827
  groupedEntries.map((groupedEntry) => {
1643
1828
  if (groupedEntry.type === "single") {
1644
- return /* @__PURE__ */ jsx(MessageEntry, { entry: groupedEntry.entry, onOptionSelect }, groupedEntry.entry.id);
1829
+ const entry = groupedEntry.entry;
1830
+ if (entry.entryType.type === "widget" && renderWidget) {
1831
+ const widgetEntry = entry.entryType;
1832
+ const widgetContent = renderWidget({
1833
+ entry,
1834
+ widgetType: widgetEntry.widgetType,
1835
+ widgetData: widgetEntry.widgetData,
1836
+ onAction: createWidgetActionHandler(entry.id, widgetEntry.widgetType)
1837
+ });
1838
+ if (widgetContent !== null) {
1839
+ return /* @__PURE__ */ jsx("div", { className: "ash-animate-fade-in", children: widgetContent }, entry.id);
1840
+ }
1841
+ }
1842
+ return /* @__PURE__ */ jsx(MessageEntry, { entry, onOptionSelect }, entry.id);
1645
1843
  }
1646
1844
  const toolCalls = extractToolCallsFromGroup(groupedEntry.entries);
1647
1845
  return /* @__PURE__ */ jsxs("div", { className: "flex gap-3 ash-animate-fade-in", children: [
1648
1846
  /* @__PURE__ */ jsx("div", { className: "w-7 h-7 rounded-full bg-[var(--ash-accent)]/20 flex items-center justify-center shrink-0", children: /* @__PURE__ */ jsx(BotIcon, { className: "w-4 h-4 text-[var(--ash-accent)]" }) }),
1649
- /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
1847
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: config.mode === "accordion" ? /* @__PURE__ */ jsx(
1848
+ StepAccordion,
1849
+ {
1850
+ toolCalls,
1851
+ defaultExpanded: config.defaultExpanded
1852
+ }
1853
+ ) : /* @__PURE__ */ jsx(
1650
1854
  ToolExecutionGroup,
1651
1855
  {
1652
1856
  toolCalls,
@@ -2066,19 +2270,22 @@ function EnvVarsPanel({
2066
2270
  function DisplayModeToggle({
2067
2271
  className,
2068
2272
  showLabel = true,
2069
- labels = { inline: "Inline", compact: "Compact" }
2273
+ labels = { inline: "Inline", compact: "Compact", accordion: "Steps" },
2274
+ modes = ["inline", "compact", "accordion"]
2070
2275
  }) {
2071
- const { config, toggleMode } = useDisplayMode();
2072
- const isInline = config.mode === "inline";
2073
- return /* @__PURE__ */ jsx(
2074
- "button",
2075
- {
2076
- type: "button",
2077
- onClick: toggleMode,
2078
- className: cn("ash-display-mode-toggle", className),
2079
- title: isInline ? "Switch to compact mode" : "Switch to inline mode",
2080
- children: isInline ? /* @__PURE__ */ jsxs(Fragment, { children: [
2081
- /* @__PURE__ */ jsx(
2276
+ const { config, setMode } = useDisplayMode();
2277
+ const currentMode = config.mode;
2278
+ const currentIndex = modes.indexOf(currentMode);
2279
+ const effectiveIndex = currentIndex === -1 ? 0 : currentIndex;
2280
+ const nextIndex = (effectiveIndex + 1) % modes.length;
2281
+ const nextMode = modes[nextIndex];
2282
+ const handleClick = () => {
2283
+ setMode(nextMode);
2284
+ };
2285
+ const getIcon = (mode) => {
2286
+ switch (mode) {
2287
+ case "inline":
2288
+ return /* @__PURE__ */ jsx(
2082
2289
  "svg",
2083
2290
  {
2084
2291
  className: "ash-display-mode-icon",
@@ -2095,10 +2302,9 @@ function DisplayModeToggle({
2095
2302
  }
2096
2303
  )
2097
2304
  }
2098
- ),
2099
- showLabel && /* @__PURE__ */ jsx("span", { className: "ash-display-mode-label", children: labels.inline })
2100
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2101
- /* @__PURE__ */ jsx(
2305
+ );
2306
+ case "compact":
2307
+ return /* @__PURE__ */ jsx(
2102
2308
  "svg",
2103
2309
  {
2104
2310
  className: "ash-display-mode-icon",
@@ -2115,9 +2321,42 @@ function DisplayModeToggle({
2115
2321
  }
2116
2322
  )
2117
2323
  }
2118
- ),
2119
- showLabel && /* @__PURE__ */ jsx("span", { className: "ash-display-mode-label", children: labels.compact })
2120
- ] })
2324
+ );
2325
+ case "accordion":
2326
+ return /* @__PURE__ */ jsx(
2327
+ "svg",
2328
+ {
2329
+ className: "ash-display-mode-icon",
2330
+ viewBox: "0 0 24 24",
2331
+ fill: "none",
2332
+ stroke: "currentColor",
2333
+ strokeWidth: "1.5",
2334
+ children: /* @__PURE__ */ jsx(
2335
+ "path",
2336
+ {
2337
+ strokeLinecap: "round",
2338
+ strokeLinejoin: "round",
2339
+ d: "M8.25 6.75h12M8.25 12h12M8.25 17.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"
2340
+ }
2341
+ )
2342
+ }
2343
+ );
2344
+ }
2345
+ };
2346
+ const getLabel = (mode) => {
2347
+ return labels[mode] || mode.charAt(0).toUpperCase() + mode.slice(1);
2348
+ };
2349
+ return /* @__PURE__ */ jsxs(
2350
+ "button",
2351
+ {
2352
+ type: "button",
2353
+ onClick: handleClick,
2354
+ className: cn("ash-display-mode-toggle", className),
2355
+ title: `Switch to ${nextMode} mode`,
2356
+ children: [
2357
+ getIcon(currentMode),
2358
+ showLabel && /* @__PURE__ */ jsx("span", { className: "ash-display-mode-label", children: getLabel(currentMode) })
2359
+ ]
2121
2360
  }
2122
2361
  );
2123
2362
  }
@@ -2729,6 +2968,6 @@ function useFileUpload({
2729
2968
  };
2730
2969
  }
2731
2970
 
2732
- export { ActionIcon, AlertCircleIcon, AlertTriangleIcon, AssistantMessage, BotIcon, BrainIcon, BugIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, ClipboardListIcon, CodeBlock, CodeIcon, CompactToolStatusLine, CopyIcon, DEFAULT_DISPLAY_CONFIG, DisplayModeProvider, DisplayModeToggle, EditIcon, EnvVarsPanel, ErrorMessage, FileIcon, FilePlusIcon, FolderSearchIcon, GlobeIcon, InfoIcon, JsonDisplay, ListChecksIcon, LoaderIcon, LoadingIndicator, LogsPanel, MessageEntry, MessageList, MessageSquareIcon, MoonIcon, OptionCards, PaperclipIcon, PlugIcon, SearchIcon, SendIcon, SparklesIcon, StatusIndicator, StopCircleIcon, StreamingText, SunIcon, TerminalIcon, ThemeProvider, ThinkingMessage, TodoPanel, ToolCallCard, ToolCallMessage, ToolExecutionGroup, ToolIcon, TypewriterText, UserIcon, UserMessage, XCircleIcon, XIcon, allKeyframesCss, borderRadius, cn, colors, createToolCall, extractTextContent, extractToolCallsFromGroup, formatFileSize, formatTimestamp, formatToolName, generateToolSummary, getActionIcon, getActionLabel, groupEntriesForCompactMode, inlineStyles, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, keyframes, keyframesCss, mapToolToActionType, normalizeToolResult, parseCommandResult, parseMcpToolName, parseOptionsFromContent, shadows, spacing, tokensToCssVariables, transitions, truncate, typography, updateToolCallWithResult, useDisplayConfig, useDisplayMode, useFileUpload, useMessageQueue, useStopExecution, useTheme, widget, zIndex };
2971
+ export { ActionIcon, AlertCircleIcon, AlertTriangleIcon, AssistantMessage, BotIcon, BrainIcon, BugIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, ClipboardListIcon, CodeBlock, CodeIcon, CompactToolStatusLine, CopyIcon, DEFAULT_DISPLAY_CONFIG, DisplayModeProvider, DisplayModeToggle, EditIcon, EnvVarsPanel, ErrorIcon, ErrorMessage, FileIcon, FilePlusIcon, FolderSearchIcon, GlobeIcon, InfoIcon, JsonDisplay, ListChecksIcon, LoaderIcon, LoadingIndicator, LogsPanel, MessageEntry, MessageList, MessageSquareIcon, MoonIcon, OptionCards, PaperclipIcon, PlugIcon, SearchIcon, SendIcon, SparklesIcon, SpinnerIcon, StatusIndicator, StepAccordion, StopCircleIcon, StreamingText, SunIcon, TerminalIcon, ThemeProvider, ThinkingMessage, TodoPanel, ToolCallCard, ToolCallMessage, ToolExecutionGroup, ToolIcon, TypewriterText, UserIcon, UserMessage, XCircleIcon, XIcon, allKeyframesCss, borderRadius, cn, colors, createToolCall, extractTextContent, extractToolCallsFromGroup, formatFileSize, formatTimestamp, formatToolName, generateToolSummary, getActionIcon, getActionLabel, groupEntriesForCompactMode, inlineStyles, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry, keyframes, keyframesCss, mapToolToActionType, normalizeToolResult, parseCommandResult, parseMcpToolName, parseOptionsFromContent, shadows, spacing, tokensToCssVariables, transitions, truncate, typography, updateToolCallWithResult, useDisplayConfig, useDisplayMode, useFileUpload, useMessageQueue, useStopExecution, useTheme, widget, zIndex };
2733
2972
  //# sourceMappingURL=index.js.map
2734
2973
  //# sourceMappingURL=index.js.map