@ash-cloud/ash-ui 0.1.0 → 0.2.0
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/design-tokens.cjs +20 -0
- package/dist/design-tokens.cjs.map +1 -1
- package/dist/design-tokens.d.cts +31 -1
- package/dist/design-tokens.d.ts +31 -1
- package/dist/design-tokens.js +20 -1
- package/dist/design-tokens.js.map +1 -1
- package/dist/icons.cjs +23 -0
- package/dist/icons.cjs.map +1 -1
- package/dist/icons.d.cts +4 -1
- package/dist/icons.d.ts +4 -1
- package/dist/icons.js +21 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.cjs +2416 -1955
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +840 -641
- package/dist/index.d.ts +840 -641
- package/dist/index.js +2360 -1930
- package/dist/index.js.map +1 -1
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/types.cjs +243 -6
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +197 -121
- package/dist/types.d.ts +197 -121
- package/dist/types.js +239 -6
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +0 -35
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -28
- package/dist/utils.d.ts +2 -28
- package/dist/utils.js +1 -34
- package/dist/utils.js.map +1 -1
- package/package.json +22 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,466 +1,454 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import React$1, { ReactNode, ComponentType, DragEvent, ChangeEvent, ClipboardEvent } from 'react';
|
|
3
|
+
import { ToolInvocation, TodoStatus, TodoItem, FileAttachment as FileAttachment$2, LogEntry, ToolStatus, ActionType, MarkdownComponents, NormalizedEntry, Message as Message$1 } from './types.js';
|
|
4
|
+
export { MessageAttachment as AIMessageAttachment, AIMessageRole, AgentToolAction, AssistantMessageEntry, CommandRunAction, CommandRunResult, DEFAULT_STYLE_CONFIG, ErrorEntry, FileEditAction, FileReadAction, FileWriteAction, GenericToolAction, GlobAction, LogCategory, LogLevel, McpToolAction, MessageMetadata, MessageStyleConfig, MessageVariant, NormalizedEntryType, NormalizedToolCall, RenderMetadataFunction, SearchAction, ThinkingEntry, TodoWriteAction, ToolCallEntry, ToolInvocationState, ToolResult, TypographyScale, UserMessageEntry, WebFetchAction, WebSearchAction, WidgetAction, WidgetEntry, WidgetRenderFunction, WidgetRenderProps, isAgentToolAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry, messageToNormalizedEntry, messagesToNormalizedEntries, normalizedEntriesToMessages, normalizedEntryToMessage } from './types.js';
|
|
5
5
|
import { ParsedOption } from './utils.js';
|
|
6
|
-
export {
|
|
7
|
-
export { AlertCircleIcon, AlertTriangleIcon, BotIcon, BrainIcon, BugIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, ClipboardListIcon, ClockIcon, 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
|
-
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';
|
|
6
|
+
export { ParsedOptionsResult, ToolUseInput, cn, createToolCall, extractTextContent, formatElapsedTime, formatFileSize, formatTimestamp, formatToolName, generateToolSummary, getActionIcon, getActionLabel, mapToolToActionType, normalizeToolResult, parseCommandResult, parseMcpToolName, parseOptionsFromContent, truncate, updateToolCallWithResult } from './utils.js';
|
|
7
|
+
export { AlertCircleIcon, AlertTriangleIcon, ArrowUpIcon, BotIcon, BrainIcon, BugIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CircleIcon, ClipboardListIcon, ClockIcon, CodeIcon, CopyIcon, EditIcon, ErrorIcon, FileIcon, FilePlusIcon, FolderSearchIcon, GlobeIcon, HomeIcon, IconProps, InfoIcon, ListChecksIcon, LoaderIcon, MessageSquareIcon, MicrophoneIcon, MoonIcon, PaperclipIcon, PlugIcon, SearchIcon, SendIcon, SparklesIcon, SpinnerIcon, StopCircleIcon, SunIcon, TerminalIcon, ToolIcon, UserIcon, XCircleIcon, XIcon } from './icons.js';
|
|
8
|
+
export { BorderRadius, Colors, CssVars, Keyframes, Shadows, Spacing, Transitions, Typography, Widget, ZIndex, allKeyframesCss, borderRadius, colors, cssVars, inlineStyles, keyframes, keyframesCss, shadows, spacing, tokensToCssVariables, transitions, typography, widget, zIndex } from './design-tokens.js';
|
|
9
9
|
|
|
10
|
-
interface
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
interface ConversationContextValue {
|
|
11
|
+
/** Reference to the scroll container */
|
|
12
|
+
containerRef: React$1.RefObject<HTMLDivElement>;
|
|
13
|
+
/** Scroll to the bottom of the conversation */
|
|
14
|
+
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
15
|
+
/** Whether the user has scrolled up from the bottom */
|
|
16
|
+
isScrolledUp: boolean;
|
|
17
|
+
/** Whether auto-scroll is enabled */
|
|
18
|
+
autoScroll: boolean;
|
|
19
|
+
/** Set auto-scroll state */
|
|
20
|
+
setAutoScroll: (value: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
declare function useConversation(): ConversationContextValue;
|
|
23
|
+
interface ConversationProps {
|
|
24
|
+
/** Child elements */
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
/** Additional class name */
|
|
13
27
|
className?: string;
|
|
28
|
+
/** Whether to auto-scroll on new messages */
|
|
29
|
+
autoScroll?: boolean;
|
|
30
|
+
/** Threshold in pixels to consider "at bottom" */
|
|
31
|
+
scrollThreshold?: number;
|
|
14
32
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* - Action-specific icon in accent-colored badge
|
|
21
|
-
* - Expandable details section with smooth animation
|
|
22
|
-
* - Glassmorphism dark theme styling
|
|
23
|
-
* - Execution duration display
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```tsx
|
|
27
|
-
* <ToolCallCard toolCall={normalizedToolCall} />
|
|
28
|
-
* <ToolCallCard toolCall={toolCall} defaultExpanded />
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
declare function ToolCallCard({ toolCall, defaultExpanded, className }: ToolCallCardProps): react_jsx_runtime.JSX.Element;
|
|
32
|
-
|
|
33
|
-
interface AgentToolCardProps {
|
|
34
|
-
/** The tool call with agent_tool action type */
|
|
35
|
-
toolCall: NormalizedToolCall;
|
|
36
|
-
/** Whether the card starts expanded */
|
|
37
|
-
defaultExpanded?: boolean;
|
|
38
|
-
/** Additional class names */
|
|
33
|
+
declare function Conversation({ children, className, autoScroll: initialAutoScroll, scrollThreshold, }: ConversationProps): react_jsx_runtime.JSX.Element;
|
|
34
|
+
interface ConversationContentProps {
|
|
35
|
+
/** Child elements */
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
/** Additional class name */
|
|
39
38
|
className?: string;
|
|
40
|
-
/** Depth level for nested rendering (0 = top level) */
|
|
41
|
-
depth?: number;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* - Description of what the agent is doing
|
|
49
|
-
* - Tool call count that updates during streaming
|
|
50
|
-
* - Loading indicator while running (spinner)
|
|
51
|
-
* - Elapsed time display while running
|
|
52
|
-
* - Expandable to show nested tool calls
|
|
53
|
-
* - Supports deep nesting (agents within agents)
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```tsx
|
|
57
|
-
* <AgentToolCard
|
|
58
|
-
* toolCall={agentToolCall}
|
|
59
|
-
* defaultExpanded={false}
|
|
60
|
-
* />
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
declare function AgentToolCard({ toolCall, defaultExpanded, className, depth, }: AgentToolCardProps): react_jsx_runtime.JSX.Element | null;
|
|
64
|
-
|
|
65
|
-
interface MessageListProps {
|
|
66
|
-
/** Normalized conversation entries to display */
|
|
67
|
-
entries: NormalizedEntry[];
|
|
68
|
-
/** Whether a response is currently loading */
|
|
69
|
-
loading?: boolean;
|
|
70
|
-
/** Streaming text content (displayed during real-time streaming) */
|
|
71
|
-
streamingContent?: string;
|
|
72
|
-
/** Display configuration override (uses context if not provided) */
|
|
73
|
-
displayConfig?: ToolDisplayConfig;
|
|
74
|
-
/** Callback when user selects an option from assistant message */
|
|
75
|
-
onOptionSelect?: (optionText: string) => void;
|
|
76
|
-
/**
|
|
77
|
-
* Custom render function for widget entries.
|
|
78
|
-
* When provided, widget entries will be rendered using this function.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```tsx
|
|
82
|
-
* <MessageList
|
|
83
|
-
* entries={entries}
|
|
84
|
-
* renderWidget={({ widgetType, widgetData, onAction }) => {
|
|
85
|
-
* if (widgetType === 'image-grid') {
|
|
86
|
-
* return <ImageGrid data={widgetData} onSelect={onAction} />;
|
|
87
|
-
* }
|
|
88
|
-
* return null;
|
|
89
|
-
* }}
|
|
90
|
-
* />
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
renderWidget?: WidgetRenderFunction;
|
|
94
|
-
/**
|
|
95
|
-
* Callback for widget interactions (e.g., selection, submit).
|
|
96
|
-
* Called when widgets dispatch actions via their onAction callback.
|
|
97
|
-
*/
|
|
98
|
-
onWidgetAction?: (action: WidgetAction) => void;
|
|
99
|
-
/**
|
|
100
|
-
* Enable auto-scroll to bottom when new entries are added.
|
|
101
|
-
* Scrolls within the message list container (not the page).
|
|
102
|
-
* Default: true
|
|
103
|
-
*/
|
|
104
|
-
autoScroll?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Custom renderers for rich content segments.
|
|
107
|
-
* Used when entries have `richContent` defined.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```tsx
|
|
111
|
-
* <MessageList
|
|
112
|
-
* entries={entriesWithRichContent}
|
|
113
|
-
* richContentRenderers={{
|
|
114
|
-
* renderMention: ({ segment }) => (
|
|
115
|
-
* <MentionBadge
|
|
116
|
-
* name={segment.name}
|
|
117
|
-
* color={segment.color}
|
|
118
|
-
* onClick={() => scrollToEntity(segment.id)}
|
|
119
|
-
* />
|
|
120
|
-
* ),
|
|
121
|
-
* }}
|
|
122
|
-
* />
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
richContentRenderers?: RichContentRenderers;
|
|
126
|
-
/** Additional class names */
|
|
40
|
+
declare function ConversationContent({ children, className, }: ConversationContentProps): react_jsx_runtime.JSX.Element;
|
|
41
|
+
interface ConversationEmptyStateProps {
|
|
42
|
+
/** Child elements */
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
/** Additional class name */
|
|
127
45
|
className?: string;
|
|
128
46
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
* - 'compact': Consecutive tool calls grouped into a single accordion with
|
|
138
|
-
* an animated status line showing the current tool
|
|
139
|
-
*
|
|
140
|
-
* Uses glassmorphism dark theme styling with animated entries.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```tsx
|
|
144
|
-
* <MessageList entries={normalizedEntries} />
|
|
145
|
-
* <MessageList entries={entries} loading streamingContent={text} />
|
|
146
|
-
* <MessageList entries={entries} displayConfig={{ mode: 'compact' }} />
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
declare function MessageList({ entries, loading, streamingContent, displayConfig: displayConfigProp, onOptionSelect, renderWidget, onWidgetAction, autoScroll, richContentRenderers, className, }: MessageListProps): react_jsx_runtime.JSX.Element;
|
|
47
|
+
declare function ConversationEmptyState({ children, className, }: ConversationEmptyStateProps): react_jsx_runtime.JSX.Element;
|
|
48
|
+
interface ConversationScrollButtonProps {
|
|
49
|
+
/** Additional class name */
|
|
50
|
+
className?: string;
|
|
51
|
+
/** Custom label */
|
|
52
|
+
label?: string;
|
|
53
|
+
}
|
|
54
|
+
declare function ConversationScrollButton({ className, label, }: ConversationScrollButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
150
55
|
|
|
151
|
-
interface
|
|
152
|
-
|
|
56
|
+
interface MessageContextValue {
|
|
57
|
+
/** Message role */
|
|
58
|
+
from: 'user' | 'assistant' | 'system';
|
|
59
|
+
/** Whether this message is streaming */
|
|
60
|
+
isStreaming?: boolean;
|
|
61
|
+
/** Tool invocations in this message */
|
|
62
|
+
toolInvocations?: ToolInvocation[];
|
|
63
|
+
}
|
|
64
|
+
declare function useMessage(): MessageContextValue;
|
|
65
|
+
interface MessageProps {
|
|
66
|
+
/** Message role */
|
|
67
|
+
from: 'user' | 'assistant' | 'system';
|
|
68
|
+
/** Child elements */
|
|
69
|
+
children: ReactNode;
|
|
70
|
+
/** Additional class name */
|
|
153
71
|
className?: string;
|
|
72
|
+
/** Whether this message is streaming */
|
|
73
|
+
isStreaming?: boolean;
|
|
74
|
+
/** Tool invocations (for assistant messages) */
|
|
75
|
+
toolInvocations?: ToolInvocation[];
|
|
76
|
+
/** Message ID for data attribute */
|
|
77
|
+
id?: string;
|
|
154
78
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
entry: NormalizedEntry;
|
|
163
|
-
/** Callback when user selects an option */
|
|
164
|
-
onOptionSelect?: (optionText: string) => void;
|
|
165
|
-
/** Custom renderers for rich content segments */
|
|
166
|
-
richContentRenderers?: RichContentRenderers;
|
|
79
|
+
declare function Message({ from, children, className, isStreaming, toolInvocations, id, }: MessageProps): react_jsx_runtime.JSX.Element;
|
|
80
|
+
interface MessageAvatarProps {
|
|
81
|
+
/** Avatar image URL */
|
|
82
|
+
src?: string;
|
|
83
|
+
/** Fallback text (initials) */
|
|
84
|
+
fallback?: string;
|
|
85
|
+
/** Additional class name */
|
|
167
86
|
className?: string;
|
|
168
87
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
* Supports rich content segments for inline rendering of mentions and custom components.
|
|
175
|
-
*/
|
|
176
|
-
declare function AssistantMessage({ entry, onOptionSelect, richContentRenderers, className, }: AssistantMessageProps): react_jsx_runtime.JSX.Element;
|
|
177
|
-
interface ThinkingMessageProps {
|
|
178
|
-
entry: NormalizedEntry;
|
|
88
|
+
declare function MessageAvatar({ src, fallback, className }: MessageAvatarProps): react_jsx_runtime.JSX.Element;
|
|
89
|
+
interface MessageContentProps {
|
|
90
|
+
/** Child elements */
|
|
91
|
+
children: ReactNode;
|
|
92
|
+
/** Additional class name */
|
|
179
93
|
className?: string;
|
|
180
94
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
entry: NormalizedEntry;
|
|
189
|
-
defaultExpanded?: boolean;
|
|
95
|
+
declare function MessageContent({ children, className }: MessageContentProps): react_jsx_runtime.JSX.Element;
|
|
96
|
+
interface MessageResponseProps {
|
|
97
|
+
/** Text content to render as markdown */
|
|
98
|
+
content: string;
|
|
99
|
+
/** Whether content is still streaming */
|
|
100
|
+
isStreaming?: boolean;
|
|
101
|
+
/** Additional class name */
|
|
190
102
|
className?: string;
|
|
103
|
+
/** Custom markdown components */
|
|
104
|
+
components?: Record<string, ComponentType<{
|
|
105
|
+
children?: ReactNode;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}>>;
|
|
191
108
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
*/
|
|
197
|
-
declare function ToolCallMessage({ entry, defaultExpanded, className }: ToolCallMessageProps): react_jsx_runtime.JSX.Element | null;
|
|
198
|
-
interface ErrorMessageProps {
|
|
199
|
-
entry: NormalizedEntry;
|
|
109
|
+
declare function MessageResponse({ content, isStreaming, className, components, }: MessageResponseProps): react_jsx_runtime.JSX.Element | null;
|
|
110
|
+
interface MessageActionsProps {
|
|
111
|
+
/** Child elements (action buttons) */
|
|
112
|
+
children: ReactNode;
|
|
113
|
+
/** Additional class name */
|
|
200
114
|
className?: string;
|
|
201
115
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
onOptionSelect?: (optionText: string) => void;
|
|
212
|
-
/** Whether tool calls should be expanded by default */
|
|
213
|
-
defaultExpanded?: boolean;
|
|
214
|
-
/** Custom renderers for rich content segments */
|
|
215
|
-
richContentRenderers?: RichContentRenderers;
|
|
116
|
+
declare function MessageActions({ children, className }: MessageActionsProps): react_jsx_runtime.JSX.Element;
|
|
117
|
+
interface MessageActionProps {
|
|
118
|
+
/** Action icon */
|
|
119
|
+
icon?: ReactNode;
|
|
120
|
+
/** Action label */
|
|
121
|
+
label: string;
|
|
122
|
+
/** Click handler */
|
|
123
|
+
onClick?: () => void;
|
|
124
|
+
/** Additional class name */
|
|
216
125
|
className?: string;
|
|
217
126
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* ```tsx
|
|
226
|
-
* {entries.map(entry => (
|
|
227
|
-
* <MessageEntry key={entry.id} entry={entry} onOptionSelect={handleSelect} />
|
|
228
|
-
* ))}
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
declare function MessageEntry({ entry, onOptionSelect, defaultExpanded, richContentRenderers, className, }: MessageEntryProps): react_jsx_runtime.JSX.Element | null;
|
|
232
|
-
|
|
233
|
-
interface LogsPanelProps {
|
|
234
|
-
logs: LogEntry[];
|
|
235
|
-
title?: string;
|
|
236
|
-
isLoading?: boolean;
|
|
237
|
-
defaultCollapsed?: boolean;
|
|
238
|
-
maxHeight?: number;
|
|
127
|
+
declare function MessageAction({ icon, label, onClick, className, }: MessageActionProps): react_jsx_runtime.JSX.Element;
|
|
128
|
+
interface MessageTimestampProps {
|
|
129
|
+
/** Timestamp to display */
|
|
130
|
+
timestamp: Date | string;
|
|
131
|
+
/** Additional class name */
|
|
239
132
|
className?: string;
|
|
240
133
|
}
|
|
241
|
-
|
|
242
|
-
* LogsPanel - Collapsible panel for displaying log entries
|
|
243
|
-
*
|
|
244
|
-
* Features:
|
|
245
|
-
* - Collapsible header with log count
|
|
246
|
-
* - Error/warning count badges
|
|
247
|
-
* - Level-based coloring and icons
|
|
248
|
-
* - Expandable entries with JSON data
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* ```tsx
|
|
252
|
-
* <LogsPanel logs={logEntries} />
|
|
253
|
-
* <LogsPanel logs={logs} title="Execution Logs" defaultCollapsed={false} />
|
|
254
|
-
* ```
|
|
255
|
-
*/
|
|
256
|
-
declare function LogsPanel({ logs, title, isLoading, defaultCollapsed, maxHeight, className, }: LogsPanelProps): react_jsx_runtime.JSX.Element | null;
|
|
134
|
+
declare function MessageTimestamp({ timestamp, className }: MessageTimestampProps): react_jsx_runtime.JSX.Element;
|
|
257
135
|
|
|
258
|
-
interface
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
/** Whether the
|
|
136
|
+
interface ToolContextValue {
|
|
137
|
+
/** The tool invocation data */
|
|
138
|
+
toolInvocation: ToolInvocation;
|
|
139
|
+
/** Whether the tool details are expanded */
|
|
140
|
+
isExpanded: boolean;
|
|
141
|
+
/** Toggle expansion state */
|
|
142
|
+
toggleExpanded: () => void;
|
|
143
|
+
}
|
|
144
|
+
declare function useTool(): ToolContextValue;
|
|
145
|
+
interface ToolProps {
|
|
146
|
+
/** Tool invocation data */
|
|
147
|
+
toolInvocation: ToolInvocation;
|
|
148
|
+
/** Child elements */
|
|
149
|
+
children?: ReactNode;
|
|
150
|
+
/** Additional class name */
|
|
151
|
+
className?: string;
|
|
152
|
+
/** Whether to start expanded */
|
|
262
153
|
defaultExpanded?: boolean;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
154
|
+
}
|
|
155
|
+
declare function Tool({ toolInvocation, children, className, defaultExpanded, }: ToolProps): react_jsx_runtime.JSX.Element;
|
|
156
|
+
interface ToolHeaderProps {
|
|
157
|
+
/** Additional class name */
|
|
266
158
|
className?: string;
|
|
159
|
+
/** Custom icon */
|
|
160
|
+
icon?: ReactNode;
|
|
161
|
+
/** Show expand/collapse button */
|
|
162
|
+
showToggle?: boolean;
|
|
267
163
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* In collapsed state, shows a summary with tool count, action type icons,
|
|
272
|
-
* and file change badges. When expanded, shows compact tool rows that can
|
|
273
|
-
* be further expanded into full detail cards.
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```tsx
|
|
277
|
-
* <ToolExecutionGroup
|
|
278
|
-
* toolCalls={consecutiveToolCalls}
|
|
279
|
-
* defaultExpanded={false}
|
|
280
|
-
* />
|
|
281
|
-
* ```
|
|
282
|
-
*/
|
|
283
|
-
declare function ToolExecutionGroup({ toolCalls, defaultExpanded, className, }: ToolExecutionGroupProps): react_jsx_runtime.JSX.Element | null;
|
|
284
|
-
|
|
285
|
-
interface CompactToolStatusLineProps {
|
|
286
|
-
/** The current tool call to display */
|
|
287
|
-
toolCall: NormalizedToolCall;
|
|
288
|
-
/** Previous tool call (for exit animation) */
|
|
289
|
-
previousToolCall?: NormalizedToolCall | null;
|
|
290
|
-
/** Animation duration in ms */
|
|
291
|
-
animationDuration?: number;
|
|
292
|
-
/** Additional class names */
|
|
164
|
+
declare function ToolHeader({ className, icon, showToggle, }: ToolHeaderProps): react_jsx_runtime.JSX.Element;
|
|
165
|
+
interface ToolInputProps {
|
|
166
|
+
/** Additional class name */
|
|
293
167
|
className?: string;
|
|
168
|
+
/** Maximum height before scroll */
|
|
169
|
+
maxHeight?: number;
|
|
294
170
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
171
|
+
declare function ToolInput({ className, maxHeight }: ToolInputProps): react_jsx_runtime.JSX.Element | null;
|
|
172
|
+
interface ToolOutputProps {
|
|
173
|
+
/** Additional class name */
|
|
174
|
+
className?: string;
|
|
175
|
+
/** Maximum height before scroll */
|
|
176
|
+
maxHeight?: number;
|
|
177
|
+
}
|
|
178
|
+
declare function ToolOutput({ className, maxHeight }: ToolOutputProps): react_jsx_runtime.JSX.Element | null;
|
|
179
|
+
interface ToolListProps {
|
|
180
|
+
/** Tool invocations to render */
|
|
181
|
+
toolInvocations: ToolInvocation[];
|
|
182
|
+
/** Additional class name */
|
|
183
|
+
className?: string;
|
|
184
|
+
/** Whether to show tools expanded by default */
|
|
185
|
+
defaultExpanded?: boolean;
|
|
186
|
+
}
|
|
187
|
+
declare function ToolList({ toolInvocations, className, defaultExpanded, }: ToolListProps): react_jsx_runtime.JSX.Element | null;
|
|
311
188
|
|
|
312
|
-
interface
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
189
|
+
interface ReasoningContextValue {
|
|
190
|
+
/** Whether the reasoning panel is open */
|
|
191
|
+
isOpen: boolean;
|
|
192
|
+
/** Toggle open state */
|
|
193
|
+
setIsOpen: (value: boolean) => void;
|
|
194
|
+
/** Whether reasoning is currently streaming */
|
|
195
|
+
isStreaming: boolean;
|
|
196
|
+
/** Duration of thinking in seconds */
|
|
197
|
+
duration: number;
|
|
198
|
+
}
|
|
199
|
+
declare function useReasoning(): ReasoningContextValue;
|
|
200
|
+
interface ReasoningProps {
|
|
201
|
+
/** Child elements */
|
|
202
|
+
children: ReactNode;
|
|
203
|
+
/** Whether reasoning is currently streaming */
|
|
204
|
+
isStreaming?: boolean;
|
|
205
|
+
/** Additional class name */
|
|
316
206
|
className?: string;
|
|
207
|
+
/** Whether to auto-expand during streaming */
|
|
208
|
+
autoExpand?: boolean;
|
|
209
|
+
/** Whether to auto-collapse when streaming completes */
|
|
210
|
+
autoCollapse?: boolean;
|
|
211
|
+
/** Initial duration in seconds (for loaded content) */
|
|
212
|
+
initialDuration?: number;
|
|
317
213
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
214
|
+
declare function Reasoning({ children, isStreaming, className, autoExpand, autoCollapse, initialDuration, }: ReasoningProps): react_jsx_runtime.JSX.Element;
|
|
215
|
+
interface ReasoningTriggerProps {
|
|
216
|
+
/** Additional class name */
|
|
217
|
+
className?: string;
|
|
218
|
+
/** Custom label */
|
|
219
|
+
label?: string;
|
|
220
|
+
/** Show duration */
|
|
221
|
+
showDuration?: boolean;
|
|
222
|
+
}
|
|
223
|
+
declare function ReasoningTrigger({ className, label, showDuration, }: ReasoningTriggerProps): react_jsx_runtime.JSX.Element;
|
|
224
|
+
interface ReasoningContentProps {
|
|
225
|
+
/** Content to display (thinking text) */
|
|
226
|
+
children: ReactNode;
|
|
227
|
+
/** Additional class name */
|
|
228
|
+
className?: string;
|
|
229
|
+
/** Maximum height before scroll */
|
|
230
|
+
maxHeight?: number;
|
|
231
|
+
}
|
|
232
|
+
declare function ReasoningContent({ children, className, maxHeight, }: ReasoningContentProps): react_jsx_runtime.JSX.Element | null;
|
|
233
|
+
interface ThinkingIndicatorProps {
|
|
234
|
+
/** Whether thinking is active */
|
|
235
|
+
isActive?: boolean;
|
|
236
|
+
/** Label to display */
|
|
237
|
+
label?: string;
|
|
238
|
+
/** Additional class name */
|
|
239
|
+
className?: string;
|
|
240
|
+
}
|
|
241
|
+
declare function ThinkingIndicator({ isActive, label, className, }: ThinkingIndicatorProps): react_jsx_runtime.JSX.Element | null;
|
|
329
242
|
|
|
330
|
-
interface
|
|
331
|
-
/**
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
243
|
+
interface TaskContextValue {
|
|
244
|
+
/** Whether the task list is open */
|
|
245
|
+
isOpen: boolean;
|
|
246
|
+
/** Toggle open state */
|
|
247
|
+
setIsOpen: (value: boolean) => void;
|
|
248
|
+
}
|
|
249
|
+
declare function useTask(): TaskContextValue;
|
|
250
|
+
interface TaskProps {
|
|
251
|
+
/** Child elements */
|
|
252
|
+
children: ReactNode;
|
|
253
|
+
/** Whether to start open */
|
|
254
|
+
defaultOpen?: boolean;
|
|
255
|
+
/** Additional class name */
|
|
339
256
|
className?: string;
|
|
340
257
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
258
|
+
declare function Task({ children, defaultOpen, className, }: TaskProps): react_jsx_runtime.JSX.Element;
|
|
259
|
+
interface TaskTriggerProps {
|
|
260
|
+
/** Trigger content (usually task count/label) */
|
|
261
|
+
children: ReactNode;
|
|
262
|
+
/** Additional class name */
|
|
263
|
+
className?: string;
|
|
264
|
+
}
|
|
265
|
+
declare function TaskTrigger({ children, className }: TaskTriggerProps): react_jsx_runtime.JSX.Element;
|
|
266
|
+
interface TaskContentProps {
|
|
267
|
+
/** Child elements (TaskItem components) */
|
|
268
|
+
children: ReactNode;
|
|
269
|
+
/** Additional class name */
|
|
270
|
+
className?: string;
|
|
271
|
+
}
|
|
272
|
+
declare function TaskContent({ children, className }: TaskContentProps): react_jsx_runtime.JSX.Element | null;
|
|
273
|
+
interface TaskItemProps {
|
|
274
|
+
/** Task content */
|
|
275
|
+
children: ReactNode;
|
|
276
|
+
/** Task status */
|
|
277
|
+
status: TodoStatus;
|
|
278
|
+
/** Active form (shown when in_progress) */
|
|
279
|
+
activeForm?: string;
|
|
280
|
+
/** Additional class name */
|
|
281
|
+
className?: string;
|
|
282
|
+
}
|
|
283
|
+
declare function TaskItem({ children, status, activeForm, className, }: TaskItemProps): react_jsx_runtime.JSX.Element;
|
|
284
|
+
interface TaskListProps {
|
|
285
|
+
/** Todo items to display */
|
|
286
|
+
items: TodoItem[];
|
|
287
|
+
/** Whether to start open */
|
|
288
|
+
defaultOpen?: boolean;
|
|
289
|
+
/** Additional class name */
|
|
290
|
+
className?: string;
|
|
291
|
+
/** Custom title */
|
|
292
|
+
title?: string;
|
|
293
|
+
}
|
|
294
|
+
declare function TaskList({ items, defaultOpen, className, title, }: TaskListProps): react_jsx_runtime.JSX.Element;
|
|
353
295
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
296
|
+
interface AttachmentContextValue {
|
|
297
|
+
/** The file attachment data */
|
|
298
|
+
file: FileAttachment$2 | AttachmentFile;
|
|
299
|
+
/** Whether the attachment can be removed */
|
|
300
|
+
removable?: boolean;
|
|
301
|
+
/** Remove callback */
|
|
302
|
+
onRemove?: () => void;
|
|
303
|
+
}
|
|
304
|
+
declare function useAttachment(): AttachmentContextValue;
|
|
305
|
+
interface AttachmentFile {
|
|
306
|
+
/** File name */
|
|
307
|
+
name: string;
|
|
308
|
+
/** MIME type */
|
|
309
|
+
type: string;
|
|
310
|
+
/** File size in bytes */
|
|
311
|
+
size: number;
|
|
312
|
+
/** URL or data URL for preview */
|
|
313
|
+
url?: string;
|
|
314
|
+
/** Base64 data (for upload) */
|
|
315
|
+
base64?: string;
|
|
316
|
+
}
|
|
317
|
+
interface AttachmentsProps {
|
|
318
|
+
/** Child elements (Attachment components) */
|
|
368
319
|
children: ReactNode;
|
|
369
|
-
/**
|
|
370
|
-
|
|
320
|
+
/** Layout style */
|
|
321
|
+
layout?: 'grid' | 'inline' | 'list';
|
|
322
|
+
/** Additional class name */
|
|
323
|
+
className?: string;
|
|
371
324
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
declare function
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
*/
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
325
|
+
declare function Attachments({ children, layout, className, }: AttachmentsProps): react_jsx_runtime.JSX.Element;
|
|
326
|
+
interface AttachmentProps {
|
|
327
|
+
/** File data */
|
|
328
|
+
file: FileAttachment$2 | AttachmentFile;
|
|
329
|
+
/** Child elements (AttachmentPreview, etc.) */
|
|
330
|
+
children?: ReactNode;
|
|
331
|
+
/** Whether the attachment can be removed */
|
|
332
|
+
removable?: boolean;
|
|
333
|
+
/** Remove callback */
|
|
334
|
+
onRemove?: () => void;
|
|
335
|
+
/** Additional class name */
|
|
336
|
+
className?: string;
|
|
337
|
+
}
|
|
338
|
+
declare function Attachment({ file, children, removable, onRemove, className, }: AttachmentProps): react_jsx_runtime.JSX.Element;
|
|
339
|
+
interface AttachmentPreviewProps {
|
|
340
|
+
/** Additional class name */
|
|
341
|
+
className?: string;
|
|
342
|
+
/** Preview height */
|
|
343
|
+
height?: number;
|
|
344
|
+
}
|
|
345
|
+
declare function AttachmentPreview({ className, height, }: AttachmentPreviewProps): react_jsx_runtime.JSX.Element;
|
|
346
|
+
interface AttachmentInfoProps {
|
|
347
|
+
/** Additional class name */
|
|
348
|
+
className?: string;
|
|
349
|
+
/** Show file size */
|
|
350
|
+
showSize?: boolean;
|
|
351
|
+
}
|
|
352
|
+
declare function AttachmentInfo({ className, showSize, }: AttachmentInfoProps): react_jsx_runtime.JSX.Element;
|
|
353
|
+
interface AttachmentRemoveProps {
|
|
354
|
+
/** Additional class name */
|
|
355
|
+
className?: string;
|
|
356
|
+
}
|
|
357
|
+
declare function AttachmentRemove({ className }: AttachmentRemoveProps): react_jsx_runtime.JSX.Element | null;
|
|
358
|
+
interface FileBadgeProps {
|
|
359
|
+
/** File data */
|
|
360
|
+
file: FileAttachment$2 | AttachmentFile;
|
|
361
|
+
/** Whether the file can be removed */
|
|
362
|
+
removable?: boolean;
|
|
363
|
+
/** Remove callback */
|
|
364
|
+
onRemove?: () => void;
|
|
365
|
+
/** Additional class name */
|
|
366
|
+
className?: string;
|
|
367
|
+
}
|
|
368
|
+
declare function FileBadgeCompact({ file, removable, onRemove, className, }: FileBadgeProps): react_jsx_runtime.JSX.Element;
|
|
407
369
|
|
|
408
|
-
interface
|
|
409
|
-
/**
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
onSelect: (option: ParsedOption) => void;
|
|
413
|
-
/** Additional class names */
|
|
370
|
+
interface ShimmerProps {
|
|
371
|
+
/** Child elements */
|
|
372
|
+
children?: ReactNode;
|
|
373
|
+
/** Additional class name */
|
|
414
374
|
className?: string;
|
|
375
|
+
/** Whether shimmer is active */
|
|
376
|
+
isActive?: boolean;
|
|
415
377
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
378
|
+
declare function Shimmer({ children, className, isActive, }: ShimmerProps): react_jsx_runtime.JSX.Element | null;
|
|
379
|
+
interface ShimmerLineProps {
|
|
380
|
+
/** Width (CSS value or percentage) */
|
|
381
|
+
width?: string | number;
|
|
382
|
+
/** Height in pixels */
|
|
383
|
+
height?: number;
|
|
384
|
+
/** Additional class name */
|
|
385
|
+
className?: string;
|
|
386
|
+
}
|
|
387
|
+
declare function ShimmerLine({ width, height, className, }: ShimmerLineProps): react_jsx_runtime.JSX.Element;
|
|
388
|
+
interface ShimmerBlockProps {
|
|
389
|
+
/** Width (CSS value or percentage) */
|
|
390
|
+
width?: string | number;
|
|
391
|
+
/** Height in pixels */
|
|
392
|
+
height?: number;
|
|
393
|
+
/** Border radius */
|
|
394
|
+
rounded?: 'sm' | 'md' | 'lg' | 'full' | 'none';
|
|
395
|
+
/** Additional class name */
|
|
396
|
+
className?: string;
|
|
397
|
+
}
|
|
398
|
+
declare function ShimmerBlock({ width, height, rounded, className, }: ShimmerBlockProps): react_jsx_runtime.JSX.Element;
|
|
399
|
+
interface ShimmerTextProps {
|
|
400
|
+
/** Number of characters to approximate width */
|
|
401
|
+
chars?: number;
|
|
402
|
+
/** Additional class name */
|
|
403
|
+
className?: string;
|
|
404
|
+
}
|
|
405
|
+
declare function ShimmerText({ chars, className, }: ShimmerTextProps): react_jsx_runtime.JSX.Element;
|
|
406
|
+
interface LoadingDotsProps {
|
|
407
|
+
/** Size variant */
|
|
408
|
+
size?: 'sm' | 'md' | 'lg';
|
|
409
|
+
/** Additional class name */
|
|
410
|
+
className?: string;
|
|
411
|
+
}
|
|
412
|
+
declare function LoadingDots({ size, className, }: LoadingDotsProps): react_jsx_runtime.JSX.Element;
|
|
413
|
+
interface LoadingSpinnerProps {
|
|
414
|
+
/** Size variant */
|
|
415
|
+
size?: 'sm' | 'md' | 'lg';
|
|
416
|
+
/** Additional class name */
|
|
417
|
+
className?: string;
|
|
418
|
+
}
|
|
419
|
+
declare function LoadingSpinner({ size, className, }: LoadingSpinnerProps): react_jsx_runtime.JSX.Element;
|
|
420
|
+
interface MessageShimmerProps {
|
|
421
|
+
/** Message role to style appropriately */
|
|
422
|
+
role?: 'user' | 'assistant';
|
|
423
|
+
/** Additional class name */
|
|
424
|
+
className?: string;
|
|
425
|
+
}
|
|
426
|
+
declare function MessageShimmer({ role, className, }: MessageShimmerProps): react_jsx_runtime.JSX.Element;
|
|
434
427
|
|
|
435
|
-
interface
|
|
436
|
-
|
|
437
|
-
todos: TodoItem[];
|
|
438
|
-
/** Optional title for the panel */
|
|
428
|
+
interface LogsPanelProps {
|
|
429
|
+
logs: LogEntry[];
|
|
439
430
|
title?: string;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
showProgress?: boolean;
|
|
444
|
-
/** Additional class names */
|
|
431
|
+
isLoading?: boolean;
|
|
432
|
+
defaultCollapsed?: boolean;
|
|
433
|
+
maxHeight?: number;
|
|
445
434
|
className?: string;
|
|
446
435
|
}
|
|
447
436
|
/**
|
|
448
|
-
*
|
|
437
|
+
* LogsPanel - Collapsible panel for displaying log entries
|
|
449
438
|
*
|
|
450
439
|
* Features:
|
|
451
|
-
* -
|
|
452
|
-
* -
|
|
453
|
-
* -
|
|
454
|
-
* -
|
|
440
|
+
* - Collapsible header with log count
|
|
441
|
+
* - Error/warning count badges
|
|
442
|
+
* - Level-based coloring and icons
|
|
443
|
+
* - Expandable entries with JSON data
|
|
455
444
|
*
|
|
456
445
|
* @example
|
|
457
446
|
* ```tsx
|
|
458
|
-
* <
|
|
459
|
-
* <
|
|
460
|
-
* <TodoPanel todos={todos} compact />
|
|
447
|
+
* <LogsPanel logs={logEntries} />
|
|
448
|
+
* <LogsPanel logs={logs} title="Execution Logs" defaultCollapsed={false} />
|
|
461
449
|
* ```
|
|
462
450
|
*/
|
|
463
|
-
declare function
|
|
451
|
+
declare function LogsPanel({ logs, title, isLoading, defaultCollapsed, maxHeight, className, }: LogsPanelProps): react_jsx_runtime.JSX.Element | null;
|
|
464
452
|
|
|
465
453
|
interface EnvVarsPanelProps {
|
|
466
454
|
/** Current environment variables */
|
|
@@ -479,99 +467,52 @@ interface EnvVarsPanelProps {
|
|
|
479
467
|
/**
|
|
480
468
|
* EnvVarsPanel - Collapsible panel for managing environment variables
|
|
481
469
|
*
|
|
482
|
-
* Provides a UI for adding, viewing, and removing environment variables.
|
|
483
|
-
* Commonly used to set environment variables for sandbox/agent execution.
|
|
484
|
-
*
|
|
485
|
-
* @example
|
|
486
|
-
* ```tsx
|
|
487
|
-
* function ChatSettings() {
|
|
488
|
-
* const [envVars, setEnvVars] = useState<Record<string, string>>({});
|
|
489
|
-
*
|
|
490
|
-
* return (
|
|
491
|
-
* <EnvVarsPanel
|
|
492
|
-
* envVars={envVars}
|
|
493
|
-
* onChange={setEnvVars}
|
|
494
|
-
* helperText="These variables will be available in the sandbox."
|
|
495
|
-
* />
|
|
496
|
-
* );
|
|
497
|
-
* }
|
|
498
|
-
* ```
|
|
499
|
-
*/
|
|
500
|
-
declare function EnvVarsPanel({ envVars, onChange, defaultCollapsed, className, label, helperText, }: EnvVarsPanelProps): react_jsx_runtime.JSX.Element;
|
|
501
|
-
|
|
502
|
-
interface DisplayModeToggleProps {
|
|
503
|
-
/** Additional class name */
|
|
504
|
-
className?: string;
|
|
505
|
-
/** Show label text (default: true) */
|
|
506
|
-
showLabel?: boolean;
|
|
507
|
-
/** Custom labels for modes */
|
|
508
|
-
labels?: {
|
|
509
|
-
inline?: string;
|
|
510
|
-
compact?: string;
|
|
511
|
-
accordion?: string;
|
|
512
|
-
};
|
|
513
|
-
/** Which modes to cycle through (default: all three) */
|
|
514
|
-
modes?: ToolDisplayMode[];
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* DisplayModeToggle - Button to cycle through display modes
|
|
518
|
-
*
|
|
519
|
-
* Uses the DisplayModeContext to cycle through 'inline', 'compact', and 'accordion' modes.
|
|
520
|
-
* Must be used within a DisplayModeProvider.
|
|
470
|
+
* Provides a UI for adding, viewing, and removing environment variables.
|
|
471
|
+
* Commonly used to set environment variables for sandbox/agent execution.
|
|
521
472
|
*
|
|
522
473
|
* @example
|
|
523
474
|
* ```tsx
|
|
524
|
-
* function
|
|
525
|
-
*
|
|
526
|
-
* <header>
|
|
527
|
-
* <h1>Chat</h1>
|
|
528
|
-
* <DisplayModeToggle />
|
|
529
|
-
* </header>
|
|
530
|
-
* );
|
|
531
|
-
* }
|
|
475
|
+
* function ChatSettings() {
|
|
476
|
+
* const [envVars, setEnvVars] = useState<Record<string, string>>({});
|
|
532
477
|
*
|
|
533
|
-
* function App() {
|
|
534
478
|
* return (
|
|
535
|
-
* <
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
479
|
+
* <EnvVarsPanel
|
|
480
|
+
* envVars={envVars}
|
|
481
|
+
* onChange={setEnvVars}
|
|
482
|
+
* helperText="These variables will be available in the sandbox."
|
|
483
|
+
* />
|
|
539
484
|
* );
|
|
540
485
|
* }
|
|
541
486
|
* ```
|
|
542
487
|
*/
|
|
543
|
-
declare function
|
|
488
|
+
declare function EnvVarsPanel({ envVars, onChange, defaultCollapsed, className, label, helperText, }: EnvVarsPanelProps): react_jsx_runtime.JSX.Element;
|
|
544
489
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
defaultExpanded?: boolean;
|
|
551
|
-
/** Controlled expanded state */
|
|
552
|
-
isExpanded?: boolean;
|
|
553
|
-
/** Callback when expanded state changes */
|
|
554
|
-
onToggle?: () => void;
|
|
490
|
+
interface OptionCardsProps {
|
|
491
|
+
/** Parsed options to display */
|
|
492
|
+
options: ParsedOption[];
|
|
493
|
+
/** Callback when an option is selected */
|
|
494
|
+
onSelect: (option: ParsedOption) => void;
|
|
555
495
|
/** Additional class names */
|
|
556
496
|
className?: string;
|
|
557
497
|
}
|
|
558
498
|
/**
|
|
559
|
-
*
|
|
499
|
+
* OptionCards - Display clickable option cards for interactive selection
|
|
560
500
|
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
* - Expanded view shows CompactToolRow for each tool call
|
|
564
|
-
* - Clean, minimal design matching the compact UI style
|
|
501
|
+
* Renders a grid of glassmorphic cards that users can click to select an option.
|
|
502
|
+
* Used when assistant messages contain structured options for the user to choose from.
|
|
565
503
|
*
|
|
566
504
|
* @example
|
|
567
505
|
* ```tsx
|
|
568
|
-
* <
|
|
569
|
-
*
|
|
570
|
-
*
|
|
506
|
+
* <OptionCards
|
|
507
|
+
* options={[
|
|
508
|
+
* { id: '1', label: 'Add Product', description: 'Upload a new product' },
|
|
509
|
+
* { id: '2', label: 'Browse Existing', description: 'View your products' },
|
|
510
|
+
* ]}
|
|
511
|
+
* onSelect={(opt) => sendMessage(opt.label)}
|
|
571
512
|
* />
|
|
572
513
|
* ```
|
|
573
514
|
*/
|
|
574
|
-
declare function
|
|
515
|
+
declare function OptionCards({ options, onSelect, className }: OptionCardsProps): react_jsx_runtime.JSX.Element;
|
|
575
516
|
|
|
576
517
|
interface StatusIndicatorProps {
|
|
577
518
|
status: ToolStatus;
|
|
@@ -620,7 +561,8 @@ interface CodeBlockProps {
|
|
|
620
561
|
/**
|
|
621
562
|
* CodeBlock - Display code with syntax-aware styling and expand/collapse
|
|
622
563
|
*
|
|
623
|
-
* Uses glassmorphism dark theme styling with
|
|
564
|
+
* Uses glassmorphism dark theme styling with ChatGPT-style header containing
|
|
565
|
+
* language label and copy button.
|
|
624
566
|
*
|
|
625
567
|
* @example
|
|
626
568
|
* ```tsx
|
|
@@ -647,55 +589,12 @@ interface JsonDisplayProps {
|
|
|
647
589
|
*/
|
|
648
590
|
declare function JsonDisplay({ value, maxHeight, className }: JsonDisplayProps): react_jsx_runtime.JSX.Element;
|
|
649
591
|
|
|
650
|
-
interface StreamingTextProps {
|
|
651
|
-
content: string;
|
|
652
|
-
isStreaming?: boolean;
|
|
653
|
-
renderMarkdown?: boolean;
|
|
654
|
-
className?: string;
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* StreamingText - Display text that may be streaming, with optional markdown
|
|
658
|
-
*
|
|
659
|
-
* Shows a blinking cursor indicator when streaming is active.
|
|
660
|
-
* Uses glassmorphism theme styling.
|
|
661
|
-
*
|
|
662
|
-
* @example
|
|
663
|
-
* ```tsx
|
|
664
|
-
* <StreamingText content={text} isStreaming />
|
|
665
|
-
* <StreamingText content={markdown} renderMarkdown />
|
|
666
|
-
* ```
|
|
667
|
-
*/
|
|
668
|
-
declare function StreamingText({ content, isStreaming, renderMarkdown, className, }: StreamingTextProps): react_jsx_runtime.JSX.Element;
|
|
669
|
-
|
|
670
|
-
interface LoadingIndicatorProps {
|
|
671
|
-
variant?: 'dots' | 'pulse' | 'spinner' | 'cursor';
|
|
672
|
-
size?: 'sm' | 'md' | 'lg';
|
|
673
|
-
className?: string;
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* LoadingIndicator - Display various loading states
|
|
677
|
-
*
|
|
678
|
-
* Uses the glassmorphism theme with accent-colored animations.
|
|
679
|
-
*
|
|
680
|
-
* Variants:
|
|
681
|
-
* - dots: Three animated dots
|
|
682
|
-
* - pulse: Single pulsing dot
|
|
683
|
-
* - spinner: Rotating spinner
|
|
684
|
-
* - cursor: Blinking cursor (like in the demo)
|
|
685
|
-
*
|
|
686
|
-
* @example
|
|
687
|
-
* ```tsx
|
|
688
|
-
* <LoadingIndicator />
|
|
689
|
-
* <LoadingIndicator variant="spinner" size="lg" />
|
|
690
|
-
* <LoadingIndicator variant="cursor" />
|
|
691
|
-
* ```
|
|
692
|
-
*/
|
|
693
|
-
declare function LoadingIndicator({ variant, size, className }: LoadingIndicatorProps): react_jsx_runtime.JSX.Element;
|
|
694
|
-
|
|
695
592
|
interface LazyMarkdownProps {
|
|
696
593
|
children: string;
|
|
697
594
|
/** Fallback content to show while loading */
|
|
698
595
|
fallback?: ReactNode;
|
|
596
|
+
/** Custom component overrides for markdown elements */
|
|
597
|
+
components?: MarkdownComponents;
|
|
699
598
|
className?: string;
|
|
700
599
|
}
|
|
701
600
|
/**
|
|
@@ -707,121 +606,19 @@ interface LazyMarkdownProps {
|
|
|
707
606
|
* @example
|
|
708
607
|
* ```tsx
|
|
709
608
|
* <LazyMarkdown>{markdownContent}</LazyMarkdown>
|
|
710
|
-
* ```
|
|
711
|
-
*/
|
|
712
|
-
declare function LazyMarkdown({ children, fallback, className }: LazyMarkdownProps): react_jsx_runtime.JSX.Element;
|
|
713
|
-
|
|
714
|
-
interface RichContentRendererProps {
|
|
715
|
-
/** Rich content segments to render */
|
|
716
|
-
content: RichContent;
|
|
717
|
-
/** Custom renderers for segments */
|
|
718
|
-
renderers?: RichContentRenderers;
|
|
719
|
-
/** Additional class name */
|
|
720
|
-
className?: string;
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* RichContentRenderer - Renders structured rich content segments
|
|
724
|
-
*
|
|
725
|
-
* This is the preferred approach for rendering rich content within messages.
|
|
726
|
-
* Each segment type can have custom rendering via the `renderers` prop.
|
|
727
609
|
*
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
* {
|
|
733
|
-
* { type: 'mention', name: 'Scene1', color: '#ff0' },
|
|
734
|
-
* { type: 'text', content: ' timeline.' },
|
|
735
|
-
* ]}
|
|
736
|
-
* renderers={{
|
|
737
|
-
* renderMention: ({ segment }) => (
|
|
738
|
-
* <MentionBadge
|
|
739
|
-
* name={segment.name}
|
|
740
|
-
* onClick={() => scrollTo(segment.id)}
|
|
741
|
-
* />
|
|
742
|
-
* ),
|
|
610
|
+
* // With custom components
|
|
611
|
+
* <LazyMarkdown
|
|
612
|
+
* components={{
|
|
613
|
+
* h2: ({ children }) => <h2 className="custom-h2">{children}</h2>,
|
|
614
|
+
* code: ({ children, className }) => <CustomCode className={className}>{children}</CustomCode>,
|
|
743
615
|
* }}
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
|
|
747
|
-
declare function RichContentRenderer({ content, renderers, className, }: RichContentRendererProps): react_jsx_runtime.JSX.Element;
|
|
748
|
-
|
|
749
|
-
interface TypewriterTextProps {
|
|
750
|
-
/** Words to cycle through */
|
|
751
|
-
words?: string[];
|
|
752
|
-
/** Typing speed in ms per character */
|
|
753
|
-
typeSpeed?: number;
|
|
754
|
-
/** Pause before erasing in ms */
|
|
755
|
-
pauseBeforeErase?: number;
|
|
756
|
-
/** Erasing speed in ms per character */
|
|
757
|
-
eraseSpeed?: number;
|
|
758
|
-
/** Pause before typing next word in ms */
|
|
759
|
-
pauseBeforeType?: number;
|
|
760
|
-
/** Whether to show a blinking cursor */
|
|
761
|
-
showCursor?: boolean;
|
|
762
|
-
/** Additional class names */
|
|
763
|
-
className?: string;
|
|
764
|
-
/** Cursor class names */
|
|
765
|
-
cursorClassName?: string;
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* TypewriterText - Animated typing component that cycles through words
|
|
769
|
-
*
|
|
770
|
-
* Creates a typewriter effect that types out words character by character,
|
|
771
|
-
* pauses, then erases them before moving to the next word.
|
|
772
|
-
*
|
|
773
|
-
* @example
|
|
774
|
-
* ```tsx
|
|
775
|
-
* // Default thinking words
|
|
776
|
-
* <TypewriterText />
|
|
777
|
-
*
|
|
778
|
-
* // Custom words
|
|
779
|
-
* <TypewriterText words={['Loading', 'Processing', 'Almost done']} />
|
|
780
|
-
*
|
|
781
|
-
* // Custom speeds
|
|
782
|
-
* <TypewriterText typeSpeed={30} pauseBeforeErase={1000} />
|
|
616
|
+
* >
|
|
617
|
+
* {markdownContent}
|
|
618
|
+
* </LazyMarkdown>
|
|
783
619
|
* ```
|
|
784
620
|
*/
|
|
785
|
-
declare function
|
|
786
|
-
|
|
787
|
-
type Theme = 'light' | 'dark';
|
|
788
|
-
interface ThemeContextType {
|
|
789
|
-
theme: Theme;
|
|
790
|
-
toggleTheme: () => void;
|
|
791
|
-
setTheme: (theme: Theme) => void;
|
|
792
|
-
}
|
|
793
|
-
interface ThemeProviderProps {
|
|
794
|
-
children: ReactNode;
|
|
795
|
-
/** Default theme to use when no stored preference exists. Defaults to system preference, then 'light'. */
|
|
796
|
-
defaultTheme?: Theme;
|
|
797
|
-
/** localStorage key for persisting theme. Defaults to 'ash-ui-theme'. */
|
|
798
|
-
storageKey?: string;
|
|
799
|
-
/** Whether to listen for system theme changes. Defaults to true. */
|
|
800
|
-
listenToSystemChanges?: boolean;
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* ThemeProvider - Unified theme management for agentic UIs.
|
|
804
|
-
*
|
|
805
|
-
* Features:
|
|
806
|
-
* - Persists theme choice to localStorage
|
|
807
|
-
* - Respects system preference when no stored preference exists
|
|
808
|
-
* - Listens for system theme changes (configurable)
|
|
809
|
-
* - Adds/removes 'dark' class on document root for Tailwind CSS
|
|
810
|
-
*
|
|
811
|
-
* @example
|
|
812
|
-
* ```tsx
|
|
813
|
-
* <ThemeProvider>
|
|
814
|
-
* <App />
|
|
815
|
-
* </ThemeProvider>
|
|
816
|
-
*
|
|
817
|
-
* // With custom defaults
|
|
818
|
-
* <ThemeProvider defaultTheme="dark" storageKey="my-theme">
|
|
819
|
-
* <App />
|
|
820
|
-
* </ThemeProvider>
|
|
821
|
-
* ```
|
|
822
|
-
*/
|
|
823
|
-
declare function ThemeProvider({ children, defaultTheme, storageKey, listenToSystemChanges, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
824
|
-
declare function useTheme(): ThemeContextType;
|
|
621
|
+
declare function LazyMarkdown({ children, fallback, components, className }: LazyMarkdownProps): react_jsx_runtime.JSX.Element;
|
|
825
622
|
|
|
826
623
|
/**
|
|
827
624
|
* A queued message waiting to be sent
|
|
@@ -1009,6 +806,10 @@ interface UseFileUploadReturn {
|
|
|
1009
806
|
/** Click handler to trigger file input */
|
|
1010
807
|
openFilePicker: () => void;
|
|
1011
808
|
}
|
|
809
|
+
/**
|
|
810
|
+
* Format file size for display
|
|
811
|
+
*/
|
|
812
|
+
declare function formatFileSize(bytes: number): string;
|
|
1012
813
|
/**
|
|
1013
814
|
* Hook for managing file uploads with drag & drop support.
|
|
1014
815
|
*
|
|
@@ -1054,6 +855,113 @@ interface UseFileUploadReturn {
|
|
|
1054
855
|
declare function useFileUpload({ maxFileSize, // 100MB
|
|
1055
856
|
maxFiles, onValidationError, }?: UseFileUploadOptions): UseFileUploadReturn;
|
|
1056
857
|
|
|
858
|
+
/**
|
|
859
|
+
* Middleware utilities for useAgentChat
|
|
860
|
+
*
|
|
861
|
+
* Provides composable request and event transformation capabilities.
|
|
862
|
+
* Middleware functions are called in order, and each can transform or filter
|
|
863
|
+
* the request/event before passing it to the next middleware.
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* ```tsx
|
|
867
|
+
* const loggingMiddleware: ChatMiddleware = {
|
|
868
|
+
* onRequest: (request) => {
|
|
869
|
+
* console.log('Sending:', request.prompt);
|
|
870
|
+
* return request;
|
|
871
|
+
* },
|
|
872
|
+
* onEvent: (event) => {
|
|
873
|
+
* console.log('Received:', event.type);
|
|
874
|
+
* return event;
|
|
875
|
+
* },
|
|
876
|
+
* };
|
|
877
|
+
*
|
|
878
|
+
* const { send } = useAgentChat({
|
|
879
|
+
* middleware: [loggingMiddleware],
|
|
880
|
+
* // ...
|
|
881
|
+
* });
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Request object passed through middleware chain
|
|
887
|
+
*/
|
|
888
|
+
interface MiddlewareRequest {
|
|
889
|
+
/** The user's prompt */
|
|
890
|
+
prompt: string;
|
|
891
|
+
/** Current session ID (if resuming a conversation) */
|
|
892
|
+
sessionId: string | null;
|
|
893
|
+
/** Additional metadata to send with the request */
|
|
894
|
+
metadata?: Record<string, unknown>;
|
|
895
|
+
/** Additional context to prepend to the session */
|
|
896
|
+
sessionContext?: string;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Result returned from request middleware
|
|
900
|
+
* Return void or omit fields to keep original values
|
|
901
|
+
*/
|
|
902
|
+
interface MiddlewareRequestResult {
|
|
903
|
+
/** Modified prompt */
|
|
904
|
+
prompt?: string;
|
|
905
|
+
/** Modified metadata (merged with existing) */
|
|
906
|
+
metadata?: Record<string, unknown>;
|
|
907
|
+
/** Modified session context */
|
|
908
|
+
sessionContext?: string;
|
|
909
|
+
/** If set, cancels the request and shows this error */
|
|
910
|
+
error?: string;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Middleware interface for composable request/event transforms
|
|
914
|
+
*/
|
|
915
|
+
interface ChatMiddleware {
|
|
916
|
+
/** Called before the request is sent. Can modify request or return error to cancel. */
|
|
917
|
+
onRequest?: (request: MiddlewareRequest) => Promise<MiddlewareRequestResult | void> | MiddlewareRequestResult | void;
|
|
918
|
+
/** Called for each event. Return null to filter out the event. */
|
|
919
|
+
onEvent?: (event: StreamEvent) => Promise<StreamEvent | null> | StreamEvent | null;
|
|
920
|
+
/** Called when the stream completes successfully */
|
|
921
|
+
onComplete?: (sessionId: string) => void | Promise<void>;
|
|
922
|
+
/** Called when an error occurs */
|
|
923
|
+
onError?: (error: string) => void | Promise<void>;
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Apply request middleware chain
|
|
927
|
+
*
|
|
928
|
+
* Executes each middleware's onRequest handler in order.
|
|
929
|
+
* Each middleware can modify the request or return an error to cancel.
|
|
930
|
+
*
|
|
931
|
+
* @param middlewares - Array of middleware to apply
|
|
932
|
+
* @param request - Initial request object
|
|
933
|
+
* @returns Modified request and optional error
|
|
934
|
+
*/
|
|
935
|
+
declare function applyRequestMiddleware(middlewares: ChatMiddleware[], request: MiddlewareRequest): Promise<{
|
|
936
|
+
request: MiddlewareRequest;
|
|
937
|
+
error?: string;
|
|
938
|
+
}>;
|
|
939
|
+
/**
|
|
940
|
+
* Apply event middleware chain
|
|
941
|
+
*
|
|
942
|
+
* Executes each middleware's onEvent handler in order.
|
|
943
|
+
* If any middleware returns null, the event is filtered out.
|
|
944
|
+
*
|
|
945
|
+
* @param middlewares - Array of middleware to apply
|
|
946
|
+
* @param event - Stream event to process
|
|
947
|
+
* @returns Processed event or null if filtered
|
|
948
|
+
*/
|
|
949
|
+
declare function applyEventMiddleware(middlewares: ChatMiddleware[], event: StreamEvent): Promise<StreamEvent | null>;
|
|
950
|
+
/**
|
|
951
|
+
* Call completion handlers on all middleware
|
|
952
|
+
*
|
|
953
|
+
* @param middlewares - Array of middleware
|
|
954
|
+
* @param sessionId - Completed session ID
|
|
955
|
+
*/
|
|
956
|
+
declare function callMiddlewareComplete(middlewares: ChatMiddleware[], sessionId: string): Promise<void>;
|
|
957
|
+
/**
|
|
958
|
+
* Call error handlers on all middleware
|
|
959
|
+
*
|
|
960
|
+
* @param middlewares - Array of middleware
|
|
961
|
+
* @param error - Error message
|
|
962
|
+
*/
|
|
963
|
+
declare function callMiddlewareError(middlewares: ChatMiddleware[], error: string): Promise<void>;
|
|
964
|
+
|
|
1057
965
|
/**
|
|
1058
966
|
* useAgentChat - A React hook for streaming agent conversations
|
|
1059
967
|
*
|
|
@@ -1128,12 +1036,70 @@ interface StreamEvent {
|
|
|
1128
1036
|
* Async generator that yields StreamEvent objects
|
|
1129
1037
|
*/
|
|
1130
1038
|
type StreamGenerator = AsyncGenerator<StreamEvent, void, unknown>;
|
|
1039
|
+
/**
|
|
1040
|
+
* Options passed to CreateStreamFn
|
|
1041
|
+
*/
|
|
1042
|
+
interface CreateStreamOptions {
|
|
1043
|
+
/** AbortSignal to cancel the request */
|
|
1044
|
+
signal?: AbortSignal;
|
|
1045
|
+
/** Additional metadata from onBeforeSend/middleware */
|
|
1046
|
+
metadata?: Record<string, unknown>;
|
|
1047
|
+
/** Session context from onBeforeSend/middleware */
|
|
1048
|
+
sessionContext?: string;
|
|
1049
|
+
}
|
|
1131
1050
|
/**
|
|
1132
1051
|
* Function that creates a stream of events
|
|
1133
1052
|
* This matches the signature of client.agents.run() and client.sessions.send()
|
|
1134
|
-
*
|
|
1053
|
+
*
|
|
1054
|
+
* @example
|
|
1055
|
+
* ```tsx
|
|
1056
|
+
* createStream: (prompt, sessionId, options) => {
|
|
1057
|
+
* if (sessionId) {
|
|
1058
|
+
* return client.sessions.send(sessionId, prompt, {
|
|
1059
|
+
* signal: options?.signal,
|
|
1060
|
+
* sessionContext: options?.sessionContext,
|
|
1061
|
+
* metadata: options?.metadata,
|
|
1062
|
+
* });
|
|
1063
|
+
* }
|
|
1064
|
+
* return client.agents.run(agentId, prompt, {
|
|
1065
|
+
* signal: options?.signal,
|
|
1066
|
+
* sessionContext: options?.sessionContext,
|
|
1067
|
+
* metadata: options?.metadata,
|
|
1068
|
+
* });
|
|
1069
|
+
* }
|
|
1070
|
+
* ```
|
|
1071
|
+
*/
|
|
1072
|
+
type CreateStreamFn = (prompt: string, sessionId?: string, options?: CreateStreamOptions) => StreamGenerator;
|
|
1073
|
+
/**
|
|
1074
|
+
* Function that subscribes to an existing session's events
|
|
1075
|
+
* This is used for auto-reconnection when the primary stream is interrupted
|
|
1076
|
+
*/
|
|
1077
|
+
type SubscribeToSessionFn = (sessionId: string, signal?: AbortSignal) => StreamGenerator;
|
|
1078
|
+
/**
|
|
1079
|
+
* Context passed to onBeforeSend hook
|
|
1135
1080
|
*/
|
|
1136
|
-
|
|
1081
|
+
interface BeforeSendContext {
|
|
1082
|
+
/** The user's prompt */
|
|
1083
|
+
prompt: string;
|
|
1084
|
+
/** Current session ID (null for new conversations) */
|
|
1085
|
+
sessionId: string | null;
|
|
1086
|
+
/** Current entries in the conversation */
|
|
1087
|
+
entries: NormalizedEntry[];
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Result returned from onBeforeSend hook
|
|
1091
|
+
* Return void or omit fields to keep original values
|
|
1092
|
+
*/
|
|
1093
|
+
interface BeforeSendResult {
|
|
1094
|
+
/** Modified prompt to send */
|
|
1095
|
+
prompt?: string;
|
|
1096
|
+
/** Additional metadata to include with the request */
|
|
1097
|
+
metadata?: Record<string, unknown>;
|
|
1098
|
+
/** Additional context to prepend to the session */
|
|
1099
|
+
sessionContext?: string;
|
|
1100
|
+
/** If true, cancels the send operation */
|
|
1101
|
+
cancel?: boolean;
|
|
1102
|
+
}
|
|
1137
1103
|
/**
|
|
1138
1104
|
* Options for useAgentChat
|
|
1139
1105
|
*/
|
|
@@ -1153,6 +1119,18 @@ interface UseAgentChatOptions {
|
|
|
1153
1119
|
* ```
|
|
1154
1120
|
*/
|
|
1155
1121
|
createStream: CreateStreamFn;
|
|
1122
|
+
/**
|
|
1123
|
+
* Function to subscribe to an existing session for reconnection.
|
|
1124
|
+
* If provided, enables auto-reconnection when the stream is interrupted.
|
|
1125
|
+
*
|
|
1126
|
+
* @example
|
|
1127
|
+
* ```tsx
|
|
1128
|
+
* subscribeToSession: (sessionId, signal) => {
|
|
1129
|
+
* return client.sessions.subscribe(sessionId, { signal });
|
|
1130
|
+
* }
|
|
1131
|
+
* ```
|
|
1132
|
+
*/
|
|
1133
|
+
subscribeToSession?: SubscribeToSessionFn;
|
|
1156
1134
|
/**
|
|
1157
1135
|
* Initial session ID (for resuming a conversation)
|
|
1158
1136
|
*/
|
|
@@ -1177,6 +1155,71 @@ interface UseAgentChatOptions {
|
|
|
1177
1155
|
* Callback for sandbox log events
|
|
1178
1156
|
*/
|
|
1179
1157
|
onSandboxLog?: (entry: NonNullable<StreamEvent['entry']>) => void;
|
|
1158
|
+
/**
|
|
1159
|
+
* Callback when reconnection is attempted
|
|
1160
|
+
*/
|
|
1161
|
+
onReconnect?: (attempt: number, sessionId: string) => void;
|
|
1162
|
+
/**
|
|
1163
|
+
* Maximum number of reconnection attempts (default: 3)
|
|
1164
|
+
*/
|
|
1165
|
+
maxReconnectAttempts?: number;
|
|
1166
|
+
/**
|
|
1167
|
+
* Base delay for exponential backoff in ms (default: 1000)
|
|
1168
|
+
*/
|
|
1169
|
+
reconnectBaseDelay?: number;
|
|
1170
|
+
/**
|
|
1171
|
+
* Called before each message is sent.
|
|
1172
|
+
* Use for pre-flight work like file synchronization, validation, or adding context.
|
|
1173
|
+
* Return { cancel: true } to prevent the message from being sent.
|
|
1174
|
+
*
|
|
1175
|
+
* @example
|
|
1176
|
+
* ```tsx
|
|
1177
|
+
* onBeforeSend: async ({ prompt, sessionId }) => {
|
|
1178
|
+
* await syncFilesToSandbox(sessionId);
|
|
1179
|
+
* return {
|
|
1180
|
+
* sessionContext: `Current file: ${currentFile}`,
|
|
1181
|
+
* metadata: { version: '1.0' },
|
|
1182
|
+
* };
|
|
1183
|
+
* }
|
|
1184
|
+
* ```
|
|
1185
|
+
*/
|
|
1186
|
+
onBeforeSend?: (context: BeforeSendContext) => Promise<BeforeSendResult | void> | BeforeSendResult | void;
|
|
1187
|
+
/**
|
|
1188
|
+
* Called for every raw stream event before internal processing.
|
|
1189
|
+
* Use for logging, analytics, or detecting specific events.
|
|
1190
|
+
*
|
|
1191
|
+
* @example
|
|
1192
|
+
* ```tsx
|
|
1193
|
+
* onEvent: (event) => {
|
|
1194
|
+
* if (event.type === 'tool_result' && event.toolName === 'browser_navigate') {
|
|
1195
|
+
* updatePreview(event.toolResult?.url);
|
|
1196
|
+
* }
|
|
1197
|
+
* }
|
|
1198
|
+
* ```
|
|
1199
|
+
*/
|
|
1200
|
+
onEvent?: (event: StreamEvent) => void | Promise<void>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Array of middleware for composable request/event transforms.
|
|
1203
|
+
* Middleware are executed in order. Each can modify requests,
|
|
1204
|
+
* transform events, or filter events by returning null.
|
|
1205
|
+
*
|
|
1206
|
+
* @example
|
|
1207
|
+
* ```tsx
|
|
1208
|
+
* middleware: [
|
|
1209
|
+
* {
|
|
1210
|
+
* onRequest: async (req) => ({
|
|
1211
|
+
* metadata: { ...req.metadata, timestamp: Date.now() },
|
|
1212
|
+
* }),
|
|
1213
|
+
* onEvent: (event) => {
|
|
1214
|
+
* // Filter out sandbox_log events
|
|
1215
|
+
* if (event.type === 'sandbox_log') return null;
|
|
1216
|
+
* return event;
|
|
1217
|
+
* },
|
|
1218
|
+
* },
|
|
1219
|
+
* ]
|
|
1220
|
+
* ```
|
|
1221
|
+
*/
|
|
1222
|
+
middleware?: ChatMiddleware[];
|
|
1180
1223
|
}
|
|
1181
1224
|
/**
|
|
1182
1225
|
* Return type for useAgentChat
|
|
@@ -1191,6 +1234,10 @@ interface UseAgentChatReturn {
|
|
|
1191
1234
|
* Whether a message is currently being streamed
|
|
1192
1235
|
*/
|
|
1193
1236
|
isStreaming: boolean;
|
|
1237
|
+
/**
|
|
1238
|
+
* Whether the hook is attempting to reconnect after a stream interruption
|
|
1239
|
+
*/
|
|
1240
|
+
isReconnecting: boolean;
|
|
1194
1241
|
/**
|
|
1195
1242
|
* Current error message (if any)
|
|
1196
1243
|
*/
|
|
@@ -1219,6 +1266,158 @@ interface UseAgentChatReturn {
|
|
|
1219
1266
|
}
|
|
1220
1267
|
declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatReturn;
|
|
1221
1268
|
|
|
1269
|
+
/**
|
|
1270
|
+
* useChat - AI SDK compatible chat hook for ash-cloud
|
|
1271
|
+
*
|
|
1272
|
+
* This hook provides an interface compatible with AI SDK's useChat hook
|
|
1273
|
+
* while using ash-cloud's streaming infrastructure under the hood.
|
|
1274
|
+
*
|
|
1275
|
+
* @example
|
|
1276
|
+
* ```tsx
|
|
1277
|
+
* import { useChat } from '@ash-cloud/ash-ui';
|
|
1278
|
+
*
|
|
1279
|
+
* function Chat() {
|
|
1280
|
+
* const {
|
|
1281
|
+
* messages,
|
|
1282
|
+
* isLoading,
|
|
1283
|
+
* append,
|
|
1284
|
+
* stop,
|
|
1285
|
+
* setMessages,
|
|
1286
|
+
* } = useChat({
|
|
1287
|
+
* createStream: (prompt, sessionId) => client.agents.run(agentId, prompt),
|
|
1288
|
+
* onToolCall: ({ toolCall }) => console.log('Tool called:', toolCall.toolName),
|
|
1289
|
+
* });
|
|
1290
|
+
*
|
|
1291
|
+
* return (
|
|
1292
|
+
* <Conversation>
|
|
1293
|
+
* {messages.map((m) => (
|
|
1294
|
+
* <Message key={m.id} from={m.role}>{m.content}</Message>
|
|
1295
|
+
* ))}
|
|
1296
|
+
* </Conversation>
|
|
1297
|
+
* );
|
|
1298
|
+
* }
|
|
1299
|
+
* ```
|
|
1300
|
+
*/
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* Message to append to the conversation
|
|
1304
|
+
*/
|
|
1305
|
+
interface CreateMessage {
|
|
1306
|
+
/** Message ID (auto-generated if not provided) */
|
|
1307
|
+
id?: string;
|
|
1308
|
+
/** Message role */
|
|
1309
|
+
role: 'user' | 'assistant' | 'system' | 'data';
|
|
1310
|
+
/** Message content */
|
|
1311
|
+
content: string;
|
|
1312
|
+
/** Tool invocations */
|
|
1313
|
+
toolInvocations?: ToolInvocation[];
|
|
1314
|
+
/** Reasoning content */
|
|
1315
|
+
reasoning?: string;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Options for appending a message
|
|
1319
|
+
*/
|
|
1320
|
+
interface ChatRequestOptions {
|
|
1321
|
+
/** Additional data to include with the request */
|
|
1322
|
+
data?: Record<string, unknown>;
|
|
1323
|
+
/** Additional body parameters */
|
|
1324
|
+
body?: Record<string, unknown>;
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* Tool call handler callback
|
|
1328
|
+
*/
|
|
1329
|
+
interface ToolCallHandler {
|
|
1330
|
+
/** The tool invocation */
|
|
1331
|
+
toolCall: ToolInvocation;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Options for useChat hook
|
|
1335
|
+
*/
|
|
1336
|
+
interface UseChatOptions {
|
|
1337
|
+
/**
|
|
1338
|
+
* Function to create a stream of events.
|
|
1339
|
+
* Can wrap client.agents.run() or client.sessions.send()
|
|
1340
|
+
*/
|
|
1341
|
+
createStream: CreateStreamFn;
|
|
1342
|
+
/**
|
|
1343
|
+
* Function to subscribe to an existing session for reconnection.
|
|
1344
|
+
*/
|
|
1345
|
+
subscribeToSession?: (sessionId: string, signal?: AbortSignal) => StreamGenerator;
|
|
1346
|
+
/**
|
|
1347
|
+
* Initial session ID (for resuming a conversation)
|
|
1348
|
+
*/
|
|
1349
|
+
initialSessionId?: string;
|
|
1350
|
+
/**
|
|
1351
|
+
* Initial messages to display
|
|
1352
|
+
*/
|
|
1353
|
+
initialMessages?: Message$1[];
|
|
1354
|
+
/**
|
|
1355
|
+
* Callback when a tool is called
|
|
1356
|
+
*/
|
|
1357
|
+
onToolCall?: (handler: ToolCallHandler) => void;
|
|
1358
|
+
/**
|
|
1359
|
+
* Callback when streaming finishes
|
|
1360
|
+
*/
|
|
1361
|
+
onFinish?: (message: Message$1) => void;
|
|
1362
|
+
/**
|
|
1363
|
+
* Callback when an error occurs
|
|
1364
|
+
*/
|
|
1365
|
+
onError?: (error: Error) => void;
|
|
1366
|
+
/**
|
|
1367
|
+
* Callback when session starts
|
|
1368
|
+
*/
|
|
1369
|
+
onSessionStart?: (sessionId: string) => void;
|
|
1370
|
+
/**
|
|
1371
|
+
* Maximum number of reconnection attempts
|
|
1372
|
+
*/
|
|
1373
|
+
maxReconnectAttempts?: number;
|
|
1374
|
+
/**
|
|
1375
|
+
* Base delay for exponential backoff in ms
|
|
1376
|
+
*/
|
|
1377
|
+
reconnectBaseDelay?: number;
|
|
1378
|
+
/**
|
|
1379
|
+
* Middleware for composable request/event transforms
|
|
1380
|
+
*/
|
|
1381
|
+
middleware?: ChatMiddleware[];
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Return type for useChat
|
|
1385
|
+
*/
|
|
1386
|
+
interface UseChatReturn {
|
|
1387
|
+
/** All messages in the conversation */
|
|
1388
|
+
messages: Message$1[];
|
|
1389
|
+
/** Whether a message is currently being streamed */
|
|
1390
|
+
isLoading: boolean;
|
|
1391
|
+
/** Current error (if any) */
|
|
1392
|
+
error: Error | undefined;
|
|
1393
|
+
/** Current session ID */
|
|
1394
|
+
sessionId: string | null;
|
|
1395
|
+
/** Append a message to the conversation and stream response */
|
|
1396
|
+
append: (message: CreateMessage | string, options?: ChatRequestOptions) => Promise<string | null | undefined>;
|
|
1397
|
+
/** Stop the current streaming request */
|
|
1398
|
+
stop: () => void;
|
|
1399
|
+
/** Set messages (replace all) */
|
|
1400
|
+
setMessages: (messages: Message$1[]) => void;
|
|
1401
|
+
/** Reload the last assistant message */
|
|
1402
|
+
reload: () => Promise<string | null | undefined>;
|
|
1403
|
+
/** The current input value (for controlled input) */
|
|
1404
|
+
input: string;
|
|
1405
|
+
/** Set the input value */
|
|
1406
|
+
setInput: (input: string) => void;
|
|
1407
|
+
/** Handle input change (for form inputs) */
|
|
1408
|
+
handleInputChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
1409
|
+
/** Handle form submission */
|
|
1410
|
+
handleSubmit: (e?: React.FormEvent<HTMLFormElement>, options?: ChatRequestOptions) => void;
|
|
1411
|
+
/** Whether currently reconnecting after stream interruption */
|
|
1412
|
+
isReconnecting: boolean;
|
|
1413
|
+
/**
|
|
1414
|
+
* Legacy: Get entries in NormalizedEntry format
|
|
1415
|
+
* For backwards compatibility during migration
|
|
1416
|
+
*/
|
|
1417
|
+
entries: NormalizedEntry[];
|
|
1418
|
+
}
|
|
1419
|
+
declare function useChat(options: UseChatOptions): UseChatReturn;
|
|
1420
|
+
|
|
1222
1421
|
/**
|
|
1223
1422
|
* Configuration for long text auto-conversion
|
|
1224
1423
|
*/
|
|
@@ -1328,4 +1527,4 @@ interface UseLongTextConversionReturn {
|
|
|
1328
1527
|
*/
|
|
1329
1528
|
declare function useLongTextConversion({ threshold, filenameTemplate, onConversion, }?: LongTextConversionOptions): UseLongTextConversionReturn;
|
|
1330
1529
|
|
|
1331
|
-
export { ActionIcon, type ActionIconProps, ActionType, type StreamEvent as AgentStreamEvent,
|
|
1530
|
+
export { Message$1 as AIMessage, ActionIcon, type ActionIconProps, ActionType, type StreamEvent as AgentStreamEvent, Attachment, type AttachmentFile, AttachmentInfo, type AttachmentInfoProps, AttachmentPreview, type AttachmentPreviewProps, type AttachmentProps, AttachmentRemove, type AttachmentRemoveProps, Attachments, type AttachmentsProps, type BeforeSendContext, type BeforeSendResult, type FileAttachment as ChatFileAttachment, type ChatMiddleware, type ChatRequestOptions, CodeBlock, type CodeBlockProps, Conversation, ConversationContent, type ConversationContentProps, ConversationEmptyState, type ConversationEmptyStateProps, type ConversationProps, ConversationScrollButton, type ConversationScrollButtonProps, type ConversionInfo, type CreateMessage, type CreateStreamFn, type CreateStreamOptions, EnvVarsPanel, type EnvVarsPanelProps, FileAttachment$2 as FileAttachment, FileBadgeCompact, type FileBadgeProps, type FileAttachment as HookFileAttachment, JsonDisplay, type JsonDisplayProps, LazyMarkdown, type LazyMarkdownProps, LoadingDots, type LoadingDotsProps, LoadingSpinner, type LoadingSpinnerProps, LogEntry, LogsPanel, type LogsPanelProps, type LongTextConversionOptions, MarkdownComponents, Message, MessageAction, type MessageActionProps, MessageActions, type MessageActionsProps, MessageAvatar, type MessageAvatarProps, MessageContent, type MessageContentProps, type MessageProps, MessageResponse, type MessageResponseProps, MessageShimmer, type MessageShimmerProps, MessageTimestamp, type MessageTimestampProps, type MiddlewareRequest, type MiddlewareRequestResult, NormalizedEntry, OptionCards, type OptionCardsProps, ParsedOption, type QueuedMessage, Reasoning, ReasoningContent, type ReasoningContentProps, type ReasoningProps, ReasoningTrigger, type ReasoningTriggerProps, Shimmer, ShimmerBlock, type ShimmerBlockProps, ShimmerLine, type ShimmerLineProps, type ShimmerProps, ShimmerText, type ShimmerTextProps, StatusIndicator, type StatusIndicatorProps, type StreamGenerator, Task, TaskContent, type TaskContentProps, TaskItem, type TaskItemProps, TaskList, type TaskListProps, type TaskProps, TaskTrigger, type TaskTriggerProps, type TextAttachment, ThinkingIndicator, type ThinkingIndicatorProps, TodoItem, TodoStatus, Tool, type ToolCallHandler, ToolHeader, type ToolHeaderProps, ToolInput, type ToolInputProps, ToolInvocation, ToolList, type ToolListProps, ToolOutput, type ToolOutputProps, type ToolProps, ToolStatus, type UseAgentChatOptions, type UseAgentChatReturn, type UseChatOptions, type UseChatReturn, type UseFileUploadOptions, type UseFileUploadReturn, type UseLongTextConversionReturn, type UseMessageQueueOptions, type UseMessageQueueReturn, type UseStopExecutionOptions, type UseStopExecutionReturn, applyEventMiddleware, applyRequestMiddleware, callMiddlewareComplete, callMiddlewareError, formatFileSize as formatFileSizeHook, useAgentChat, useAttachment, useChat, useConversation, useFileUpload, useLongTextConversion, useMessage, useMessageQueue, useReasoning, useStopExecution, useTask, useTool };
|