@apteva/apteva-kit 0.1.25 → 0.1.27
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 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -639,108 +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
|
-
context += `- JSON must be valid (use double quotes for strings)
|
|
717
|
-
`;
|
|
718
|
-
context += `- Widget actions (button clicks, form submissions) are sent back to you
|
|
719
|
-
`;
|
|
720
|
-
context += `- You can include multiple widgets in a single response
|
|
721
|
-
`;
|
|
722
|
-
context += `- Combine widgets with regular text for context
|
|
684
|
+
context += `
|
|
685
|
+
Meta example: @ui:list[{"items": [{"id": "1", "title": "Task"}], "meta": {"fullData": [...]}}]
|
|
723
686
|
`;
|
|
724
687
|
return context;
|
|
725
688
|
}
|
|
726
689
|
function generateCompactWidgetContext(enabledWidgets) {
|
|
727
690
|
const widgets = enabledWidgets || ALL_WIDGET_TYPES;
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
`;
|
|
731
|
-
context += `Available: ${widgets.join(", ")}
|
|
691
|
+
return `
|
|
692
|
+
Widgets: @ui:type[{props}]. Types: ${widgets.join(", ")}. Add "meta" for extended data.
|
|
732
693
|
`;
|
|
733
|
-
context += `Examples:
|
|
734
|
-
`;
|
|
735
|
-
const examples = ["card", "list", "button_group"].filter((w) => widgets.includes(w));
|
|
736
|
-
for (const type of examples) {
|
|
737
|
-
const def = WIDGET_DEFINITIONS[type];
|
|
738
|
-
if (def) {
|
|
739
|
-
context += `${def.example}
|
|
740
|
-
`;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
return context;
|
|
744
694
|
}
|
|
745
695
|
|
|
746
696
|
// src/components/Widgets/Widgets.tsx
|