@apteva/apteva-kit 0.1.40 → 0.1.41
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.js +45 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1351,6 +1351,45 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1351
1351
|
}
|
|
1352
1352
|
return renderTextContent(message.content);
|
|
1353
1353
|
};
|
|
1354
|
+
const renderTextSegmentWithWidgets = (text, keyPrefix) => {
|
|
1355
|
+
if (!enableWidgets) {
|
|
1356
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MarkdownContent, { content: text }) }) }, keyPrefix);
|
|
1357
|
+
}
|
|
1358
|
+
const parsed = parseWidgetsFromText(text);
|
|
1359
|
+
const elements = [];
|
|
1360
|
+
let textBuffer = "";
|
|
1361
|
+
parsed.segments.forEach((seg, idx) => {
|
|
1362
|
+
if (seg.type === "text" && seg.content) {
|
|
1363
|
+
textBuffer += seg.content;
|
|
1364
|
+
} else if (seg.type === "widget" && seg.widget) {
|
|
1365
|
+
if (textBuffer.trim()) {
|
|
1366
|
+
elements.push(
|
|
1367
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-${idx}`)
|
|
1368
|
+
);
|
|
1369
|
+
textBuffer = "";
|
|
1370
|
+
}
|
|
1371
|
+
elements.push(
|
|
1372
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetRenderer, { widget: seg.widget, onAction }) }, `${keyPrefix}-widget-${idx}`)
|
|
1373
|
+
);
|
|
1374
|
+
} else if (seg.type === "widget_pending" && seg.pendingType) {
|
|
1375
|
+
if (textBuffer.trim()) {
|
|
1376
|
+
elements.push(
|
|
1377
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-${idx}`)
|
|
1378
|
+
);
|
|
1379
|
+
textBuffer = "";
|
|
1380
|
+
}
|
|
1381
|
+
elements.push(
|
|
1382
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetSkeleton, { type: seg.pendingType }) }, `${keyPrefix}-pending-${idx}`)
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
if (textBuffer.trim()) {
|
|
1387
|
+
elements.push(
|
|
1388
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-final`)
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
return elements;
|
|
1392
|
+
};
|
|
1354
1393
|
const renderSegmentedContent = () => {
|
|
1355
1394
|
if (!contentSegments || contentSegments.length === 0) {
|
|
1356
1395
|
return null;
|
|
@@ -1358,16 +1397,12 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1358
1397
|
const elements = [];
|
|
1359
1398
|
contentSegments.forEach((segment, index) => {
|
|
1360
1399
|
if (segment.type === "text" && segment.content) {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
},
|
|
1368
|
-
`text-${index}`
|
|
1369
|
-
)
|
|
1370
|
-
);
|
|
1400
|
+
const textElements = renderTextSegmentWithWidgets(segment.content, `seg-${index}`);
|
|
1401
|
+
if (Array.isArray(textElements)) {
|
|
1402
|
+
elements.push(...textElements);
|
|
1403
|
+
} else {
|
|
1404
|
+
elements.push(textElements);
|
|
1405
|
+
}
|
|
1371
1406
|
} else if (segment.type === "tool") {
|
|
1372
1407
|
elements.push(
|
|
1373
1408
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|