langchain_agentx_stream_ui 0.8.3 → 0.8.5

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.
@@ -241,10 +241,12 @@ function asInputRecord(input) {
241
241
  return {};
242
242
  }
243
243
  function strField(record, key) {
244
+ if (record == null) return "";
244
245
  const value = record[key];
245
246
  return value == null ? "" : String(value).trim();
246
247
  }
247
248
  function numField(record, key) {
249
+ if (record == null) return void 0;
248
250
  const value = record[key];
249
251
  if (typeof value === "number" && Number.isFinite(value)) return value;
250
252
  if (typeof value === "string" && value.trim() !== "") {
@@ -884,10 +886,25 @@ function AgentProgressLines({
884
886
  // src/view/tools/presentation/subagentTranscriptRenderer.ts
885
887
  function toolCallsFromAssistant(message) {
886
888
  const raw = message.tool_calls;
887
- if (!Array.isArray(raw)) return [];
888
- return raw.filter(
889
- (item) => item != null && typeof item === "object" && !Array.isArray(item)
890
- );
889
+ if (Array.isArray(raw) && raw.length > 0) {
890
+ return raw.filter(
891
+ (item) => item != null && typeof item === "object" && !Array.isArray(item)
892
+ );
893
+ }
894
+ const content = message.content;
895
+ if (!Array.isArray(content)) return [];
896
+ const fromContent = [];
897
+ for (const block of content) {
898
+ if (block == null || typeof block !== "object" || Array.isArray(block)) continue;
899
+ const item = block;
900
+ if (item.type !== "tool_use") continue;
901
+ fromContent.push({
902
+ name: item.name,
903
+ input: item.input,
904
+ id: item.id
905
+ });
906
+ }
907
+ return fromContent;
891
908
  }
892
909
  function toolInputFromCall(call) {
893
910
  const args = call.args;
@@ -1048,10 +1065,11 @@ function renderTranscriptLaneLines(entries) {
1048
1065
  }
1049
1066
  };
1050
1067
  for (const entry of entries) {
1068
+ const entryKey = entry.id ?? "entry";
1051
1069
  if (entry.messageKind === "assistant") {
1052
1070
  const toolCalls = toolCallsFromAssistant(entry.message);
1053
1071
  if (toolCalls.length > 0) {
1054
- for (const call of toolCalls) {
1072
+ toolCalls.forEach((call, callIndex) => {
1055
1073
  const callName = String(call.name ?? entry.toolName ?? "Tool").trim();
1056
1074
  const text2 = formatAssistantToolLine(
1057
1075
  callName,
@@ -1059,15 +1077,23 @@ function renderTranscriptLaneLines(entries) {
1059
1077
  toolInputFromCall(call)
1060
1078
  );
1061
1079
  if (text2.length > 0) {
1062
- pendingCalls.push({ kind: "call", text: text2 });
1080
+ pendingCalls.push({
1081
+ kind: "call",
1082
+ text: text2,
1083
+ lineKey: `${entryKey}:a:${callIndex}`
1084
+ });
1063
1085
  }
1064
- }
1086
+ });
1065
1087
  continue;
1066
1088
  }
1067
1089
  flushPendingCalls();
1068
1090
  const text = String(entry.message.content ?? "").trim();
1069
1091
  if (text) {
1070
- lines.push({ kind: "call", text: truncatePreview2(text, 240) });
1092
+ lines.push({
1093
+ kind: "call",
1094
+ text: truncatePreview2(text, 240),
1095
+ lineKey: `${entryKey}:a:0`
1096
+ });
1071
1097
  }
1072
1098
  continue;
1073
1099
  }
@@ -1078,7 +1104,7 @@ function renderTranscriptLaneLines(entries) {
1078
1104
  if (paired && paired.text.length > 0) {
1079
1105
  lines.push(paired);
1080
1106
  }
1081
- lines.push(result);
1107
+ lines.push({ ...result, lineKey: `${entryKey}:u:0` });
1082
1108
  }
1083
1109
  }
1084
1110
  flushPendingCalls();
@@ -1642,25 +1668,128 @@ function ReadToolBody({
1642
1668
  ] });
1643
1669
  }
1644
1670
 
1671
+ // src/view/tools/skill/skillForkUI.ts
1672
+ var SKILL_PROGRESS_TAIL_LINES = 3;
1673
+ var SKILL_FORK_INITIALIZING = "Initializing\u2026";
1674
+ function isSkillForkExecution(input, display) {
1675
+ const inp = asInputRecord(input);
1676
+ const d = asDisplayRecord(display);
1677
+ const ctx = strField(inp, "context") || strField(d, "execution_context") || strField(inp, "execution_context");
1678
+ return typeof ctx === "string" && ctx.trim().toLowerCase() === "fork";
1679
+ }
1680
+ function isSkillForkRunningUi(input, display, skillProgressCount) {
1681
+ if (isSkillForkExecution(input, display)) return true;
1682
+ return skillProgressCount > 0;
1683
+ }
1684
+ function isSkillForkDoneResult(input, display) {
1685
+ if (!isSkillForkExecution(input, display)) return false;
1686
+ const d = asDisplayRecord(display);
1687
+ if (d?.status === "forked") return true;
1688
+ if (d?.execution_context === "fork" && d?.fork_result != null) return true;
1689
+ return false;
1690
+ }
1691
+
1692
+ // src/view/tools/skill/SkillProgressLines.tsx
1693
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
1694
+ function toTranscriptEntry(entry) {
1695
+ return {
1696
+ id: entry.id,
1697
+ agentId: entry.agentId,
1698
+ messageKind: entry.messageKind,
1699
+ message: entry.message,
1700
+ step: entry.step,
1701
+ toolName: entry.toolName
1702
+ };
1703
+ }
1704
+ function SkillProgressLines({
1705
+ entries,
1706
+ mode,
1707
+ maxVisible = SKILL_PROGRESS_TAIL_LINES,
1708
+ onExpand
1709
+ }) {
1710
+ if (entries.length === 0) {
1711
+ return /* @__PURE__ */ jsx11("div", { className: "lax-skill-progress", "data-testid": "lax-skill-progress-initializing", children: /* @__PURE__ */ jsxs8("div", { className: "lax-agent-progress__line", children: [
1712
+ /* @__PURE__ */ jsx11("span", { className: "lax-agent-progress__gutter", "aria-hidden": true, children: AGENT_PROGRESS_GUTTER }),
1713
+ /* @__PURE__ */ jsx11("span", { className: "lax-agent-progress__text lax-skill-progress__initializing", children: SKILL_FORK_INITIALIZING })
1714
+ ] }) });
1715
+ }
1716
+ const allLines = renderTranscriptLaneLines(entries.map(toTranscriptEntry));
1717
+ const limit = mode === "full" ? allLines.length : maxVisible;
1718
+ const visible = allLines.slice(-limit);
1719
+ const hiddenCount = allLines.length - visible.length;
1720
+ return /* @__PURE__ */ jsxs8("div", { className: "lax-skill-progress", "data-testid": "lax-skill-progress", children: [
1721
+ visible.map((line, index) => /* @__PURE__ */ jsxs8(
1722
+ "div",
1723
+ {
1724
+ className: "lax-agent-progress__line",
1725
+ children: [
1726
+ /* @__PURE__ */ jsx11("span", { className: "lax-agent-progress__gutter", "aria-hidden": true, children: AGENT_PROGRESS_GUTTER }),
1727
+ /* @__PURE__ */ jsx11("span", { className: "lax-agent-progress__text", children: line.text })
1728
+ ]
1729
+ },
1730
+ line.lineKey ?? `skill-progress-line:${index}`
1731
+ )),
1732
+ hiddenCount > 0 && mode !== "full" ? /* @__PURE__ */ jsxs8("div", { className: "lax-agent-progress__line lax-agent-progress__line--more", children: [
1733
+ /* @__PURE__ */ jsx11("span", { className: "lax-agent-progress__gutter", "aria-hidden": true, children: AGENT_PROGRESS_INDENT }),
1734
+ /* @__PURE__ */ jsxs8(
1735
+ "button",
1736
+ {
1737
+ type: "button",
1738
+ className: "lax-agent-progress__more",
1739
+ "aria-expanded": false,
1740
+ onClick: onExpand,
1741
+ children: [
1742
+ "+",
1743
+ hiddenCount,
1744
+ " more tool ",
1745
+ hiddenCount === 1 ? "use" : "uses"
1746
+ ]
1747
+ }
1748
+ )
1749
+ ] }) : null
1750
+ ] });
1751
+ }
1752
+
1645
1753
  // src/view/tools/skill/SkillToolBody.tsx
1646
- import { jsx as jsx11 } from "react/jsx-runtime";
1754
+ import { jsx as jsx12 } from "react/jsx-runtime";
1647
1755
  var MAX_BODY_LINES = 20;
1648
1756
  function SkillToolBody({
1757
+ input,
1649
1758
  result,
1650
1759
  bodyMode,
1651
- onBodyModeChange
1760
+ onBodyModeChange,
1761
+ status,
1762
+ skillProgressMessages
1652
1763
  }) {
1653
1764
  if (result?.error) {
1654
- return /* @__PURE__ */ jsx11("div", { className: "lax-tool-body lax-tool-body--skill", children: /* @__PURE__ */ jsx11("div", { className: "lax-tool-body__block", "data-variant": "error", children: /* @__PURE__ */ jsx11("pre", { className: "lax-tool-body__text", children: result.error.message }) }) });
1765
+ return /* @__PURE__ */ jsx12("div", { className: "lax-tool-body lax-tool-body--skill", children: /* @__PURE__ */ jsx12("div", { className: "lax-tool-body__block", "data-variant": "error", children: /* @__PURE__ */ jsx12("pre", { className: "lax-tool-body__text", children: result.error.message }) }) });
1766
+ }
1767
+ const display = result?.display;
1768
+ const progressCount = skillProgressMessages?.length ?? 0;
1769
+ const forkExec = isSkillForkExecution(input, display);
1770
+ const forkRunning = status === "running" && isSkillForkRunningUi(input, display, progressCount);
1771
+ const forkDone = isSkillForkDoneResult(input, display);
1772
+ if (forkDone || forkExec && status === "done") {
1773
+ return /* @__PURE__ */ jsx12("div", { className: "lax-tool-body lax-tool-body--skill", "data-testid": "lax-skill-fork-done", children: /* @__PURE__ */ jsx12("div", { className: "lax-tool-body__block", "data-variant": "dim", children: /* @__PURE__ */ jsx12("pre", { className: "lax-tool-body__text", children: "Done" }) }) });
1774
+ }
1775
+ if (forkRunning) {
1776
+ return /* @__PURE__ */ jsx12("div", { className: "lax-tool-body lax-tool-body--skill lax-tool-body--skill-fork-running", children: /* @__PURE__ */ jsx12(
1777
+ SkillProgressLines,
1778
+ {
1779
+ entries: skillProgressMessages ?? [],
1780
+ mode: bodyMode,
1781
+ onExpand: () => onBodyModeChange?.("full")
1782
+ }
1783
+ ) });
1655
1784
  }
1656
1785
  const text = result?.summary?.trim() ?? "";
1657
1786
  if (!text) {
1658
- return /* @__PURE__ */ jsx11("div", { className: "lax-tool-body lax-tool-body--skill", children: /* @__PURE__ */ jsx11("div", { className: "lax-tool-body__block", "data-variant": "dim", children: /* @__PURE__ */ jsx11("pre", { className: "lax-tool-body__text", children: "(done)" }) }) });
1787
+ return /* @__PURE__ */ jsx12("div", { className: "lax-tool-body lax-tool-body--skill", children: /* @__PURE__ */ jsx12("div", { className: "lax-tool-body__block", "data-variant": "dim", children: /* @__PURE__ */ jsx12("pre", { className: "lax-tool-body__text", children: "(done)" }) }) });
1659
1788
  }
1660
1789
  const { text: truncated, truncated: was } = truncateLines(text, MAX_BODY_LINES);
1661
1790
  const bodyText = was ? `${truncated}
1662
1791
  \u2026 \u5DF2\u622A\u65AD` : truncated;
1663
- return /* @__PURE__ */ jsx11("div", { className: "lax-tool-body lax-tool-body--skill", children: /* @__PURE__ */ jsx11(
1792
+ return /* @__PURE__ */ jsx12("div", { className: "lax-tool-body lax-tool-body--skill", children: /* @__PURE__ */ jsx12(
1664
1793
  TruncatedContent,
1665
1794
  {
1666
1795
  text: bodyText,
@@ -1672,7 +1801,7 @@ function SkillToolBody({
1672
1801
  }
1673
1802
 
1674
1803
  // src/view/tools/webfetch/WebFetchToolBody.tsx
1675
- import { jsx as jsx12 } from "react/jsx-runtime";
1804
+ import { jsx as jsx13 } from "react/jsx-runtime";
1676
1805
  var RECEIVED_RE = /Received\s+.+/i;
1677
1806
  var MAX_BODY_LINES2 = 15;
1678
1807
  function buildWebFetchBody(result) {
@@ -1701,10 +1830,10 @@ function WebFetchToolBody({
1701
1830
  onBodyModeChange
1702
1831
  }) {
1703
1832
  if (result?.error) {
1704
- return /* @__PURE__ */ jsx12("div", { className: "lax-tool-body lax-tool-body--webfetch", children: /* @__PURE__ */ jsx12("div", { className: "lax-tool-body__block", "data-variant": "error", children: /* @__PURE__ */ jsx12("pre", { className: "lax-tool-body__text", children: result.error.message }) }) });
1833
+ return /* @__PURE__ */ jsx13("div", { className: "lax-tool-body lax-tool-body--webfetch", children: /* @__PURE__ */ jsx13("div", { className: "lax-tool-body__block", "data-variant": "error", children: /* @__PURE__ */ jsx13("pre", { className: "lax-tool-body__text", children: result.error.message }) }) });
1705
1834
  }
1706
1835
  const bodyText = buildWebFetchBody(result);
1707
- return /* @__PURE__ */ jsx12("div", { className: "lax-tool-body lax-tool-body--webfetch", children: /* @__PURE__ */ jsx12(
1836
+ return /* @__PURE__ */ jsx13("div", { className: "lax-tool-body lax-tool-body--webfetch", children: /* @__PURE__ */ jsx13(
1708
1837
  TruncatedContent,
1709
1838
  {
1710
1839
  text: bodyText,
@@ -1716,7 +1845,7 @@ function WebFetchToolBody({
1716
1845
  }
1717
1846
 
1718
1847
  // src/view/tools/websearch/WebSearchToolBody.tsx
1719
- import { jsx as jsx13 } from "react/jsx-runtime";
1848
+ import { jsx as jsx14 } from "react/jsx-runtime";
1720
1849
  var MAX_BODY_LINES3 = 15;
1721
1850
  function buildWebSearchBody(result) {
1722
1851
  const d = asDisplayRecord(result?.display);
@@ -1741,10 +1870,10 @@ function WebSearchToolBody({
1741
1870
  onBodyModeChange
1742
1871
  }) {
1743
1872
  if (result?.error) {
1744
- return /* @__PURE__ */ jsx13("div", { className: "lax-tool-body lax-tool-body--websearch", children: /* @__PURE__ */ jsx13("div", { className: "lax-tool-body__block", "data-variant": "error", children: /* @__PURE__ */ jsx13("pre", { className: "lax-tool-body__text", children: result.error.message }) }) });
1873
+ return /* @__PURE__ */ jsx14("div", { className: "lax-tool-body lax-tool-body--websearch", children: /* @__PURE__ */ jsx14("div", { className: "lax-tool-body__block", "data-variant": "error", children: /* @__PURE__ */ jsx14("pre", { className: "lax-tool-body__text", children: result.error.message }) }) });
1745
1874
  }
1746
1875
  const bodyText = buildWebSearchBody(result);
1747
- return /* @__PURE__ */ jsx13("div", { className: "lax-tool-body lax-tool-body--websearch", children: /* @__PURE__ */ jsx13(
1876
+ return /* @__PURE__ */ jsx14("div", { className: "lax-tool-body lax-tool-body--websearch", children: /* @__PURE__ */ jsx14(
1748
1877
  TruncatedContent,
1749
1878
  {
1750
1879
  text: bodyText,
@@ -1756,7 +1885,7 @@ function WebSearchToolBody({
1756
1885
  }
1757
1886
 
1758
1887
  // src/view/tools/write/WriteToolBody.tsx
1759
- import { jsx as jsx14 } from "react/jsx-runtime";
1888
+ import { jsx as jsx15 } from "react/jsx-runtime";
1760
1889
  function buildWriteBodyText(input, display, summary) {
1761
1890
  const d = asDisplayRecord(display);
1762
1891
  const inp = asInputRecord(input);
@@ -1798,7 +1927,7 @@ function WriteToolBody({
1798
1927
  onBodyModeChange
1799
1928
  }) {
1800
1929
  if (result?.error) {
1801
- return /* @__PURE__ */ jsx14("div", { className: "lax-tool-body lax-tool-body--write", children: /* @__PURE__ */ jsx14("div", { className: "lax-tool-body__block", "data-variant": "error", children: /* @__PURE__ */ jsx14("pre", { className: "lax-tool-body__text", children: result.error.message }) }) });
1930
+ return /* @__PURE__ */ jsx15("div", { className: "lax-tool-body lax-tool-body--write", children: /* @__PURE__ */ jsx15("div", { className: "lax-tool-body__block", "data-variant": "error", children: /* @__PURE__ */ jsx15("pre", { className: "lax-tool-body__text", children: result.error.message }) }) });
1802
1931
  }
1803
1932
  const body = buildWriteBodyText(
1804
1933
  input,
@@ -1806,7 +1935,7 @@ function WriteToolBody({
1806
1935
  result?.summary ?? ""
1807
1936
  );
1808
1937
  if (body.kind === "diff") {
1809
- return /* @__PURE__ */ jsx14("div", { className: "lax-tool-body lax-tool-body--write", children: /* @__PURE__ */ jsx14(
1938
+ return /* @__PURE__ */ jsx15("div", { className: "lax-tool-body lax-tool-body--write", children: /* @__PURE__ */ jsx15(
1810
1939
  DiffView,
1811
1940
  {
1812
1941
  diff: body.text,
@@ -1815,7 +1944,7 @@ function WriteToolBody({
1815
1944
  }
1816
1945
  ) });
1817
1946
  }
1818
- return /* @__PURE__ */ jsx14("div", { className: "lax-tool-body lax-tool-body--write", children: /* @__PURE__ */ jsx14(
1947
+ return /* @__PURE__ */ jsx15("div", { className: "lax-tool-body lax-tool-body--write", children: /* @__PURE__ */ jsx15(
1819
1948
  TruncatedContent,
1820
1949
  {
1821
1950
  text: body.text,
@@ -1893,6 +2022,7 @@ export {
1893
2022
  GlobToolBody,
1894
2023
  GrepToolBody,
1895
2024
  ReadToolBody,
2025
+ isSkillForkRunningUi,
1896
2026
  SkillToolBody,
1897
2027
  WebFetchToolBody,
1898
2028
  WebSearchToolBody,
@@ -1900,4 +2030,4 @@ export {
1900
2030
  ToolDisplayRegistry,
1901
2031
  createDefaultToolRegistry
1902
2032
  };
1903
- //# sourceMappingURL=chunk-Z5EWWIP3.js.map
2033
+ //# sourceMappingURL=chunk-DQVSFHKW.js.map