@devicai/ui 0.2.0 → 0.3.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.
Files changed (54) hide show
  1. package/dist/cjs/api/client.js +31 -15
  2. package/dist/cjs/api/client.js.map +1 -1
  3. package/dist/cjs/components/AICommandBar/AICommandBar.js +314 -0
  4. package/dist/cjs/components/AICommandBar/AICommandBar.js.map +1 -0
  5. package/dist/cjs/components/AICommandBar/useAICommandBar.js +595 -0
  6. package/dist/cjs/components/AICommandBar/useAICommandBar.js.map +1 -0
  7. package/dist/cjs/components/ChatDrawer/ChatDrawer.js +73 -5
  8. package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
  9. package/dist/cjs/components/ChatDrawer/ChatMessages.js +5 -2
  10. package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
  11. package/dist/cjs/components/Feedback/FeedbackModal.js +87 -0
  12. package/dist/cjs/components/Feedback/FeedbackModal.js.map +1 -0
  13. package/dist/cjs/components/Feedback/MessageActions.js +74 -0
  14. package/dist/cjs/components/Feedback/MessageActions.js.map +1 -0
  15. package/dist/cjs/index.js +9 -0
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/styles.css +1 -1
  18. package/dist/esm/api/client.d.ts +10 -2
  19. package/dist/esm/api/client.js +31 -15
  20. package/dist/esm/api/client.js.map +1 -1
  21. package/dist/esm/api/types.d.ts +25 -0
  22. package/dist/esm/components/AICommandBar/AICommandBar.d.ts +22 -0
  23. package/dist/esm/components/AICommandBar/AICommandBar.js +312 -0
  24. package/dist/esm/components/AICommandBar/AICommandBar.js.map +1 -0
  25. package/dist/esm/components/AICommandBar/AICommandBar.types.d.ts +321 -0
  26. package/dist/esm/components/AICommandBar/index.d.ts +3 -0
  27. package/dist/esm/components/AICommandBar/useAICommandBar.d.ts +57 -0
  28. package/dist/esm/components/AICommandBar/useAICommandBar.js +592 -0
  29. package/dist/esm/components/AICommandBar/useAICommandBar.js.map +1 -0
  30. package/dist/esm/components/AutocompleteInput/AutocompleteInput.d.ts +4 -0
  31. package/dist/esm/components/AutocompleteInput/AutocompleteInput.types.d.ts +50 -0
  32. package/dist/esm/components/AutocompleteInput/index.d.ts +4 -0
  33. package/dist/esm/components/AutocompleteInput/useAutocomplete.d.ts +29 -0
  34. package/dist/esm/components/ChatDrawer/ChatDrawer.d.ts +4 -2
  35. package/dist/esm/components/ChatDrawer/ChatDrawer.js +74 -6
  36. package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
  37. package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +36 -0
  38. package/dist/esm/components/ChatDrawer/ChatMessages.d.ts +2 -1
  39. package/dist/esm/components/ChatDrawer/ChatMessages.js +5 -2
  40. package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
  41. package/dist/esm/components/ChatDrawer/index.d.ts +1 -1
  42. package/dist/esm/components/Feedback/Feedback.types.d.ts +50 -0
  43. package/dist/esm/components/Feedback/FeedbackModal.d.ts +5 -0
  44. package/dist/esm/components/Feedback/FeedbackModal.js +85 -0
  45. package/dist/esm/components/Feedback/FeedbackModal.js.map +1 -0
  46. package/dist/esm/components/Feedback/MessageActions.d.ts +5 -0
  47. package/dist/esm/components/Feedback/MessageActions.js +72 -0
  48. package/dist/esm/components/Feedback/MessageActions.js.map +1 -0
  49. package/dist/esm/components/Feedback/index.d.ts +3 -0
  50. package/dist/esm/index.d.ts +6 -2
  51. package/dist/esm/index.js +4 -0
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/styles.css +1 -1
  54. package/package.json +1 -1
@@ -0,0 +1,321 @@
1
+ import type { ChatMessage, ModelInterfaceTool } from '../../api/types';
2
+ /**
3
+ * Command definition for the command bar
4
+ */
5
+ export interface AICommandBarCommand {
6
+ /**
7
+ * The keyword that triggers this command (without the leading /)
8
+ * e.g., "help", "clear", "support"
9
+ */
10
+ keyword: string;
11
+ /**
12
+ * Description shown in the command list
13
+ */
14
+ description: string;
15
+ /**
16
+ * The message to send when this command is selected
17
+ */
18
+ message: string;
19
+ /**
20
+ * Optional icon to show next to the command
21
+ */
22
+ icon?: React.ReactNode;
23
+ }
24
+ /**
25
+ * Options for positioning and styling the AICommandBar
26
+ */
27
+ export interface AICommandBarOptions {
28
+ /**
29
+ * Position mode: 'inline' renders in document flow, 'fixed' positions relative to viewport
30
+ * @default 'inline'
31
+ */
32
+ position?: 'inline' | 'fixed';
33
+ /**
34
+ * Placement when position is 'fixed'. Use CSS values.
35
+ */
36
+ fixedPlacement?: {
37
+ top?: number | string;
38
+ right?: number | string;
39
+ bottom?: number | string;
40
+ left?: number | string;
41
+ };
42
+ /**
43
+ * Keyboard shortcut to toggle the command bar (e.g., "cmd+j", "ctrl+k")
44
+ */
45
+ shortcut?: string;
46
+ /**
47
+ * Show the keyboard shortcut hint in the bar
48
+ * @default true
49
+ */
50
+ showShortcutHint?: boolean;
51
+ /**
52
+ * Placeholder text for the input
53
+ * @default 'Ask AI...'
54
+ */
55
+ placeholder?: string;
56
+ /**
57
+ * Custom icon to display on the left side of the bar
58
+ */
59
+ icon?: React.ReactNode;
60
+ /**
61
+ * Width of the command bar
62
+ * @default 400
63
+ */
64
+ width?: number | string;
65
+ /**
66
+ * Maximum width of the command bar
67
+ */
68
+ maxWidth?: number | string;
69
+ /**
70
+ * Z-index for the command bar
71
+ * @default 9999
72
+ */
73
+ zIndex?: number;
74
+ /**
75
+ * Whether to show the result card after completion
76
+ * @default true
77
+ */
78
+ showResultCard?: boolean;
79
+ /**
80
+ * Maximum height for the result card
81
+ * @default 300
82
+ */
83
+ resultCardMaxHeight?: number | string;
84
+ /**
85
+ * Primary color (used for accents)
86
+ */
87
+ color?: string;
88
+ /**
89
+ * Background color of the bar
90
+ */
91
+ backgroundColor?: string;
92
+ /**
93
+ * Text color
94
+ */
95
+ textColor?: string;
96
+ /**
97
+ * Border color
98
+ */
99
+ borderColor?: string;
100
+ /**
101
+ * Border radius
102
+ * @default 12
103
+ */
104
+ borderRadius?: number | string;
105
+ /**
106
+ * Font family
107
+ */
108
+ fontFamily?: string;
109
+ /**
110
+ * Font size
111
+ */
112
+ fontSize?: number | string;
113
+ /**
114
+ * Padding inside the bar
115
+ */
116
+ padding?: number | string;
117
+ /**
118
+ * Box shadow
119
+ */
120
+ boxShadow?: string;
121
+ /**
122
+ * Animation duration in ms
123
+ * @default 200
124
+ */
125
+ animationDuration?: number;
126
+ /**
127
+ * Custom renderers for tool calls by tool name.
128
+ * When a completed tool has a matching renderer, it replaces the default summary line.
129
+ */
130
+ toolRenderers?: Record<string, (input: any, output: any) => React.ReactNode>;
131
+ /**
132
+ * Custom icons for completed tool calls by tool name.
133
+ * Replaces the default check icon.
134
+ */
135
+ toolIcons?: Record<string, React.ReactNode>;
136
+ /**
137
+ * Message shown while processing (before any tools are called)
138
+ * @default 'Processing...'
139
+ */
140
+ processingMessage?: string;
141
+ /**
142
+ * Enable command history with arrow up/down navigation.
143
+ * History is stored in localStorage.
144
+ * @default true (opt-out)
145
+ */
146
+ enableHistory?: boolean;
147
+ /**
148
+ * Maximum number of history items to store
149
+ * @default 50
150
+ */
151
+ maxHistoryItems?: number;
152
+ /**
153
+ * localStorage key for storing history
154
+ * @default 'devic-command-bar-history'
155
+ */
156
+ historyStorageKey?: string;
157
+ /**
158
+ * Predefined commands that can be triggered with /keyword
159
+ * When user types /, a list of available commands is shown.
160
+ */
161
+ commands?: AICommandBarCommand[];
162
+ /**
163
+ * Whether to show the built-in /history command
164
+ * @default true
165
+ */
166
+ showHistoryCommand?: boolean;
167
+ }
168
+ /**
169
+ * Result returned after command bar execution
170
+ */
171
+ export interface CommandBarResult {
172
+ chatUid: string;
173
+ message: ChatMessage;
174
+ toolCalls: ToolCallSummary[];
175
+ }
176
+ /**
177
+ * Summary of a tool call for display
178
+ */
179
+ export interface ToolCallSummary {
180
+ id: string;
181
+ name: string;
182
+ status: 'pending' | 'executing' | 'completed' | 'error';
183
+ summary?: string;
184
+ input?: any;
185
+ output?: any;
186
+ error?: string;
187
+ }
188
+ /**
189
+ * Handle for programmatically controlling the AICommandBar
190
+ */
191
+ export interface AICommandBarHandle {
192
+ /**
193
+ * Open the command bar
194
+ */
195
+ open: () => void;
196
+ /**
197
+ * Close the command bar
198
+ */
199
+ close: () => void;
200
+ /**
201
+ * Toggle the command bar visibility
202
+ */
203
+ toggle: () => void;
204
+ /**
205
+ * Focus the input field
206
+ */
207
+ focus: () => void;
208
+ /**
209
+ * Programmatically submit a message
210
+ */
211
+ submit: (message: string) => Promise<void>;
212
+ /**
213
+ * Reset the command bar to initial state
214
+ */
215
+ reset: () => void;
216
+ }
217
+ /**
218
+ * Handle for programmatically controlling the ChatDrawer
219
+ */
220
+ export interface ChatDrawerHandle {
221
+ /**
222
+ * Open the drawer
223
+ */
224
+ open: () => void;
225
+ /**
226
+ * Close the drawer
227
+ */
228
+ close: () => void;
229
+ /**
230
+ * Toggle the drawer visibility
231
+ */
232
+ toggle: () => void;
233
+ /**
234
+ * Set the chat UID to load
235
+ */
236
+ setChatUid: (chatUid: string) => void;
237
+ /**
238
+ * Send a message in the drawer
239
+ */
240
+ sendMessage: (message: string) => void;
241
+ }
242
+ /**
243
+ * Props for the AICommandBar component
244
+ */
245
+ export interface AICommandBarProps {
246
+ /**
247
+ * Assistant identifier
248
+ */
249
+ assistantId: string;
250
+ /**
251
+ * API key (overrides DevicContext)
252
+ */
253
+ apiKey?: string;
254
+ /**
255
+ * Base URL (overrides DevicContext)
256
+ */
257
+ baseUrl?: string;
258
+ /**
259
+ * Tenant ID
260
+ */
261
+ tenantId?: string;
262
+ /**
263
+ * Tenant metadata
264
+ */
265
+ tenantMetadata?: Record<string, any>;
266
+ /**
267
+ * Display and behavior options
268
+ */
269
+ options?: AICommandBarOptions;
270
+ /**
271
+ * Controlled visibility state
272
+ */
273
+ isVisible?: boolean;
274
+ /**
275
+ * Callback when visibility changes
276
+ */
277
+ onVisibilityChange?: (visible: boolean) => void;
278
+ /**
279
+ * What happens when execution completes
280
+ * - 'openDrawer': Opens the ChatDrawer with the conversation
281
+ * - 'callback': Fires onResponse callback with result
282
+ * @default 'callback'
283
+ */
284
+ onExecute?: 'openDrawer' | 'callback';
285
+ /**
286
+ * Ref to the ChatDrawer component (required when onExecute is 'openDrawer')
287
+ */
288
+ chatDrawerRef?: React.RefObject<ChatDrawerHandle>;
289
+ /**
290
+ * Callback fired when execution completes (when onExecute is 'callback')
291
+ */
292
+ onResponse?: (response: CommandBarResult) => void;
293
+ /**
294
+ * Client-side tools for model interface protocol
295
+ */
296
+ modelInterfaceTools?: ModelInterfaceTool[];
297
+ /**
298
+ * Callback when a message is submitted
299
+ */
300
+ onSubmit?: (message: string) => void;
301
+ /**
302
+ * Callback when a tool is called
303
+ */
304
+ onToolCall?: (toolName: string, params: Record<string, any>) => void;
305
+ /**
306
+ * Callback when an error occurs
307
+ */
308
+ onError?: (error: Error) => void;
309
+ /**
310
+ * Callback when the command bar opens
311
+ */
312
+ onOpen?: () => void;
313
+ /**
314
+ * Callback when the command bar closes
315
+ */
316
+ onClose?: () => void;
317
+ /**
318
+ * Additional CSS class
319
+ */
320
+ className?: string;
321
+ }
@@ -0,0 +1,3 @@
1
+ export { AICommandBar } from './AICommandBar';
2
+ export { useAICommandBar, formatShortcut } from './useAICommandBar';
3
+ export type { AICommandBarProps, AICommandBarOptions, AICommandBarHandle, AICommandBarCommand, CommandBarResult, ToolCallSummary, ChatDrawerHandle, } from './AICommandBar.types';
@@ -0,0 +1,57 @@
1
+ import type { ModelInterfaceTool } from '../../api/types';
2
+ import type { AICommandBarOptions, AICommandBarCommand, CommandBarResult, ToolCallSummary, ChatDrawerHandle } from './AICommandBar.types';
3
+ export interface UseAICommandBarOptions {
4
+ assistantId: string;
5
+ apiKey?: string;
6
+ baseUrl?: string;
7
+ tenantId?: string;
8
+ tenantMetadata?: Record<string, any>;
9
+ options?: AICommandBarOptions;
10
+ isVisible?: boolean;
11
+ onVisibilityChange?: (visible: boolean) => void;
12
+ onExecute?: 'openDrawer' | 'callback';
13
+ chatDrawerRef?: React.RefObject<ChatDrawerHandle>;
14
+ onResponse?: (response: CommandBarResult) => void;
15
+ modelInterfaceTools?: ModelInterfaceTool[];
16
+ onSubmit?: (message: string) => void;
17
+ onToolCall?: (toolName: string, params: Record<string, any>) => void;
18
+ onError?: (error: Error) => void;
19
+ onOpen?: () => void;
20
+ onClose?: () => void;
21
+ }
22
+ export interface UseAICommandBarResult {
23
+ isVisible: boolean;
24
+ open: () => void;
25
+ close: () => void;
26
+ toggle: () => void;
27
+ inputValue: string;
28
+ setInputValue: (value: string) => void;
29
+ inputRef: React.RefObject<HTMLInputElement>;
30
+ focus: () => void;
31
+ isProcessing: boolean;
32
+ toolCalls: ToolCallSummary[];
33
+ currentToolSummary: string | null;
34
+ result: CommandBarResult | null;
35
+ chatUid: string | null;
36
+ error: Error | null;
37
+ history: string[];
38
+ historyIndex: number;
39
+ showingHistory: boolean;
40
+ setShowingHistory: (show: boolean) => void;
41
+ showingCommands: boolean;
42
+ filteredCommands: AICommandBarCommand[];
43
+ selectedCommandIndex: number;
44
+ selectCommand: (command: AICommandBarCommand) => void;
45
+ submit: (message?: string) => Promise<void>;
46
+ reset: () => void;
47
+ handleKeyDown: (e: React.KeyboardEvent) => void;
48
+ clearHistory: () => void;
49
+ }
50
+ /**
51
+ * Format a shortcut string for display
52
+ */
53
+ export declare function formatShortcut(shortcut: string): string;
54
+ /**
55
+ * Hook for managing AICommandBar state and behavior
56
+ */
57
+ export declare function useAICommandBar(options: UseAICommandBarOptions): UseAICommandBarResult;