@apteva/apteva-kit 0.1.125 → 0.1.127
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 +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +48 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -21
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -225,36 +225,36 @@ interface SendMessageParams {
|
|
|
225
225
|
*/
|
|
226
226
|
declare const WIDGET_DEFINITIONS: {
|
|
227
227
|
readonly card: {
|
|
228
|
-
readonly schema: "title, description?, image
|
|
228
|
+
readonly schema: "title, description?, image?(url), footer?, actions?: [{type, label}]";
|
|
229
229
|
readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Details here\"}]";
|
|
230
230
|
};
|
|
231
231
|
readonly list: {
|
|
232
|
-
readonly schema: "items: [{id, title, subtitle?, description?, image
|
|
232
|
+
readonly schema: "items: [{id, title, subtitle?, description?, image?(url), metadata?: {…}}], actions?: [{type, label}]";
|
|
233
233
|
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"Item\", \"subtitle\": \"Info\", \"metadata\": {\"key\": \"value\"}}]}]";
|
|
234
234
|
};
|
|
235
235
|
readonly button_group: {
|
|
236
|
-
readonly schema: "buttons: [{id, label, variant
|
|
236
|
+
readonly schema: "buttons: [{id, label, variant?: \"default\"|\"primary\"|\"danger\"}]";
|
|
237
237
|
readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"ok\", \"label\": \"OK\"}]}]";
|
|
238
238
|
};
|
|
239
239
|
readonly form: {
|
|
240
|
-
readonly schema: "title?, fields: [{name, type: text
|
|
241
|
-
readonly example: "@ui:form[{\"title\": \"Settings\", \"fields\": [{\"name\": \"
|
|
240
|
+
readonly schema: "title?, fields: [{name, type: \"text\"|\"password\"|\"number\"|\"select\"|\"checkbox\"|\"textarea\"|\"date\", label, required?, placeholder?, options?: [{label, value}]}], actions: [{type, label}]";
|
|
241
|
+
readonly example: "@ui:form[{\"title\": \"Settings\", \"fields\": [{\"name\": \"key\", \"type\": \"password\", \"label\": \"API Key\", \"required\": true}], \"actions\": [{\"type\": \"save\", \"label\": \"Save\"}]}]";
|
|
242
242
|
};
|
|
243
243
|
readonly table: {
|
|
244
|
-
readonly schema: "columns: [{key, label}], rows: [
|
|
245
|
-
readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}], \"rows\": [{\"name\": \"
|
|
244
|
+
readonly schema: "columns: [{key, label}], rows: [{key: value, …}], striped?, compact?";
|
|
245
|
+
readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}], \"rows\": [{\"name\": \"Alice\"}]}]";
|
|
246
246
|
};
|
|
247
247
|
readonly image: {
|
|
248
|
-
readonly schema: "src, alt, caption?";
|
|
249
|
-
readonly example: "@ui:image[{\"src\": \"
|
|
248
|
+
readonly schema: "src(url), alt, caption?";
|
|
249
|
+
readonly example: "@ui:image[{\"src\": \"https://example.com/img.png\", \"alt\": \"Photo\"}]";
|
|
250
250
|
};
|
|
251
251
|
readonly chart: {
|
|
252
|
-
readonly schema: "chartType: line
|
|
253
|
-
readonly example: "@ui:chart[{\"chartType\": \"bar\", \"data\": {\"labels\": [\"
|
|
252
|
+
readonly schema: "chartType: \"line\"|\"bar\"|\"pie\", data: {labels: [...], datasets: [{label, data: [numbers]}]}";
|
|
253
|
+
readonly example: "@ui:chart[{\"chartType\": \"bar\", \"data\": {\"labels\": [\"Q1\", \"Q2\"], \"datasets\": [{\"label\": \"Revenue\", \"data\": [100, 150]}]}}]";
|
|
254
254
|
};
|
|
255
255
|
readonly flow: {
|
|
256
|
-
readonly schema: "title, subtitle?, icon?: research
|
|
257
|
-
readonly example: "@ui:flow[{\"title\": \"
|
|
256
|
+
readonly schema: "title, subtitle?, icon?: \"research\"|\"schedule\"|\"analyze\"|\"deploy\"|\"recurring\"|\"automation\"|\"data\", steps: [{id, label, color?: \"blue\"|\"purple\"|\"cyan\"|\"amber\"|\"emerald\"|\"rose\"|\"indigo\"|\"orange\", status?: \"pending\"|\"active\"|\"completed\"|\"error\"|\"skipped\"}]";
|
|
257
|
+
readonly example: "@ui:flow[{\"title\": \"Pipeline\", \"steps\": [{\"id\": \"1\", \"label\": \"Test\", \"color\": \"cyan\"}, {\"id\": \"2\", \"label\": \"Deploy\", \"color\": \"rose\"}]}]";
|
|
258
258
|
};
|
|
259
259
|
};
|
|
260
260
|
type WidgetType = keyof typeof WIDGET_DEFINITIONS;
|
package/dist/index.d.ts
CHANGED
|
@@ -225,36 +225,36 @@ interface SendMessageParams {
|
|
|
225
225
|
*/
|
|
226
226
|
declare const WIDGET_DEFINITIONS: {
|
|
227
227
|
readonly card: {
|
|
228
|
-
readonly schema: "title, description?, image
|
|
228
|
+
readonly schema: "title, description?, image?(url), footer?, actions?: [{type, label}]";
|
|
229
229
|
readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Details here\"}]";
|
|
230
230
|
};
|
|
231
231
|
readonly list: {
|
|
232
|
-
readonly schema: "items: [{id, title, subtitle?, description?, image
|
|
232
|
+
readonly schema: "items: [{id, title, subtitle?, description?, image?(url), metadata?: {…}}], actions?: [{type, label}]";
|
|
233
233
|
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"Item\", \"subtitle\": \"Info\", \"metadata\": {\"key\": \"value\"}}]}]";
|
|
234
234
|
};
|
|
235
235
|
readonly button_group: {
|
|
236
|
-
readonly schema: "buttons: [{id, label, variant
|
|
236
|
+
readonly schema: "buttons: [{id, label, variant?: \"default\"|\"primary\"|\"danger\"}]";
|
|
237
237
|
readonly example: "@ui:button_group[{\"buttons\": [{\"id\": \"ok\", \"label\": \"OK\"}]}]";
|
|
238
238
|
};
|
|
239
239
|
readonly form: {
|
|
240
|
-
readonly schema: "title?, fields: [{name, type: text
|
|
241
|
-
readonly example: "@ui:form[{\"title\": \"Settings\", \"fields\": [{\"name\": \"
|
|
240
|
+
readonly schema: "title?, fields: [{name, type: \"text\"|\"password\"|\"number\"|\"select\"|\"checkbox\"|\"textarea\"|\"date\", label, required?, placeholder?, options?: [{label, value}]}], actions: [{type, label}]";
|
|
241
|
+
readonly example: "@ui:form[{\"title\": \"Settings\", \"fields\": [{\"name\": \"key\", \"type\": \"password\", \"label\": \"API Key\", \"required\": true}], \"actions\": [{\"type\": \"save\", \"label\": \"Save\"}]}]";
|
|
242
242
|
};
|
|
243
243
|
readonly table: {
|
|
244
|
-
readonly schema: "columns: [{key, label}], rows: [
|
|
245
|
-
readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}], \"rows\": [{\"name\": \"
|
|
244
|
+
readonly schema: "columns: [{key, label}], rows: [{key: value, …}], striped?, compact?";
|
|
245
|
+
readonly example: "@ui:table[{\"columns\": [{\"key\": \"name\", \"label\": \"Name\"}], \"rows\": [{\"name\": \"Alice\"}]}]";
|
|
246
246
|
};
|
|
247
247
|
readonly image: {
|
|
248
|
-
readonly schema: "src, alt, caption?";
|
|
249
|
-
readonly example: "@ui:image[{\"src\": \"
|
|
248
|
+
readonly schema: "src(url), alt, caption?";
|
|
249
|
+
readonly example: "@ui:image[{\"src\": \"https://example.com/img.png\", \"alt\": \"Photo\"}]";
|
|
250
250
|
};
|
|
251
251
|
readonly chart: {
|
|
252
|
-
readonly schema: "chartType: line
|
|
253
|
-
readonly example: "@ui:chart[{\"chartType\": \"bar\", \"data\": {\"labels\": [\"
|
|
252
|
+
readonly schema: "chartType: \"line\"|\"bar\"|\"pie\", data: {labels: [...], datasets: [{label, data: [numbers]}]}";
|
|
253
|
+
readonly example: "@ui:chart[{\"chartType\": \"bar\", \"data\": {\"labels\": [\"Q1\", \"Q2\"], \"datasets\": [{\"label\": \"Revenue\", \"data\": [100, 150]}]}}]";
|
|
254
254
|
};
|
|
255
255
|
readonly flow: {
|
|
256
|
-
readonly schema: "title, subtitle?, icon?: research
|
|
257
|
-
readonly example: "@ui:flow[{\"title\": \"
|
|
256
|
+
readonly schema: "title, subtitle?, icon?: \"research\"|\"schedule\"|\"analyze\"|\"deploy\"|\"recurring\"|\"automation\"|\"data\", steps: [{id, label, color?: \"blue\"|\"purple\"|\"cyan\"|\"amber\"|\"emerald\"|\"rose\"|\"indigo\"|\"orange\", status?: \"pending\"|\"active\"|\"completed\"|\"error\"|\"skipped\"}]";
|
|
257
|
+
readonly example: "@ui:flow[{\"title\": \"Pipeline\", \"steps\": [{\"id\": \"1\", \"label\": \"Test\", \"color\": \"cyan\"}, {\"id\": \"2\", \"label\": \"Deploy\", \"color\": \"rose\"}]}]";
|
|
258
258
|
};
|
|
259
259
|
};
|
|
260
260
|
type WidgetType = keyof typeof WIDGET_DEFINITIONS;
|
package/dist/index.js
CHANGED
|
@@ -735,36 +735,36 @@ function parseWidgetsFromText(text) {
|
|
|
735
735
|
// src/utils/widget-context.ts
|
|
736
736
|
var WIDGET_DEFINITIONS = {
|
|
737
737
|
card: {
|
|
738
|
-
schema: "title, description?, image
|
|
738
|
+
schema: "title, description?, image?(url), footer?, actions?: [{type, label}]",
|
|
739
739
|
example: '@ui:card[{"title": "Summary", "description": "Details here"}]'
|
|
740
740
|
},
|
|
741
741
|
list: {
|
|
742
|
-
schema: "items: [{id, title, subtitle?, description?, image
|
|
742
|
+
schema: "items: [{id, title, subtitle?, description?, image?(url), metadata?: {\u2026}}], actions?: [{type, label}]",
|
|
743
743
|
example: '@ui:list[{"items": [{"id": "1", "title": "Item", "subtitle": "Info", "metadata": {"key": "value"}}]}]'
|
|
744
744
|
},
|
|
745
745
|
button_group: {
|
|
746
|
-
schema:
|
|
746
|
+
schema: 'buttons: [{id, label, variant?: "default"|"primary"|"danger"}]',
|
|
747
747
|
example: '@ui:button_group[{"buttons": [{"id": "ok", "label": "OK"}]}]'
|
|
748
748
|
},
|
|
749
749
|
form: {
|
|
750
|
-
schema:
|
|
751
|
-
example: '@ui:form[{"title": "Settings", "fields": [{"name": "
|
|
750
|
+
schema: 'title?, fields: [{name, type: "text"|"password"|"number"|"select"|"checkbox"|"textarea"|"date", label, required?, placeholder?, options?: [{label, value}]}], actions: [{type, label}]',
|
|
751
|
+
example: '@ui:form[{"title": "Settings", "fields": [{"name": "key", "type": "password", "label": "API Key", "required": true}], "actions": [{"type": "save", "label": "Save"}]}]'
|
|
752
752
|
},
|
|
753
753
|
table: {
|
|
754
|
-
schema: "columns: [{key, label}], rows: [
|
|
755
|
-
example: '@ui:table[{"columns": [{"key": "name", "label": "Name"}], "rows": [{"name": "
|
|
754
|
+
schema: "columns: [{key, label}], rows: [{key: value, \u2026}], striped?, compact?",
|
|
755
|
+
example: '@ui:table[{"columns": [{"key": "name", "label": "Name"}], "rows": [{"name": "Alice"}]}]'
|
|
756
756
|
},
|
|
757
757
|
image: {
|
|
758
|
-
schema: "src, alt, caption?",
|
|
759
|
-
example: '@ui:image[{"src": "
|
|
758
|
+
schema: "src(url), alt, caption?",
|
|
759
|
+
example: '@ui:image[{"src": "https://example.com/img.png", "alt": "Photo"}]'
|
|
760
760
|
},
|
|
761
761
|
chart: {
|
|
762
|
-
schema:
|
|
763
|
-
example: '@ui:chart[{"chartType": "bar", "data": {"labels": ["
|
|
762
|
+
schema: 'chartType: "line"|"bar"|"pie", data: {labels: [...], datasets: [{label, data: [numbers]}]}',
|
|
763
|
+
example: '@ui:chart[{"chartType": "bar", "data": {"labels": ["Q1", "Q2"], "datasets": [{"label": "Revenue", "data": [100, 150]}]}}]'
|
|
764
764
|
},
|
|
765
765
|
flow: {
|
|
766
|
-
schema:
|
|
767
|
-
example: '@ui:flow[{"title": "
|
|
766
|
+
schema: 'title, subtitle?, icon?: "research"|"schedule"|"analyze"|"deploy"|"recurring"|"automation"|"data", steps: [{id, label, color?: "blue"|"purple"|"cyan"|"amber"|"emerald"|"rose"|"indigo"|"orange", status?: "pending"|"active"|"completed"|"error"|"skipped"}]',
|
|
767
|
+
example: '@ui:flow[{"title": "Pipeline", "steps": [{"id": "1", "label": "Test", "color": "cyan"}, {"id": "2", "label": "Deploy", "color": "rose"}]}]'
|
|
768
768
|
}
|
|
769
769
|
};
|
|
770
770
|
var ALL_WIDGET_TYPES = Object.keys(WIDGET_DEFINITIONS);
|
|
@@ -774,27 +774,54 @@ function generateWidgetContext(enabledWidgets) {
|
|
|
774
774
|
const widgets = enabledWidgets || DEFAULT_WIDGET_TYPES;
|
|
775
775
|
let context = `
|
|
776
776
|
## UI Widgets
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
777
|
+
|
|
778
|
+
You can render interactive UI widgets inline in your responses. Use them when structured display is clearer than plain text (showing data, forms, actions, images). You may include normal text before or after a widget.
|
|
779
|
+
|
|
780
|
+
**Syntax:** \`@ui:type[{json}]\` \u2014 the JSON object MUST be wrapped in square brackets \`[]\`.
|
|
781
|
+
|
|
782
|
+
Example:
|
|
783
|
+
@ui:list[{"items": [{"id": "1", "title": "First item"}]}]
|
|
784
|
+
|
|
785
|
+
Do NOT wrap widgets in code blocks or backticks. Write them directly in your response text.
|
|
786
|
+
|
|
787
|
+
### Available widgets
|
|
780
788
|
|
|
781
789
|
`;
|
|
782
790
|
for (const type of widgets) {
|
|
783
791
|
const def = WIDGET_DEFINITIONS[type];
|
|
784
792
|
if (!def) continue;
|
|
785
|
-
context +=
|
|
793
|
+
context += `**${type}** \u2014 ${def.schema}
|
|
794
|
+
`;
|
|
795
|
+
context += ` ${def.example}
|
|
796
|
+
|
|
786
797
|
`;
|
|
787
798
|
}
|
|
788
|
-
context +=
|
|
789
|
-
|
|
799
|
+
context += `### Notes
|
|
800
|
+
- **actions**: the \`type\` field is a custom string you choose (e.g. "edit", "delete", "submit"). It is returned to the app when the user clicks the button.
|
|
801
|
+
- **metadata** on list items: any extra data attached to an item. Returned as the action payload when the user clicks that item.
|
|
802
|
+
- **form**: buttons are defined in \`actions\`, do NOT add a separate button_group for form submission.
|
|
803
|
+
- **select fields**: \`options\` is an array of \`{label, value}\` objects.
|
|
790
804
|
`;
|
|
791
805
|
return context;
|
|
792
806
|
}
|
|
793
807
|
function generateCompactWidgetContext(enabledWidgets) {
|
|
794
808
|
const widgets = enabledWidgets || DEFAULT_WIDGET_TYPES;
|
|
795
|
-
|
|
796
|
-
|
|
809
|
+
let context = `
|
|
810
|
+
## UI Widgets
|
|
811
|
+
Render widgets inline: \`@ui:type[{json}]\` (square brackets required, no code blocks).
|
|
812
|
+
Use when structured display is clearer than plain text. Normal text can surround widgets.
|
|
813
|
+
|
|
814
|
+
`;
|
|
815
|
+
for (const type of widgets) {
|
|
816
|
+
const def = WIDGET_DEFINITIONS[type];
|
|
817
|
+
if (!def) continue;
|
|
818
|
+
context += `**${type}**: ${def.schema}
|
|
797
819
|
`;
|
|
820
|
+
}
|
|
821
|
+
context += `
|
|
822
|
+
actions.type = custom string returned on click. list metadata = payload on item click. form buttons go in actions, not button_group.
|
|
823
|
+
`;
|
|
824
|
+
return context;
|
|
798
825
|
}
|
|
799
826
|
|
|
800
827
|
// src/utils/interface-parser.ts
|