@iota-uz/sdk 0.4.27 → 0.4.28
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/README.md +5 -3
- package/dist/bichat/index.cjs +99 -26
- package/dist/bichat/index.cjs.map +1 -1
- package/dist/bichat/index.mjs +99 -26
- package/dist/bichat/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bichat/index.mjs
CHANGED
|
@@ -1896,6 +1896,50 @@ function deriveInputSnapshot(state, methods) {
|
|
|
1896
1896
|
};
|
|
1897
1897
|
}
|
|
1898
1898
|
|
|
1899
|
+
// ui/src/bichat/utils/assistantTurnState.ts
|
|
1900
|
+
function isEmptyAssistantTurn(turn) {
|
|
1901
|
+
if (turn.content.trim().length > 0) {
|
|
1902
|
+
return false;
|
|
1903
|
+
}
|
|
1904
|
+
if ((turn.explanation?.trim().length ?? 0) > 0) {
|
|
1905
|
+
return false;
|
|
1906
|
+
}
|
|
1907
|
+
if ((turn.citations?.length ?? 0) > 0) {
|
|
1908
|
+
return false;
|
|
1909
|
+
}
|
|
1910
|
+
if ((turn.toolCalls?.length ?? 0) > 0) {
|
|
1911
|
+
return false;
|
|
1912
|
+
}
|
|
1913
|
+
if ((turn.charts?.length ?? 0) > 0) {
|
|
1914
|
+
return false;
|
|
1915
|
+
}
|
|
1916
|
+
if ((turn.renderTables?.length ?? 0) > 0) {
|
|
1917
|
+
return false;
|
|
1918
|
+
}
|
|
1919
|
+
if ((turn.artifacts?.length ?? 0) > 0) {
|
|
1920
|
+
return false;
|
|
1921
|
+
}
|
|
1922
|
+
if ((turn.codeOutputs?.length ?? 0) > 0) {
|
|
1923
|
+
return false;
|
|
1924
|
+
}
|
|
1925
|
+
if (turn.debug) {
|
|
1926
|
+
return false;
|
|
1927
|
+
}
|
|
1928
|
+
return true;
|
|
1929
|
+
}
|
|
1930
|
+
function isPlaceholderWaitingAssistantTurn(turn) {
|
|
1931
|
+
return turn.lifecycle === "waiting_for_human_input" && isEmptyAssistantTurn(turn);
|
|
1932
|
+
}
|
|
1933
|
+
function shouldRenderInlineRetry(turn, canRegenerate) {
|
|
1934
|
+
if (!canRegenerate) {
|
|
1935
|
+
return false;
|
|
1936
|
+
}
|
|
1937
|
+
if (turn.lifecycle === "waiting_for_human_input") {
|
|
1938
|
+
return false;
|
|
1939
|
+
}
|
|
1940
|
+
return isEmptyAssistantTurn(turn);
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1899
1943
|
// ui/src/bichat/machine/hitlLifecycle.ts
|
|
1900
1944
|
function normalizeQuestionType(rawType) {
|
|
1901
1945
|
const normalized = String(rawType || "").trim().toUpperCase().replace(/[\s-]+/g, "_");
|
|
@@ -1975,6 +2019,13 @@ function applyTurnLifecycleForPendingQuestion(turns, pendingQuestion) {
|
|
|
1975
2019
|
}
|
|
1976
2020
|
};
|
|
1977
2021
|
}
|
|
2022
|
+
if (!shouldWaitForInput && isPlaceholderWaitingAssistantTurn(turn.assistantTurn)) {
|
|
2023
|
+
changed = true;
|
|
2024
|
+
return {
|
|
2025
|
+
...turn,
|
|
2026
|
+
assistantTurn: void 0
|
|
2027
|
+
};
|
|
2028
|
+
}
|
|
1978
2029
|
if (turn.assistantTurn.lifecycle === desiredLifecycle) {
|
|
1979
2030
|
return turn;
|
|
1980
2031
|
}
|
|
@@ -4425,7 +4476,7 @@ init_useTranslation();
|
|
|
4425
4476
|
var COPY_FEEDBACK_MS = 2e3;
|
|
4426
4477
|
var defaultClassNames = {
|
|
4427
4478
|
root: "flex gap-3 justify-end group",
|
|
4428
|
-
wrapper: "flex-1 flex flex-col items-end max-w-[var(--bichat-bubble-max-width)]",
|
|
4479
|
+
wrapper: "flex-1 min-w-0 flex flex-col items-end max-w-[var(--bichat-bubble-max-width)]",
|
|
4429
4480
|
avatar: "flex-shrink-0 w-8 h-8 rounded-full bg-primary-600 flex items-center justify-center text-white font-medium text-sm",
|
|
4430
4481
|
bubble: "bg-primary-600 text-white rounded-2xl rounded-br-sm px-4 py-3 shadow-sm",
|
|
4431
4482
|
content: "text-sm whitespace-pre-wrap break-words leading-relaxed",
|
|
@@ -5989,6 +6040,7 @@ function FullscreenOverlay({ title, onClose, closeLabel, children }) {
|
|
|
5989
6040
|
)
|
|
5990
6041
|
] });
|
|
5991
6042
|
}
|
|
6043
|
+
var FULL_WIDTH_CLASS = "w-full min-w-0 max-w-full";
|
|
5992
6044
|
function getPageNumbers(current, total) {
|
|
5993
6045
|
if (total <= 7) {
|
|
5994
6046
|
return Array.from({ length: total }, (_, i) => i + 1);
|
|
@@ -6083,6 +6135,8 @@ var InteractiveTableCard = memo(function InteractiveTableCard2({
|
|
|
6083
6135
|
const hasHiddenColumns = dt.columns.some((c) => !c.visible);
|
|
6084
6136
|
const from = dt.totalFilteredRows === 0 ? 0 : (dt.page - 1) * dt.pageSize + 1;
|
|
6085
6137
|
const to = Math.min(dt.page * dt.pageSize, dt.totalFilteredRows);
|
|
6138
|
+
const loadedRowsCount = table.rows.length;
|
|
6139
|
+
const reportedRowsCount = Math.max(table.totalRows || 0, loadedRowsCount);
|
|
6086
6140
|
const renderToolbar = () => /* @__PURE__ */ jsx(
|
|
6087
6141
|
DataTableToolbar,
|
|
6088
6142
|
{
|
|
@@ -6103,9 +6157,12 @@ var InteractiveTableCard = memo(function InteractiveTableCard2({
|
|
|
6103
6157
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
6104
6158
|
/* @__PURE__ */ jsx("h4", { className: "truncate text-sm font-semibold text-gray-900 dark:text-gray-100", children: table.title || t("BiChat.Table.QueryResults") }),
|
|
6105
6159
|
/* @__PURE__ */ jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: [
|
|
6106
|
-
dt.totalFilteredRows ===
|
|
6160
|
+
dt.totalFilteredRows === loadedRowsCount ? loadedRowsCount === reportedRowsCount ? loadedRowsCount === 1 ? t("BiChat.Table.OneRowLoaded") : t("BiChat.Table.RowsLoaded", { count: String(loadedRowsCount) }) : t("BiChat.DataTable.FilteredRows", {
|
|
6161
|
+
filtered: String(loadedRowsCount),
|
|
6162
|
+
total: String(reportedRowsCount)
|
|
6163
|
+
}) : t("BiChat.DataTable.FilteredRows", {
|
|
6107
6164
|
filtered: String(dt.totalFilteredRows),
|
|
6108
|
-
total: String(
|
|
6165
|
+
total: String(loadedRowsCount)
|
|
6109
6166
|
}),
|
|
6110
6167
|
table.truncated ? ` ${t("BiChat.Table.TruncatedSuffix")}` : ""
|
|
6111
6168
|
] })
|
|
@@ -6120,7 +6177,7 @@ var InteractiveTableCard = memo(function InteractiveTableCard2({
|
|
|
6120
6177
|
}
|
|
6121
6178
|
)
|
|
6122
6179
|
] });
|
|
6123
|
-
const renderTable = (scrollClass) => /* @__PURE__ */ jsx("div", { className: scrollClass
|
|
6180
|
+
const renderTable = (scrollClass) => /* @__PURE__ */ jsx("div", { className: `${FULL_WIDTH_CLASS} ${scrollClass}`, children: /* @__PURE__ */ jsxs("table", { className: "min-w-full border-collapse text-sm", children: [
|
|
6124
6181
|
/* @__PURE__ */ jsx(
|
|
6125
6182
|
DataTableHeader,
|
|
6126
6183
|
{
|
|
@@ -6261,7 +6318,7 @@ var InteractiveTableCard = memo(function InteractiveTableCard2({
|
|
|
6261
6318
|
] });
|
|
6262
6319
|
const renderTruncationNotice = () => table.truncated ? /* @__PURE__ */ jsx("p", { className: "border-t border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-700/60 dark:bg-amber-900/20 dark:text-amber-300", children: t("BiChat.Table.TruncatedNotice") }) : null;
|
|
6263
6320
|
const fillHeight = host?.isFullscreen ?? false;
|
|
6264
|
-
const sectionClassName = host ?
|
|
6321
|
+
const sectionClassName = host ? `${FULL_WIDTH_CLASS} overflow-hidden${fillHeight ? " flex flex-col flex-1" : ""}` : `${FULL_WIDTH_CLASS} rounded-xl border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900/40 overflow-hidden`;
|
|
6265
6322
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6266
6323
|
/* @__PURE__ */ jsxs("section", { className: sectionClassName, children: [
|
|
6267
6324
|
renderToolbar(),
|
|
@@ -6414,7 +6471,7 @@ var TabbedTableGroup = memo(function TabbedTableGroup2({
|
|
|
6414
6471
|
const tabs = useMemo(
|
|
6415
6472
|
() => tables.map((table, i) => ({
|
|
6416
6473
|
id: table.id,
|
|
6417
|
-
label: `${table.title || `${t("BiChat.Table.QueryResults")} ${i + 1}`} (${table.rows.length})`
|
|
6474
|
+
label: `${table.title || `${t("BiChat.Table.QueryResults")} ${i + 1}`} (${Math.max(table.totalRows || 0, table.rows.length)})`
|
|
6418
6475
|
})),
|
|
6419
6476
|
[tables, t]
|
|
6420
6477
|
);
|
|
@@ -7477,8 +7534,8 @@ var MarkdownRenderer2 = lazy(
|
|
|
7477
7534
|
);
|
|
7478
7535
|
var COPY_FEEDBACK_MS2 = 2e3;
|
|
7479
7536
|
var defaultClassNames2 = {
|
|
7480
|
-
root: "flex gap-3 group",
|
|
7481
|
-
wrapper: "flex-1 min-w-0 flex flex-col gap-3 max-w-[var(--bichat-bubble-assistant-max-width,85%)]",
|
|
7537
|
+
root: "flex min-w-0 gap-3 group",
|
|
7538
|
+
wrapper: "flex-1 w-full min-w-0 flex flex-col gap-3 max-w-[var(--bichat-bubble-assistant-max-width,85%)]",
|
|
7482
7539
|
avatar: "flex-shrink-0 w-8 h-8 rounded-full bg-primary-600 flex items-center justify-center text-white font-medium text-xs",
|
|
7483
7540
|
bubble: "bg-white dark:bg-gray-800 rounded-2xl rounded-bl-sm px-4 py-3 shadow-sm",
|
|
7484
7541
|
codeOutputs: "",
|
|
@@ -7556,8 +7613,8 @@ function AssistantMessage({
|
|
|
7556
7613
|
const hasDebug = showDebug && !!turn.debug;
|
|
7557
7614
|
const hasAnyRenderedContent = hasContent || hasExplanation || hasCodeOutputs || hasChart || hasTables || hasArtifacts || hasDebug;
|
|
7558
7615
|
const canRegenerate = !!onRegenerate && !!turnId && !isSystemMessage && isLastTurn;
|
|
7559
|
-
const
|
|
7560
|
-
const
|
|
7616
|
+
const showInlineRetry = shouldRenderInlineRetry(turn, canRegenerate) && !hasAnyRenderedContent;
|
|
7617
|
+
const renderMode = hasPendingQuestion ? "hitl_form" : isAwaitingHumanInput ? "hitl_waiting" : hasAnyRenderedContent ? "content" : showInlineRetry ? "retry" : "empty";
|
|
7561
7618
|
const handleCopyClick = useCallback(async () => {
|
|
7562
7619
|
try {
|
|
7563
7620
|
if (onCopy) {
|
|
@@ -7949,7 +8006,7 @@ function AssistantTurnView({
|
|
|
7949
8006
|
);
|
|
7950
8007
|
}
|
|
7951
8008
|
var defaultClassNames3 = {
|
|
7952
|
-
root: "space-y-4",
|
|
8009
|
+
root: "space-y-4 min-w-0",
|
|
7953
8010
|
userTurn: "",
|
|
7954
8011
|
assistantTurn: ""
|
|
7955
8012
|
};
|
|
@@ -8782,9 +8839,9 @@ function MessageListSkeleton() {
|
|
|
8782
8839
|
] });
|
|
8783
8840
|
}
|
|
8784
8841
|
function StreamingBubble({ content, normalizedContent }) {
|
|
8785
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
8842
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 gap-3", children: [
|
|
8786
8843
|
/* @__PURE__ */ jsx("div", { className: "flex-shrink-0 w-8 h-8 rounded-full bg-primary-600 flex items-center justify-center text-white font-medium text-xs", children: "AI" }),
|
|
8787
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-2xl rounded-bl-sm px-4 py-3 text-gray-900 dark:text-gray-100", style: { maxWidth: "var(--bichat-bubble-assistant-max-width, 85%)" }, children: [
|
|
8844
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-2xl rounded-bl-sm px-4 py-3 text-gray-900 dark:text-gray-100", style: { maxWidth: "var(--bichat-bubble-assistant-max-width, 85%)" }, children: [
|
|
8788
8845
|
/* @__PURE__ */ jsx(
|
|
8789
8846
|
Suspense,
|
|
8790
8847
|
{
|
|
@@ -8815,8 +8872,8 @@ function MessageList({ renderUserTurn, renderAssistantTurn, thinkingVerbs, readO
|
|
|
8815
8872
|
);
|
|
8816
8873
|
const showAuthorNames = Boolean(session?.isGroup);
|
|
8817
8874
|
const showEphemeral = showActivityTrace || showTypingIndicator;
|
|
8818
|
-
return /* @__PURE__ */ jsxs("div", { className: "relative flex-1 min-h-0", children: [
|
|
8819
|
-
/* @__PURE__ */ jsx("div", { ref: containerRef, className: "h-full overflow-y-auto overflow-x-hidden px-4 py-6", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto space-y-6", children: [
|
|
8875
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex-1 min-w-0 min-h-0", children: [
|
|
8876
|
+
/* @__PURE__ */ jsx("div", { ref: containerRef, className: "h-full overflow-y-auto overflow-x-hidden px-4 py-6", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto w-full min-w-0 space-y-6", children: [
|
|
8820
8877
|
fetching && turns.length === 0 && /* @__PURE__ */ jsx(MessageListSkeleton, {}),
|
|
8821
8878
|
turns.map((turn, index) => {
|
|
8822
8879
|
const turnDate = new Date(turn.createdAt);
|
|
@@ -10228,6 +10285,14 @@ function readString(value) {
|
|
|
10228
10285
|
return trimmed.length > 0 ? trimmed : null;
|
|
10229
10286
|
}
|
|
10230
10287
|
function readPositiveInteger(value) {
|
|
10288
|
+
if (typeof value === "string") {
|
|
10289
|
+
const trimmed = value.trim();
|
|
10290
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
10291
|
+
return null;
|
|
10292
|
+
}
|
|
10293
|
+
const parsed = Number(trimmed);
|
|
10294
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
|
|
10295
|
+
}
|
|
10231
10296
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
10232
10297
|
return null;
|
|
10233
10298
|
}
|
|
@@ -10278,7 +10343,7 @@ function parseRenderTableDataFromObject(parsed, fallbackId) {
|
|
|
10278
10343
|
const headers = headersRaw.length === columns.length ? headersRaw : columns;
|
|
10279
10344
|
const columnTypesRaw = Array.isArray(parsed.column_types) ? parsed.column_types : Array.isArray(parsed.columnTypes) ? parsed.columnTypes : [];
|
|
10280
10345
|
const columnTypes = columnTypesRaw.length === columns.length ? columnTypesRaw.map((t) => readString(t) || "string") : void 0;
|
|
10281
|
-
const totalRows = readPositiveInteger(parsed.total_rows) || readPositiveInteger(parsed.totalRows) || rows.length;
|
|
10346
|
+
const totalRows = readPositiveInteger(parsed.total_rows) || readPositiveInteger(parsed.totalRows) || readPositiveInteger(parsed.row_count) || readPositiveInteger(parsed.rowCount) || rows.length;
|
|
10282
10347
|
const pageSize = readPositiveInteger(parsed.page_size) || readPositiveInteger(parsed.pageSize) || 25;
|
|
10283
10348
|
const query = readString(parsed.query) || readString(parsed.sql);
|
|
10284
10349
|
if (!query) {
|
|
@@ -12052,7 +12117,7 @@ function ChatSessionCore({
|
|
|
12052
12117
|
return /* @__PURE__ */ jsxs(
|
|
12053
12118
|
"main",
|
|
12054
12119
|
{
|
|
12055
|
-
className: `flex min-h-0 flex-1 flex-col overflow-hidden bg-gray-50 dark:bg-gray-900 ${className}`,
|
|
12120
|
+
className: `flex min-w-0 min-h-0 flex-1 flex-col overflow-hidden bg-gray-50 dark:bg-gray-900 ${className}`,
|
|
12056
12121
|
children: [
|
|
12057
12122
|
headerSlot || /* @__PURE__ */ jsx(
|
|
12058
12123
|
ChatHeader,
|
|
@@ -14559,10 +14624,14 @@ function Sidebar2({
|
|
|
14559
14624
|
sessions: Array.isArray(group.sessions) ? group.sessions : []
|
|
14560
14625
|
})) : [];
|
|
14561
14626
|
}, [unpinnedSessions, t]);
|
|
14627
|
+
const orderedUnpinnedSessions = useMemo(
|
|
14628
|
+
() => sessionGroups.flatMap((group) => group.sessions),
|
|
14629
|
+
[sessionGroups]
|
|
14630
|
+
);
|
|
14562
14631
|
const collapsedIndicators = useMemo(() => {
|
|
14563
14632
|
const seen = /* @__PURE__ */ new Set();
|
|
14564
14633
|
const result = [];
|
|
14565
|
-
for (const s of [...pinnedSessions, ...
|
|
14634
|
+
for (const s of [...pinnedSessions, ...orderedUnpinnedSessions]) {
|
|
14566
14635
|
if (seen.has(s.id)) {
|
|
14567
14636
|
continue;
|
|
14568
14637
|
}
|
|
@@ -14573,7 +14642,7 @@ function Sidebar2({
|
|
|
14573
14642
|
}
|
|
14574
14643
|
}
|
|
14575
14644
|
return result;
|
|
14576
|
-
}, [pinnedSessions,
|
|
14645
|
+
}, [pinnedSessions, orderedUnpinnedSessions]);
|
|
14577
14646
|
const totalSessionCount = filteredSessions.length;
|
|
14578
14647
|
const overflowCount = Math.max(0, totalSessionCount - collapsedIndicators.length);
|
|
14579
14648
|
const handleSessionListKeyDown = useCallback(
|
|
@@ -15394,7 +15463,7 @@ function BiChatLayout({
|
|
|
15394
15463
|
const content = routeKey ? /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ jsx(
|
|
15395
15464
|
motion.div,
|
|
15396
15465
|
{
|
|
15397
|
-
className: "flex flex-1 min-h-0",
|
|
15466
|
+
className: "flex flex-1 min-w-0 min-h-0",
|
|
15398
15467
|
initial: { opacity: 0, y: 4 },
|
|
15399
15468
|
animate: { opacity: 1, y: 0 },
|
|
15400
15469
|
exit: { opacity: 0, y: -4 },
|
|
@@ -15402,7 +15471,7 @@ function BiChatLayout({
|
|
|
15402
15471
|
children
|
|
15403
15472
|
},
|
|
15404
15473
|
routeKey
|
|
15405
|
-
) }) : /* @__PURE__ */ jsx("div", { className: "flex flex-1 min-h-0", children });
|
|
15474
|
+
) }) : /* @__PURE__ */ jsx("div", { className: "flex flex-1 min-w-0 min-h-0", children });
|
|
15406
15475
|
return /* @__PURE__ */ jsxs("div", { className: `relative flex flex-1 w-full h-full min-h-0 overflow-hidden ${className}`, children: [
|
|
15407
15476
|
/* @__PURE__ */ jsx(SkipLink, {}),
|
|
15408
15477
|
/* @__PURE__ */ jsx("div", { className: "hidden md:block", children: renderSidebar({}) }),
|
|
@@ -15438,7 +15507,7 @@ function BiChatLayout({
|
|
|
15438
15507
|
"sidebar-drawer"
|
|
15439
15508
|
)
|
|
15440
15509
|
] }) }),
|
|
15441
|
-
/* @__PURE__ */ jsxs("main", { id: "main-content", className: "relative flex-1 flex flex-col min-h-0 overflow-hidden", children: [
|
|
15510
|
+
/* @__PURE__ */ jsxs("main", { id: "main-content", className: "relative flex-1 min-w-0 flex flex-col min-h-0 overflow-hidden", children: [
|
|
15442
15511
|
isMobile && !isMobileOpen && /* @__PURE__ */ jsx(
|
|
15443
15512
|
"button",
|
|
15444
15513
|
{
|
|
@@ -17850,13 +17919,17 @@ function parseRowCount(metadata) {
|
|
|
17850
17919
|
if (!metadata) {
|
|
17851
17920
|
return void 0;
|
|
17852
17921
|
}
|
|
17853
|
-
const raw = metadata.row_count ?? metadata.rowCount;
|
|
17854
|
-
if (typeof raw === "number" && Number.
|
|
17922
|
+
const raw = metadata.row_count ?? metadata.rowCount ?? metadata.total_rows ?? metadata.totalRows;
|
|
17923
|
+
if (typeof raw === "number" && Number.isSafeInteger(raw) && raw >= 0) {
|
|
17855
17924
|
return raw;
|
|
17856
17925
|
}
|
|
17857
17926
|
if (typeof raw === "string") {
|
|
17858
|
-
const
|
|
17859
|
-
if (
|
|
17927
|
+
const trimmed = raw.trim();
|
|
17928
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
17929
|
+
return void 0;
|
|
17930
|
+
}
|
|
17931
|
+
const parsed = Number(trimmed);
|
|
17932
|
+
if (Number.isSafeInteger(parsed)) {
|
|
17860
17933
|
return parsed;
|
|
17861
17934
|
}
|
|
17862
17935
|
}
|