@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 CHANGED
@@ -81,9 +81,11 @@ applet secrets delete --name <applet> --key OPENAI_API_KEY
81
81
 
82
82
  ### Release flow
83
83
 
84
- 1. Publish SDK changes from `applets/` (bump `applets/package.json` version and release).
85
- 2. Upgrade consumers (`eai/back`, applet web packages, etc.) to the published version.
86
- 3. Commit only version upgrades in consumer repos; never commit local-link overrides.
84
+ 1. Publish SDK changes from `applets/` (bump `applets/package.json` version).
85
+ 2. Create and push a tag `iota-sdk-v<version>` where `<version>` exactly matches
86
+ `applets/package.json`. This triggers `publish-npm.yml`.
87
+ 3. Upgrade consumers (`eai/back`, applet web packages, etc.) to the published version.
88
+ 4. Commit only version upgrades in consumer repos; never commit local-link overrides.
87
89
 
88
90
  ---
89
91
 
@@ -1908,6 +1908,50 @@ function deriveInputSnapshot(state, methods) {
1908
1908
  };
1909
1909
  }
1910
1910
 
1911
+ // ui/src/bichat/utils/assistantTurnState.ts
1912
+ function isEmptyAssistantTurn(turn) {
1913
+ if (turn.content.trim().length > 0) {
1914
+ return false;
1915
+ }
1916
+ if ((turn.explanation?.trim().length ?? 0) > 0) {
1917
+ return false;
1918
+ }
1919
+ if ((turn.citations?.length ?? 0) > 0) {
1920
+ return false;
1921
+ }
1922
+ if ((turn.toolCalls?.length ?? 0) > 0) {
1923
+ return false;
1924
+ }
1925
+ if ((turn.charts?.length ?? 0) > 0) {
1926
+ return false;
1927
+ }
1928
+ if ((turn.renderTables?.length ?? 0) > 0) {
1929
+ return false;
1930
+ }
1931
+ if ((turn.artifacts?.length ?? 0) > 0) {
1932
+ return false;
1933
+ }
1934
+ if ((turn.codeOutputs?.length ?? 0) > 0) {
1935
+ return false;
1936
+ }
1937
+ if (turn.debug) {
1938
+ return false;
1939
+ }
1940
+ return true;
1941
+ }
1942
+ function isPlaceholderWaitingAssistantTurn(turn) {
1943
+ return turn.lifecycle === "waiting_for_human_input" && isEmptyAssistantTurn(turn);
1944
+ }
1945
+ function shouldRenderInlineRetry(turn, canRegenerate) {
1946
+ if (!canRegenerate) {
1947
+ return false;
1948
+ }
1949
+ if (turn.lifecycle === "waiting_for_human_input") {
1950
+ return false;
1951
+ }
1952
+ return isEmptyAssistantTurn(turn);
1953
+ }
1954
+
1911
1955
  // ui/src/bichat/machine/hitlLifecycle.ts
1912
1956
  function normalizeQuestionType(rawType) {
1913
1957
  const normalized = String(rawType || "").trim().toUpperCase().replace(/[\s-]+/g, "_");
@@ -1987,6 +2031,13 @@ function applyTurnLifecycleForPendingQuestion(turns, pendingQuestion) {
1987
2031
  }
1988
2032
  };
1989
2033
  }
2034
+ if (!shouldWaitForInput && isPlaceholderWaitingAssistantTurn(turn.assistantTurn)) {
2035
+ changed = true;
2036
+ return {
2037
+ ...turn,
2038
+ assistantTurn: void 0
2039
+ };
2040
+ }
1990
2041
  if (turn.assistantTurn.lifecycle === desiredLifecycle) {
1991
2042
  return turn;
1992
2043
  }
@@ -4437,7 +4488,7 @@ init_useTranslation();
4437
4488
  var COPY_FEEDBACK_MS = 2e3;
4438
4489
  var defaultClassNames = {
4439
4490
  root: "flex gap-3 justify-end group",
4440
- wrapper: "flex-1 flex flex-col items-end max-w-[var(--bichat-bubble-max-width)]",
4491
+ wrapper: "flex-1 min-w-0 flex flex-col items-end max-w-[var(--bichat-bubble-max-width)]",
4441
4492
  avatar: "flex-shrink-0 w-8 h-8 rounded-full bg-primary-600 flex items-center justify-center text-white font-medium text-sm",
4442
4493
  bubble: "bg-primary-600 text-white rounded-2xl rounded-br-sm px-4 py-3 shadow-sm",
4443
4494
  content: "text-sm whitespace-pre-wrap break-words leading-relaxed",
@@ -6001,6 +6052,7 @@ function FullscreenOverlay({ title, onClose, closeLabel, children }) {
6001
6052
  )
6002
6053
  ] });
6003
6054
  }
6055
+ var FULL_WIDTH_CLASS = "w-full min-w-0 max-w-full";
6004
6056
  function getPageNumbers(current, total) {
6005
6057
  if (total <= 7) {
6006
6058
  return Array.from({ length: total }, (_, i) => i + 1);
@@ -6095,6 +6147,8 @@ var InteractiveTableCard = React.memo(function InteractiveTableCard2({
6095
6147
  const hasHiddenColumns = dt.columns.some((c) => !c.visible);
6096
6148
  const from = dt.totalFilteredRows === 0 ? 0 : (dt.page - 1) * dt.pageSize + 1;
6097
6149
  const to = Math.min(dt.page * dt.pageSize, dt.totalFilteredRows);
6150
+ const loadedRowsCount = table.rows.length;
6151
+ const reportedRowsCount = Math.max(table.totalRows || 0, loadedRowsCount);
6098
6152
  const renderToolbar = () => /* @__PURE__ */ jsxRuntime.jsx(
6099
6153
  DataTableToolbar,
6100
6154
  {
@@ -6115,9 +6169,12 @@ var InteractiveTableCard = React.memo(function InteractiveTableCard2({
6115
6169
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
6116
6170
  /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "truncate text-sm font-semibold text-gray-900 dark:text-gray-100", children: table.title || t("BiChat.Table.QueryResults") }),
6117
6171
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: [
6118
- dt.totalFilteredRows === table.rows.length ? dt.totalFilteredRows === 1 ? t("BiChat.Table.OneRowLoaded") : t("BiChat.Table.RowsLoaded", { count: String(dt.totalFilteredRows) }) : t("BiChat.DataTable.FilteredRows", {
6172
+ dt.totalFilteredRows === loadedRowsCount ? loadedRowsCount === reportedRowsCount ? loadedRowsCount === 1 ? t("BiChat.Table.OneRowLoaded") : t("BiChat.Table.RowsLoaded", { count: String(loadedRowsCount) }) : t("BiChat.DataTable.FilteredRows", {
6173
+ filtered: String(loadedRowsCount),
6174
+ total: String(reportedRowsCount)
6175
+ }) : t("BiChat.DataTable.FilteredRows", {
6119
6176
  filtered: String(dt.totalFilteredRows),
6120
- total: String(table.rows.length)
6177
+ total: String(loadedRowsCount)
6121
6178
  }),
6122
6179
  table.truncated ? ` ${t("BiChat.Table.TruncatedSuffix")}` : ""
6123
6180
  ] })
@@ -6132,7 +6189,7 @@ var InteractiveTableCard = React.memo(function InteractiveTableCard2({
6132
6189
  }
6133
6190
  )
6134
6191
  ] });
6135
- const renderTable = (scrollClass) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: scrollClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full border-collapse text-sm", children: [
6192
+ const renderTable = (scrollClass) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${FULL_WIDTH_CLASS} ${scrollClass}`, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full border-collapse text-sm", children: [
6136
6193
  /* @__PURE__ */ jsxRuntime.jsx(
6137
6194
  DataTableHeader,
6138
6195
  {
@@ -6273,7 +6330,7 @@ var InteractiveTableCard = React.memo(function InteractiveTableCard2({
6273
6330
  ] });
6274
6331
  const renderTruncationNotice = () => table.truncated ? /* @__PURE__ */ jsxRuntime.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;
6275
6332
  const fillHeight = host?.isFullscreen ?? false;
6276
- const sectionClassName = host ? `w-full min-w-0 overflow-hidden${fillHeight ? " flex flex-col flex-1" : ""}` : "w-full min-w-0 rounded-xl border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900/40 overflow-hidden";
6333
+ 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`;
6277
6334
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6278
6335
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionClassName, children: [
6279
6336
  renderToolbar(),
@@ -6426,7 +6483,7 @@ var TabbedTableGroup = React.memo(function TabbedTableGroup2({
6426
6483
  const tabs = React.useMemo(
6427
6484
  () => tables.map((table, i) => ({
6428
6485
  id: table.id,
6429
- label: `${table.title || `${t("BiChat.Table.QueryResults")} ${i + 1}`} (${table.rows.length})`
6486
+ label: `${table.title || `${t("BiChat.Table.QueryResults")} ${i + 1}`} (${Math.max(table.totalRows || 0, table.rows.length)})`
6430
6487
  })),
6431
6488
  [tables, t]
6432
6489
  );
@@ -7489,8 +7546,8 @@ var MarkdownRenderer2 = React.lazy(
7489
7546
  );
7490
7547
  var COPY_FEEDBACK_MS2 = 2e3;
7491
7548
  var defaultClassNames2 = {
7492
- root: "flex gap-3 group",
7493
- wrapper: "flex-1 min-w-0 flex flex-col gap-3 max-w-[var(--bichat-bubble-assistant-max-width,85%)]",
7549
+ root: "flex min-w-0 gap-3 group",
7550
+ wrapper: "flex-1 w-full min-w-0 flex flex-col gap-3 max-w-[var(--bichat-bubble-assistant-max-width,85%)]",
7494
7551
  avatar: "flex-shrink-0 w-8 h-8 rounded-full bg-primary-600 flex items-center justify-center text-white font-medium text-xs",
7495
7552
  bubble: "bg-white dark:bg-gray-800 rounded-2xl rounded-bl-sm px-4 py-3 shadow-sm",
7496
7553
  codeOutputs: "",
@@ -7568,8 +7625,8 @@ function AssistantMessage({
7568
7625
  const hasDebug = showDebug && !!turn.debug;
7569
7626
  const hasAnyRenderedContent = hasContent || hasExplanation || hasCodeOutputs || hasChart || hasTables || hasArtifacts || hasDebug;
7570
7627
  const canRegenerate = !!onRegenerate && !!turnId && !isSystemMessage && isLastTurn;
7571
- const renderMode = hasPendingQuestion ? "hitl_form" : isAwaitingHumanInput ? "hitl_waiting" : hasAnyRenderedContent ? "content" : canRegenerate ? "retry" : "empty";
7572
- const showInlineRetry = renderMode === "retry";
7628
+ const showInlineRetry = shouldRenderInlineRetry(turn, canRegenerate) && !hasAnyRenderedContent;
7629
+ const renderMode = hasPendingQuestion ? "hitl_form" : isAwaitingHumanInput ? "hitl_waiting" : hasAnyRenderedContent ? "content" : showInlineRetry ? "retry" : "empty";
7573
7630
  const handleCopyClick = React.useCallback(async () => {
7574
7631
  try {
7575
7632
  if (onCopy) {
@@ -7961,7 +8018,7 @@ function AssistantTurnView({
7961
8018
  );
7962
8019
  }
7963
8020
  var defaultClassNames3 = {
7964
- root: "space-y-4",
8021
+ root: "space-y-4 min-w-0",
7965
8022
  userTurn: "",
7966
8023
  assistantTurn: ""
7967
8024
  };
@@ -8794,9 +8851,9 @@ function MessageListSkeleton() {
8794
8851
  ] });
8795
8852
  }
8796
8853
  function StreamingBubble({ content, normalizedContent }) {
8797
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
8854
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 gap-3", children: [
8798
8855
  /* @__PURE__ */ jsxRuntime.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" }),
8799
- /* @__PURE__ */ jsxRuntime.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: [
8856
+ /* @__PURE__ */ jsxRuntime.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: [
8800
8857
  /* @__PURE__ */ jsxRuntime.jsx(
8801
8858
  React.Suspense,
8802
8859
  {
@@ -8827,8 +8884,8 @@ function MessageList({ renderUserTurn, renderAssistantTurn, thinkingVerbs, readO
8827
8884
  );
8828
8885
  const showAuthorNames = Boolean(session?.isGroup);
8829
8886
  const showEphemeral = showActivityTrace || showTypingIndicator;
8830
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1 min-h-0", children: [
8831
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "h-full overflow-y-auto overflow-x-hidden px-4 py-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto space-y-6", children: [
8887
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1 min-w-0 min-h-0", children: [
8888
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "h-full overflow-y-auto overflow-x-hidden px-4 py-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto w-full min-w-0 space-y-6", children: [
8832
8889
  fetching && turns.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(MessageListSkeleton, {}),
8833
8890
  turns.map((turn, index) => {
8834
8891
  const turnDate = new Date(turn.createdAt);
@@ -10240,6 +10297,14 @@ function readString(value) {
10240
10297
  return trimmed.length > 0 ? trimmed : null;
10241
10298
  }
10242
10299
  function readPositiveInteger(value) {
10300
+ if (typeof value === "string") {
10301
+ const trimmed = value.trim();
10302
+ if (!/^\d+$/.test(trimmed)) {
10303
+ return null;
10304
+ }
10305
+ const parsed = Number(trimmed);
10306
+ return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
10307
+ }
10243
10308
  if (typeof value !== "number" || !Number.isFinite(value)) {
10244
10309
  return null;
10245
10310
  }
@@ -10290,7 +10355,7 @@ function parseRenderTableDataFromObject(parsed, fallbackId) {
10290
10355
  const headers = headersRaw.length === columns.length ? headersRaw : columns;
10291
10356
  const columnTypesRaw = Array.isArray(parsed.column_types) ? parsed.column_types : Array.isArray(parsed.columnTypes) ? parsed.columnTypes : [];
10292
10357
  const columnTypes = columnTypesRaw.length === columns.length ? columnTypesRaw.map((t) => readString(t) || "string") : void 0;
10293
- const totalRows = readPositiveInteger(parsed.total_rows) || readPositiveInteger(parsed.totalRows) || rows.length;
10358
+ const totalRows = readPositiveInteger(parsed.total_rows) || readPositiveInteger(parsed.totalRows) || readPositiveInteger(parsed.row_count) || readPositiveInteger(parsed.rowCount) || rows.length;
10294
10359
  const pageSize = readPositiveInteger(parsed.page_size) || readPositiveInteger(parsed.pageSize) || 25;
10295
10360
  const query = readString(parsed.query) || readString(parsed.sql);
10296
10361
  if (!query) {
@@ -12064,7 +12129,7 @@ function ChatSessionCore({
12064
12129
  return /* @__PURE__ */ jsxRuntime.jsxs(
12065
12130
  "main",
12066
12131
  {
12067
- className: `flex min-h-0 flex-1 flex-col overflow-hidden bg-gray-50 dark:bg-gray-900 ${className}`,
12132
+ className: `flex min-w-0 min-h-0 flex-1 flex-col overflow-hidden bg-gray-50 dark:bg-gray-900 ${className}`,
12068
12133
  children: [
12069
12134
  headerSlot || /* @__PURE__ */ jsxRuntime.jsx(
12070
12135
  ChatHeader,
@@ -14571,10 +14636,14 @@ function Sidebar2({
14571
14636
  sessions: Array.isArray(group.sessions) ? group.sessions : []
14572
14637
  })) : [];
14573
14638
  }, [unpinnedSessions, t]);
14639
+ const orderedUnpinnedSessions = React.useMemo(
14640
+ () => sessionGroups.flatMap((group) => group.sessions),
14641
+ [sessionGroups]
14642
+ );
14574
14643
  const collapsedIndicators = React.useMemo(() => {
14575
14644
  const seen = /* @__PURE__ */ new Set();
14576
14645
  const result = [];
14577
- for (const s of [...pinnedSessions, ...unpinnedSessions]) {
14646
+ for (const s of [...pinnedSessions, ...orderedUnpinnedSessions]) {
14578
14647
  if (seen.has(s.id)) {
14579
14648
  continue;
14580
14649
  }
@@ -14585,7 +14654,7 @@ function Sidebar2({
14585
14654
  }
14586
14655
  }
14587
14656
  return result;
14588
- }, [pinnedSessions, unpinnedSessions]);
14657
+ }, [pinnedSessions, orderedUnpinnedSessions]);
14589
14658
  const totalSessionCount = filteredSessions.length;
14590
14659
  const overflowCount = Math.max(0, totalSessionCount - collapsedIndicators.length);
14591
14660
  const handleSessionListKeyDown = React.useCallback(
@@ -15406,7 +15475,7 @@ function BiChatLayout({
15406
15475
  const content = routeKey ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ jsxRuntime.jsx(
15407
15476
  framerMotion.motion.div,
15408
15477
  {
15409
- className: "flex flex-1 min-h-0",
15478
+ className: "flex flex-1 min-w-0 min-h-0",
15410
15479
  initial: { opacity: 0, y: 4 },
15411
15480
  animate: { opacity: 1, y: 0 },
15412
15481
  exit: { opacity: 0, y: -4 },
@@ -15414,7 +15483,7 @@ function BiChatLayout({
15414
15483
  children
15415
15484
  },
15416
15485
  routeKey
15417
- ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 min-h-0", children });
15486
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 min-w-0 min-h-0", children });
15418
15487
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `relative flex flex-1 w-full h-full min-h-0 overflow-hidden ${className}`, children: [
15419
15488
  /* @__PURE__ */ jsxRuntime.jsx(SkipLink, {}),
15420
15489
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden md:block", children: renderSidebar({}) }),
@@ -15450,7 +15519,7 @@ function BiChatLayout({
15450
15519
  "sidebar-drawer"
15451
15520
  )
15452
15521
  ] }) }),
15453
- /* @__PURE__ */ jsxRuntime.jsxs("main", { id: "main-content", className: "relative flex-1 flex flex-col min-h-0 overflow-hidden", children: [
15522
+ /* @__PURE__ */ jsxRuntime.jsxs("main", { id: "main-content", className: "relative flex-1 min-w-0 flex flex-col min-h-0 overflow-hidden", children: [
15454
15523
  isMobile && !isMobileOpen && /* @__PURE__ */ jsxRuntime.jsx(
15455
15524
  "button",
15456
15525
  {
@@ -17862,13 +17931,17 @@ function parseRowCount(metadata) {
17862
17931
  if (!metadata) {
17863
17932
  return void 0;
17864
17933
  }
17865
- const raw = metadata.row_count ?? metadata.rowCount;
17866
- if (typeof raw === "number" && Number.isFinite(raw)) {
17934
+ const raw = metadata.row_count ?? metadata.rowCount ?? metadata.total_rows ?? metadata.totalRows;
17935
+ if (typeof raw === "number" && Number.isSafeInteger(raw) && raw >= 0) {
17867
17936
  return raw;
17868
17937
  }
17869
17938
  if (typeof raw === "string") {
17870
- const parsed = Number.parseInt(raw, 10);
17871
- if (Number.isFinite(parsed)) {
17939
+ const trimmed = raw.trim();
17940
+ if (!/^\d+$/.test(trimmed)) {
17941
+ return void 0;
17942
+ }
17943
+ const parsed = Number(trimmed);
17944
+ if (Number.isSafeInteger(parsed)) {
17872
17945
  return parsed;
17873
17946
  }
17874
17947
  }