@aigentyc/chat-sdk 0.5.2 → 0.5.4
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/{ChatInterface-DKF3BY42.d.cts → ChatInterface-Bo0dU48x.d.cts} +23 -1
- package/dist/{ChatInterface-CRmM_RG_.d.ts → ChatInterface-D5tY6WT1.d.ts} +23 -1
- package/dist/ai-elements.cjs +29 -29
- package/dist/ai-elements.js +1 -1
- package/dist/{chunk-B277MAUK.cjs → chunk-7LJMBYHC.cjs} +5 -11
- package/dist/chunk-7LJMBYHC.cjs.map +1 -0
- package/dist/{chunk-PNUHUUA3.js → chunk-BKIYPLMT.js} +39 -10
- package/dist/chunk-BKIYPLMT.js.map +1 -0
- package/dist/{chunk-KHQYSEYN.cjs → chunk-CPWM6NNE.cjs} +54 -23
- package/dist/chunk-CPWM6NNE.cjs.map +1 -0
- package/dist/{chunk-O5TPHZRP.js → chunk-TXX2W7ZR.js} +5 -11
- package/dist/chunk-TXX2W7ZR.js.map +1 -0
- package/dist/components.cjs +14 -14
- package/dist/components.d.cts +8 -3
- package/dist/components.d.ts +8 -3
- package/dist/components.js +3 -3
- package/dist/index.cjs +20 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/llms-full.txt +4 -4
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-B277MAUK.cjs.map +0 -1
- package/dist/chunk-KHQYSEYN.cjs.map +0 -1
- package/dist/chunk-O5TPHZRP.js.map +0 -1
- package/dist/chunk-PNUHUUA3.js.map +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var chunkDVWX2UGY_cjs = require('./chunk-DVWX2UGY.cjs');
|
|
5
5
|
var chunkBYX6IOGX_cjs = require('./chunk-BYX6IOGX.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunk7LJMBYHC_cjs = require('./chunk-7LJMBYHC.cjs');
|
|
7
7
|
var chunk72QJ2ORD_cjs = require('./chunk-72QJ2ORD.cjs');
|
|
8
8
|
var chunkJEK2V5I3_cjs = require('./chunk-JEK2V5I3.cjs');
|
|
9
9
|
var chunkUXVOUC2A_cjs = require('./chunk-UXVOUC2A.cjs');
|
|
@@ -1099,15 +1099,15 @@ function ChatInterface(props) {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
),
|
|
1101
1101
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1102
|
-
|
|
1102
|
+
chunk7LJMBYHC_cjs.Conversation,
|
|
1103
1103
|
{
|
|
1104
1104
|
className: "flex-1",
|
|
1105
|
-
targetScrollTop: anchorLatestTurn ?
|
|
1105
|
+
targetScrollTop: anchorLatestTurn ? chunk7LJMBYHC_cjs.anchorToLatestTurn : void 0,
|
|
1106
1106
|
...anchorLatestTurn ? { initial: "instant", resize: "instant" } : {},
|
|
1107
1107
|
children: [
|
|
1108
|
-
anchorLatestTurn && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1109
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1110
|
-
messages.length === 0 && chunkUXVOUC2A_cjs.renderSlot("emptyState", {},
|
|
1108
|
+
anchorLatestTurn && /* @__PURE__ */ jsxRuntime.jsx(chunk7LJMBYHC_cjs.FollowLatestTurn, { turnKey: latestUserId }),
|
|
1109
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunk7LJMBYHC_cjs.ConversationContent, { className: "px-[15px] md:px-[40px] py-6 sm:py-8 w-full space-y-6", children: [
|
|
1110
|
+
messages.length === 0 && chunkUXVOUC2A_cjs.renderSlot("emptyState", {}, chunk7LJMBYHC_cjs.ConversationEmptyState, slots),
|
|
1111
1111
|
messages.map((message, messageIndex) => {
|
|
1112
1112
|
if (hideFirstUserMessage && messageIndex === 0 && message.role === "user") return null;
|
|
1113
1113
|
if (message.role === "system") {
|
|
@@ -1117,14 +1117,14 @@ function ChatInterface(props) {
|
|
|
1117
1117
|
"div",
|
|
1118
1118
|
{
|
|
1119
1119
|
className: `group ${message.role === "assistant" ? "is-assistant" : "is-user"}`,
|
|
1120
|
-
...message.id === latestUserId ? { [
|
|
1120
|
+
...message.id === latestUserId ? { [chunk7LJMBYHC_cjs.LATEST_TURN_ATTR]: "" } : {},
|
|
1121
1121
|
children: [
|
|
1122
1122
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1123
|
-
|
|
1123
|
+
chunk7LJMBYHC_cjs.MessageAttachments,
|
|
1124
1124
|
{
|
|
1125
1125
|
className: message.role === "user" ? "mb-2" : "mr-auto ml-0 mb-2",
|
|
1126
1126
|
children: (message.parts || []).filter((p) => p.type === "file" && p.url).map((p, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1127
|
-
|
|
1127
|
+
chunk7LJMBYHC_cjs.MessageAttachment,
|
|
1128
1128
|
{
|
|
1129
1129
|
className: "size-32",
|
|
1130
1130
|
data: {
|
|
@@ -1190,10 +1190,10 @@ function ChatInterface(props) {
|
|
|
1190
1190
|
showSources && message.role === "assistant" && (() => {
|
|
1191
1191
|
const kbSources = extractKbSources(message.parts);
|
|
1192
1192
|
if (kbSources.length === 0) return null;
|
|
1193
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1194
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1195
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1196
|
-
|
|
1193
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunk7LJMBYHC_cjs.Sources, { children: [
|
|
1194
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk7LJMBYHC_cjs.SourcesTrigger, { count: kbSources.length }),
|
|
1195
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk7LJMBYHC_cjs.SourcesContent, { children: kbSources.map((s, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1196
|
+
chunk7LJMBYHC_cjs.Source,
|
|
1197
1197
|
{
|
|
1198
1198
|
href: s.sourceUrl ?? "#",
|
|
1199
1199
|
title: s.documentName || s.pageTitle || `Source ${idx + 1}`
|
|
@@ -1209,7 +1209,7 @@ function ChatInterface(props) {
|
|
|
1209
1209
|
apiKey: config.apiKey,
|
|
1210
1210
|
apiEndpoint: config.apiEndpoint,
|
|
1211
1211
|
textContent: (message.parts || []).filter((p) => p.type === "text").map((p) => p.text || "").join("\n") || (typeof message.content === "string" ? message.content : "")
|
|
1212
|
-
},
|
|
1212
|
+
}, chunk7LJMBYHC_cjs.MessageFeedback, slots)
|
|
1213
1213
|
]
|
|
1214
1214
|
},
|
|
1215
1215
|
message.id
|
|
@@ -1223,7 +1223,7 @@ function ChatInterface(props) {
|
|
|
1223
1223
|
);
|
|
1224
1224
|
const allToolsComplete = (lastMessage.parts || []).filter((p) => p.type.startsWith("tool-")).every((p) => p.state === "output-available");
|
|
1225
1225
|
return allToolsComplete && !hasText;
|
|
1226
|
-
})() && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1226
|
+
})() && /* @__PURE__ */ jsxRuntime.jsx(chunk7LJMBYHC_cjs.Loader, { text: t("thinking") }),
|
|
1227
1227
|
status === "error" && chunkUXVOUC2A_cjs.renderSlot(
|
|
1228
1228
|
"error",
|
|
1229
1229
|
{
|
|
@@ -1271,6 +1271,35 @@ function ChatInterface(props) {
|
|
|
1271
1271
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-session-id": sessionId, className: "hidden" })
|
|
1272
1272
|
] });
|
|
1273
1273
|
}
|
|
1274
|
+
|
|
1275
|
+
// src/core/panel-width.ts
|
|
1276
|
+
var DEFAULT_PANEL_WIDTH = 780;
|
|
1277
|
+
var MIN_PANEL_WIDTH = 320;
|
|
1278
|
+
var SIDE_PANEL_GAP_PX = 10;
|
|
1279
|
+
function panelMaxWidth(width) {
|
|
1280
|
+
if (typeof width === "number") {
|
|
1281
|
+
if (!Number.isFinite(width) || width <= 0) return `${DEFAULT_PANEL_WIDTH}px`;
|
|
1282
|
+
return `${Math.max(MIN_PANEL_WIDTH, Math.round(width))}px`;
|
|
1283
|
+
}
|
|
1284
|
+
if (typeof width === "string") {
|
|
1285
|
+
const value = width.trim();
|
|
1286
|
+
if (value && isValidLength(value)) return value;
|
|
1287
|
+
}
|
|
1288
|
+
return `${DEFAULT_PANEL_WIDTH}px`;
|
|
1289
|
+
}
|
|
1290
|
+
function panelRenderedWidth(width) {
|
|
1291
|
+
return `min(100vw, ${panelMaxWidth(width)})`;
|
|
1292
|
+
}
|
|
1293
|
+
function sidePanelOffset(width) {
|
|
1294
|
+
return `calc(${panelRenderedWidth(width)} + ${SIDE_PANEL_GAP_PX}px)`;
|
|
1295
|
+
}
|
|
1296
|
+
function sidePanelWidth(preferredPx, width) {
|
|
1297
|
+
return `min(${preferredPx}px, calc(100vw - ${panelRenderedWidth(width)} - ${SIDE_PANEL_GAP_PX * 2}px))`;
|
|
1298
|
+
}
|
|
1299
|
+
function isValidLength(value) {
|
|
1300
|
+
if (typeof CSS === "undefined" || typeof CSS.supports !== "function") return true;
|
|
1301
|
+
return CSS.supports("max-width", value);
|
|
1302
|
+
}
|
|
1274
1303
|
function FloatingButton({
|
|
1275
1304
|
onClick,
|
|
1276
1305
|
position,
|
|
@@ -1434,7 +1463,7 @@ function useLiveChatOrThrow() {
|
|
|
1434
1463
|
if (!ctx) throw new Error("LiveChat sub-view rendered outside LiveChatProvider \u2014 this should never happen");
|
|
1435
1464
|
return ctx;
|
|
1436
1465
|
}
|
|
1437
|
-
function LiveChatPanel({ isWidgetOpen, isRightSide, zIndex }) {
|
|
1466
|
+
function LiveChatPanel({ isWidgetOpen, isRightSide, zIndex, panelWidth }) {
|
|
1438
1467
|
const lc = chunkDVWX2UGY_cjs.useLiveChat();
|
|
1439
1468
|
if (!lc) return null;
|
|
1440
1469
|
const isActive = lc.state !== "ai" || lc.showIdentityForm;
|
|
@@ -1458,9 +1487,9 @@ function LiveChatPanel({ isWidgetOpen, isRightSide, zIndex }) {
|
|
|
1458
1487
|
backgroundColor: "var(--ac-background)",
|
|
1459
1488
|
borderColor: "var(--ac-border)",
|
|
1460
1489
|
zIndex,
|
|
1461
|
-
width:
|
|
1490
|
+
width: sidePanelWidth(420, panelWidth),
|
|
1462
1491
|
height: "75vh",
|
|
1463
|
-
...isRightSide ? { right:
|
|
1492
|
+
...isRightSide ? { right: sidePanelOffset(panelWidth) } : { left: sidePanelOffset(panelWidth) },
|
|
1464
1493
|
transform: showPanel ? "translateY(-50%) translateX(0)" : `translateY(-50%) ${isRightSide ? "translateX(20px)" : "translateX(-20px)"}`,
|
|
1465
1494
|
opacity: showPanel ? 1 : 0,
|
|
1466
1495
|
pointerEvents: showPanel ? "auto" : "none",
|
|
@@ -1848,7 +1877,7 @@ function EndedView() {
|
|
|
1848
1877
|
)
|
|
1849
1878
|
] });
|
|
1850
1879
|
}
|
|
1851
|
-
function PreviewEmbedPanel({ isOpen, isRightSide, zIndex }) {
|
|
1880
|
+
function PreviewEmbedPanel({ isOpen, isRightSide, zIndex, panelWidth }) {
|
|
1852
1881
|
const previewEmbed = chunkDVWX2UGY_cjs.usePreviewEmbed();
|
|
1853
1882
|
if (!previewEmbed) return null;
|
|
1854
1883
|
const { preview, closePreview } = previewEmbed;
|
|
@@ -1861,9 +1890,9 @@ function PreviewEmbedPanel({ isOpen, isRightSide, zIndex }) {
|
|
|
1861
1890
|
backgroundColor: "var(--ac-background)",
|
|
1862
1891
|
borderColor: "var(--ac-border)",
|
|
1863
1892
|
zIndex,
|
|
1864
|
-
width:
|
|
1893
|
+
width: sidePanelWidth(560, panelWidth),
|
|
1865
1894
|
height: "70vh",
|
|
1866
|
-
...isRightSide ? { right:
|
|
1895
|
+
...isRightSide ? { right: sidePanelOffset(panelWidth) } : { left: sidePanelOffset(panelWidth) },
|
|
1867
1896
|
transform: showPanel ? "translateY(-50%) translateX(0)" : `translateY(-50%) ${isRightSide ? "translateX(20px)" : "translateX(-20px)"}`,
|
|
1868
1897
|
opacity: showPanel ? 1 : 0,
|
|
1869
1898
|
pointerEvents: showPanel ? "auto" : "none",
|
|
@@ -1911,6 +1940,7 @@ exports.ChatFooter = ChatFooter;
|
|
|
1911
1940
|
exports.ChatHeader = ChatHeader;
|
|
1912
1941
|
exports.ChatInput = ChatInput;
|
|
1913
1942
|
exports.ChatInterface = ChatInterface;
|
|
1943
|
+
exports.DEFAULT_PANEL_WIDTH = DEFAULT_PANEL_WIDTH;
|
|
1914
1944
|
exports.FloatingButton = FloatingButton;
|
|
1915
1945
|
exports.LiveChatPanel = LiveChatPanel;
|
|
1916
1946
|
exports.MobileLiveChatDrawer = MobileLiveChatDrawer;
|
|
@@ -1918,5 +1948,6 @@ exports.PreviewEmbedPanel = PreviewEmbedPanel;
|
|
|
1918
1948
|
exports.QuickQuestions = QuickQuestions;
|
|
1919
1949
|
exports.SystemMessage = SystemMessage;
|
|
1920
1950
|
exports.WelcomePage = WelcomePage;
|
|
1921
|
-
|
|
1922
|
-
//# sourceMappingURL=chunk-
|
|
1951
|
+
exports.panelMaxWidth = panelMaxWidth;
|
|
1952
|
+
//# sourceMappingURL=chunk-CPWM6NNE.cjs.map
|
|
1953
|
+
//# sourceMappingURL=chunk-CPWM6NNE.cjs.map
|