@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.mjs
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: () => onAction?.({
|
|
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
|
}),
|
|
@@ -1522,8 +1520,8 @@ function MarkdownContent({ content, className = "" }) {
|
|
|
1522
1520
|
}
|
|
1523
1521
|
|
|
1524
1522
|
// src/components/Chat/ToolCall.tsx
|
|
1525
|
-
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1526
|
-
function ToolCall({ name, status, isReceiving = false, inputLength = 0 }) {
|
|
1523
|
+
import { Fragment, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1524
|
+
function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOutput }) {
|
|
1527
1525
|
if (status === "preparing") {
|
|
1528
1526
|
return /* @__PURE__ */ jsxs8("div", { className: "apteva-tool-card apteva-tool-card-preparing", children: [
|
|
1529
1527
|
/* @__PURE__ */ jsxs8("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__ */ jsxs8("span", { className: "apteva-tool-label", children: [
|
|
1546
1544
|
/* @__PURE__ */ jsx11("strong", { children: name }),
|
|
1547
|
-
/* @__PURE__ */
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
/* @__PURE__ */ jsx11("span", { children: "
|
|
1545
|
+
streamOutput ? /* @__PURE__ */ jsxs8("span", { className: "apteva-tool-stream-output", children: [
|
|
1546
|
+
" ",
|
|
1547
|
+
streamOutput
|
|
1548
|
+
] }) : /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
1549
|
+
/* @__PURE__ */ jsx11("span", { className: "apteva-tool-status-text", children: " running" }),
|
|
1550
|
+
/* @__PURE__ */ jsxs8("span", { className: "apteva-tool-dots", children: [
|
|
1551
|
+
/* @__PURE__ */ jsx11("span", { children: "." }),
|
|
1552
|
+
/* @__PURE__ */ jsx11("span", { children: "." }),
|
|
1553
|
+
/* @__PURE__ */ jsx11("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
|
);
|
|
@@ -2001,7 +2005,7 @@ function MessageList({
|
|
|
2001
2005
|
|
|
2002
2006
|
// src/components/Chat/Composer.tsx
|
|
2003
2007
|
import { useState as useState4, useRef as useRef5 } from "react";
|
|
2004
|
-
import { Fragment, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2008
|
+
import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2005
2009
|
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, isLoading = false, onStop, onFileUpload, onSwitchMode }) {
|
|
2006
2010
|
const [text, setText] = useState4("");
|
|
2007
2011
|
const [showMenu, setShowMenu] = useState4(false);
|
|
@@ -2122,7 +2126,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2122
2126
|
children: /* @__PURE__ */ jsx15("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx15("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2123
2127
|
}
|
|
2124
2128
|
),
|
|
2125
|
-
showMenu && /* @__PURE__ */ jsxs11(
|
|
2129
|
+
showMenu && /* @__PURE__ */ jsxs11(Fragment2, { children: [
|
|
2126
2130
|
/* @__PURE__ */ jsx15("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
2127
2131
|
/* @__PURE__ */ jsxs11(
|
|
2128
2132
|
"div",
|
|
@@ -2214,7 +2218,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2214
2218
|
|
|
2215
2219
|
// src/components/Chat/CommandComposer.tsx
|
|
2216
2220
|
import { useState as useState5, useRef as useRef6 } from "react";
|
|
2217
|
-
import { Fragment as
|
|
2221
|
+
import { Fragment as Fragment3, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2218
2222
|
function CommandComposer({
|
|
2219
2223
|
onExecute,
|
|
2220
2224
|
state,
|
|
@@ -2363,7 +2367,7 @@ function CommandComposer({
|
|
|
2363
2367
|
children: /* @__PURE__ */ jsx16("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx16("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2364
2368
|
}
|
|
2365
2369
|
),
|
|
2366
|
-
showMenu && /* @__PURE__ */ jsxs12(
|
|
2370
|
+
showMenu && /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
2367
2371
|
/* @__PURE__ */ jsx16("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
2368
2372
|
/* @__PURE__ */ jsxs12(
|
|
2369
2373
|
"div",
|
|
@@ -2459,7 +2463,7 @@ function CommandComposer({
|
|
|
2459
2463
|
state === "error" && "!text-red-600 dark:!text-red-400",
|
|
2460
2464
|
state === "plan-pending" && "!text-amber-700 dark:!text-amber-300"
|
|
2461
2465
|
),
|
|
2462
|
-
children: isToolCall ? /* @__PURE__ */ jsxs12(
|
|
2466
|
+
children: isToolCall ? /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
2463
2467
|
/* @__PURE__ */ jsx16("span", { className: "font-mono", children: displayContent }),
|
|
2464
2468
|
/* @__PURE__ */ jsx16("span", { className: "text-neutral-400 dark:text-neutral-500", children: "Running..." })
|
|
2465
2469
|
] }) : displayContent
|
|
@@ -2482,7 +2486,7 @@ function CommandComposer({
|
|
|
2482
2486
|
children: "Modify"
|
|
2483
2487
|
}
|
|
2484
2488
|
)
|
|
2485
|
-
] }) : /* @__PURE__ */ jsxs12(
|
|
2489
|
+
] }) : /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
2486
2490
|
state === "loading" && onStop && /* @__PURE__ */ jsx16(
|
|
2487
2491
|
"button",
|
|
2488
2492
|
{
|
|
@@ -2720,7 +2724,7 @@ var AptevaClient = class {
|
|
|
2720
2724
|
var aptevaClient = new AptevaClient();
|
|
2721
2725
|
|
|
2722
2726
|
// src/components/Chat/Chat.tsx
|
|
2723
|
-
import { Fragment as
|
|
2727
|
+
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2724
2728
|
var Chat = forwardRef(function Chat2({
|
|
2725
2729
|
agentId,
|
|
2726
2730
|
threadId,
|
|
@@ -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);
|
|
@@ -3315,7 +3328,7 @@ ${planToExecute}`;
|
|
|
3315
3328
|
isLoading ? chatToolName ? "apteva-chat-status-tool" : "apteva-chat-status-thinking" : "apteva-chat-status-ready"
|
|
3316
3329
|
), children: isLoading ? chatToolName ? `Using ${chatToolName}...` : "Thinking..." : "Ready" })
|
|
3317
3330
|
] }) }),
|
|
3318
|
-
mode === "chat" && /* @__PURE__ */ jsxs13(
|
|
3331
|
+
mode === "chat" && /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
3319
3332
|
/* @__PURE__ */ jsx17(
|
|
3320
3333
|
MessageList,
|
|
3321
3334
|
{
|
|
@@ -3388,7 +3401,7 @@ import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
|
3388
3401
|
|
|
3389
3402
|
// src/components/Command/Command.tsx
|
|
3390
3403
|
import React, { useState as useState8, useEffect as useEffect7 } from "react";
|
|
3391
|
-
import { Fragment as
|
|
3404
|
+
import { Fragment as Fragment5, jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3392
3405
|
function Command({
|
|
3393
3406
|
agentId,
|
|
3394
3407
|
command: initialCommand,
|
|
@@ -3854,7 +3867,7 @@ ${planToExecute}`;
|
|
|
3854
3867
|
style: { minHeight: isCompact ? "auto" : "180px" },
|
|
3855
3868
|
children: [
|
|
3856
3869
|
/* @__PURE__ */ jsxs15("div", { className: cn("flex-1 flex", isCompact ? "flex-row items-center p-3 gap-3" : "flex-col p-4"), children: [
|
|
3857
|
-
state === "idle" && allowInput && !isCompact && /* @__PURE__ */ jsxs15(
|
|
3870
|
+
state === "idle" && allowInput && !isCompact && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
3858
3871
|
/* @__PURE__ */ jsx19(
|
|
3859
3872
|
"textarea",
|
|
3860
3873
|
{
|
|
@@ -3894,7 +3907,7 @@ ${planToExecute}`;
|
|
|
3894
3907
|
)
|
|
3895
3908
|
] }, index)) })
|
|
3896
3909
|
] }),
|
|
3897
|
-
state === "idle" && allowInput && isCompact && /* @__PURE__ */ jsxs15(
|
|
3910
|
+
state === "idle" && allowInput && isCompact && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
3898
3911
|
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-0.5 flex-shrink-0", children: [
|
|
3899
3912
|
enableFileUpload && /* @__PURE__ */ jsx19(
|
|
3900
3913
|
"button",
|
|
@@ -4034,7 +4047,7 @@ ${planToExecute}`;
|
|
|
4034
4047
|
] })
|
|
4035
4048
|
] })
|
|
4036
4049
|
] }),
|
|
4037
|
-
state === "loading" && isCompact && /* @__PURE__ */ jsxs15(
|
|
4050
|
+
state === "loading" && isCompact && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
4038
4051
|
/* @__PURE__ */ jsxs15("div", { className: "flex-1 flex items-center gap-3 py-1", children: [
|
|
4039
4052
|
/* @__PURE__ */ jsx19("div", { className: "w-4 h-4 border-2 border-neutral-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
4040
4053
|
/* @__PURE__ */ jsx19("div", { className: "text-neutral-600 dark:text-neutral-400 text-sm truncate", children: enableStreaming && streamedContent ? streamedContent : loadingText })
|
|
@@ -4082,7 +4095,7 @@ ${planToExecute}`;
|
|
|
4082
4095
|
)
|
|
4083
4096
|
] })
|
|
4084
4097
|
] }) }),
|
|
4085
|
-
state === "plan-pending" && isCompact && /* @__PURE__ */ jsxs15(
|
|
4098
|
+
state === "plan-pending" && isCompact && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
4086
4099
|
/* @__PURE__ */ jsxs15(
|
|
4087
4100
|
"button",
|
|
4088
4101
|
{
|
|
@@ -4156,7 +4169,7 @@ ${planToExecute}`;
|
|
|
4156
4169
|
widget.id
|
|
4157
4170
|
)) })
|
|
4158
4171
|
] }) }),
|
|
4159
|
-
state === "success" && result && isCompact && /* @__PURE__ */ jsxs15(
|
|
4172
|
+
state === "success" && result && isCompact && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
4160
4173
|
/* @__PURE__ */ jsxs15(
|
|
4161
4174
|
"div",
|
|
4162
4175
|
{
|
|
@@ -4193,7 +4206,7 @@ ${planToExecute}`;
|
|
|
4193
4206
|
] })
|
|
4194
4207
|
] }),
|
|
4195
4208
|
!isCompact && /* @__PURE__ */ jsxs15("div", { className: "p-3 flex items-center justify-between gap-2", children: [
|
|
4196
|
-
/* @__PURE__ */ jsx19("div", { className: "flex items-center gap-1", children: state === "idle" && allowInput && /* @__PURE__ */ jsxs15(
|
|
4209
|
+
/* @__PURE__ */ jsx19("div", { className: "flex items-center gap-1", children: state === "idle" && allowInput && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
4197
4210
|
enableFileUpload && /* @__PURE__ */ jsx19(
|
|
4198
4211
|
"button",
|
|
4199
4212
|
{
|