@ash-cloud/ash-ui 0.0.1 → 0.0.2

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,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { NormalizedToolCall, NormalizedEntry, ToolDisplayConfig, LogEntry, ToolDisplayMode, TodoItem, ToolStatus, ActionType } from './types.cjs';
3
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';
4
- import { ReactNode } from 'react';
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
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';
@@ -532,4 +532,235 @@ interface ThemeProviderProps {
532
532
  declare function ThemeProvider({ children, defaultTheme, storageKey, listenToSystemChanges, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
533
533
  declare function useTheme(): ThemeContextType;
534
534
 
535
- export { ActionIcon, type ActionIconProps, ActionType, AssistantMessage, type AssistantMessageProps, CodeBlock, type CodeBlockProps, CompactToolStatusLine, type CompactToolStatusLineProps, type DisplayModeContextType, DisplayModeProvider, type DisplayModeProviderProps, 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, 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, UserMessage, type UserMessageProps, useDisplayConfig, useDisplayMode, useTheme };
535
+ /**
536
+ * A queued message waiting to be sent
537
+ */
538
+ interface QueuedMessage {
539
+ /** Unique ID for this queued message */
540
+ id: string;
541
+ /** The message text */
542
+ text: string;
543
+ /** Optional file attachments */
544
+ files?: FileAttachment$1[];
545
+ /** Timestamp when queued */
546
+ queuedAt: number;
547
+ }
548
+ /**
549
+ * File attachment for upload
550
+ */
551
+ interface FileAttachment$1 {
552
+ /** Original filename */
553
+ filename: string;
554
+ /** Base64-encoded file content */
555
+ content: string;
556
+ /** MIME type of the file */
557
+ mimeType: string;
558
+ /** File size in bytes */
559
+ size: number;
560
+ }
561
+ interface UseMessageQueueOptions {
562
+ /** Callback to process a message - should return when processing is complete */
563
+ onProcessMessage: (message: QueuedMessage) => Promise<void>;
564
+ /** Whether messages can currently be processed (e.g., agent selected) */
565
+ canProcess?: boolean;
566
+ }
567
+ interface UseMessageQueueReturn {
568
+ /** Current queue of pending messages */
569
+ queue: QueuedMessage[];
570
+ /** Whether a message is currently being processed */
571
+ isProcessing: boolean;
572
+ /** Add a message to the queue (or process immediately if idle) */
573
+ enqueue: (text: string, files?: FileAttachment$1[]) => void;
574
+ /** Cancel a queued message by ID */
575
+ cancel: (id: string) => void;
576
+ /** Clear all queued messages */
577
+ clearQueue: () => void;
578
+ /** Number of messages in queue */
579
+ queueLength: number;
580
+ }
581
+ /**
582
+ * Hook for managing a message queue with sequential processing.
583
+ *
584
+ * Messages are queued when the agent is busy and processed sequentially.
585
+ * Users can continue typing while the agent processes previous messages.
586
+ *
587
+ * @example
588
+ * ```tsx
589
+ * function ChatInput() {
590
+ * const { queue, isProcessing, enqueue, cancel } = useMessageQueue({
591
+ * onProcessMessage: async (msg) => {
592
+ * for await (const event of client.agents.run(agentId, msg.text)) {
593
+ * // handle events
594
+ * }
595
+ * }
596
+ * });
597
+ *
598
+ * return (
599
+ * <div>
600
+ * {queue.map(msg => (
601
+ * <div key={msg.id}>
602
+ * Queued: {msg.text}
603
+ * <button onClick={() => cancel(msg.id)}>Cancel</button>
604
+ * </div>
605
+ * ))}
606
+ * <input onSubmit={(text) => enqueue(text)} />
607
+ * <button>{isProcessing ? `Queue (${queue.length})` : 'Send'}</button>
608
+ * </div>
609
+ * );
610
+ * }
611
+ * ```
612
+ */
613
+ declare function useMessageQueue({ onProcessMessage, canProcess, }: UseMessageQueueOptions): UseMessageQueueReturn;
614
+
615
+ interface UseStopExecutionOptions {
616
+ /** Callback to stop server-side execution (e.g., client.sessions.stop) */
617
+ onServerStop?: (sessionId: string) => Promise<void>;
618
+ }
619
+ interface UseStopExecutionReturn {
620
+ /** Whether execution can currently be stopped */
621
+ canStop: boolean;
622
+ /** The AbortSignal to pass to fetch requests */
623
+ signal: AbortSignal | undefined;
624
+ /** Start tracking a new execution (call when starting a request) */
625
+ startExecution: () => void;
626
+ /** Mark execution as complete (call when request finishes) */
627
+ endExecution: () => void;
628
+ /** Stop the current execution (aborts client + optionally server) */
629
+ stop: (sessionId?: string) => Promise<void>;
630
+ /** Set the current session ID for server-side stop */
631
+ setSessionId: (sessionId: string | null) => void;
632
+ }
633
+ /**
634
+ * Hook for managing execution stopping with AbortController.
635
+ *
636
+ * Handles both client-side request abortion and optional server-side stop calls.
637
+ * Use this to implement stop/cancel buttons for long-running agent executions.
638
+ *
639
+ * @example
640
+ * ```tsx
641
+ * function Chat() {
642
+ * const { canStop, signal, startExecution, endExecution, stop, setSessionId } = useStopExecution({
643
+ * onServerStop: (sessionId) => client.sessions.stop(sessionId)
644
+ * });
645
+ *
646
+ * async function sendMessage(text: string) {
647
+ * startExecution();
648
+ * try {
649
+ * for await (const event of client.agents.run(agentId, text, { signal })) {
650
+ * if (event.type === 'session_start') {
651
+ * setSessionId(event.sessionId);
652
+ * }
653
+ * // handle events...
654
+ * }
655
+ * } catch (err) {
656
+ * if (err.name === 'AbortError') {
657
+ * console.log('Request aborted');
658
+ * }
659
+ * } finally {
660
+ * endExecution();
661
+ * }
662
+ * }
663
+ *
664
+ * return (
665
+ * <div>
666
+ * {canStop && <button onClick={() => stop()}>Stop</button>}
667
+ * </div>
668
+ * );
669
+ * }
670
+ * ```
671
+ */
672
+ declare function useStopExecution({ onServerStop, }?: UseStopExecutionOptions): UseStopExecutionReturn;
673
+
674
+ /**
675
+ * File attachment ready for upload
676
+ */
677
+ interface FileAttachment {
678
+ /** Original filename */
679
+ filename: string;
680
+ /** Base64-encoded file content (without data URL prefix) */
681
+ content: string;
682
+ /** MIME type of the file */
683
+ mimeType: string;
684
+ /** File size in bytes */
685
+ size: number;
686
+ }
687
+ interface UseFileUploadOptions {
688
+ /** Maximum file size in bytes (default: 100MB) */
689
+ maxFileSize?: number;
690
+ /** Maximum number of files (default: 10) */
691
+ maxFiles?: number;
692
+ /** Callback when file validation fails */
693
+ onValidationError?: (filename: string, error: string) => void;
694
+ }
695
+ interface UseFileUploadReturn {
696
+ /** Current list of attached files */
697
+ files: FileAttachment[];
698
+ /** Whether drag is currently over the drop zone */
699
+ isDragOver: boolean;
700
+ /** Add files from a FileList (e.g., from input or drop) */
701
+ addFiles: (fileList: FileList | null) => Promise<void>;
702
+ /** Remove a file by index */
703
+ removeFile: (index: number) => void;
704
+ /** Clear all files */
705
+ clearFiles: () => void;
706
+ /** Whether more files can be added */
707
+ canAddMore: boolean;
708
+ /** Props to spread on a drop zone element */
709
+ dropZoneProps: {
710
+ onDragOver: (e: DragEvent) => void;
711
+ onDragLeave: (e: DragEvent) => void;
712
+ onDrop: (e: DragEvent) => void;
713
+ };
714
+ /** Handler for file input onChange */
715
+ handleFileInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
716
+ /** Ref for a hidden file input */
717
+ fileInputRef: React.RefObject<HTMLInputElement | null>;
718
+ /** Click handler to trigger file input */
719
+ openFilePicker: () => void;
720
+ }
721
+ /**
722
+ * Hook for managing file uploads with drag & drop support.
723
+ *
724
+ * Handles file selection, validation, base64 encoding, and drag/drop UI state.
725
+ *
726
+ * @example
727
+ * ```tsx
728
+ * function FileUploadArea() {
729
+ * const {
730
+ * files,
731
+ * isDragOver,
732
+ * addFiles,
733
+ * removeFile,
734
+ * dropZoneProps,
735
+ * fileInputRef,
736
+ * openFilePicker,
737
+ * canAddMore,
738
+ * } = useFileUpload({
739
+ * maxFileSize: 50 * 1024 * 1024, // 50MB
740
+ * maxFiles: 5,
741
+ * onValidationError: (filename, error) => {
742
+ * toast.error(`${filename}: ${error}`);
743
+ * }
744
+ * });
745
+ *
746
+ * return (
747
+ * <div {...dropZoneProps} className={isDragOver ? 'drag-over' : ''}>
748
+ * <input ref={fileInputRef} type="file" multiple hidden />
749
+ * <button onClick={openFilePicker} disabled={!canAddMore}>
750
+ * Add Files
751
+ * </button>
752
+ * {files.map((file, i) => (
753
+ * <div key={i}>
754
+ * {file.filename} ({formatFileSize(file.size)})
755
+ * <button onClick={() => removeFile(i)}>Remove</button>
756
+ * </div>
757
+ * ))}
758
+ * </div>
759
+ * );
760
+ * }
761
+ * ```
762
+ */
763
+ declare function useFileUpload({ maxFileSize, // 100MB
764
+ maxFiles, onValidationError, }?: UseFileUploadOptions): UseFileUploadReturn;
765
+
766
+ export { ActionIcon, type ActionIconProps, ActionType, AssistantMessage, type AssistantMessageProps, type FileAttachment as ChatFileAttachment, CodeBlock, type CodeBlockProps, CompactToolStatusLine, type CompactToolStatusLineProps, type DisplayModeContextType, DisplayModeProvider, type DisplayModeProviderProps, 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 };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { NormalizedToolCall, NormalizedEntry, ToolDisplayConfig, LogEntry, ToolDisplayMode, TodoItem, ToolStatus, ActionType } from './types.js';
3
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';
4
- import { ReactNode } from 'react';
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
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';
@@ -532,4 +532,235 @@ interface ThemeProviderProps {
532
532
  declare function ThemeProvider({ children, defaultTheme, storageKey, listenToSystemChanges, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
533
533
  declare function useTheme(): ThemeContextType;
534
534
 
535
- export { ActionIcon, type ActionIconProps, ActionType, AssistantMessage, type AssistantMessageProps, CodeBlock, type CodeBlockProps, CompactToolStatusLine, type CompactToolStatusLineProps, type DisplayModeContextType, DisplayModeProvider, type DisplayModeProviderProps, 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, 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, UserMessage, type UserMessageProps, useDisplayConfig, useDisplayMode, useTheme };
535
+ /**
536
+ * A queued message waiting to be sent
537
+ */
538
+ interface QueuedMessage {
539
+ /** Unique ID for this queued message */
540
+ id: string;
541
+ /** The message text */
542
+ text: string;
543
+ /** Optional file attachments */
544
+ files?: FileAttachment$1[];
545
+ /** Timestamp when queued */
546
+ queuedAt: number;
547
+ }
548
+ /**
549
+ * File attachment for upload
550
+ */
551
+ interface FileAttachment$1 {
552
+ /** Original filename */
553
+ filename: string;
554
+ /** Base64-encoded file content */
555
+ content: string;
556
+ /** MIME type of the file */
557
+ mimeType: string;
558
+ /** File size in bytes */
559
+ size: number;
560
+ }
561
+ interface UseMessageQueueOptions {
562
+ /** Callback to process a message - should return when processing is complete */
563
+ onProcessMessage: (message: QueuedMessage) => Promise<void>;
564
+ /** Whether messages can currently be processed (e.g., agent selected) */
565
+ canProcess?: boolean;
566
+ }
567
+ interface UseMessageQueueReturn {
568
+ /** Current queue of pending messages */
569
+ queue: QueuedMessage[];
570
+ /** Whether a message is currently being processed */
571
+ isProcessing: boolean;
572
+ /** Add a message to the queue (or process immediately if idle) */
573
+ enqueue: (text: string, files?: FileAttachment$1[]) => void;
574
+ /** Cancel a queued message by ID */
575
+ cancel: (id: string) => void;
576
+ /** Clear all queued messages */
577
+ clearQueue: () => void;
578
+ /** Number of messages in queue */
579
+ queueLength: number;
580
+ }
581
+ /**
582
+ * Hook for managing a message queue with sequential processing.
583
+ *
584
+ * Messages are queued when the agent is busy and processed sequentially.
585
+ * Users can continue typing while the agent processes previous messages.
586
+ *
587
+ * @example
588
+ * ```tsx
589
+ * function ChatInput() {
590
+ * const { queue, isProcessing, enqueue, cancel } = useMessageQueue({
591
+ * onProcessMessage: async (msg) => {
592
+ * for await (const event of client.agents.run(agentId, msg.text)) {
593
+ * // handle events
594
+ * }
595
+ * }
596
+ * });
597
+ *
598
+ * return (
599
+ * <div>
600
+ * {queue.map(msg => (
601
+ * <div key={msg.id}>
602
+ * Queued: {msg.text}
603
+ * <button onClick={() => cancel(msg.id)}>Cancel</button>
604
+ * </div>
605
+ * ))}
606
+ * <input onSubmit={(text) => enqueue(text)} />
607
+ * <button>{isProcessing ? `Queue (${queue.length})` : 'Send'}</button>
608
+ * </div>
609
+ * );
610
+ * }
611
+ * ```
612
+ */
613
+ declare function useMessageQueue({ onProcessMessage, canProcess, }: UseMessageQueueOptions): UseMessageQueueReturn;
614
+
615
+ interface UseStopExecutionOptions {
616
+ /** Callback to stop server-side execution (e.g., client.sessions.stop) */
617
+ onServerStop?: (sessionId: string) => Promise<void>;
618
+ }
619
+ interface UseStopExecutionReturn {
620
+ /** Whether execution can currently be stopped */
621
+ canStop: boolean;
622
+ /** The AbortSignal to pass to fetch requests */
623
+ signal: AbortSignal | undefined;
624
+ /** Start tracking a new execution (call when starting a request) */
625
+ startExecution: () => void;
626
+ /** Mark execution as complete (call when request finishes) */
627
+ endExecution: () => void;
628
+ /** Stop the current execution (aborts client + optionally server) */
629
+ stop: (sessionId?: string) => Promise<void>;
630
+ /** Set the current session ID for server-side stop */
631
+ setSessionId: (sessionId: string | null) => void;
632
+ }
633
+ /**
634
+ * Hook for managing execution stopping with AbortController.
635
+ *
636
+ * Handles both client-side request abortion and optional server-side stop calls.
637
+ * Use this to implement stop/cancel buttons for long-running agent executions.
638
+ *
639
+ * @example
640
+ * ```tsx
641
+ * function Chat() {
642
+ * const { canStop, signal, startExecution, endExecution, stop, setSessionId } = useStopExecution({
643
+ * onServerStop: (sessionId) => client.sessions.stop(sessionId)
644
+ * });
645
+ *
646
+ * async function sendMessage(text: string) {
647
+ * startExecution();
648
+ * try {
649
+ * for await (const event of client.agents.run(agentId, text, { signal })) {
650
+ * if (event.type === 'session_start') {
651
+ * setSessionId(event.sessionId);
652
+ * }
653
+ * // handle events...
654
+ * }
655
+ * } catch (err) {
656
+ * if (err.name === 'AbortError') {
657
+ * console.log('Request aborted');
658
+ * }
659
+ * } finally {
660
+ * endExecution();
661
+ * }
662
+ * }
663
+ *
664
+ * return (
665
+ * <div>
666
+ * {canStop && <button onClick={() => stop()}>Stop</button>}
667
+ * </div>
668
+ * );
669
+ * }
670
+ * ```
671
+ */
672
+ declare function useStopExecution({ onServerStop, }?: UseStopExecutionOptions): UseStopExecutionReturn;
673
+
674
+ /**
675
+ * File attachment ready for upload
676
+ */
677
+ interface FileAttachment {
678
+ /** Original filename */
679
+ filename: string;
680
+ /** Base64-encoded file content (without data URL prefix) */
681
+ content: string;
682
+ /** MIME type of the file */
683
+ mimeType: string;
684
+ /** File size in bytes */
685
+ size: number;
686
+ }
687
+ interface UseFileUploadOptions {
688
+ /** Maximum file size in bytes (default: 100MB) */
689
+ maxFileSize?: number;
690
+ /** Maximum number of files (default: 10) */
691
+ maxFiles?: number;
692
+ /** Callback when file validation fails */
693
+ onValidationError?: (filename: string, error: string) => void;
694
+ }
695
+ interface UseFileUploadReturn {
696
+ /** Current list of attached files */
697
+ files: FileAttachment[];
698
+ /** Whether drag is currently over the drop zone */
699
+ isDragOver: boolean;
700
+ /** Add files from a FileList (e.g., from input or drop) */
701
+ addFiles: (fileList: FileList | null) => Promise<void>;
702
+ /** Remove a file by index */
703
+ removeFile: (index: number) => void;
704
+ /** Clear all files */
705
+ clearFiles: () => void;
706
+ /** Whether more files can be added */
707
+ canAddMore: boolean;
708
+ /** Props to spread on a drop zone element */
709
+ dropZoneProps: {
710
+ onDragOver: (e: DragEvent) => void;
711
+ onDragLeave: (e: DragEvent) => void;
712
+ onDrop: (e: DragEvent) => void;
713
+ };
714
+ /** Handler for file input onChange */
715
+ handleFileInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
716
+ /** Ref for a hidden file input */
717
+ fileInputRef: React.RefObject<HTMLInputElement | null>;
718
+ /** Click handler to trigger file input */
719
+ openFilePicker: () => void;
720
+ }
721
+ /**
722
+ * Hook for managing file uploads with drag & drop support.
723
+ *
724
+ * Handles file selection, validation, base64 encoding, and drag/drop UI state.
725
+ *
726
+ * @example
727
+ * ```tsx
728
+ * function FileUploadArea() {
729
+ * const {
730
+ * files,
731
+ * isDragOver,
732
+ * addFiles,
733
+ * removeFile,
734
+ * dropZoneProps,
735
+ * fileInputRef,
736
+ * openFilePicker,
737
+ * canAddMore,
738
+ * } = useFileUpload({
739
+ * maxFileSize: 50 * 1024 * 1024, // 50MB
740
+ * maxFiles: 5,
741
+ * onValidationError: (filename, error) => {
742
+ * toast.error(`${filename}: ${error}`);
743
+ * }
744
+ * });
745
+ *
746
+ * return (
747
+ * <div {...dropZoneProps} className={isDragOver ? 'drag-over' : ''}>
748
+ * <input ref={fileInputRef} type="file" multiple hidden />
749
+ * <button onClick={openFilePicker} disabled={!canAddMore}>
750
+ * Add Files
751
+ * </button>
752
+ * {files.map((file, i) => (
753
+ * <div key={i}>
754
+ * {file.filename} ({formatFileSize(file.size)})
755
+ * <button onClick={() => removeFile(i)}>Remove</button>
756
+ * </div>
757
+ * ))}
758
+ * </div>
759
+ * );
760
+ * }
761
+ * ```
762
+ */
763
+ declare function useFileUpload({ maxFileSize, // 100MB
764
+ maxFiles, onValidationError, }?: UseFileUploadOptions): UseFileUploadReturn;
765
+
766
+ export { ActionIcon, type ActionIconProps, ActionType, AssistantMessage, type AssistantMessageProps, type FileAttachment as ChatFileAttachment, CodeBlock, type CodeBlockProps, CompactToolStatusLine, type CompactToolStatusLineProps, type DisplayModeContextType, DisplayModeProvider, type DisplayModeProviderProps, 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 };