@apteva/apteva-kit 0.1.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/README.md +147 -0
- package/dist/index.d.mts +310 -0
- package/dist/index.d.ts +310 -0
- package/dist/index.js +1229 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1190 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2 -0
- package/package.json +65 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ClassValue } from 'clsx';
|
|
3
|
+
|
|
4
|
+
interface Action {
|
|
5
|
+
type: string;
|
|
6
|
+
label: string;
|
|
7
|
+
payload: any;
|
|
8
|
+
handler: 'client' | 'server';
|
|
9
|
+
loadingText?: string;
|
|
10
|
+
}
|
|
11
|
+
interface ActionEvent {
|
|
12
|
+
type: string;
|
|
13
|
+
payload: any;
|
|
14
|
+
widgetId?: string;
|
|
15
|
+
timestamp: Date;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Widget {
|
|
19
|
+
type: string;
|
|
20
|
+
id: string;
|
|
21
|
+
props: Record<string, any>;
|
|
22
|
+
actions?: Action[];
|
|
23
|
+
}
|
|
24
|
+
interface CardWidget extends Widget {
|
|
25
|
+
type: 'card';
|
|
26
|
+
props: {
|
|
27
|
+
title: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
image?: string;
|
|
30
|
+
footer?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface ButtonWidget extends Widget {
|
|
34
|
+
type: 'button';
|
|
35
|
+
props: {
|
|
36
|
+
label: string;
|
|
37
|
+
variant?: 'primary' | 'secondary' | 'outline' | 'ghost';
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
interface ButtonGroupWidget extends Widget {
|
|
42
|
+
type: 'button_group';
|
|
43
|
+
props: {
|
|
44
|
+
layout?: 'horizontal' | 'vertical';
|
|
45
|
+
buttons: Array<{
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
variant?: 'primary' | 'secondary' | 'outline';
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
interface FormWidget extends Widget {
|
|
53
|
+
type: 'form';
|
|
54
|
+
props: {
|
|
55
|
+
title?: string;
|
|
56
|
+
fields: FormField[];
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
interface FormField {
|
|
60
|
+
name: string;
|
|
61
|
+
type: 'text' | 'number' | 'select' | 'checkbox' | 'textarea' | 'date';
|
|
62
|
+
label: string;
|
|
63
|
+
placeholder?: string;
|
|
64
|
+
required?: boolean;
|
|
65
|
+
options?: Array<{
|
|
66
|
+
label: string;
|
|
67
|
+
value: string;
|
|
68
|
+
}>;
|
|
69
|
+
defaultValue?: any;
|
|
70
|
+
}
|
|
71
|
+
interface ListWidget extends Widget {
|
|
72
|
+
type: 'list';
|
|
73
|
+
props: {
|
|
74
|
+
items: ListItem[];
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
interface ListItem {
|
|
78
|
+
id: string;
|
|
79
|
+
title: string;
|
|
80
|
+
subtitle?: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
image?: string;
|
|
83
|
+
metadata?: Record<string, any>;
|
|
84
|
+
}
|
|
85
|
+
interface ChartWidget extends Widget {
|
|
86
|
+
type: 'chart';
|
|
87
|
+
props: {
|
|
88
|
+
chartType: 'line' | 'bar' | 'pie' | 'doughnut';
|
|
89
|
+
title?: string;
|
|
90
|
+
data: {
|
|
91
|
+
labels: string[];
|
|
92
|
+
datasets: Array<{
|
|
93
|
+
label: string;
|
|
94
|
+
data: number[];
|
|
95
|
+
backgroundColor?: string | string[];
|
|
96
|
+
borderColor?: string;
|
|
97
|
+
}>;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
interface MapWidget extends Widget {
|
|
102
|
+
type: 'map';
|
|
103
|
+
props: {
|
|
104
|
+
center: {
|
|
105
|
+
lat: number;
|
|
106
|
+
lng: number;
|
|
107
|
+
};
|
|
108
|
+
zoom?: number;
|
|
109
|
+
markers?: Array<{
|
|
110
|
+
id: string;
|
|
111
|
+
position: {
|
|
112
|
+
lat: number;
|
|
113
|
+
lng: number;
|
|
114
|
+
};
|
|
115
|
+
title: string;
|
|
116
|
+
icon?: string;
|
|
117
|
+
}>;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
interface ImageWidget extends Widget {
|
|
121
|
+
type: 'image';
|
|
122
|
+
props: {
|
|
123
|
+
src: string;
|
|
124
|
+
alt: string;
|
|
125
|
+
caption?: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
interface GalleryWidget extends Widget {
|
|
129
|
+
type: 'gallery';
|
|
130
|
+
props: {
|
|
131
|
+
images: Array<{
|
|
132
|
+
id: string;
|
|
133
|
+
src: string;
|
|
134
|
+
alt: string;
|
|
135
|
+
caption?: string;
|
|
136
|
+
}>;
|
|
137
|
+
layout?: 'grid' | 'carousel';
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface Message {
|
|
142
|
+
id: string;
|
|
143
|
+
role: 'user' | 'assistant' | 'system';
|
|
144
|
+
content: string;
|
|
145
|
+
widgets?: Widget[];
|
|
146
|
+
timestamp: Date;
|
|
147
|
+
metadata?: Record<string, any>;
|
|
148
|
+
}
|
|
149
|
+
interface Thread {
|
|
150
|
+
id: string;
|
|
151
|
+
title: string;
|
|
152
|
+
preview?: string;
|
|
153
|
+
createdAt: Date;
|
|
154
|
+
updatedAt: Date;
|
|
155
|
+
messageCount: number;
|
|
156
|
+
metadata?: Record<string, any>;
|
|
157
|
+
}
|
|
158
|
+
interface SendMessageParams {
|
|
159
|
+
text: string;
|
|
160
|
+
attachments?: File[];
|
|
161
|
+
metadata?: Record<string, any>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface ChatProps {
|
|
165
|
+
agentId: string;
|
|
166
|
+
threadId?: string | null;
|
|
167
|
+
initialMessages?: Message[];
|
|
168
|
+
onThreadChange?: (threadId: string) => void;
|
|
169
|
+
onMessageSent?: (message: Message) => void;
|
|
170
|
+
onAction?: (action: ActionEvent) => void;
|
|
171
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
172
|
+
placeholder?: string;
|
|
173
|
+
showHeader?: boolean;
|
|
174
|
+
headerTitle?: string;
|
|
175
|
+
enableFileUpload?: boolean;
|
|
176
|
+
enableMarkdown?: boolean;
|
|
177
|
+
className?: string;
|
|
178
|
+
}
|
|
179
|
+
interface CommandProps {
|
|
180
|
+
agentId: string;
|
|
181
|
+
command?: string;
|
|
182
|
+
context?: Record<string, any>;
|
|
183
|
+
autoExecute?: boolean;
|
|
184
|
+
allowInput?: boolean;
|
|
185
|
+
placeholder?: string;
|
|
186
|
+
submitButtonText?: string;
|
|
187
|
+
variant?: 'default' | 'compact';
|
|
188
|
+
onStart?: () => void;
|
|
189
|
+
onProgress?: (progress: number) => void;
|
|
190
|
+
onChunk?: (chunk: string) => void;
|
|
191
|
+
onComplete?: (result: CommandResult) => void;
|
|
192
|
+
onError?: (error: Error) => void;
|
|
193
|
+
loadingText?: string;
|
|
194
|
+
showProgress?: boolean;
|
|
195
|
+
enableStreaming?: boolean;
|
|
196
|
+
resultRenderer?: (result: any) => React.ReactNode;
|
|
197
|
+
className?: string;
|
|
198
|
+
}
|
|
199
|
+
interface CommandResult {
|
|
200
|
+
success: boolean;
|
|
201
|
+
data: any;
|
|
202
|
+
widgets?: Widget[];
|
|
203
|
+
message?: string;
|
|
204
|
+
}
|
|
205
|
+
interface PromptProps {
|
|
206
|
+
agentId: string;
|
|
207
|
+
placeholder?: string;
|
|
208
|
+
initialValue?: string;
|
|
209
|
+
submitOn?: 'enter' | 'button' | 'blur';
|
|
210
|
+
debounceMs?: number;
|
|
211
|
+
minLength?: number;
|
|
212
|
+
maxLength?: number;
|
|
213
|
+
onSubmit?: (prompt: string) => void;
|
|
214
|
+
onResult?: (result: string) => void;
|
|
215
|
+
onChange?: (value: string) => void;
|
|
216
|
+
variant?: 'inline' | 'floating';
|
|
217
|
+
showSuggestions?: boolean;
|
|
218
|
+
className?: string;
|
|
219
|
+
}
|
|
220
|
+
interface StreamProps {
|
|
221
|
+
agentId: string;
|
|
222
|
+
prompt: string;
|
|
223
|
+
context?: Record<string, any>;
|
|
224
|
+
autoStart?: boolean;
|
|
225
|
+
onStart?: () => void;
|
|
226
|
+
onChunk?: (chunk: string) => void;
|
|
227
|
+
onComplete?: (fullText: string) => void;
|
|
228
|
+
onError?: (error: Error) => void;
|
|
229
|
+
variant?: 'prose' | 'code' | 'plain';
|
|
230
|
+
showCursor?: boolean;
|
|
231
|
+
typingSpeed?: number;
|
|
232
|
+
className?: string;
|
|
233
|
+
}
|
|
234
|
+
interface WidgetsProps {
|
|
235
|
+
widgets: Widget[];
|
|
236
|
+
onAction?: (action: ActionEvent) => void;
|
|
237
|
+
onWidgetMount?: (widgetId: string) => void;
|
|
238
|
+
layout?: 'stack' | 'grid' | 'masonry';
|
|
239
|
+
spacing?: 'tight' | 'normal' | 'loose';
|
|
240
|
+
columns?: number;
|
|
241
|
+
className?: string;
|
|
242
|
+
}
|
|
243
|
+
interface ThreadsProps {
|
|
244
|
+
threads: Thread[];
|
|
245
|
+
currentThreadId?: string;
|
|
246
|
+
onThreadSelect?: (threadId: string) => void;
|
|
247
|
+
onThreadDelete?: (threadId: string) => void;
|
|
248
|
+
onNewThread?: () => void;
|
|
249
|
+
variant?: 'sidebar' | 'dropdown' | 'tabs';
|
|
250
|
+
showSearch?: boolean;
|
|
251
|
+
showNewButton?: boolean;
|
|
252
|
+
groupBy?: 'date' | 'agent' | 'none';
|
|
253
|
+
className?: string;
|
|
254
|
+
}
|
|
255
|
+
interface AptevaKitControl {
|
|
256
|
+
setThreadId: (threadId: string | null) => Promise<void>;
|
|
257
|
+
createThread: (metadata?: object) => Promise<string>;
|
|
258
|
+
sendMessage: (params: SendMessageParams) => Promise<void>;
|
|
259
|
+
setComposerValue: (text: string) => Promise<void>;
|
|
260
|
+
sendAction: (action: Action) => Promise<void>;
|
|
261
|
+
refresh: () => Promise<void>;
|
|
262
|
+
focusComposer: () => Promise<void>;
|
|
263
|
+
scrollToBottom: () => void;
|
|
264
|
+
}
|
|
265
|
+
interface UseAptevaKitReturn {
|
|
266
|
+
control: AptevaKitControl;
|
|
267
|
+
threadId: string | null;
|
|
268
|
+
isLoading: boolean;
|
|
269
|
+
error: Error | null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare function Chat({ agentId, threadId, initialMessages, onThreadChange, onMessageSent, onAction, placeholder, showHeader, headerTitle, className, }: ChatProps): react_jsx_runtime.JSX.Element;
|
|
273
|
+
|
|
274
|
+
declare function Command({ agentId, command: initialCommand, context, autoExecute, allowInput, placeholder, submitButtonText, variant, onStart, onProgress, onChunk, onComplete, onError, loadingText, showProgress, enableStreaming, resultRenderer, className, }: CommandProps): react_jsx_runtime.JSX.Element;
|
|
275
|
+
|
|
276
|
+
declare function Prompt({ agentId, placeholder, initialValue, submitOn, debounceMs, minLength, maxLength, onSubmit, onResult, onChange, variant, showSuggestions, className, }: PromptProps): react_jsx_runtime.JSX.Element;
|
|
277
|
+
|
|
278
|
+
declare function Stream({ agentId, prompt, context, autoStart, onStart, onChunk, onComplete, onError, variant, showCursor, typingSpeed, className, }: StreamProps): react_jsx_runtime.JSX.Element;
|
|
279
|
+
|
|
280
|
+
declare function Widgets({ widgets, onAction, onWidgetMount, layout, spacing, columns, className, }: WidgetsProps): react_jsx_runtime.JSX.Element;
|
|
281
|
+
|
|
282
|
+
interface CardProps {
|
|
283
|
+
widget: CardWidget;
|
|
284
|
+
onAction?: (action: ActionEvent) => void;
|
|
285
|
+
}
|
|
286
|
+
declare function Card({ widget, onAction }: CardProps): react_jsx_runtime.JSX.Element;
|
|
287
|
+
|
|
288
|
+
interface ListProps {
|
|
289
|
+
widget: ListWidget;
|
|
290
|
+
onAction?: (action: ActionEvent) => void;
|
|
291
|
+
}
|
|
292
|
+
declare function List({ widget, onAction }: ListProps): react_jsx_runtime.JSX.Element;
|
|
293
|
+
|
|
294
|
+
interface ButtonProps {
|
|
295
|
+
widget: ButtonWidget;
|
|
296
|
+
onAction?: (action: ActionEvent) => void;
|
|
297
|
+
}
|
|
298
|
+
declare function Button({ widget, onAction }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
299
|
+
|
|
300
|
+
declare function Threads({ threads, currentThreadId, onThreadSelect, onThreadDelete, onNewThread, variant, showSearch, showNewButton, groupBy, className, }: ThreadsProps): react_jsx_runtime.JSX.Element;
|
|
301
|
+
|
|
302
|
+
declare function getThemeScript(): string;
|
|
303
|
+
|
|
304
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
305
|
+
|
|
306
|
+
declare const mockMessages: Message[];
|
|
307
|
+
declare const mockThreads: Thread[];
|
|
308
|
+
declare const mockWidgets: Widget[];
|
|
309
|
+
|
|
310
|
+
export { type Action, type ActionEvent, type AptevaKitControl, Button, type ButtonGroupWidget, type ButtonWidget, Card, type CardWidget, type ChartWidget, Chat, type ChatProps, Command, type CommandProps, type CommandResult, type FormField, type FormWidget, type GalleryWidget, type ImageWidget, List, type ListItem, type ListWidget, type MapWidget, type Message, Prompt, type PromptProps, type SendMessageParams, Stream, type StreamProps, type Thread, Threads, type ThreadsProps, type UseAptevaKitReturn, type Widget, Widgets, type WidgetsProps, cn, getThemeScript, mockMessages, mockThreads, mockWidgets };
|