@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/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Apteva-Kit
|
|
2
|
+
|
|
3
|
+
AI-powered component library for React. Build conversational interfaces with specialized components for different AI interaction patterns.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start
|
|
6
|
+
|
|
7
|
+
### Run the Example App (Port 3060)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
cd example
|
|
11
|
+
npm install
|
|
12
|
+
npm run dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then visit [http://localhost:3060](http://localhost:3060)
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @apteva/apteva-kit
|
|
21
|
+
# or
|
|
22
|
+
yarn add @apteva/apteva-kit
|
|
23
|
+
# or
|
|
24
|
+
bun add @apteva/apteva-kit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Components
|
|
28
|
+
|
|
29
|
+
### `<Chat>` - Full Chat Interface
|
|
30
|
+
Complete chat experience with message history, streaming, and widgets.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { Chat } from '@apteva/apteva-kit';
|
|
34
|
+
|
|
35
|
+
<Chat
|
|
36
|
+
agentId="agent_support"
|
|
37
|
+
headerTitle="Customer Support"
|
|
38
|
+
onAction={(action) => {
|
|
39
|
+
console.log('Action:', action);
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### `<Command>` - Single Command Execution
|
|
45
|
+
Execute a command, show loading, display result.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { Command } from '@apteva/apteva-kit';
|
|
49
|
+
|
|
50
|
+
<Command
|
|
51
|
+
agentId="agent_analyst"
|
|
52
|
+
command="Analyze Q4 sales data"
|
|
53
|
+
autoExecute
|
|
54
|
+
onComplete={(result) => {
|
|
55
|
+
console.log('Result:', result);
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### `<Prompt>` - Inline AI Input
|
|
61
|
+
Single input field with AI completion.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Prompt } from '@apteva/apteva-kit';
|
|
65
|
+
|
|
66
|
+
<Prompt
|
|
67
|
+
agentId="agent_writer"
|
|
68
|
+
placeholder="Describe your product..."
|
|
69
|
+
onResult={(text) => {
|
|
70
|
+
setDescription(text);
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `<Stream>` - Streaming Text Display
|
|
76
|
+
Display streaming AI text without input UI.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { Stream } from '@apteva/apteva-kit';
|
|
80
|
+
|
|
81
|
+
<Stream
|
|
82
|
+
agentId="agent_narrator"
|
|
83
|
+
prompt="Describe this dashboard"
|
|
84
|
+
autoStart
|
|
85
|
+
showCursor
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `<Widgets>` - Widget Renderer
|
|
90
|
+
Render AI-generated interactive widgets.
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { Widgets } from '@apteva/apteva-kit';
|
|
94
|
+
|
|
95
|
+
<Widgets
|
|
96
|
+
widgets={aiGeneratedWidgets}
|
|
97
|
+
layout="grid"
|
|
98
|
+
columns={3}
|
|
99
|
+
onAction={(action) => {
|
|
100
|
+
console.log('Widget action:', action);
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### `<Threads>` - Thread Management
|
|
106
|
+
Manage conversation threads.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { Threads } from '@apteva/apteva-kit';
|
|
110
|
+
|
|
111
|
+
<Threads
|
|
112
|
+
threads={conversations}
|
|
113
|
+
currentThreadId={activeThread}
|
|
114
|
+
onThreadSelect={setActiveThread}
|
|
115
|
+
variant="sidebar"
|
|
116
|
+
showSearch
|
|
117
|
+
/>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Features
|
|
121
|
+
|
|
122
|
+
- **Mock Data Built-in** - All components work with mock data out of the box
|
|
123
|
+
- **TypeScript Native** - Full type safety and autocompletion
|
|
124
|
+
- **Tailwind CSS** - Styled with Tailwind v4
|
|
125
|
+
- **Customizable** - Theme and style everything
|
|
126
|
+
- **Widget System** - Rich interactive widgets (cards, lists, forms, charts, maps)
|
|
127
|
+
- **Action Handling** - Client-side and server-side actions
|
|
128
|
+
|
|
129
|
+
## Development
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Install dependencies
|
|
133
|
+
npm install
|
|
134
|
+
|
|
135
|
+
# Build package
|
|
136
|
+
npm run build
|
|
137
|
+
|
|
138
|
+
# Watch mode
|
|
139
|
+
npm run dev
|
|
140
|
+
|
|
141
|
+
# Type check
|
|
142
|
+
npm run type-check
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
package/dist/index.d.mts
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 };
|