@apteva/apteva-kit 0.1.26 → 0.1.28
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 +16 -34
- package/dist/index.d.ts +16 -34
- package/dist/index.js +23 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -89
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -182,53 +182,35 @@ interface SendMessageParams {
|
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
184
|
* Widget definitions for context injection
|
|
185
|
-
* These are sent to the agent so it knows what UI widgets are available
|
|
186
185
|
*/
|
|
187
186
|
declare const WIDGET_DEFINITIONS: {
|
|
188
187
|
readonly card: {
|
|
189
|
-
readonly
|
|
190
|
-
readonly
|
|
191
|
-
readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Key findings from the analysis\"}]";
|
|
188
|
+
readonly schema: "title, description?, image?, footer?";
|
|
189
|
+
readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Details here\"}]";
|
|
192
190
|
};
|
|
193
191
|
readonly list: {
|
|
194
|
-
readonly
|
|
195
|
-
readonly
|
|
196
|
-
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"First item\", \"subtitle\": \"Details\"}]}]";
|
|
192
|
+
readonly schema: "items: [{id, title, subtitle?, description?}]";
|
|
193
|
+
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"Item\", \"subtitle\": \"Info\"}]}]";
|
|
197
194
|
};
|
|
198
195
|
readonly button_group: {
|
|
199
|
-
readonly
|
|
200
|
-
readonly
|
|
201
|
-
readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"confirm\", \"label\": \"Confirm\", \"variant\": \"primary\"}, {\"id\": \"cancel\", \"label\": \"Cancel\"}]}]";
|
|
196
|
+
readonly schema: "buttons: [{id, label, variant?}]";
|
|
197
|
+
readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"ok\", \"label\": \"OK\"}]}]";
|
|
202
198
|
};
|
|
203
199
|
readonly form: {
|
|
204
|
-
readonly
|
|
205
|
-
readonly
|
|
206
|
-
readonly example: "@ui:form[{\"title\": \"Contact\", \"fields\": [{\"name\": \"email\", \"type\": \"text\", \"label\": \"Email\", \"required\": true}]}]";
|
|
200
|
+
readonly schema: "fields: [{name, type, label, required?}]";
|
|
201
|
+
readonly example: "@ui:form[{\"fields\": [{\"name\": \"email\", \"type\": \"text\", \"label\": \"Email\"}]}]";
|
|
207
202
|
};
|
|
208
|
-
readonly
|
|
209
|
-
readonly
|
|
210
|
-
readonly
|
|
211
|
-
readonly example: "@ui:image[{\"src\": \"https://example.com/img.png\", \"alt\": \"Description\", \"caption\": \"Figure 1\"}]";
|
|
203
|
+
readonly table: {
|
|
204
|
+
readonly schema: "columns: [{key, label}], rows: [...]";
|
|
205
|
+
readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}], \"rows\": [{\"name\": \"A\"}]}]";
|
|
212
206
|
};
|
|
213
|
-
readonly
|
|
214
|
-
readonly
|
|
215
|
-
readonly
|
|
216
|
-
readonly example: "@ui:gallery[{\"images\": [{\"id\": \"1\", \"src\": \"https://example.com/1.png\", \"alt\": \"Image 1\"}], \"layout\": \"grid\"}]";
|
|
207
|
+
readonly image: {
|
|
208
|
+
readonly schema: "src, alt, caption?";
|
|
209
|
+
readonly example: "@ui:image[{\"src\": \"url\", \"alt\": \"desc\"}]";
|
|
217
210
|
};
|
|
218
211
|
readonly chart: {
|
|
219
|
-
readonly
|
|
220
|
-
readonly
|
|
221
|
-
readonly example: "@ui:chart[{\"chartType\": \"bar\", \"title\": \"Sales\", \"data\": {\"labels\": [\"Q1\", \"Q2\"], \"datasets\": [{\"label\": \"Revenue\", \"data\": [100, 150]}]}}]";
|
|
222
|
-
};
|
|
223
|
-
readonly map: {
|
|
224
|
-
readonly description: "Displays an interactive map with optional markers";
|
|
225
|
-
readonly schema: "{\"center\": {\"lat\": number, \"lng\": number}, \"zoom?\": number, \"markers?\": [{\"id\": \"string\", \"position\": {\"lat\": number, \"lng\": number}, \"title\": \"string\"}]}";
|
|
226
|
-
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\"}]}]";
|
|
227
|
-
};
|
|
228
|
-
readonly table: {
|
|
229
|
-
readonly description: "Displays structured data in rows and columns";
|
|
230
|
-
readonly schema: "{\"columns\": [{\"key\": \"string\", \"label\": \"string\", \"align?\": \"left|center|right\"}], \"rows\": [{\"id?\": \"string\", ...}], \"caption?\": \"string\", \"compact?\": boolean, \"striped?\": boolean}";
|
|
231
|
-
readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}, {\"key\": \"status\", \"label\": \"Status\"}], \"rows\": [{\"name\": \"Item 1\", \"status\": \"Active\"}, {\"name\": \"Item 2\", \"status\": \"Pending\"}]}]";
|
|
212
|
+
readonly schema: "chartType: line|bar|pie, data: {labels, datasets}";
|
|
213
|
+
readonly example: "@ui:chart[{\"chartType\": \"bar\", \"data\": {\"labels\": [\"A\"], \"datasets\": [{\"label\": \"X\", \"data\": [10]}]}}]";
|
|
232
214
|
};
|
|
233
215
|
};
|
|
234
216
|
type WidgetType = keyof typeof WIDGET_DEFINITIONS;
|
package/dist/index.d.ts
CHANGED
|
@@ -182,53 +182,35 @@ interface SendMessageParams {
|
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
184
|
* Widget definitions for context injection
|
|
185
|
-
* These are sent to the agent so it knows what UI widgets are available
|
|
186
185
|
*/
|
|
187
186
|
declare const WIDGET_DEFINITIONS: {
|
|
188
187
|
readonly card: {
|
|
189
|
-
readonly
|
|
190
|
-
readonly
|
|
191
|
-
readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Key findings from the analysis\"}]";
|
|
188
|
+
readonly schema: "title, description?, image?, footer?";
|
|
189
|
+
readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Details here\"}]";
|
|
192
190
|
};
|
|
193
191
|
readonly list: {
|
|
194
|
-
readonly
|
|
195
|
-
readonly
|
|
196
|
-
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"First item\", \"subtitle\": \"Details\"}]}]";
|
|
192
|
+
readonly schema: "items: [{id, title, subtitle?, description?}]";
|
|
193
|
+
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"Item\", \"subtitle\": \"Info\"}]}]";
|
|
197
194
|
};
|
|
198
195
|
readonly button_group: {
|
|
199
|
-
readonly
|
|
200
|
-
readonly
|
|
201
|
-
readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"confirm\", \"label\": \"Confirm\", \"variant\": \"primary\"}, {\"id\": \"cancel\", \"label\": \"Cancel\"}]}]";
|
|
196
|
+
readonly schema: "buttons: [{id, label, variant?}]";
|
|
197
|
+
readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"ok\", \"label\": \"OK\"}]}]";
|
|
202
198
|
};
|
|
203
199
|
readonly form: {
|
|
204
|
-
readonly
|
|
205
|
-
readonly
|
|
206
|
-
readonly example: "@ui:form[{\"title\": \"Contact\", \"fields\": [{\"name\": \"email\", \"type\": \"text\", \"label\": \"Email\", \"required\": true}]}]";
|
|
200
|
+
readonly schema: "fields: [{name, type, label, required?}]";
|
|
201
|
+
readonly example: "@ui:form[{\"fields\": [{\"name\": \"email\", \"type\": \"text\", \"label\": \"Email\"}]}]";
|
|
207
202
|
};
|
|
208
|
-
readonly
|
|
209
|
-
readonly
|
|
210
|
-
readonly
|
|
211
|
-
readonly example: "@ui:image[{\"src\": \"https://example.com/img.png\", \"alt\": \"Description\", \"caption\": \"Figure 1\"}]";
|
|
203
|
+
readonly table: {
|
|
204
|
+
readonly schema: "columns: [{key, label}], rows: [...]";
|
|
205
|
+
readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}], \"rows\": [{\"name\": \"A\"}]}]";
|
|
212
206
|
};
|
|
213
|
-
readonly
|
|
214
|
-
readonly
|
|
215
|
-
readonly
|
|
216
|
-
readonly example: "@ui:gallery[{\"images\": [{\"id\": \"1\", \"src\": \"https://example.com/1.png\", \"alt\": \"Image 1\"}], \"layout\": \"grid\"}]";
|
|
207
|
+
readonly image: {
|
|
208
|
+
readonly schema: "src, alt, caption?";
|
|
209
|
+
readonly example: "@ui:image[{\"src\": \"url\", \"alt\": \"desc\"}]";
|
|
217
210
|
};
|
|
218
211
|
readonly chart: {
|
|
219
|
-
readonly
|
|
220
|
-
readonly
|
|
221
|
-
readonly example: "@ui:chart[{\"chartType\": \"bar\", \"title\": \"Sales\", \"data\": {\"labels\": [\"Q1\", \"Q2\"], \"datasets\": [{\"label\": \"Revenue\", \"data\": [100, 150]}]}}]";
|
|
222
|
-
};
|
|
223
|
-
readonly map: {
|
|
224
|
-
readonly description: "Displays an interactive map with optional markers";
|
|
225
|
-
readonly schema: "{\"center\": {\"lat\": number, \"lng\": number}, \"zoom?\": number, \"markers?\": [{\"id\": \"string\", \"position\": {\"lat\": number, \"lng\": number}, \"title\": \"string\"}]}";
|
|
226
|
-
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\"}]}]";
|
|
227
|
-
};
|
|
228
|
-
readonly table: {
|
|
229
|
-
readonly description: "Displays structured data in rows and columns";
|
|
230
|
-
readonly schema: "{\"columns\": [{\"key\": \"string\", \"label\": \"string\", \"align?\": \"left|center|right\"}], \"rows\": [{\"id?\": \"string\", ...}], \"caption?\": \"string\", \"compact?\": boolean, \"striped?\": boolean}";
|
|
231
|
-
readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}, {\"key\": \"status\", \"label\": \"Status\"}], \"rows\": [{\"name\": \"Item 1\", \"status\": \"Active\"}, {\"name\": \"Item 2\", \"status\": \"Pending\"}]}]";
|
|
212
|
+
readonly schema: "chartType: line|bar|pie, data: {labels, datasets}";
|
|
213
|
+
readonly example: "@ui:chart[{\"chartType\": \"bar\", \"data\": {\"labels\": [\"A\"], \"datasets\": [{\"label\": \"X\", \"data\": [10]}]}}]";
|
|
232
214
|
};
|
|
233
215
|
};
|
|
234
216
|
type WidgetType = keyof typeof WIDGET_DEFINITIONS;
|
package/dist/index.js
CHANGED
|
@@ -639,124 +639,58 @@ function parseWidgetsFromText(text) {
|
|
|
639
639
|
// src/utils/widget-context.ts
|
|
640
640
|
var WIDGET_DEFINITIONS = {
|
|
641
641
|
card: {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
example: '@ui:card[{"title": "Summary", "description": "Key findings from the analysis"}]'
|
|
642
|
+
schema: "title, description?, image?, footer?",
|
|
643
|
+
example: '@ui:card[{"title": "Summary", "description": "Details here"}]'
|
|
645
644
|
},
|
|
646
645
|
list: {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
example: '@ui:list[{"items": [{"id": "1", "title": "First item", "subtitle": "Details"}]}]'
|
|
646
|
+
schema: "items: [{id, title, subtitle?, description?}]",
|
|
647
|
+
example: '@ui:list[{"items": [{"id": "1", "title": "Item", "subtitle": "Info"}]}]'
|
|
650
648
|
},
|
|
651
649
|
button_group: {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
example: '@ui:button_group[{"buttons": [{"id": "confirm", "label": "Confirm", "variant": "primary"}, {"id": "cancel", "label": "Cancel"}]}]'
|
|
650
|
+
schema: "buttons: [{id, label, variant?}]",
|
|
651
|
+
example: '@ui:button_group[{"buttons": [{"id": "ok", "label": "OK"}]}]'
|
|
655
652
|
},
|
|
656
653
|
form: {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
example: '@ui:form[{"title": "Contact", "fields": [{"name": "email", "type": "text", "label": "Email", "required": true}]}]'
|
|
654
|
+
schema: "fields: [{name, type, label, required?}]",
|
|
655
|
+
example: '@ui:form[{"fields": [{"name": "email", "type": "text", "label": "Email"}]}]'
|
|
660
656
|
},
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
example: '@ui:image[{"src": "https://example.com/img.png", "alt": "Description", "caption": "Figure 1"}]'
|
|
657
|
+
table: {
|
|
658
|
+
schema: "columns: [{key, label}], rows: [...]",
|
|
659
|
+
example: '@ui:table[{"columns": [{"key": "name", "label": "Name"}], "rows": [{"name": "A"}]}]'
|
|
665
660
|
},
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
example: '@ui:gallery[{"images": [{"id": "1", "src": "https://example.com/1.png", "alt": "Image 1"}], "layout": "grid"}]'
|
|
661
|
+
image: {
|
|
662
|
+
schema: "src, alt, caption?",
|
|
663
|
+
example: '@ui:image[{"src": "url", "alt": "desc"}]'
|
|
670
664
|
},
|
|
671
665
|
chart: {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
example: '@ui:chart[{"chartType": "bar", "title": "Sales", "data": {"labels": ["Q1", "Q2"], "datasets": [{"label": "Revenue", "data": [100, 150]}]}}]'
|
|
675
|
-
},
|
|
676
|
-
map: {
|
|
677
|
-
description: "Displays an interactive map with optional markers",
|
|
678
|
-
schema: '{"center": {"lat": number, "lng": number}, "zoom?": number, "markers?": [{"id": "string", "position": {"lat": number, "lng": number}, "title": "string"}]}',
|
|
679
|
-
example: '@ui:map[{"center": {"lat": 40.7128, "lng": -74.0060}, "zoom": 12, "markers": [{"id": "1", "position": {"lat": 40.7128, "lng": -74.0060}, "title": "NYC"}]}]'
|
|
680
|
-
},
|
|
681
|
-
table: {
|
|
682
|
-
description: "Displays structured data in rows and columns",
|
|
683
|
-
schema: '{"columns": [{"key": "string", "label": "string", "align?": "left|center|right"}], "rows": [{"id?": "string", ...}], "caption?": "string", "compact?": boolean, "striped?": boolean}',
|
|
684
|
-
example: '@ui:table[{"columns": [{"key": "name", "label": "Name"}, {"key": "status", "label": "Status"}], "rows": [{"name": "Item 1", "status": "Active"}, {"name": "Item 2", "status": "Pending"}]}]'
|
|
666
|
+
schema: "chartType: line|bar|pie, data: {labels, datasets}",
|
|
667
|
+
example: '@ui:chart[{"chartType": "bar", "data": {"labels": ["A"], "datasets": [{"label": "X", "data": [10]}]}}]'
|
|
685
668
|
}
|
|
686
669
|
};
|
|
687
670
|
var ALL_WIDGET_TYPES = Object.keys(WIDGET_DEFINITIONS);
|
|
688
671
|
function generateWidgetContext(enabledWidgets) {
|
|
689
672
|
const widgets = enabledWidgets || ALL_WIDGET_TYPES;
|
|
690
673
|
let context = `
|
|
691
|
-
##
|
|
692
|
-
|
|
693
|
-
`;
|
|
694
|
-
context += `You can render rich UI components in your responses using this syntax: @ui:type[{json_props}]
|
|
695
|
-
|
|
696
|
-
`;
|
|
697
|
-
context += `The widget syntax will be automatically converted to interactive UI. Users see the rendered widget, not the raw syntax.
|
|
698
|
-
|
|
699
|
-
`;
|
|
700
|
-
context += `### Available widgets:
|
|
674
|
+
## UI Widgets
|
|
675
|
+
Render widgets: @ui:type[{props}]. Add "meta" for hidden data captured by UI.
|
|
701
676
|
|
|
702
677
|
`;
|
|
703
678
|
for (const type of widgets) {
|
|
704
679
|
const def = WIDGET_DEFINITIONS[type];
|
|
705
680
|
if (!def) continue;
|
|
706
|
-
context +=
|
|
707
|
-
`;
|
|
708
|
-
context += `Schema: \`${def.schema}\`
|
|
709
|
-
`;
|
|
710
|
-
context += `Example: \`${def.example}\`
|
|
711
|
-
|
|
681
|
+
context += `${type}: ${def.schema} | ${def.example}
|
|
712
682
|
`;
|
|
713
683
|
}
|
|
714
|
-
context +=
|
|
715
|
-
|
|
716
|
-
`;
|
|
717
|
-
context += `Any widget can include a "meta" field with extended data that isn't displayed but is captured by the UI:
|
|
718
|
-
`;
|
|
719
|
-
context += `- The widget displays from regular props (compact view)
|
|
720
|
-
`;
|
|
721
|
-
context += `- The "meta" field contains full/detailed data for external UI components
|
|
722
|
-
`;
|
|
723
|
-
context += `- Example: \`@ui:list[{"items": [{"id": "1", "title": "Task"}], "meta": {"items": [{"id": "1", "title": "Task", "description": "Full details...", "assignees": ["Alice"]}], "totalCount": 50}}]\`
|
|
724
|
-
|
|
725
|
-
`;
|
|
726
|
-
context += `### Important notes:
|
|
727
|
-
`;
|
|
728
|
-
context += `- JSON must be valid (use double quotes for strings)
|
|
729
|
-
`;
|
|
730
|
-
context += `- Widget actions (button clicks, form submissions) are sent back to you
|
|
731
|
-
`;
|
|
732
|
-
context += `- You can include multiple widgets in a single response
|
|
733
|
-
`;
|
|
734
|
-
context += `- Combine widgets with regular text for context
|
|
735
|
-
`;
|
|
736
|
-
context += `- Use "meta" field when the UI needs more data than what's displayed
|
|
684
|
+
context += `
|
|
685
|
+
Meta example: @ui:list[{"items": [{"id": "1", "title": "Task"}], "meta": {"fullData": [...]}}]
|
|
737
686
|
`;
|
|
738
687
|
return context;
|
|
739
688
|
}
|
|
740
689
|
function generateCompactWidgetContext(enabledWidgets) {
|
|
741
690
|
const widgets = enabledWidgets || ALL_WIDGET_TYPES;
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
`;
|
|
745
|
-
context += `Available: ${widgets.join(", ")}
|
|
746
|
-
`;
|
|
747
|
-
context += `Add "meta" field for extended data not shown in widget but captured by UI.
|
|
691
|
+
return `
|
|
692
|
+
Widgets: @ui:type[{props}]. Types: ${widgets.join(", ")}. Add "meta" for extended data.
|
|
748
693
|
`;
|
|
749
|
-
context += `Examples:
|
|
750
|
-
`;
|
|
751
|
-
const examples = ["card", "list", "button_group"].filter((w) => widgets.includes(w));
|
|
752
|
-
for (const type of examples) {
|
|
753
|
-
const def = WIDGET_DEFINITIONS[type];
|
|
754
|
-
if (def) {
|
|
755
|
-
context += `${def.example}
|
|
756
|
-
`;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
return context;
|
|
760
694
|
}
|
|
761
695
|
|
|
762
696
|
// src/components/Widgets/Widgets.tsx
|