@apteva/apteva-kit 0.1.17 → 0.1.22

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/index.d.mts CHANGED
@@ -138,6 +138,22 @@ interface GalleryWidget extends Widget {
138
138
  layout?: 'grid' | 'carousel';
139
139
  };
140
140
  }
141
+ interface TableColumn {
142
+ key: string;
143
+ label: string;
144
+ align?: 'left' | 'center' | 'right';
145
+ width?: string;
146
+ }
147
+ interface TableWidget extends Widget {
148
+ type: 'table';
149
+ props: {
150
+ columns: TableColumn[];
151
+ rows: Array<Record<string, any>>;
152
+ caption?: string;
153
+ compact?: boolean;
154
+ striped?: boolean;
155
+ };
156
+ }
141
157
 
142
158
  interface Message {
143
159
  id: string;
@@ -162,6 +178,59 @@ interface SendMessageParams {
162
178
  metadata?: Record<string, any>;
163
179
  }
164
180
 
181
+ /**
182
+ * Widget definitions for context injection
183
+ * These are sent to the agent so it knows what UI widgets are available
184
+ */
185
+ declare const WIDGET_DEFINITIONS: {
186
+ readonly card: {
187
+ readonly description: "Displays a card with title and optional description, image, footer";
188
+ readonly schema: "{\"title\": \"string\", \"description?\": \"string\", \"image?\": \"url\", \"footer?\": \"string\"}";
189
+ readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Key findings from the analysis\"}]";
190
+ };
191
+ readonly list: {
192
+ readonly description: "Displays a list of items with title, subtitle, and optional description";
193
+ readonly schema: "{\"items\": [{\"id\": \"string\", \"title\": \"string\", \"subtitle?\": \"string\", \"description?\": \"string\", \"image?\": \"url\"}]}";
194
+ readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"First item\", \"subtitle\": \"Details\"}]}]";
195
+ };
196
+ readonly button_group: {
197
+ readonly description: "Displays action buttons. User clicks are sent back to you with the button id";
198
+ readonly schema: "{\"buttons\": [{\"id\": \"string\", \"label\": \"string\", \"variant?\": \"primary|secondary|outline\"}], \"layout?\": \"horizontal|vertical\"}";
199
+ readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"confirm\", \"label\": \"Confirm\", \"variant\": \"primary\"}, {\"id\": \"cancel\", \"label\": \"Cancel\"}]}]";
200
+ };
201
+ readonly form: {
202
+ readonly description: "Displays an input form. Submitted data is sent back to you";
203
+ readonly schema: "{\"title?\": \"string\", \"fields\": [{\"name\": \"string\", \"type\": \"text|number|select|checkbox|textarea|date\", \"label\": \"string\", \"required?\": boolean, \"placeholder?\": \"string\", \"options?\": [{\"label\": \"string\", \"value\": \"string\"}]}]}";
204
+ readonly example: "@ui:form[{\"title\": \"Contact\", \"fields\": [{\"name\": \"email\", \"type\": \"text\", \"label\": \"Email\", \"required\": true}]}]";
205
+ };
206
+ readonly image: {
207
+ readonly description: "Displays a single image with optional caption";
208
+ readonly schema: "{\"src\": \"url\", \"alt\": \"string\", \"caption?\": \"string\"}";
209
+ readonly example: "@ui:image[{\"src\": \"https://example.com/img.png\", \"alt\": \"Description\", \"caption\": \"Figure 1\"}]";
210
+ };
211
+ readonly gallery: {
212
+ readonly description: "Displays multiple images in a grid or carousel layout";
213
+ readonly schema: "{\"images\": [{\"id\": \"string\", \"src\": \"url\", \"alt\": \"string\", \"caption?\": \"string\"}], \"layout?\": \"grid|carousel\"}";
214
+ readonly example: "@ui:gallery[{\"images\": [{\"id\": \"1\", \"src\": \"https://example.com/1.png\", \"alt\": \"Image 1\"}], \"layout\": \"grid\"}]";
215
+ };
216
+ readonly chart: {
217
+ readonly description: "Displays a chart visualization (line, bar, pie, doughnut)";
218
+ readonly schema: "{\"chartType\": \"line|bar|pie|doughnut\", \"title?\": \"string\", \"data\": {\"labels\": [\"string\"], \"datasets\": [{\"label\": \"string\", \"data\": [number], \"backgroundColor?\": \"string|string[]\"}]}}";
219
+ readonly example: "@ui:chart[{\"chartType\": \"bar\", \"title\": \"Sales\", \"data\": {\"labels\": [\"Q1\", \"Q2\"], \"datasets\": [{\"label\": \"Revenue\", \"data\": [100, 150]}]}}]";
220
+ };
221
+ readonly map: {
222
+ readonly description: "Displays an interactive map with optional markers";
223
+ readonly schema: "{\"center\": {\"lat\": number, \"lng\": number}, \"zoom?\": number, \"markers?\": [{\"id\": \"string\", \"position\": {\"lat\": number, \"lng\": number}, \"title\": \"string\"}]}";
224
+ readonly example: "@ui:map[{\"center\": {\"lat\": 40.7128, \"lng\": -74.0060}, \"zoom\": 12, \"markers\": [{\"id\": \"1\", \"position\": {\"lat\": 40.7128, \"lng\": -74.0060}, \"title\": \"NYC\"}]}]";
225
+ };
226
+ readonly table: {
227
+ readonly description: "Displays structured data in rows and columns";
228
+ readonly schema: "{\"columns\": [{\"key\": \"string\", \"label\": \"string\", \"align?\": \"left|center|right\"}], \"rows\": [{\"id?\": \"string\", ...}], \"caption?\": \"string\", \"compact?\": boolean, \"striped?\": boolean}";
229
+ readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}, {\"key\": \"status\", \"label\": \"Status\"}], \"rows\": [{\"name\": \"Item 1\", \"status\": \"Active\"}, {\"name\": \"Item 2\", \"status\": \"Pending\"}]}]";
230
+ };
231
+ };
232
+ type WidgetType = keyof typeof WIDGET_DEFINITIONS;
233
+
165
234
  interface SuggestedPrompt {
166
235
  text: string;
167
236
  icon?: React.ReactNode;
@@ -202,6 +271,10 @@ interface ChatProps {
202
271
  headerTitle?: string;
203
272
  enableFileUpload?: boolean;
204
273
  enableMarkdown?: boolean;
274
+ enableWidgets?: boolean;
275
+ availableWidgets?: WidgetType[];
276
+ compactWidgetContext?: boolean;
277
+ onWidgetRender?: (widget: Widget) => void;
205
278
  className?: string;
206
279
  }
207
280
  interface CommandProps {
@@ -306,7 +379,7 @@ interface UseAptevaKitReturn {
306
379
  error: Error | null;
307
380
  }
308
381
 
309
- declare function Chat({ agentId, threadId, initialMessages, context, apiUrl, apiKey, useMock, initialMode, showModeToggle, onModeChange, commandVariant, planMode, onPlanModeChange, enableStreaming, showProgress, loadingText, welcomeTitle, welcomeSubtitle, welcomeIcon, suggestedPrompts, welcomeVariant, onThreadChange, onMessageSent, onAction, onFileUpload, onComplete, onError, onToolResult, placeholder, showHeader, headerTitle, className, }: ChatProps): react_jsx_runtime.JSX.Element;
382
+ declare function Chat({ agentId, threadId, initialMessages, context, apiUrl, apiKey, useMock, initialMode, showModeToggle, onModeChange, commandVariant, planMode, onPlanModeChange, enableStreaming, showProgress, loadingText, welcomeTitle, welcomeSubtitle, welcomeIcon, suggestedPrompts, welcomeVariant, onThreadChange, onMessageSent, onAction, onFileUpload, onComplete, onError, onToolResult, placeholder, showHeader, headerTitle, enableWidgets, availableWidgets, compactWidgetContext, onWidgetRender, className, }: ChatProps): react_jsx_runtime.JSX.Element;
310
383
 
311
384
  declare function Command({ agentId, command: initialCommand, context, autoExecute, allowInput, placeholder, submitButtonText, variant, useMock, planMode, onPlanModeChange, enableFileUpload, onStart, onProgress, onChunk, onComplete, onError, onFileUpload, onAction, loadingText, showProgress, enableStreaming, resultRenderer, className, }: CommandProps): react_jsx_runtime.JSX.Element;
312
385
 
@@ -367,10 +440,11 @@ interface ChatResponse {
367
440
  widgets?: any[];
368
441
  }
369
442
  interface StreamChunk {
370
- type: 'start' | 'thread_id' | 'content' | 'token' | 'tool_call' | 'tool_input_delta' | 'tool_use' | 'tool_result' | 'stop' | 'widget' | 'complete' | 'done' | 'error';
443
+ type: 'start' | 'thread_id' | 'request_id' | 'content' | 'token' | 'tool_call' | 'tool_input_delta' | 'tool_use' | 'tool_result' | 'stop' | 'widget' | 'complete' | 'done' | 'error';
371
444
  content?: string;
372
445
  widget?: any;
373
446
  thread_id?: string;
447
+ request_id?: string;
374
448
  tool_id?: string;
375
449
  tool_name?: string;
376
450
  error?: string;
@@ -403,6 +477,10 @@ declare class AptevaClient {
403
477
  * Get thread messages
404
478
  */
405
479
  getThreadMessages(threadId: string): Promise<ChatMessage[]>;
480
+ /**
481
+ * Cancel an in-progress request
482
+ */
483
+ cancelRequest(agentId: string, requestId: string): Promise<void>;
406
484
  }
407
485
  declare const aptevaClient: AptevaClient;
408
486
 
@@ -412,4 +490,4 @@ declare const mockMessages: Message[];
412
490
  declare const mockThreads: Thread[];
413
491
  declare const mockWidgets: Widget[];
414
492
 
415
- export { type Action, type ActionEvent, AptevaClient, type AptevaClientConfig, type AptevaKitControl, Button, type ButtonGroupWidget, type ButtonWidget, Card, type CardWidget, type ChartWidget, Chat, type ChatMessage, type ChatProps, type ChatRequest, type ChatResponse, 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 StreamChunk, type StreamProps, type SuggestedPrompt, type Thread, Threads, type ThreadsProps, type UseAptevaKitReturn, type Widget, Widgets, type WidgetsProps, aptevaClient, cn, getThemeScript, mockMessages, mockThreads, mockWidgets };
493
+ export { type Action, type ActionEvent, AptevaClient, type AptevaClientConfig, type AptevaKitControl, Button, type ButtonGroupWidget, type ButtonWidget, Card, type CardWidget, type ChartWidget, Chat, type ChatMessage, type ChatProps, type ChatRequest, type ChatResponse, 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 StreamChunk, type StreamProps, type SuggestedPrompt, type TableColumn, type TableWidget, type Thread, Threads, type ThreadsProps, type UseAptevaKitReturn, type Widget, Widgets, type WidgetsProps, aptevaClient, cn, getThemeScript, mockMessages, mockThreads, mockWidgets };
package/dist/index.d.ts CHANGED
@@ -138,6 +138,22 @@ interface GalleryWidget extends Widget {
138
138
  layout?: 'grid' | 'carousel';
139
139
  };
140
140
  }
141
+ interface TableColumn {
142
+ key: string;
143
+ label: string;
144
+ align?: 'left' | 'center' | 'right';
145
+ width?: string;
146
+ }
147
+ interface TableWidget extends Widget {
148
+ type: 'table';
149
+ props: {
150
+ columns: TableColumn[];
151
+ rows: Array<Record<string, any>>;
152
+ caption?: string;
153
+ compact?: boolean;
154
+ striped?: boolean;
155
+ };
156
+ }
141
157
 
142
158
  interface Message {
143
159
  id: string;
@@ -162,6 +178,59 @@ interface SendMessageParams {
162
178
  metadata?: Record<string, any>;
163
179
  }
164
180
 
181
+ /**
182
+ * Widget definitions for context injection
183
+ * These are sent to the agent so it knows what UI widgets are available
184
+ */
185
+ declare const WIDGET_DEFINITIONS: {
186
+ readonly card: {
187
+ readonly description: "Displays a card with title and optional description, image, footer";
188
+ readonly schema: "{\"title\": \"string\", \"description?\": \"string\", \"image?\": \"url\", \"footer?\": \"string\"}";
189
+ readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Key findings from the analysis\"}]";
190
+ };
191
+ readonly list: {
192
+ readonly description: "Displays a list of items with title, subtitle, and optional description";
193
+ readonly schema: "{\"items\": [{\"id\": \"string\", \"title\": \"string\", \"subtitle?\": \"string\", \"description?\": \"string\", \"image?\": \"url\"}]}";
194
+ readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"First item\", \"subtitle\": \"Details\"}]}]";
195
+ };
196
+ readonly button_group: {
197
+ readonly description: "Displays action buttons. User clicks are sent back to you with the button id";
198
+ readonly schema: "{\"buttons\": [{\"id\": \"string\", \"label\": \"string\", \"variant?\": \"primary|secondary|outline\"}], \"layout?\": \"horizontal|vertical\"}";
199
+ readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"confirm\", \"label\": \"Confirm\", \"variant\": \"primary\"}, {\"id\": \"cancel\", \"label\": \"Cancel\"}]}]";
200
+ };
201
+ readonly form: {
202
+ readonly description: "Displays an input form. Submitted data is sent back to you";
203
+ readonly schema: "{\"title?\": \"string\", \"fields\": [{\"name\": \"string\", \"type\": \"text|number|select|checkbox|textarea|date\", \"label\": \"string\", \"required?\": boolean, \"placeholder?\": \"string\", \"options?\": [{\"label\": \"string\", \"value\": \"string\"}]}]}";
204
+ readonly example: "@ui:form[{\"title\": \"Contact\", \"fields\": [{\"name\": \"email\", \"type\": \"text\", \"label\": \"Email\", \"required\": true}]}]";
205
+ };
206
+ readonly image: {
207
+ readonly description: "Displays a single image with optional caption";
208
+ readonly schema: "{\"src\": \"url\", \"alt\": \"string\", \"caption?\": \"string\"}";
209
+ readonly example: "@ui:image[{\"src\": \"https://example.com/img.png\", \"alt\": \"Description\", \"caption\": \"Figure 1\"}]";
210
+ };
211
+ readonly gallery: {
212
+ readonly description: "Displays multiple images in a grid or carousel layout";
213
+ readonly schema: "{\"images\": [{\"id\": \"string\", \"src\": \"url\", \"alt\": \"string\", \"caption?\": \"string\"}], \"layout?\": \"grid|carousel\"}";
214
+ readonly example: "@ui:gallery[{\"images\": [{\"id\": \"1\", \"src\": \"https://example.com/1.png\", \"alt\": \"Image 1\"}], \"layout\": \"grid\"}]";
215
+ };
216
+ readonly chart: {
217
+ readonly description: "Displays a chart visualization (line, bar, pie, doughnut)";
218
+ readonly schema: "{\"chartType\": \"line|bar|pie|doughnut\", \"title?\": \"string\", \"data\": {\"labels\": [\"string\"], \"datasets\": [{\"label\": \"string\", \"data\": [number], \"backgroundColor?\": \"string|string[]\"}]}}";
219
+ readonly example: "@ui:chart[{\"chartType\": \"bar\", \"title\": \"Sales\", \"data\": {\"labels\": [\"Q1\", \"Q2\"], \"datasets\": [{\"label\": \"Revenue\", \"data\": [100, 150]}]}}]";
220
+ };
221
+ readonly map: {
222
+ readonly description: "Displays an interactive map with optional markers";
223
+ readonly schema: "{\"center\": {\"lat\": number, \"lng\": number}, \"zoom?\": number, \"markers?\": [{\"id\": \"string\", \"position\": {\"lat\": number, \"lng\": number}, \"title\": \"string\"}]}";
224
+ readonly example: "@ui:map[{\"center\": {\"lat\": 40.7128, \"lng\": -74.0060}, \"zoom\": 12, \"markers\": [{\"id\": \"1\", \"position\": {\"lat\": 40.7128, \"lng\": -74.0060}, \"title\": \"NYC\"}]}]";
225
+ };
226
+ readonly table: {
227
+ readonly description: "Displays structured data in rows and columns";
228
+ readonly schema: "{\"columns\": [{\"key\": \"string\", \"label\": \"string\", \"align?\": \"left|center|right\"}], \"rows\": [{\"id?\": \"string\", ...}], \"caption?\": \"string\", \"compact?\": boolean, \"striped?\": boolean}";
229
+ readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}, {\"key\": \"status\", \"label\": \"Status\"}], \"rows\": [{\"name\": \"Item 1\", \"status\": \"Active\"}, {\"name\": \"Item 2\", \"status\": \"Pending\"}]}]";
230
+ };
231
+ };
232
+ type WidgetType = keyof typeof WIDGET_DEFINITIONS;
233
+
165
234
  interface SuggestedPrompt {
166
235
  text: string;
167
236
  icon?: React.ReactNode;
@@ -202,6 +271,10 @@ interface ChatProps {
202
271
  headerTitle?: string;
203
272
  enableFileUpload?: boolean;
204
273
  enableMarkdown?: boolean;
274
+ enableWidgets?: boolean;
275
+ availableWidgets?: WidgetType[];
276
+ compactWidgetContext?: boolean;
277
+ onWidgetRender?: (widget: Widget) => void;
205
278
  className?: string;
206
279
  }
207
280
  interface CommandProps {
@@ -306,7 +379,7 @@ interface UseAptevaKitReturn {
306
379
  error: Error | null;
307
380
  }
308
381
 
309
- declare function Chat({ agentId, threadId, initialMessages, context, apiUrl, apiKey, useMock, initialMode, showModeToggle, onModeChange, commandVariant, planMode, onPlanModeChange, enableStreaming, showProgress, loadingText, welcomeTitle, welcomeSubtitle, welcomeIcon, suggestedPrompts, welcomeVariant, onThreadChange, onMessageSent, onAction, onFileUpload, onComplete, onError, onToolResult, placeholder, showHeader, headerTitle, className, }: ChatProps): react_jsx_runtime.JSX.Element;
382
+ declare function Chat({ agentId, threadId, initialMessages, context, apiUrl, apiKey, useMock, initialMode, showModeToggle, onModeChange, commandVariant, planMode, onPlanModeChange, enableStreaming, showProgress, loadingText, welcomeTitle, welcomeSubtitle, welcomeIcon, suggestedPrompts, welcomeVariant, onThreadChange, onMessageSent, onAction, onFileUpload, onComplete, onError, onToolResult, placeholder, showHeader, headerTitle, enableWidgets, availableWidgets, compactWidgetContext, onWidgetRender, className, }: ChatProps): react_jsx_runtime.JSX.Element;
310
383
 
311
384
  declare function Command({ agentId, command: initialCommand, context, autoExecute, allowInput, placeholder, submitButtonText, variant, useMock, planMode, onPlanModeChange, enableFileUpload, onStart, onProgress, onChunk, onComplete, onError, onFileUpload, onAction, loadingText, showProgress, enableStreaming, resultRenderer, className, }: CommandProps): react_jsx_runtime.JSX.Element;
312
385
 
@@ -367,10 +440,11 @@ interface ChatResponse {
367
440
  widgets?: any[];
368
441
  }
369
442
  interface StreamChunk {
370
- type: 'start' | 'thread_id' | 'content' | 'token' | 'tool_call' | 'tool_input_delta' | 'tool_use' | 'tool_result' | 'stop' | 'widget' | 'complete' | 'done' | 'error';
443
+ type: 'start' | 'thread_id' | 'request_id' | 'content' | 'token' | 'tool_call' | 'tool_input_delta' | 'tool_use' | 'tool_result' | 'stop' | 'widget' | 'complete' | 'done' | 'error';
371
444
  content?: string;
372
445
  widget?: any;
373
446
  thread_id?: string;
447
+ request_id?: string;
374
448
  tool_id?: string;
375
449
  tool_name?: string;
376
450
  error?: string;
@@ -403,6 +477,10 @@ declare class AptevaClient {
403
477
  * Get thread messages
404
478
  */
405
479
  getThreadMessages(threadId: string): Promise<ChatMessage[]>;
480
+ /**
481
+ * Cancel an in-progress request
482
+ */
483
+ cancelRequest(agentId: string, requestId: string): Promise<void>;
406
484
  }
407
485
  declare const aptevaClient: AptevaClient;
408
486
 
@@ -412,4 +490,4 @@ declare const mockMessages: Message[];
412
490
  declare const mockThreads: Thread[];
413
491
  declare const mockWidgets: Widget[];
414
492
 
415
- export { type Action, type ActionEvent, AptevaClient, type AptevaClientConfig, type AptevaKitControl, Button, type ButtonGroupWidget, type ButtonWidget, Card, type CardWidget, type ChartWidget, Chat, type ChatMessage, type ChatProps, type ChatRequest, type ChatResponse, 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 StreamChunk, type StreamProps, type SuggestedPrompt, type Thread, Threads, type ThreadsProps, type UseAptevaKitReturn, type Widget, Widgets, type WidgetsProps, aptevaClient, cn, getThemeScript, mockMessages, mockThreads, mockWidgets };
493
+ export { type Action, type ActionEvent, AptevaClient, type AptevaClientConfig, type AptevaKitControl, Button, type ButtonGroupWidget, type ButtonWidget, Card, type CardWidget, type ChartWidget, Chat, type ChatMessage, type ChatProps, type ChatRequest, type ChatResponse, 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 StreamChunk, type StreamProps, type SuggestedPrompt, type TableColumn, type TableWidget, type Thread, Threads, type ThreadsProps, type UseAptevaKitReturn, type Widget, Widgets, type WidgetsProps, aptevaClient, cn, getThemeScript, mockMessages, mockThreads, mockWidgets };