@cadraos/sdk 0.1.6 → 0.1.7
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/chat/index.cjs +1046 -34
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +173 -7
- package/dist/chat/index.d.ts +173 -7
- package/dist/chat/index.js +1046 -37
- package/dist/chat/index.js.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/package.json +3 -3
package/dist/chat/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Components } from 'react-markdown';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
|
+
import React__default from 'react';
|
|
4
5
|
|
|
5
6
|
interface MarkdownContentProps {
|
|
6
7
|
/** Markdown content to render */
|
|
@@ -188,11 +189,19 @@ interface AttachmentFile {
|
|
|
188
189
|
/** Original file object */
|
|
189
190
|
file: File;
|
|
190
191
|
/** Upload status */
|
|
191
|
-
status: "pending" | "uploading" | "ready" | "failed";
|
|
192
|
+
status: "pending" | "uploading" | "processing" | "ready" | "error" | "failed";
|
|
192
193
|
/** Preview URL for local display */
|
|
193
194
|
previewUrl?: string;
|
|
194
195
|
/** Progress percentage (0-100) */
|
|
195
|
-
progress
|
|
196
|
+
progress: number;
|
|
197
|
+
/** File category */
|
|
198
|
+
category: "document" | "image" | "audio";
|
|
199
|
+
/** Error message when status is "error" */
|
|
200
|
+
error?: string;
|
|
201
|
+
/** Whether a thumbnail has been generated */
|
|
202
|
+
hasThumbnail?: boolean;
|
|
203
|
+
/** Override file.size for external attachments where actual File is empty */
|
|
204
|
+
actualSize?: number;
|
|
196
205
|
}
|
|
197
206
|
|
|
198
207
|
interface ChatMessageProps {
|
|
@@ -370,7 +379,11 @@ interface ExecuteInput {
|
|
|
370
379
|
context?: Record<string, unknown>;
|
|
371
380
|
/** Attachment UUIDs to include with the message (for images, documents, etc.) */
|
|
372
381
|
attachmentIds?: string[];
|
|
373
|
-
/**
|
|
382
|
+
/**
|
|
383
|
+
* Team UUID for team-based execution (routes to team's lead orchestrator).
|
|
384
|
+
* @deprecated Pass the team UUID directly as the agent/entity ID instead.
|
|
385
|
+
* The platform now auto-detects whether a UUID is an agent, team, or tool.
|
|
386
|
+
*/
|
|
374
387
|
teamUuid?: string;
|
|
375
388
|
/** Execution options */
|
|
376
389
|
options?: ExecuteOptions;
|
|
@@ -1167,7 +1180,7 @@ interface AgentChatProps {
|
|
|
1167
1180
|
className?: string;
|
|
1168
1181
|
/** Theme mode */
|
|
1169
1182
|
theme?: ThemeMode;
|
|
1170
|
-
/** Enable file attachments
|
|
1183
|
+
/** Enable file attachments */
|
|
1171
1184
|
enableAttachments?: boolean;
|
|
1172
1185
|
/** Enable markdown rendering */
|
|
1173
1186
|
enableMarkdown?: boolean;
|
|
@@ -1195,6 +1208,7 @@ interface AgentChatProps {
|
|
|
1195
1208
|
* <ChatConfigProvider config={{ baseUrl: '...', apiKey: '...' }}>
|
|
1196
1209
|
* <AgentChat
|
|
1197
1210
|
* agentId="agent-uuid"
|
|
1211
|
+
* enableAttachments
|
|
1198
1212
|
* onMessage={(msg) => console.log('New message:', msg)}
|
|
1199
1213
|
* />
|
|
1200
1214
|
* </ChatConfigProvider>
|
|
@@ -2855,6 +2869,13 @@ interface UseAgentChatOptions {
|
|
|
2855
2869
|
/** Callback fired when clarification is needed */
|
|
2856
2870
|
onClarification?: (data: ClarificationData) => void;
|
|
2857
2871
|
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Options for sendMessage
|
|
2874
|
+
*/
|
|
2875
|
+
interface SendMessageOptions {
|
|
2876
|
+
/** UUIDs of attached files to include with the message */
|
|
2877
|
+
attachmentUuids?: string[];
|
|
2878
|
+
}
|
|
2858
2879
|
interface UseAgentChatResult {
|
|
2859
2880
|
/** Current messages in the chat */
|
|
2860
2881
|
messages: ChatMessage$1[];
|
|
@@ -2871,7 +2892,7 @@ interface UseAgentChatResult {
|
|
|
2871
2892
|
/** Current clarification request if any */
|
|
2872
2893
|
clarification: ClarificationData | null;
|
|
2873
2894
|
/** Send a message to the agent */
|
|
2874
|
-
sendMessage: (content: string) => Promise<void>;
|
|
2895
|
+
sendMessage: (content: string, options?: SendMessageOptions) => Promise<void>;
|
|
2875
2896
|
/** Respond to a clarification request */
|
|
2876
2897
|
respondToClarification: (response: string) => Promise<void>;
|
|
2877
2898
|
/** Cancel the current execution */
|
|
@@ -2978,6 +2999,122 @@ interface UseExecutionStreamResult {
|
|
|
2978
2999
|
*/
|
|
2979
3000
|
declare function useExecutionStream(options: UseExecutionStreamOptions): UseExecutionStreamResult;
|
|
2980
3001
|
|
|
3002
|
+
/**
|
|
3003
|
+
* FileDropZone - Reusable file upload component with drag-and-drop
|
|
3004
|
+
*
|
|
3005
|
+
* Supports drag-and-drop file upload with visual feedback, file validation,
|
|
3006
|
+
* image compression, upload progress tracking, and thumbnail previews.
|
|
3007
|
+
*
|
|
3008
|
+
* Two modes:
|
|
3009
|
+
* - Standalone: renders a drop zone UI (default)
|
|
3010
|
+
* - Wrapper: wraps children with a drag-drop overlay (when children provided)
|
|
3011
|
+
*
|
|
3012
|
+
* @packageDocumentation
|
|
3013
|
+
*/
|
|
3014
|
+
|
|
3015
|
+
interface FileDropZoneProps {
|
|
3016
|
+
files: AttachmentFile[];
|
|
3017
|
+
onFilesChange: (files: AttachmentFile[]) => void;
|
|
3018
|
+
/** Upload a file. Return the UUID and presigned URL. If uploadUrl is empty, the S3 PUT step is skipped. */
|
|
3019
|
+
onUpload: (file: File, metadata: {
|
|
3020
|
+
filename: string;
|
|
3021
|
+
mimeType: string;
|
|
3022
|
+
size: number;
|
|
3023
|
+
}) => Promise<{
|
|
3024
|
+
uuid: string;
|
|
3025
|
+
uploadUrl: string;
|
|
3026
|
+
}>;
|
|
3027
|
+
/** Confirm the upload after S3 PUT succeeds */
|
|
3028
|
+
onConfirmUpload?: (uuid: string) => Promise<void>;
|
|
3029
|
+
/** Error callback instead of toast */
|
|
3030
|
+
onError?: (message: string) => void;
|
|
3031
|
+
maxFiles?: number;
|
|
3032
|
+
maxTotalSizeMB?: number;
|
|
3033
|
+
disabled?: boolean;
|
|
3034
|
+
className?: string;
|
|
3035
|
+
/** Restrict accepted file types, e.g. "image/*" */
|
|
3036
|
+
accept?: string;
|
|
3037
|
+
/** Compact mode for embedding in small panels */
|
|
3038
|
+
compact?: boolean;
|
|
3039
|
+
children?: React__default.ReactNode;
|
|
3040
|
+
}
|
|
3041
|
+
/** Ref interface for programmatic access to FileDropZone */
|
|
3042
|
+
interface FileDropZoneRef {
|
|
3043
|
+
/** Trigger the file selection dialog */
|
|
3044
|
+
openFileDialog: () => void;
|
|
3045
|
+
}
|
|
3046
|
+
declare const FileDropZone: React__default.ForwardRefExoticComponent<FileDropZoneProps & React__default.RefAttributes<FileDropZoneRef>>;
|
|
3047
|
+
|
|
3048
|
+
interface UseFileAttachmentsOptions {
|
|
3049
|
+
/**
|
|
3050
|
+
* Upload handler called immediately when files are dropped/selected.
|
|
3051
|
+
* Return the UUID and a presigned upload URL.
|
|
3052
|
+
* If uploadUrl is empty, the S3 PUT step in FileDropZone is skipped
|
|
3053
|
+
* (useful for direct-upload patterns where the upload happens here).
|
|
3054
|
+
*/
|
|
3055
|
+
onUpload: (file: File, metadata: {
|
|
3056
|
+
filename: string;
|
|
3057
|
+
mimeType: string;
|
|
3058
|
+
size: number;
|
|
3059
|
+
}) => Promise<{
|
|
3060
|
+
uuid: string;
|
|
3061
|
+
uploadUrl: string;
|
|
3062
|
+
}>;
|
|
3063
|
+
/** Optional confirm callback after S3 PUT succeeds */
|
|
3064
|
+
onConfirmUpload?: (uuid: string) => Promise<void>;
|
|
3065
|
+
/**
|
|
3066
|
+
* Deferred upload handler called during prepareForSubmit().
|
|
3067
|
+
* Use this for two-phase upload patterns where files are uploaded to local
|
|
3068
|
+
* storage on drop, but a second upload to an AI service happens on submit.
|
|
3069
|
+
*
|
|
3070
|
+
* Receives the file and localUuid (from onUpload) and should return
|
|
3071
|
+
* the AI service's attachment UUID.
|
|
3072
|
+
*
|
|
3073
|
+
* If not provided, prepareForSubmit() returns the UUIDs from onUpload as-is.
|
|
3074
|
+
*/
|
|
3075
|
+
onSubmitUpload?: (file: File, localUuid: string, metadata: {
|
|
3076
|
+
filename: string;
|
|
3077
|
+
mimeType: string;
|
|
3078
|
+
size: number;
|
|
3079
|
+
}) => Promise<string>;
|
|
3080
|
+
/** Error handler */
|
|
3081
|
+
onError?: (message: string) => void;
|
|
3082
|
+
/** Maximum number of files (default: 10) */
|
|
3083
|
+
maxFiles?: number;
|
|
3084
|
+
/** Maximum total upload size in MB (default: 100) */
|
|
3085
|
+
maxTotalSizeMB?: number;
|
|
3086
|
+
}
|
|
3087
|
+
interface UseFileAttachmentsResult {
|
|
3088
|
+
/** Current attachment files */
|
|
3089
|
+
files: AttachmentFile[];
|
|
3090
|
+
/**
|
|
3091
|
+
* Props to spread onto FileDropZone.
|
|
3092
|
+
* Includes: files, onFilesChange, onUpload, onConfirmUpload, onError, maxFiles, maxTotalSizeMB
|
|
3093
|
+
*/
|
|
3094
|
+
dropZoneProps: Pick<FileDropZoneProps, "files" | "onFilesChange" | "onUpload" | "onConfirmUpload" | "onError" | "maxFiles" | "maxTotalSizeMB">;
|
|
3095
|
+
/** Remove a file by UUID */
|
|
3096
|
+
removeFile: (uuid: string) => void;
|
|
3097
|
+
/** Get UUIDs of ready (uploaded) attachments — for Cadra adapter pattern */
|
|
3098
|
+
getReadyUuids: () => string[];
|
|
3099
|
+
/** Get UUIDs of ready attachments as URLs — for direct-upload pattern where uuid IS the url */
|
|
3100
|
+
getReadyUrls: () => string[];
|
|
3101
|
+
/**
|
|
3102
|
+
* Two-phase submit: uploads ready files to the AI service via onSubmitUpload,
|
|
3103
|
+
* returns the AI service attachment UUIDs. Call this on Generate/Remix.
|
|
3104
|
+
* If onSubmitUpload is not configured, returns getReadyUuids().
|
|
3105
|
+
*/
|
|
3106
|
+
prepareForSubmit: () => Promise<string[]>;
|
|
3107
|
+
/** Clear all attachments (revokes preview URLs) */
|
|
3108
|
+
clear: () => void;
|
|
3109
|
+
/** Whether any files are currently uploading */
|
|
3110
|
+
isUploading: boolean;
|
|
3111
|
+
/** Whether there are files ready to send */
|
|
3112
|
+
hasReadyFiles: boolean;
|
|
3113
|
+
/** Total number of files */
|
|
3114
|
+
fileCount: number;
|
|
3115
|
+
}
|
|
3116
|
+
declare function useFileAttachments(options: UseFileAttachmentsOptions): UseFileAttachmentsResult;
|
|
3117
|
+
|
|
2981
3118
|
interface ChatContainerProps {
|
|
2982
3119
|
/** Child components (MessageList, ChatInput, etc.) */
|
|
2983
3120
|
children: React$1.ReactNode;
|
|
@@ -3014,6 +3151,14 @@ interface ChatInputProps {
|
|
|
3014
3151
|
isLoading?: boolean;
|
|
3015
3152
|
/** Whether to enable attachments */
|
|
3016
3153
|
enableAttachments?: boolean;
|
|
3154
|
+
/** Current attachment files (when enableAttachments is true) */
|
|
3155
|
+
attachments?: AttachmentFile[];
|
|
3156
|
+
/** Callback to remove an attachment */
|
|
3157
|
+
onRemoveAttachment?: (uuid: string) => void;
|
|
3158
|
+
/** Ref to FileDropZone for triggering file dialog */
|
|
3159
|
+
dropZoneRef?: React$1.RefObject<FileDropZoneRef | null>;
|
|
3160
|
+
/** Whether attachments are currently uploading */
|
|
3161
|
+
isUploadingAttachments?: boolean;
|
|
3017
3162
|
/** Additional CSS classes */
|
|
3018
3163
|
className?: string;
|
|
3019
3164
|
}
|
|
@@ -3031,7 +3176,7 @@ interface ChatInputProps {
|
|
|
3031
3176
|
* />
|
|
3032
3177
|
* ```
|
|
3033
3178
|
*/
|
|
3034
|
-
declare function ChatInput({ onSend, onStop, placeholder, disabled, isLoading, enableAttachments, className, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
3179
|
+
declare function ChatInput({ onSend, onStop, placeholder, disabled, isLoading, enableAttachments, attachments, onRemoveAttachment, dropZoneRef, isUploadingAttachments, className, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
3035
3180
|
|
|
3036
3181
|
interface ToolCallEntryProps {
|
|
3037
3182
|
/** Tool call data */
|
|
@@ -3163,4 +3308,25 @@ declare function HelpCircleIcon({ className, ...props }: IconProps): react_jsx_r
|
|
|
3163
3308
|
declare function DatabaseIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
|
|
3164
3309
|
declare function ClockIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
|
|
3165
3310
|
|
|
3166
|
-
|
|
3311
|
+
/**
|
|
3312
|
+
* Client-side image compression using Canvas API.
|
|
3313
|
+
*
|
|
3314
|
+
* Resizes images to max 1920px on longest side and iteratively
|
|
3315
|
+
* reduces JPEG/WebP quality to hit a ~150KB target size.
|
|
3316
|
+
* Skips SVGs, non-image files, and files already under the target.
|
|
3317
|
+
*/
|
|
3318
|
+
/**
|
|
3319
|
+
* Compress an image file to approximately targetSizeKB using Canvas API.
|
|
3320
|
+
*
|
|
3321
|
+
* - Returns the original file if it's already under targetSizeKB
|
|
3322
|
+
* - Skips SVGs and non-image files (returns as-is)
|
|
3323
|
+
* - Resizes to max 1920px on longest side
|
|
3324
|
+
* - Iteratively reduces quality to approach target size
|
|
3325
|
+
*
|
|
3326
|
+
* @param file - The File to compress
|
|
3327
|
+
* @param targetSizeKB - Target output size in KB (default: 150)
|
|
3328
|
+
* @returns Compressed File, or the original if no compression needed
|
|
3329
|
+
*/
|
|
3330
|
+
declare function compressImage(file: File, targetSizeKB?: number): Promise<File>;
|
|
3331
|
+
|
|
3332
|
+
export { AgentChat, type AgentChatProps, AlertCircleIcon, type Artifact$1 as Artifact, AskUserPrompt, type AskUserPromptProps, type AttachmentData, type AttachmentFile, BotIcon, type ChatAdapter, ChatConfigProvider, type ChatConfigProviderProps, ChatContainer, type ChatContainerProps, type ChatError, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, type ClarificationData, ClockIcon, CodeIcon, CopyIcon, DatabaseIcon, type DefaultAdapterConfig, DownloadIcon, type Execution, type ExecutionResult, type ExecutionStreamEvent, ExternalLinkIcon, FileDropZone, type FileDropZoneProps, type FileDropZoneRef, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, type IconProps, ImageIcon, ImagesIcon, type ListSessionsInput, ListTodoIcon, LoadingSpinner, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput$1 as SendMessageInput, type SendMessageOptions, type SessionHistory$1 as SessionHistory, type SessionList, type SessionListItem, SparklesIcon, type StartExecutionInput, StopCircleIcon, type ThemeMode, type ThinkingBlock, type TodoItem, TodoList, type TodoListProps, type ToolCall, ToolCallEntry, type ToolCallEntryProps, type UploadUrlInput, type UploadUrlResult, type UseAgentChatOptions, type UseAgentChatResult, type UseExecutionStreamOptions, type UseExecutionStreamResult, type UseFileAttachmentsOptions, type UseFileAttachmentsResult, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments };
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Components } from 'react-markdown';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
|
+
import React__default from 'react';
|
|
4
5
|
|
|
5
6
|
interface MarkdownContentProps {
|
|
6
7
|
/** Markdown content to render */
|
|
@@ -188,11 +189,19 @@ interface AttachmentFile {
|
|
|
188
189
|
/** Original file object */
|
|
189
190
|
file: File;
|
|
190
191
|
/** Upload status */
|
|
191
|
-
status: "pending" | "uploading" | "ready" | "failed";
|
|
192
|
+
status: "pending" | "uploading" | "processing" | "ready" | "error" | "failed";
|
|
192
193
|
/** Preview URL for local display */
|
|
193
194
|
previewUrl?: string;
|
|
194
195
|
/** Progress percentage (0-100) */
|
|
195
|
-
progress
|
|
196
|
+
progress: number;
|
|
197
|
+
/** File category */
|
|
198
|
+
category: "document" | "image" | "audio";
|
|
199
|
+
/** Error message when status is "error" */
|
|
200
|
+
error?: string;
|
|
201
|
+
/** Whether a thumbnail has been generated */
|
|
202
|
+
hasThumbnail?: boolean;
|
|
203
|
+
/** Override file.size for external attachments where actual File is empty */
|
|
204
|
+
actualSize?: number;
|
|
196
205
|
}
|
|
197
206
|
|
|
198
207
|
interface ChatMessageProps {
|
|
@@ -370,7 +379,11 @@ interface ExecuteInput {
|
|
|
370
379
|
context?: Record<string, unknown>;
|
|
371
380
|
/** Attachment UUIDs to include with the message (for images, documents, etc.) */
|
|
372
381
|
attachmentIds?: string[];
|
|
373
|
-
/**
|
|
382
|
+
/**
|
|
383
|
+
* Team UUID for team-based execution (routes to team's lead orchestrator).
|
|
384
|
+
* @deprecated Pass the team UUID directly as the agent/entity ID instead.
|
|
385
|
+
* The platform now auto-detects whether a UUID is an agent, team, or tool.
|
|
386
|
+
*/
|
|
374
387
|
teamUuid?: string;
|
|
375
388
|
/** Execution options */
|
|
376
389
|
options?: ExecuteOptions;
|
|
@@ -1167,7 +1180,7 @@ interface AgentChatProps {
|
|
|
1167
1180
|
className?: string;
|
|
1168
1181
|
/** Theme mode */
|
|
1169
1182
|
theme?: ThemeMode;
|
|
1170
|
-
/** Enable file attachments
|
|
1183
|
+
/** Enable file attachments */
|
|
1171
1184
|
enableAttachments?: boolean;
|
|
1172
1185
|
/** Enable markdown rendering */
|
|
1173
1186
|
enableMarkdown?: boolean;
|
|
@@ -1195,6 +1208,7 @@ interface AgentChatProps {
|
|
|
1195
1208
|
* <ChatConfigProvider config={{ baseUrl: '...', apiKey: '...' }}>
|
|
1196
1209
|
* <AgentChat
|
|
1197
1210
|
* agentId="agent-uuid"
|
|
1211
|
+
* enableAttachments
|
|
1198
1212
|
* onMessage={(msg) => console.log('New message:', msg)}
|
|
1199
1213
|
* />
|
|
1200
1214
|
* </ChatConfigProvider>
|
|
@@ -2855,6 +2869,13 @@ interface UseAgentChatOptions {
|
|
|
2855
2869
|
/** Callback fired when clarification is needed */
|
|
2856
2870
|
onClarification?: (data: ClarificationData) => void;
|
|
2857
2871
|
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Options for sendMessage
|
|
2874
|
+
*/
|
|
2875
|
+
interface SendMessageOptions {
|
|
2876
|
+
/** UUIDs of attached files to include with the message */
|
|
2877
|
+
attachmentUuids?: string[];
|
|
2878
|
+
}
|
|
2858
2879
|
interface UseAgentChatResult {
|
|
2859
2880
|
/** Current messages in the chat */
|
|
2860
2881
|
messages: ChatMessage$1[];
|
|
@@ -2871,7 +2892,7 @@ interface UseAgentChatResult {
|
|
|
2871
2892
|
/** Current clarification request if any */
|
|
2872
2893
|
clarification: ClarificationData | null;
|
|
2873
2894
|
/** Send a message to the agent */
|
|
2874
|
-
sendMessage: (content: string) => Promise<void>;
|
|
2895
|
+
sendMessage: (content: string, options?: SendMessageOptions) => Promise<void>;
|
|
2875
2896
|
/** Respond to a clarification request */
|
|
2876
2897
|
respondToClarification: (response: string) => Promise<void>;
|
|
2877
2898
|
/** Cancel the current execution */
|
|
@@ -2978,6 +2999,122 @@ interface UseExecutionStreamResult {
|
|
|
2978
2999
|
*/
|
|
2979
3000
|
declare function useExecutionStream(options: UseExecutionStreamOptions): UseExecutionStreamResult;
|
|
2980
3001
|
|
|
3002
|
+
/**
|
|
3003
|
+
* FileDropZone - Reusable file upload component with drag-and-drop
|
|
3004
|
+
*
|
|
3005
|
+
* Supports drag-and-drop file upload with visual feedback, file validation,
|
|
3006
|
+
* image compression, upload progress tracking, and thumbnail previews.
|
|
3007
|
+
*
|
|
3008
|
+
* Two modes:
|
|
3009
|
+
* - Standalone: renders a drop zone UI (default)
|
|
3010
|
+
* - Wrapper: wraps children with a drag-drop overlay (when children provided)
|
|
3011
|
+
*
|
|
3012
|
+
* @packageDocumentation
|
|
3013
|
+
*/
|
|
3014
|
+
|
|
3015
|
+
interface FileDropZoneProps {
|
|
3016
|
+
files: AttachmentFile[];
|
|
3017
|
+
onFilesChange: (files: AttachmentFile[]) => void;
|
|
3018
|
+
/** Upload a file. Return the UUID and presigned URL. If uploadUrl is empty, the S3 PUT step is skipped. */
|
|
3019
|
+
onUpload: (file: File, metadata: {
|
|
3020
|
+
filename: string;
|
|
3021
|
+
mimeType: string;
|
|
3022
|
+
size: number;
|
|
3023
|
+
}) => Promise<{
|
|
3024
|
+
uuid: string;
|
|
3025
|
+
uploadUrl: string;
|
|
3026
|
+
}>;
|
|
3027
|
+
/** Confirm the upload after S3 PUT succeeds */
|
|
3028
|
+
onConfirmUpload?: (uuid: string) => Promise<void>;
|
|
3029
|
+
/** Error callback instead of toast */
|
|
3030
|
+
onError?: (message: string) => void;
|
|
3031
|
+
maxFiles?: number;
|
|
3032
|
+
maxTotalSizeMB?: number;
|
|
3033
|
+
disabled?: boolean;
|
|
3034
|
+
className?: string;
|
|
3035
|
+
/** Restrict accepted file types, e.g. "image/*" */
|
|
3036
|
+
accept?: string;
|
|
3037
|
+
/** Compact mode for embedding in small panels */
|
|
3038
|
+
compact?: boolean;
|
|
3039
|
+
children?: React__default.ReactNode;
|
|
3040
|
+
}
|
|
3041
|
+
/** Ref interface for programmatic access to FileDropZone */
|
|
3042
|
+
interface FileDropZoneRef {
|
|
3043
|
+
/** Trigger the file selection dialog */
|
|
3044
|
+
openFileDialog: () => void;
|
|
3045
|
+
}
|
|
3046
|
+
declare const FileDropZone: React__default.ForwardRefExoticComponent<FileDropZoneProps & React__default.RefAttributes<FileDropZoneRef>>;
|
|
3047
|
+
|
|
3048
|
+
interface UseFileAttachmentsOptions {
|
|
3049
|
+
/**
|
|
3050
|
+
* Upload handler called immediately when files are dropped/selected.
|
|
3051
|
+
* Return the UUID and a presigned upload URL.
|
|
3052
|
+
* If uploadUrl is empty, the S3 PUT step in FileDropZone is skipped
|
|
3053
|
+
* (useful for direct-upload patterns where the upload happens here).
|
|
3054
|
+
*/
|
|
3055
|
+
onUpload: (file: File, metadata: {
|
|
3056
|
+
filename: string;
|
|
3057
|
+
mimeType: string;
|
|
3058
|
+
size: number;
|
|
3059
|
+
}) => Promise<{
|
|
3060
|
+
uuid: string;
|
|
3061
|
+
uploadUrl: string;
|
|
3062
|
+
}>;
|
|
3063
|
+
/** Optional confirm callback after S3 PUT succeeds */
|
|
3064
|
+
onConfirmUpload?: (uuid: string) => Promise<void>;
|
|
3065
|
+
/**
|
|
3066
|
+
* Deferred upload handler called during prepareForSubmit().
|
|
3067
|
+
* Use this for two-phase upload patterns where files are uploaded to local
|
|
3068
|
+
* storage on drop, but a second upload to an AI service happens on submit.
|
|
3069
|
+
*
|
|
3070
|
+
* Receives the file and localUuid (from onUpload) and should return
|
|
3071
|
+
* the AI service's attachment UUID.
|
|
3072
|
+
*
|
|
3073
|
+
* If not provided, prepareForSubmit() returns the UUIDs from onUpload as-is.
|
|
3074
|
+
*/
|
|
3075
|
+
onSubmitUpload?: (file: File, localUuid: string, metadata: {
|
|
3076
|
+
filename: string;
|
|
3077
|
+
mimeType: string;
|
|
3078
|
+
size: number;
|
|
3079
|
+
}) => Promise<string>;
|
|
3080
|
+
/** Error handler */
|
|
3081
|
+
onError?: (message: string) => void;
|
|
3082
|
+
/** Maximum number of files (default: 10) */
|
|
3083
|
+
maxFiles?: number;
|
|
3084
|
+
/** Maximum total upload size in MB (default: 100) */
|
|
3085
|
+
maxTotalSizeMB?: number;
|
|
3086
|
+
}
|
|
3087
|
+
interface UseFileAttachmentsResult {
|
|
3088
|
+
/** Current attachment files */
|
|
3089
|
+
files: AttachmentFile[];
|
|
3090
|
+
/**
|
|
3091
|
+
* Props to spread onto FileDropZone.
|
|
3092
|
+
* Includes: files, onFilesChange, onUpload, onConfirmUpload, onError, maxFiles, maxTotalSizeMB
|
|
3093
|
+
*/
|
|
3094
|
+
dropZoneProps: Pick<FileDropZoneProps, "files" | "onFilesChange" | "onUpload" | "onConfirmUpload" | "onError" | "maxFiles" | "maxTotalSizeMB">;
|
|
3095
|
+
/** Remove a file by UUID */
|
|
3096
|
+
removeFile: (uuid: string) => void;
|
|
3097
|
+
/** Get UUIDs of ready (uploaded) attachments — for Cadra adapter pattern */
|
|
3098
|
+
getReadyUuids: () => string[];
|
|
3099
|
+
/** Get UUIDs of ready attachments as URLs — for direct-upload pattern where uuid IS the url */
|
|
3100
|
+
getReadyUrls: () => string[];
|
|
3101
|
+
/**
|
|
3102
|
+
* Two-phase submit: uploads ready files to the AI service via onSubmitUpload,
|
|
3103
|
+
* returns the AI service attachment UUIDs. Call this on Generate/Remix.
|
|
3104
|
+
* If onSubmitUpload is not configured, returns getReadyUuids().
|
|
3105
|
+
*/
|
|
3106
|
+
prepareForSubmit: () => Promise<string[]>;
|
|
3107
|
+
/** Clear all attachments (revokes preview URLs) */
|
|
3108
|
+
clear: () => void;
|
|
3109
|
+
/** Whether any files are currently uploading */
|
|
3110
|
+
isUploading: boolean;
|
|
3111
|
+
/** Whether there are files ready to send */
|
|
3112
|
+
hasReadyFiles: boolean;
|
|
3113
|
+
/** Total number of files */
|
|
3114
|
+
fileCount: number;
|
|
3115
|
+
}
|
|
3116
|
+
declare function useFileAttachments(options: UseFileAttachmentsOptions): UseFileAttachmentsResult;
|
|
3117
|
+
|
|
2981
3118
|
interface ChatContainerProps {
|
|
2982
3119
|
/** Child components (MessageList, ChatInput, etc.) */
|
|
2983
3120
|
children: React$1.ReactNode;
|
|
@@ -3014,6 +3151,14 @@ interface ChatInputProps {
|
|
|
3014
3151
|
isLoading?: boolean;
|
|
3015
3152
|
/** Whether to enable attachments */
|
|
3016
3153
|
enableAttachments?: boolean;
|
|
3154
|
+
/** Current attachment files (when enableAttachments is true) */
|
|
3155
|
+
attachments?: AttachmentFile[];
|
|
3156
|
+
/** Callback to remove an attachment */
|
|
3157
|
+
onRemoveAttachment?: (uuid: string) => void;
|
|
3158
|
+
/** Ref to FileDropZone for triggering file dialog */
|
|
3159
|
+
dropZoneRef?: React$1.RefObject<FileDropZoneRef | null>;
|
|
3160
|
+
/** Whether attachments are currently uploading */
|
|
3161
|
+
isUploadingAttachments?: boolean;
|
|
3017
3162
|
/** Additional CSS classes */
|
|
3018
3163
|
className?: string;
|
|
3019
3164
|
}
|
|
@@ -3031,7 +3176,7 @@ interface ChatInputProps {
|
|
|
3031
3176
|
* />
|
|
3032
3177
|
* ```
|
|
3033
3178
|
*/
|
|
3034
|
-
declare function ChatInput({ onSend, onStop, placeholder, disabled, isLoading, enableAttachments, className, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
3179
|
+
declare function ChatInput({ onSend, onStop, placeholder, disabled, isLoading, enableAttachments, attachments, onRemoveAttachment, dropZoneRef, isUploadingAttachments, className, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
3035
3180
|
|
|
3036
3181
|
interface ToolCallEntryProps {
|
|
3037
3182
|
/** Tool call data */
|
|
@@ -3163,4 +3308,25 @@ declare function HelpCircleIcon({ className, ...props }: IconProps): react_jsx_r
|
|
|
3163
3308
|
declare function DatabaseIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
|
|
3164
3309
|
declare function ClockIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
|
|
3165
3310
|
|
|
3166
|
-
|
|
3311
|
+
/**
|
|
3312
|
+
* Client-side image compression using Canvas API.
|
|
3313
|
+
*
|
|
3314
|
+
* Resizes images to max 1920px on longest side and iteratively
|
|
3315
|
+
* reduces JPEG/WebP quality to hit a ~150KB target size.
|
|
3316
|
+
* Skips SVGs, non-image files, and files already under the target.
|
|
3317
|
+
*/
|
|
3318
|
+
/**
|
|
3319
|
+
* Compress an image file to approximately targetSizeKB using Canvas API.
|
|
3320
|
+
*
|
|
3321
|
+
* - Returns the original file if it's already under targetSizeKB
|
|
3322
|
+
* - Skips SVGs and non-image files (returns as-is)
|
|
3323
|
+
* - Resizes to max 1920px on longest side
|
|
3324
|
+
* - Iteratively reduces quality to approach target size
|
|
3325
|
+
*
|
|
3326
|
+
* @param file - The File to compress
|
|
3327
|
+
* @param targetSizeKB - Target output size in KB (default: 150)
|
|
3328
|
+
* @returns Compressed File, or the original if no compression needed
|
|
3329
|
+
*/
|
|
3330
|
+
declare function compressImage(file: File, targetSizeKB?: number): Promise<File>;
|
|
3331
|
+
|
|
3332
|
+
export { AgentChat, type AgentChatProps, AlertCircleIcon, type Artifact$1 as Artifact, AskUserPrompt, type AskUserPromptProps, type AttachmentData, type AttachmentFile, BotIcon, type ChatAdapter, ChatConfigProvider, type ChatConfigProviderProps, ChatContainer, type ChatContainerProps, type ChatError, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, type ClarificationData, ClockIcon, CodeIcon, CopyIcon, DatabaseIcon, type DefaultAdapterConfig, DownloadIcon, type Execution, type ExecutionResult, type ExecutionStreamEvent, ExternalLinkIcon, FileDropZone, type FileDropZoneProps, type FileDropZoneRef, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, type IconProps, ImageIcon, ImagesIcon, type ListSessionsInput, ListTodoIcon, LoadingSpinner, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput$1 as SendMessageInput, type SendMessageOptions, type SessionHistory$1 as SessionHistory, type SessionList, type SessionListItem, SparklesIcon, type StartExecutionInput, StopCircleIcon, type ThemeMode, type ThinkingBlock, type TodoItem, TodoList, type TodoListProps, type ToolCall, ToolCallEntry, type ToolCallEntryProps, type UploadUrlInput, type UploadUrlResult, type UseAgentChatOptions, type UseAgentChatResult, type UseExecutionStreamOptions, type UseExecutionStreamResult, type UseFileAttachmentsOptions, type UseFileAttachmentsResult, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments };
|