@apteva/apteva-kit 0.1.81 → 0.1.83
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 +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +29 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -32
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ interface Widget {
|
|
|
22
22
|
props: Record<string, any>;
|
|
23
23
|
actions?: Action[];
|
|
24
24
|
/** Additional data not displayed but captured via onWidgetRender */
|
|
25
|
-
|
|
25
|
+
metadata?: Record<string, any>;
|
|
26
26
|
/** Whether the widget is still receiving streaming data */
|
|
27
27
|
isStreaming?: boolean;
|
|
28
28
|
}
|
|
@@ -85,7 +85,7 @@ interface ListItem {
|
|
|
85
85
|
subtitle?: string;
|
|
86
86
|
description?: string;
|
|
87
87
|
image?: string;
|
|
88
|
-
|
|
88
|
+
metadata?: Record<string, any>;
|
|
89
89
|
backgroundColor?: string;
|
|
90
90
|
}
|
|
91
91
|
interface ChartWidget extends Widget {
|
|
@@ -192,8 +192,8 @@ declare const WIDGET_DEFINITIONS: {
|
|
|
192
192
|
readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Details here\"}]";
|
|
193
193
|
};
|
|
194
194
|
readonly list: {
|
|
195
|
-
readonly schema: "items: [{id, title, subtitle?, description?, image?,
|
|
196
|
-
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"Item\", \"subtitle\": \"Info\", \"
|
|
195
|
+
readonly schema: "items: [{id, title, subtitle?, description?, image?, metadata?: {any extra data}}], actions?: [{type, label}] - metadata is sent as action payload when clicked";
|
|
196
|
+
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"Item\", \"subtitle\": \"Info\", \"metadata\": {\"key\": \"value\"}}]}]";
|
|
197
197
|
};
|
|
198
198
|
readonly button_group: {
|
|
199
199
|
readonly schema: "buttons: [{id, label, variant?}] - Use for standalone buttons only, NOT for form submits";
|
|
@@ -440,7 +440,7 @@ interface ChatResponse {
|
|
|
440
440
|
widgets?: any[];
|
|
441
441
|
}
|
|
442
442
|
interface StreamChunk {
|
|
443
|
-
type: 'start' | 'thread_id' | 'request_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' | 'tool_stream' | 'stop' | 'widget' | 'complete' | 'done' | 'error';
|
|
444
444
|
content?: string;
|
|
445
445
|
widget?: any;
|
|
446
446
|
thread_id?: string;
|
|
@@ -450,6 +450,8 @@ interface StreamChunk {
|
|
|
450
450
|
tool_display_name?: string;
|
|
451
451
|
error?: string;
|
|
452
452
|
message?: string;
|
|
453
|
+
event?: 'chunk' | 'log' | 'progress';
|
|
454
|
+
progress?: number;
|
|
453
455
|
}
|
|
454
456
|
declare class AptevaClient {
|
|
455
457
|
private config;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface Widget {
|
|
|
22
22
|
props: Record<string, any>;
|
|
23
23
|
actions?: Action[];
|
|
24
24
|
/** Additional data not displayed but captured via onWidgetRender */
|
|
25
|
-
|
|
25
|
+
metadata?: Record<string, any>;
|
|
26
26
|
/** Whether the widget is still receiving streaming data */
|
|
27
27
|
isStreaming?: boolean;
|
|
28
28
|
}
|
|
@@ -85,7 +85,7 @@ interface ListItem {
|
|
|
85
85
|
subtitle?: string;
|
|
86
86
|
description?: string;
|
|
87
87
|
image?: string;
|
|
88
|
-
|
|
88
|
+
metadata?: Record<string, any>;
|
|
89
89
|
backgroundColor?: string;
|
|
90
90
|
}
|
|
91
91
|
interface ChartWidget extends Widget {
|
|
@@ -192,8 +192,8 @@ declare const WIDGET_DEFINITIONS: {
|
|
|
192
192
|
readonly example: "@ui:card[{\"title\": \"Summary\", \"description\": \"Details here\"}]";
|
|
193
193
|
};
|
|
194
194
|
readonly list: {
|
|
195
|
-
readonly schema: "items: [{id, title, subtitle?, description?, image?,
|
|
196
|
-
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"Item\", \"subtitle\": \"Info\", \"
|
|
195
|
+
readonly schema: "items: [{id, title, subtitle?, description?, image?, metadata?: {any extra data}}], actions?: [{type, label}] - metadata is sent as action payload when clicked";
|
|
196
|
+
readonly example: "@ui:list[{\"items\": [{\"id\": \"1\", \"title\": \"Item\", \"subtitle\": \"Info\", \"metadata\": {\"key\": \"value\"}}]}]";
|
|
197
197
|
};
|
|
198
198
|
readonly button_group: {
|
|
199
199
|
readonly schema: "buttons: [{id, label, variant?}] - Use for standalone buttons only, NOT for form submits";
|
|
@@ -440,7 +440,7 @@ interface ChatResponse {
|
|
|
440
440
|
widgets?: any[];
|
|
441
441
|
}
|
|
442
442
|
interface StreamChunk {
|
|
443
|
-
type: 'start' | 'thread_id' | 'request_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' | 'tool_stream' | 'stop' | 'widget' | 'complete' | 'done' | 'error';
|
|
444
444
|
content?: string;
|
|
445
445
|
widget?: any;
|
|
446
446
|
thread_id?: string;
|
|
@@ -450,6 +450,8 @@ interface StreamChunk {
|
|
|
450
450
|
tool_display_name?: string;
|
|
451
451
|
error?: string;
|
|
452
452
|
message?: string;
|
|
453
|
+
event?: 'chunk' | 'log' | 'progress';
|
|
454
|
+
progress?: number;
|
|
453
455
|
}
|
|
454
456
|
declare class AptevaClient {
|
|
455
457
|
private config;
|
package/dist/index.js
CHANGED
|
@@ -691,7 +691,7 @@ function parseWidgetsFromText(text) {
|
|
|
691
691
|
const trimmedJson = jsonContent.trim();
|
|
692
692
|
const parsed = JSON.parse(trimmedJson);
|
|
693
693
|
const widgetId = `widget-${widgetType}-${simpleHash(trimmedJson)}`;
|
|
694
|
-
const {
|
|
694
|
+
const { metadata, actions, ...props } = parsed;
|
|
695
695
|
segments.push({
|
|
696
696
|
type: "widget",
|
|
697
697
|
widget: {
|
|
@@ -699,7 +699,7 @@ function parseWidgetsFromText(text) {
|
|
|
699
699
|
id: widgetId,
|
|
700
700
|
props,
|
|
701
701
|
...actions && { actions },
|
|
702
|
-
...
|
|
702
|
+
...metadata && { metadata }
|
|
703
703
|
}
|
|
704
704
|
});
|
|
705
705
|
hasWidgets = true;
|
|
@@ -739,8 +739,8 @@ var WIDGET_DEFINITIONS = {
|
|
|
739
739
|
example: '@ui:card[{"title": "Summary", "description": "Details here"}]'
|
|
740
740
|
},
|
|
741
741
|
list: {
|
|
742
|
-
schema: "items: [{id, title, subtitle?, description?, image?,
|
|
743
|
-
example: '@ui:list[{"items": [{"id": "1", "title": "Item", "subtitle": "Info", "
|
|
742
|
+
schema: "items: [{id, title, subtitle?, description?, image?, metadata?: {any extra data}}], actions?: [{type, label}] - metadata is sent as action payload when clicked",
|
|
743
|
+
example: '@ui:list[{"items": [{"id": "1", "title": "Item", "subtitle": "Info", "metadata": {"key": "value"}}]}]'
|
|
744
744
|
},
|
|
745
745
|
button_group: {
|
|
746
746
|
schema: "buttons: [{id, label, variant?}] - Use for standalone buttons only, NOT for form submits",
|
|
@@ -772,8 +772,6 @@ SYNTAX: @ui:type[{json}] - MUST use SQUARE BRACKETS [] around the JSON object.
|
|
|
772
772
|
CORRECT: @ui:list[{"items": [...]}]
|
|
773
773
|
WRONG: @ui:list{"items": [...]} (missing square brackets)
|
|
774
774
|
|
|
775
|
-
"meta" field (at root level, NOT inside items) holds extended data captured by UI.
|
|
776
|
-
|
|
777
775
|
`;
|
|
778
776
|
for (const type of widgets) {
|
|
779
777
|
const def = WIDGET_DEFINITIONS[type];
|
|
@@ -782,14 +780,14 @@ WRONG: @ui:list{"items": [...]} (missing square brackets)
|
|
|
782
780
|
`;
|
|
783
781
|
}
|
|
784
782
|
context += `
|
|
785
|
-
Per-item "
|
|
783
|
+
Per-item "metadata" is sent as payload on action click.
|
|
786
784
|
`;
|
|
787
785
|
return context;
|
|
788
786
|
}
|
|
789
787
|
function generateCompactWidgetContext(enabledWidgets) {
|
|
790
788
|
const widgets = enabledWidgets || ALL_WIDGET_TYPES;
|
|
791
789
|
return `
|
|
792
|
-
Widgets: @ui:type[{json}] - MUST use square brackets []. Example: @ui:list[{"items": [...]}]. Types: ${widgets.join(", ")}.
|
|
790
|
+
Widgets: @ui:type[{json}] - MUST use square brackets []. Example: @ui:list[{"items": [...]}]. Types: ${widgets.join(", ")}. Per-item "metadata" is sent as action payload.
|
|
793
791
|
`;
|
|
794
792
|
}
|
|
795
793
|
|
|
@@ -872,7 +870,7 @@ function List({ widget, onAction }) {
|
|
|
872
870
|
{
|
|
873
871
|
onClick: () => _optionalChain([onAction, 'optionalCall', _3 => _3({
|
|
874
872
|
type: action.type,
|
|
875
|
-
payload: item.
|
|
873
|
+
payload: item.metadata || item,
|
|
876
874
|
widgetId: widget.id,
|
|
877
875
|
timestamp: /* @__PURE__ */ new Date()
|
|
878
876
|
})]),
|
|
@@ -1523,7 +1521,7 @@ function MarkdownContent({ content, className = "" }) {
|
|
|
1523
1521
|
|
|
1524
1522
|
// src/components/Chat/ToolCall.tsx
|
|
1525
1523
|
|
|
1526
|
-
function ToolCall({ name, status, isReceiving = false, inputLength = 0 }) {
|
|
1524
|
+
function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOutput }) {
|
|
1527
1525
|
if (status === "preparing") {
|
|
1528
1526
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-tool-card apteva-tool-card-preparing", children: [
|
|
1529
1527
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
@@ -1544,11 +1542,16 @@ function ToolCall({ name, status, isReceiving = false, inputLength = 0 }) {
|
|
|
1544
1542
|
] }),
|
|
1545
1543
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-label", children: [
|
|
1546
1544
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children: name }),
|
|
1547
|
-
/* @__PURE__ */ _jsxruntime.
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "
|
|
1545
|
+
streamOutput ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-stream-output", children: [
|
|
1546
|
+
" ",
|
|
1547
|
+
streamOutput
|
|
1548
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1549
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-tool-status-text", children: " running" }),
|
|
1550
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-tool-dots", children: [
|
|
1551
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." }),
|
|
1552
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." }),
|
|
1553
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "." })
|
|
1554
|
+
] })
|
|
1552
1555
|
] })
|
|
1553
1556
|
] })
|
|
1554
1557
|
] });
|
|
@@ -1766,7 +1769,8 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1766
1769
|
name: segment.name,
|
|
1767
1770
|
status: segment.status || (segment.result !== void 0 ? "completed" : "running"),
|
|
1768
1771
|
isReceiving: segment.isReceiving,
|
|
1769
|
-
inputLength: segment.inputLength
|
|
1772
|
+
inputLength: segment.inputLength,
|
|
1773
|
+
streamOutput: segment.streamOutput
|
|
1770
1774
|
}
|
|
1771
1775
|
) }, segment.id)
|
|
1772
1776
|
);
|
|
@@ -2988,6 +2992,15 @@ ${widgetContext}` : widgetContext;
|
|
|
2988
2992
|
}
|
|
2989
2993
|
}
|
|
2990
2994
|
break;
|
|
2995
|
+
case "tool_stream":
|
|
2996
|
+
if (chunk.tool_id && chunk.event === "chunk" && chunk.content) {
|
|
2997
|
+
const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
|
|
2998
|
+
if (toolSegment) {
|
|
2999
|
+
toolSegment.streamOutput = (toolSegment.streamOutput || "") + chunk.content;
|
|
3000
|
+
updateMessage();
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
break;
|
|
2991
3004
|
case "tool_result":
|
|
2992
3005
|
if (chunk.tool_id) {
|
|
2993
3006
|
const toolSegment = contentSegments.find((s) => s.type === "tool" && s.id === chunk.tool_id);
|