@cadraos/sdk 0.1.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.
@@ -0,0 +1,974 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+
4
+ /**
5
+ * ChatAdapter interface for customizable API integration
6
+ *
7
+ * Implement this interface to:
8
+ * - Connect to different backends
9
+ * - Use direct DB access (in ai-saas-v2)
10
+ * - Mock for testing
11
+ *
12
+ * @module @cadraos/sdk/chat
13
+ */
14
+ /**
15
+ * Input for starting an agent execution
16
+ */
17
+ interface StartExecutionInput {
18
+ /** UUID of the agent to execute */
19
+ agentId: string;
20
+ /** Optional session ID for continuing a conversation */
21
+ sessionId?: string;
22
+ /** User message content */
23
+ content: string;
24
+ /** UUIDs of attached files */
25
+ attachmentUuids?: string[];
26
+ }
27
+ /**
28
+ * Input for sending a message in an existing session
29
+ */
30
+ interface SendMessageInput {
31
+ /** Session ID */
32
+ sessionId: string;
33
+ /** Message content */
34
+ content: string;
35
+ /** UUIDs of attached files */
36
+ attachmentUuids?: string[];
37
+ }
38
+ /**
39
+ * Input for getting an upload URL
40
+ */
41
+ interface UploadUrlInput {
42
+ /** Session ID */
43
+ sessionId: string;
44
+ /** Filename */
45
+ filename: string;
46
+ /** MIME type */
47
+ mimeType: string;
48
+ /** File size in bytes */
49
+ size: number;
50
+ }
51
+ /**
52
+ * Result from starting an execution
53
+ */
54
+ interface ExecutionResult {
55
+ /** UUID of the created execution */
56
+ executionId: string;
57
+ /** UUID of the session (new or existing) */
58
+ sessionId: string;
59
+ }
60
+ /**
61
+ * Result from getting an upload URL
62
+ */
63
+ interface UploadUrlResult {
64
+ /** Pre-signed upload URL */
65
+ uploadUrl: string;
66
+ /** UUID for the attachment */
67
+ attachmentUuid: string;
68
+ }
69
+ /**
70
+ * Execution status and result
71
+ */
72
+ interface Execution {
73
+ /** Execution UUID */
74
+ uuid: string;
75
+ /** Current status */
76
+ status: "pending" | "running" | "completed" | "failed" | "cancelled";
77
+ /** Final result (when completed) */
78
+ result?: string;
79
+ /** Error message (when failed) */
80
+ error?: string;
81
+ }
82
+ /**
83
+ * Artifact generated during execution
84
+ */
85
+ interface Artifact {
86
+ /** Artifact UUID */
87
+ uuid: string;
88
+ /** Artifact type */
89
+ type: "image" | "document" | "code" | "audio";
90
+ /** Filename */
91
+ filename: string;
92
+ /** MIME type */
93
+ mimeType: string;
94
+ /** Download URL */
95
+ url: string;
96
+ }
97
+ /**
98
+ * Attachment metadata for history messages
99
+ */
100
+ interface HistoryAttachment {
101
+ /** Attachment UUID */
102
+ uuid: string;
103
+ /** Original filename */
104
+ filename: string;
105
+ /** MIME type */
106
+ mimeType: string;
107
+ /** File size in bytes */
108
+ size: number;
109
+ /** Category classification */
110
+ category: "document" | "image" | "audio";
111
+ /** Preview URL (for images) */
112
+ previewUrl?: string;
113
+ /** Thumbnail URL */
114
+ thumbnailUrl?: string;
115
+ }
116
+ /**
117
+ * Tool call data for history messages
118
+ */
119
+ interface HistoryToolCall {
120
+ /** Tool call ID */
121
+ id: string;
122
+ /** Tool name */
123
+ name: string;
124
+ /** Tool arguments */
125
+ args?: Record<string, unknown>;
126
+ /** Tool result */
127
+ result?: unknown;
128
+ /** Execution status */
129
+ status: "pending" | "running" | "completed" | "failed";
130
+ /** Execution duration in ms */
131
+ durationMs?: number;
132
+ }
133
+ /**
134
+ * A message in the session history
135
+ */
136
+ interface HistoryMessage {
137
+ /** Message UUID */
138
+ uuid: string;
139
+ /** Message role */
140
+ role: "user" | "assistant";
141
+ /** Message content */
142
+ content: string;
143
+ /** Message timestamp */
144
+ timestamp: string;
145
+ /** File attachments (for user messages) */
146
+ attachments?: HistoryAttachment[];
147
+ /** Tool calls (for assistant messages) */
148
+ toolCalls?: HistoryToolCall[];
149
+ }
150
+ /**
151
+ * Session with chat history
152
+ */
153
+ interface SessionHistory {
154
+ /** Session UUID */
155
+ sessionId: string;
156
+ /** Agent UUID */
157
+ agentId: string;
158
+ /** Messages in chronological order */
159
+ messages: HistoryMessage[];
160
+ /** When the session was created */
161
+ createdAt: string;
162
+ /** When the session was last updated */
163
+ updatedAt: string;
164
+ }
165
+ /**
166
+ * ChatAdapter interface for API integration
167
+ *
168
+ * This interface decouples the UI from the API implementation,
169
+ * allowing:
170
+ * - Built-in HTTP adapter for external API consumers
171
+ * - Custom adapter for ai-saas-v2 (direct tRPC/DB access)
172
+ * - Testing with mock adapters
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * // Using default HTTP adapter
177
+ * const adapter = createDefaultAdapter({
178
+ * baseUrl: 'https://api.example.com/api/v1/external',
179
+ * apiKey: 'your-api-key',
180
+ * orgId: 123,
181
+ * });
182
+ *
183
+ * // Using custom tRPC adapter
184
+ * const adapter: ChatAdapter = {
185
+ * startExecution: (input) => api.agents.execute.mutate(input),
186
+ * // ... other methods
187
+ * };
188
+ * ```
189
+ */
190
+ interface ChatAdapter {
191
+ /**
192
+ * Start a new agent execution
193
+ * @param input - Execution input
194
+ * @returns Execution and session IDs
195
+ */
196
+ startExecution(input: StartExecutionInput): Promise<ExecutionResult>;
197
+ /**
198
+ * Send a message in an existing session
199
+ * @param input - Message input
200
+ * @returns Execution and session IDs
201
+ */
202
+ sendMessage(input: SendMessageInput): Promise<ExecutionResult>;
203
+ /**
204
+ * Cancel a running execution
205
+ * @param uuid - Execution UUID
206
+ */
207
+ cancelExecution(uuid: string): Promise<void>;
208
+ /**
209
+ * Get execution status and result
210
+ * @param uuid - Execution UUID
211
+ * @returns Execution details
212
+ */
213
+ getExecution(uuid: string): Promise<Execution>;
214
+ /**
215
+ * Get a pre-signed URL for uploading a file
216
+ * @param input - Upload URL input
217
+ * @returns Upload URL and attachment UUID
218
+ */
219
+ getUploadUrl(input: UploadUrlInput): Promise<UploadUrlResult>;
220
+ /**
221
+ * Confirm that a file upload has completed
222
+ * @param uuid - Attachment UUID
223
+ */
224
+ confirmUpload(uuid: string): Promise<void>;
225
+ /**
226
+ * Get a download URL for an attachment
227
+ * @param uuid - Attachment UUID
228
+ * @returns Signed download URL
229
+ */
230
+ getDownloadUrl(uuid: string): Promise<string>;
231
+ /**
232
+ * Get artifacts generated in a session
233
+ * @param sessionId - Session UUID
234
+ * @returns List of artifacts
235
+ */
236
+ getSessionArtifacts?(sessionId: string): Promise<Artifact[]>;
237
+ /**
238
+ * Load chat history for an existing session
239
+ *
240
+ * This method is optional. If not implemented, session loading will not be available.
241
+ * The returned data is designed to be cacheable with React Query, SWR, or Next.js caching.
242
+ *
243
+ * @param sessionId - Session UUID
244
+ * @returns Session with message history
245
+ */
246
+ getSessionHistory?(sessionId: string): Promise<SessionHistory>;
247
+ /**
248
+ * Get the SSE stream URL for an execution
249
+ * @param executionId - Execution UUID
250
+ * @returns Full URL for SSE connection
251
+ */
252
+ getStreamUrl(executionId: string): string;
253
+ }
254
+
255
+ /**
256
+ * Type definitions for @cadraos/sdk/chat
257
+ *
258
+ * @module @cadraos/sdk/chat
259
+ */
260
+ /**
261
+ * Represents a chat message in the conversation
262
+ */
263
+ interface ChatMessage$1 {
264
+ /** Unique identifier for the message */
265
+ id: string;
266
+ /** Role of the message sender */
267
+ role: "user" | "assistant" | "system";
268
+ /** Text content of the message */
269
+ content: string;
270
+ /** When the message was created */
271
+ timestamp: Date;
272
+ /** Whether this message is still streaming */
273
+ isStreaming?: boolean;
274
+ /** Attached files */
275
+ attachments?: AttachmentData[];
276
+ /** Tool calls made during this message */
277
+ toolCalls?: ToolCall[];
278
+ /** Thinking blocks (for models that support extended thinking) */
279
+ thinkingBlocks?: ThinkingBlock[];
280
+ }
281
+ /**
282
+ * Attachment data for files sent with messages
283
+ */
284
+ interface AttachmentData {
285
+ /** Unique identifier */
286
+ uuid: string;
287
+ /** Original filename */
288
+ filename: string;
289
+ /** MIME type */
290
+ mimeType: string;
291
+ /** File size in bytes */
292
+ size: number;
293
+ /** Category classification */
294
+ category: "document" | "image" | "audio";
295
+ /** Preview URL (for images) */
296
+ previewUrl?: string;
297
+ /** Thumbnail URL */
298
+ thumbnailUrl?: string;
299
+ /** Upload status */
300
+ status?: "uploading" | "processing" | "ready" | "failed";
301
+ }
302
+ /**
303
+ * Tool call information
304
+ */
305
+ interface ToolCall {
306
+ /** Unique identifier for the tool call */
307
+ id: string;
308
+ /** Name of the tool */
309
+ name: string;
310
+ /** Arguments passed to the tool */
311
+ args?: Record<string, unknown>;
312
+ /** Result from the tool execution */
313
+ result?: unknown;
314
+ /** Error message if tool failed */
315
+ error?: string;
316
+ /** Current status */
317
+ status: "pending" | "running" | "completed" | "failed";
318
+ /** Execution duration in milliseconds */
319
+ durationMs?: number;
320
+ }
321
+ /**
322
+ * Thinking block for extended thinking models
323
+ */
324
+ interface ThinkingBlock {
325
+ /** Unique identifier */
326
+ id: string;
327
+ /** Thinking content */
328
+ content: string;
329
+ /** When the thinking block was created */
330
+ timestamp: Date;
331
+ }
332
+ /**
333
+ * Chat error information
334
+ */
335
+ interface ChatError {
336
+ /** Error code for programmatic handling */
337
+ code: string;
338
+ /** Human-readable error message */
339
+ message: string;
340
+ /** Additional error details */
341
+ details?: Record<string, unknown>;
342
+ /** Whether the error is retryable */
343
+ retryable?: boolean;
344
+ }
345
+ /**
346
+ * Data for agent clarification requests (ask_user tool)
347
+ */
348
+ interface ClarificationData {
349
+ /** The question being asked */
350
+ question: string;
351
+ /** Optional reason for asking */
352
+ reason?: string;
353
+ /** Suggested response options */
354
+ suggestedOptions?: string[];
355
+ }
356
+ /**
357
+ * Todo item for agent task lists
358
+ */
359
+ interface TodoItem {
360
+ /** Task description (imperative form) */
361
+ content: string;
362
+ /** Current status */
363
+ status: "pending" | "in_progress" | "completed";
364
+ /** Present continuous form for active display */
365
+ activeForm: string;
366
+ }
367
+ /**
368
+ * SSE stream event from agent execution
369
+ */
370
+ interface ExecutionStreamEvent {
371
+ /** Event type */
372
+ type: string;
373
+ /** Unique event ID for deduplication */
374
+ id: string;
375
+ /** ISO timestamp */
376
+ timestamp: string;
377
+ /** Event data payload */
378
+ data: {
379
+ type?: string;
380
+ log?: {
381
+ stepIndex: number;
382
+ logType: string;
383
+ message: string;
384
+ metadata: Record<string, unknown>;
385
+ timestamp: string;
386
+ durationMs?: number;
387
+ };
388
+ executionId?: string;
389
+ toolName?: string;
390
+ args?: unknown;
391
+ iteration?: number;
392
+ tokenUsage?: {
393
+ prompt: number;
394
+ completion: number;
395
+ total: number;
396
+ };
397
+ cost?: number;
398
+ error?: string;
399
+ question?: string;
400
+ reason?: string;
401
+ suggestedOptions?: string[];
402
+ redisAvailable?: boolean;
403
+ [key: string]: unknown;
404
+ };
405
+ }
406
+ /**
407
+ * Theme mode options
408
+ */
409
+ type ThemeMode = "light" | "dark" | "system";
410
+ /**
411
+ * Attachment file for upload
412
+ */
413
+ interface AttachmentFile {
414
+ /** File UUID after upload */
415
+ uuid: string;
416
+ /** Original file object */
417
+ file: File;
418
+ /** Upload status */
419
+ status: "pending" | "uploading" | "ready" | "failed";
420
+ /** Preview URL for local display */
421
+ previewUrl?: string;
422
+ /** Progress percentage (0-100) */
423
+ progress?: number;
424
+ }
425
+
426
+ interface AgentChatProps {
427
+ /** The UUID of the agent to chat with */
428
+ agentId: string;
429
+ /**
430
+ * Session ID to resume an existing conversation
431
+ * When provided, the component will load the session's chat history
432
+ */
433
+ sessionId?: string;
434
+ /** Custom adapter (optional - uses context if not provided) */
435
+ adapter?: ChatAdapter;
436
+ /** Callback fired when a new message is added */
437
+ onMessage?: (message: ChatMessage$1) => void;
438
+ /** Callback fired when an error occurs */
439
+ onError?: (error: ChatError) => void;
440
+ /**
441
+ * Callback fired when a new session is created
442
+ * Called with the sessionId when starting a new chat (no existing sessionId)
443
+ * Useful for updating external state like session lists
444
+ */
445
+ onSessionCreated?: (sessionId: string) => void;
446
+ /** @deprecated Use onSessionCreated instead */
447
+ onSessionStart?: (sessionId: string) => void;
448
+ /** Callback fired when a tool is called */
449
+ onToolCall?: (toolName: string, args: unknown) => void;
450
+ /** Callback fired when clarification is needed */
451
+ onClarification?: (data: ClarificationData) => void;
452
+ /** Initial messages to populate the chat */
453
+ initialMessages?: ChatMessage$1[];
454
+ /** Placeholder text for the input */
455
+ placeholder?: string;
456
+ /** Welcome message shown when chat is empty */
457
+ welcomeMessage?: string;
458
+ /** Maximum height of the chat container */
459
+ maxHeight?: string | number;
460
+ /** Additional CSS class for the container */
461
+ className?: string;
462
+ /** Theme mode */
463
+ theme?: ThemeMode;
464
+ /** Enable file attachments (future feature) */
465
+ enableAttachments?: boolean;
466
+ /** Enable markdown rendering */
467
+ enableMarkdown?: boolean;
468
+ /** Show tool call visualization */
469
+ showToolCalls?: boolean;
470
+ }
471
+ /**
472
+ * Complete chat interface for interacting with AI agents
473
+ *
474
+ * @example
475
+ * ```tsx
476
+ * // With ChatConfigProvider (recommended for API key users)
477
+ * <ChatConfigProvider config={{ baseUrl: '...', apiKey: '...' }}>
478
+ * <AgentChat
479
+ * agentId="agent-uuid"
480
+ * onMessage={(msg) => console.log('New message:', msg)}
481
+ * />
482
+ * </ChatConfigProvider>
483
+ *
484
+ * // With custom adapter
485
+ * <AgentChat
486
+ * agentId="agent-uuid"
487
+ * adapter={myCustomAdapter}
488
+ * />
489
+ * ```
490
+ */
491
+ declare function AgentChat({ agentId, sessionId, adapter, onMessage, onError, onSessionCreated, onSessionStart, onToolCall, onClarification, initialMessages, placeholder, welcomeMessage, maxHeight, className, theme, enableAttachments, enableMarkdown, showToolCalls, }: AgentChatProps): react_jsx_runtime.JSX.Element;
492
+
493
+ /**
494
+ * Default HTTP adapter for ChatAdapter
495
+ *
496
+ * Uses the AI SaaS External API for all operations.
497
+ *
498
+ * @module @cadraos/sdk/chat
499
+ */
500
+
501
+ /**
502
+ * Configuration for the default HTTP adapter
503
+ */
504
+ interface DefaultAdapterConfig {
505
+ /**
506
+ * Base URL for the API
507
+ * @example "https://api.example.com/api/v1/external"
508
+ */
509
+ baseUrl: string;
510
+ /**
511
+ * API key for authentication
512
+ */
513
+ apiKey?: string;
514
+ /**
515
+ * Organization ID for multi-tenant access
516
+ */
517
+ orgId?: number;
518
+ /**
519
+ * Custom fetch function (for testing or custom HTTP clients)
520
+ */
521
+ fetch?: typeof fetch;
522
+ }
523
+ /**
524
+ * Create a default HTTP adapter for the Chat component
525
+ *
526
+ * @param config - Adapter configuration
527
+ * @returns ChatAdapter implementation
528
+ *
529
+ * @example
530
+ * ```typescript
531
+ * const adapter = createDefaultAdapter({
532
+ * baseUrl: 'https://api.example.com/api/v1/external',
533
+ * apiKey: 'your-api-key',
534
+ * orgId: 123,
535
+ * });
536
+ * ```
537
+ */
538
+ declare function createDefaultAdapter(config: DefaultAdapterConfig): ChatAdapter;
539
+
540
+ interface ChatConfigContextValue {
541
+ /** The configured adapter instance */
542
+ adapter: ChatAdapter;
543
+ }
544
+ interface ChatConfigProviderProps {
545
+ /**
546
+ * Configuration for the default HTTP adapter
547
+ */
548
+ config: DefaultAdapterConfig;
549
+ /**
550
+ * Child components
551
+ */
552
+ children: React.ReactNode;
553
+ }
554
+ /**
555
+ * Provider component that configures the default adapter for all child AgentChat components
556
+ *
557
+ * @example
558
+ * ```tsx
559
+ * import { ChatConfigProvider, AgentChat } from '@cadraos/sdk/chat';
560
+ *
561
+ * function App() {
562
+ * return (
563
+ * <ChatConfigProvider config={{
564
+ * baseUrl: 'https://api.example.com/api/v1/external',
565
+ * apiKey: 'your-api-key',
566
+ * orgId: 123,
567
+ * }}>
568
+ * <AgentChat agentId="agent-uuid" />
569
+ * </ChatConfigProvider>
570
+ * );
571
+ * }
572
+ * ```
573
+ */
574
+ declare function ChatConfigProvider({ config, children }: ChatConfigProviderProps): react_jsx_runtime.JSX.Element;
575
+ /**
576
+ * Hook to access the chat configuration from context
577
+ *
578
+ * @returns The chat configuration context value
579
+ * @throws Error if used outside of ChatConfigProvider
580
+ */
581
+ declare function useChatConfig(): ChatConfigContextValue;
582
+ /**
583
+ * Hook to optionally access the chat configuration from context
584
+ *
585
+ * @returns The chat configuration context value, or null if not available
586
+ */
587
+ declare function useChatConfigOptional(): ChatConfigContextValue | null;
588
+
589
+ interface UseAgentChatOptions {
590
+ /** UUID of the agent to chat with */
591
+ agentId: string;
592
+ /**
593
+ * Session ID to resume an existing conversation
594
+ * If provided, the hook will attempt to load the session history on mount
595
+ */
596
+ sessionId?: string;
597
+ /** Custom adapter (optional - uses context if not provided) */
598
+ adapter?: ChatAdapter;
599
+ /** Initial messages to populate the chat */
600
+ initialMessages?: ChatMessage$1[];
601
+ /** Callback fired when a new message is added */
602
+ onMessage?: (message: ChatMessage$1) => void;
603
+ /** Callback fired when an error occurs */
604
+ onError?: (error: ChatError) => void;
605
+ /**
606
+ * Callback fired when a new session is created
607
+ * Called with the sessionId when starting a new chat (no existing sessionId)
608
+ * Useful for updating external state like session lists
609
+ */
610
+ onSessionCreated?: (sessionId: string) => void;
611
+ /** @deprecated Use onSessionCreated instead */
612
+ onSessionStart?: (sessionId: string) => void;
613
+ /** Callback fired when a tool is called */
614
+ onToolCall?: (toolName: string, args: unknown) => void;
615
+ /** Callback fired when clarification is needed */
616
+ onClarification?: (data: ClarificationData) => void;
617
+ }
618
+ interface UseAgentChatResult {
619
+ /** Current messages in the chat */
620
+ messages: ChatMessage$1[];
621
+ /** Whether a message is being sent */
622
+ isLoading: boolean;
623
+ /** Whether the assistant is currently streaming */
624
+ isStreaming: boolean;
625
+ /** Whether session history is being loaded */
626
+ isLoadingHistory: boolean;
627
+ /** Current error if any */
628
+ error: ChatError | null;
629
+ /** Current session ID */
630
+ sessionId: string | null;
631
+ /** Current clarification request if any */
632
+ clarification: ClarificationData | null;
633
+ /** Send a message to the agent */
634
+ sendMessage: (content: string) => Promise<void>;
635
+ /** Respond to a clarification request */
636
+ respondToClarification: (response: string) => Promise<void>;
637
+ /** Cancel the current execution */
638
+ cancel: () => Promise<void>;
639
+ /** Retry the last failed message */
640
+ retry: () => void;
641
+ /** Clear the current error */
642
+ clearError: () => void;
643
+ /** Clear all messages and start a new session */
644
+ clearMessages: () => void;
645
+ /**
646
+ * Load history for a specific session
647
+ * @param sessionId - Session ID to load
648
+ * @returns Promise that resolves when history is loaded
649
+ */
650
+ loadSession: (sessionId: string) => Promise<void>;
651
+ }
652
+ declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatResult;
653
+
654
+ interface UseExecutionStreamOptions {
655
+ /** Execution ID to stream events for */
656
+ executionId: string | undefined;
657
+ /** Function to get stream URL - allows adapter pattern */
658
+ getStreamUrl: (executionId: string) => string;
659
+ /** Whether streaming is enabled */
660
+ enabled?: boolean;
661
+ /** Callback for all events */
662
+ onEvent?: (event: ExecutionStreamEvent) => void;
663
+ /** Callback for log events */
664
+ onLog?: (log: NonNullable<ExecutionStreamEvent["data"]["log"]>) => void;
665
+ /** Callback when a tool is called */
666
+ onToolCall?: (toolName: string, args: unknown) => void;
667
+ /** Callback when a tool returns a result */
668
+ onToolResult?: (toolName: string, result: unknown, durationMs: number) => void;
669
+ /** Callback for progress updates */
670
+ onProgress?: (data: {
671
+ iteration?: number;
672
+ tokenUsage?: {
673
+ prompt: number;
674
+ completion: number;
675
+ total: number;
676
+ };
677
+ cost?: number;
678
+ }) => void;
679
+ /** Callback when execution completes */
680
+ onComplete?: () => void;
681
+ /** Callback when an error occurs */
682
+ onError?: (error: string) => void;
683
+ /** Callback when agent needs clarification */
684
+ onClarification?: (data: ClarificationData) => void;
685
+ /** Callback when connection status changes */
686
+ onConnectionChange?: (connected: boolean, usingFallback: boolean) => void;
687
+ }
688
+ interface UseExecutionStreamResult {
689
+ /** Whether SSE is currently connected */
690
+ isConnected: boolean;
691
+ /** Whether using polling fallback */
692
+ isUsingFallback: boolean;
693
+ /** Connection error message if any */
694
+ connectionError: string | null;
695
+ /** Disconnect from the stream */
696
+ disconnect: () => void;
697
+ /** Reconnect to the stream */
698
+ reconnect: () => void;
699
+ }
700
+ /**
701
+ * Hook for streaming agent execution events via SSE
702
+ *
703
+ * @example
704
+ * ```typescript
705
+ * const { isConnected, disconnect } = useExecutionStream({
706
+ * executionId: currentExecutionId,
707
+ * getStreamUrl: (id) => adapter.getStreamUrl(id),
708
+ * onLog: (log) => console.log(log.message),
709
+ * onComplete: () => console.log('Done!'),
710
+ * });
711
+ * ```
712
+ */
713
+ declare function useExecutionStream(options: UseExecutionStreamOptions): UseExecutionStreamResult;
714
+
715
+ interface ChatContainerProps {
716
+ /** Child components (MessageList, ChatInput, etc.) */
717
+ children: React.ReactNode;
718
+ /** Maximum height of the container */
719
+ maxHeight?: string | number;
720
+ /** Additional CSS classes */
721
+ className?: string;
722
+ /** Theme mode */
723
+ theme?: ThemeMode;
724
+ }
725
+ /**
726
+ * Container component for the chat interface
727
+ *
728
+ * @example
729
+ * ```tsx
730
+ * <ChatContainer maxHeight="600px" theme="dark">
731
+ * <MessageList messages={messages} />
732
+ * <ChatInput onSend={handleSend} />
733
+ * </ChatContainer>
734
+ * ```
735
+ */
736
+ declare function ChatContainer({ children, maxHeight, className, theme, }: ChatContainerProps): react_jsx_runtime.JSX.Element;
737
+
738
+ interface ChatInputProps {
739
+ /** Callback when user sends a message */
740
+ onSend: (content: string) => void | Promise<void>;
741
+ /** Callback when user requests to stop/cancel */
742
+ onStop?: () => void;
743
+ /** Placeholder text */
744
+ placeholder?: string;
745
+ /** Whether the input is disabled */
746
+ disabled?: boolean;
747
+ /** Whether currently sending/streaming */
748
+ isLoading?: boolean;
749
+ /** Whether to enable attachments */
750
+ enableAttachments?: boolean;
751
+ /** Additional CSS classes */
752
+ className?: string;
753
+ }
754
+ /**
755
+ * Input component for sending chat messages
756
+ *
757
+ * @example
758
+ * ```tsx
759
+ * <ChatInput
760
+ * onSend={async (content) => {
761
+ * await sendMessage(content);
762
+ * }}
763
+ * placeholder="Type a message..."
764
+ * disabled={isStreaming}
765
+ * />
766
+ * ```
767
+ */
768
+ declare function ChatInput({ onSend, onStop, placeholder, disabled, isLoading, enableAttachments, className, }: ChatInputProps): react_jsx_runtime.JSX.Element;
769
+
770
+ interface MessageListProps {
771
+ /** Array of messages to display */
772
+ messages: ChatMessage$1[];
773
+ /** Welcome message shown when chat is empty */
774
+ welcomeMessage?: string;
775
+ /** Whether a new message is loading */
776
+ isLoading?: boolean;
777
+ /** Whether the assistant is currently streaming a response */
778
+ isStreaming?: boolean;
779
+ /** Whether session history is being loaded */
780
+ isLoadingHistory?: boolean;
781
+ /** Whether to enable markdown rendering */
782
+ enableMarkdown?: boolean;
783
+ /** Whether to show tool calls */
784
+ showToolCalls?: boolean;
785
+ /** Additional CSS classes */
786
+ className?: string;
787
+ }
788
+ /**
789
+ * Renders a scrollable list of chat messages with auto-scroll
790
+ *
791
+ * @example
792
+ * ```tsx
793
+ * <MessageList
794
+ * messages={messages}
795
+ * welcomeMessage="Hello! How can I help you today?"
796
+ * isLoading={isLoading}
797
+ * isStreaming={isStreaming}
798
+ * enableMarkdown
799
+ * showToolCalls
800
+ * />
801
+ * ```
802
+ */
803
+ declare function MessageList({ messages, welcomeMessage, isLoading, isStreaming, isLoadingHistory, enableMarkdown, showToolCalls, className, }: MessageListProps): react_jsx_runtime.JSX.Element;
804
+
805
+ interface ChatMessageProps {
806
+ /** Message data */
807
+ message: ChatMessage$1;
808
+ /** Whether to enable markdown rendering */
809
+ enableMarkdown?: boolean;
810
+ /** Whether to show tool calls */
811
+ showToolCalls?: boolean;
812
+ /** Additional CSS classes */
813
+ className?: string;
814
+ }
815
+ /**
816
+ * Renders a single chat message with appropriate styling
817
+ *
818
+ * @example
819
+ * ```tsx
820
+ * <ChatMessage
821
+ * message={{
822
+ * id: "1",
823
+ * role: "assistant",
824
+ * content: "Hello! How can I help?",
825
+ * timestamp: new Date(),
826
+ * }}
827
+ * enableMarkdown
828
+ * showToolCalls
829
+ * />
830
+ * ```
831
+ */
832
+ declare function ChatMessage({ message, enableMarkdown, showToolCalls, className, }: ChatMessageProps): react_jsx_runtime.JSX.Element;
833
+
834
+ interface MarkdownContentProps {
835
+ /** Markdown content to render */
836
+ content: string;
837
+ /** Additional CSS classes */
838
+ className?: string;
839
+ }
840
+ /**
841
+ * Renders markdown content with chat-appropriate styling
842
+ *
843
+ * @example
844
+ * ```tsx
845
+ * <MarkdownContent content="# Hello\n\nThis is **bold** text." />
846
+ * ```
847
+ */
848
+ declare function MarkdownContent({ content, className }: MarkdownContentProps): react_jsx_runtime.JSX.Element;
849
+
850
+ interface ToolCallEntryProps {
851
+ /** Tool call data */
852
+ toolCall: ToolCall;
853
+ /** Additional CSS classes */
854
+ className?: string;
855
+ /** Whether to show the full JSON in expanded view */
856
+ showFullJson?: boolean;
857
+ }
858
+ /**
859
+ * Displays a single tool call with status and expandable details
860
+ *
861
+ * @example
862
+ * ```tsx
863
+ * <ToolCallEntry
864
+ * toolCall={{
865
+ * id: "1",
866
+ * name: "search_google",
867
+ * status: "completed",
868
+ * args: { query: "weather today" },
869
+ * result: { results: [...] },
870
+ * durationMs: 1234,
871
+ * }}
872
+ * />
873
+ * ```
874
+ */
875
+ declare function ToolCallEntry({ toolCall, className, showFullJson, }: ToolCallEntryProps): react_jsx_runtime.JSX.Element;
876
+
877
+ interface AskUserPromptProps {
878
+ /** The question to display to the user */
879
+ question: string;
880
+ /** Optional predefined choices */
881
+ options?: string[];
882
+ /** Callback when user submits their response */
883
+ onSubmit: (response: string) => void;
884
+ /** Whether a response is required */
885
+ required?: boolean;
886
+ /** Whether the prompt is disabled (e.g., already responded) */
887
+ disabled?: boolean;
888
+ /** Current status */
889
+ status?: "waiting" | "submitted" | "processing";
890
+ /** Additional CSS classes */
891
+ className?: string;
892
+ }
893
+ /**
894
+ * Input prompt for agent clarification requests
895
+ *
896
+ * @example
897
+ * ```tsx
898
+ * <AskUserPrompt
899
+ * question="What format would you like the report in?"
900
+ * options={["PDF", "CSV", "Excel"]}
901
+ * onSubmit={(response) => handleClarification(response)}
902
+ * />
903
+ * ```
904
+ */
905
+ declare function AskUserPrompt({ question, options, onSubmit, required, disabled, status, className, }: AskUserPromptProps): react_jsx_runtime.JSX.Element;
906
+
907
+ interface TodoListProps {
908
+ /** List of todo items */
909
+ todos: TodoItem[];
910
+ /** Whether the list is collapsible */
911
+ collapsible?: boolean;
912
+ /** Default collapsed state */
913
+ defaultCollapsed?: boolean;
914
+ /** Custom title */
915
+ title?: string;
916
+ /** Additional CSS classes */
917
+ className?: string;
918
+ }
919
+ /**
920
+ * Displays a task list with progress tracking
921
+ *
922
+ * @example
923
+ * ```tsx
924
+ * <TodoList
925
+ * todos={[
926
+ * { content: "Research topic", status: "completed", activeForm: "Researching topic" },
927
+ * { content: "Write outline", status: "in_progress", activeForm: "Writing outline" },
928
+ * { content: "Draft document", status: "pending", activeForm: "Drafting document" },
929
+ * ]}
930
+ * />
931
+ * ```
932
+ */
933
+ declare function TodoList({ todos, collapsible, defaultCollapsed, title, className, }: TodoListProps): react_jsx_runtime.JSX.Element | null;
934
+
935
+ interface IconProps {
936
+ /** Additional CSS classes */
937
+ className?: string;
938
+ /** Accessibility label */
939
+ "aria-label"?: string;
940
+ }
941
+ declare function SendIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
942
+ declare function MessageCircleIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
943
+ declare function PaperclipIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
944
+ declare function XIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
945
+ declare function CheckIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
946
+ declare function CheckCircleIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
947
+ declare function CopyIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
948
+ declare function ChevronDownIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
949
+ declare function ChevronRightIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
950
+ declare function ChevronLeftIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
951
+ declare function LoadingSpinner({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
952
+ declare function AlertCircleIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
953
+ declare function CircleIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
954
+ declare function StopCircleIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
955
+ declare function ImageIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
956
+ declare function ImagesIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
957
+ declare function FileIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
958
+ declare function FileTextIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
959
+ declare function CodeIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
960
+ declare function ZoomInIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
961
+ declare function ZoomOutIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
962
+ declare function DownloadIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
963
+ declare function ExternalLinkIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
964
+ declare function Minimize2Icon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
965
+ declare function Maximize2Icon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
966
+ declare function BotIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
967
+ declare function UserIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
968
+ declare function SparklesIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
969
+ declare function ListTodoIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
970
+ declare function HelpCircleIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
971
+ declare function DatabaseIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
972
+ declare function ClockIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
973
+
974
+ export { AgentChat, type AgentChatProps, AlertCircleIcon, type 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, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, type IconProps, ImageIcon, ImagesIcon, ListTodoIcon, LoadingSpinner, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput, type SessionHistory, 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, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, createDefaultAdapter, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream };