@zero-library/chat-copilot 3.1.8 → 3.1.10

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.cjs.js CHANGED
@@ -72,7 +72,7 @@ var styles_module_default = {
72
72
  chatAttachments: "styles_module_chatAttachments",
73
73
  chatSender: "styles_module_chatSender"};
74
74
  var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
75
- const { message: message2 } = antd.App.useApp();
75
+ const { message: message3 } = antd.App.useApp();
76
76
  const chatStore = useChatStore();
77
77
  valtio.useSnapshot(chatStore.agent);
78
78
  const fileListRef = React10.useRef([]);
@@ -100,7 +100,7 @@ var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fi
100
100
  onChange(files);
101
101
  }, [attachedFiles]);
102
102
  const onErrorTip = common.useDebounce((errorMsg) => {
103
- message2.error(errorMsg);
103
+ message3.error(errorMsg);
104
104
  }, 300);
105
105
  const findConfig = (file) => {
106
106
  return fileUploadConfig?.allowedTypes?.find((type) => type === common.getFileSuffixName(file.name)) || "";
@@ -294,6 +294,41 @@ var classifyTime = (timestamp) => {
294
294
  return "\u66F4\u65E9";
295
295
  }
296
296
  };
297
+ var variablesToObject = (variables) => {
298
+ if (!common.isArray(variables)) return {};
299
+ const jsonTypes = ["OBJECT", "ARRAY", "ARRAY_STRING", "ARRAY_NUMBER", "ARRAY_DECIMAL", "ARRAY_BOOLEAN", "ARRAY_OBJECT"];
300
+ return variables.reduce(
301
+ (acc, cur) => {
302
+ if (cur.type === "BOOLEAN") {
303
+ if (common.isDef(cur.value) && !common.isNull(cur.value)) {
304
+ acc[cur.name] = cur.value;
305
+ }
306
+ } else if (jsonTypes.includes(cur.type)) {
307
+ if (common.isDef(cur.value) && !common.isNull(cur.value)) {
308
+ if (typeof cur.value === "string") {
309
+ if (cur.value === "") {
310
+ acc[cur.name] = cur.type === "OBJECT" ? {} : [];
311
+ } else {
312
+ try {
313
+ acc[cur.name] = JSON.parse(cur.value);
314
+ } catch (e) {
315
+ acc[cur.name] = cur.type === "OBJECT" ? {} : [];
316
+ }
317
+ }
318
+ } else {
319
+ acc[cur.name] = cur.value;
320
+ }
321
+ }
322
+ } else {
323
+ if (common.isDef(cur.value) && !common.isNull(cur.value) && cur.value !== "") {
324
+ acc[cur.name] = cur.value;
325
+ }
326
+ }
327
+ return acc;
328
+ },
329
+ {}
330
+ );
331
+ };
297
332
  var getChatSocketUrl = (baseURL, params) => {
298
333
  return common.buildUrlParams(params, common.getWebSocketUrl(`${baseURL}/ws`), "comma");
299
334
  };
@@ -331,6 +366,15 @@ var getFileUrl = (params, baseUrl, url) => {
331
366
  };
332
367
  return common.buildUrlParams(data, url || `${baseUrl}/files/access`);
333
368
  };
369
+ var formatFileSize = (size = 0) => {
370
+ if (size < 1024) return `${size} B`;
371
+ const kb = size / 1024;
372
+ if (kb < 1024) return `${kb.toFixed(2)} KB`;
373
+ const mb = kb / 1024;
374
+ if (mb < 1024) return `${mb.toFixed(2)} MB`;
375
+ const gb = mb / 1024;
376
+ return `${gb.toFixed(2)} GB`;
377
+ };
334
378
  function GroupPicker({
335
379
  groups,
336
380
  selectedIndex,
@@ -401,6 +445,13 @@ function formatResourceName(resourceName) {
401
445
  if (name.length <= 6) return `${name}${extension}`;
402
446
  return `${name.slice(0, 3)}***${name.slice(-3)}${extension}`;
403
447
  }
448
+ function ReadonlyResourceTag({ resource }) {
449
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.resourceTag, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Tag, { color: "blue", children: [
450
+ resource.resourceLabel,
451
+ "\uFF1A",
452
+ formatResourceName(resource.resourceName)
453
+ ] }) });
454
+ }
404
455
  function ResourceTag({ resource }) {
405
456
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
406
457
  const handleClose = (event) => {
@@ -488,7 +539,7 @@ var VariableNode = class _VariableNode extends lexical.DecoratorNode {
488
539
  * 生成节点的纯文本表达,便于发送、存储和重新初始化编辑器内容。
489
540
  */
490
541
  getTextContent() {
491
- return `${this.__resourceType}://${this.__resourceId}?name=${this.__resourceName}&label=${this.__resourceLabel}`;
542
+ return ` ${this.__resourceType}://${this.__resourceId}?name=${this.__resourceName}&label=${this.__resourceLabel} `;
492
543
  }
493
544
  /**
494
545
  * 将变量节点渲染为可交互的资源标签组件。
@@ -556,6 +607,7 @@ function VariablePickerPlugin({ commandConfig = {} }) {
556
607
  React10.useEffect(() => {
557
608
  setCommandDataSource(commandConfig);
558
609
  }, [commandConfig]);
610
+ const commandKeys = React10.useMemo(() => Object.keys(commandConfig), [commandConfig]);
559
611
  const commandKey = queryString?.[0] || "";
560
612
  const searchKeyword = queryString?.slice(commandKey.length).trim().toLocaleLowerCase() || "";
561
613
  const categoryConfig = React10.useMemo(
@@ -668,15 +720,15 @@ function VariablePickerPlugin({ commandConfig = {} }) {
668
720
  onQueryChange: (query) => setQueryString(query),
669
721
  onSelectOption,
670
722
  triggerFn: (text) => {
671
- const match = new RegExp(
672
- `(?:${Object.keys(commandConfig).map((key) => key.replace(/[.*+?^${}()|[\\]\\]/g, "\\$&")).join("|")})([^\\s]*)$`
673
- ).exec(text);
723
+ if (!commandKeys.length) return null;
724
+ const match = new RegExp(`(?:${commandKeys.map((key) => key.replace(/[.*+?^${}()|[\\]\\]/g, "\\$&")).join("|")})([^\\s]*)$`).exec(text);
674
725
  if (!match) return null;
675
726
  return { leadOffset: match.index, matchingString: match[0], replaceableString: match[0] };
676
727
  },
677
728
  options: commandOptions,
678
729
  menuRenderFn: (anchorElementRef, { selectedIndex, setHighlightedIndex, selectOptionAndCleanUp }) => {
679
- if (!isEditorFocused || !anchorElementRef.current || searchKeyword && !commandGroups.length) return null;
730
+ if (!isEditorFocused || !anchorElementRef.current || !commandKeys.length || !commandGroups.length && !searchKeyword) return null;
731
+ if (searchKeyword && !commandGroups.length) return null;
680
732
  return ReactDOM__namespace.createPortal(
681
733
  /* @__PURE__ */ jsxRuntime.jsx(ResourcePickerMenu, { anchorElementRef, children: /* @__PURE__ */ jsxRuntime.jsx(
682
734
  GroupPicker,
@@ -1006,7 +1058,8 @@ var defaultLayout = {
1006
1058
  messageList: true,
1007
1059
  senderHeader: false,
1008
1060
  senderFooter: false,
1009
- disclaimerNotice: true
1061
+ disclaimerNotice: true,
1062
+ userInput: false
1010
1063
  };
1011
1064
  function createChatStore() {
1012
1065
  const config = valtio.proxy({
@@ -1119,6 +1172,17 @@ function createChatStore() {
1119
1172
  agent.model = { ...agent.model, ...model };
1120
1173
  config.hooks?.onAfterSwitchModel?.(model);
1121
1174
  };
1175
+ const getUserInput = async (agentId) => {
1176
+ agent.loading = true;
1177
+ try {
1178
+ const { data } = await config.services.request.getAgentUserInput(agentId);
1179
+ if (data?.inputs && !agent.agentInfo.userInput?.length) {
1180
+ agent.agentInfo.userInput = data.inputs.filter((item) => item.enableEdit);
1181
+ }
1182
+ } finally {
1183
+ agent.loading = false;
1184
+ }
1185
+ };
1122
1186
  const setAgent = (agentInfo) => {
1123
1187
  agent.agentInfo = agentInfo;
1124
1188
  if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
@@ -1126,6 +1190,13 @@ function createChatStore() {
1126
1190
  modelName: agent.agentInfo.spec?.model?.modelName || "",
1127
1191
  providerName: agent.agentInfo.spec?.model?.providerName || ""
1128
1192
  });
1193
+ } else if (config.layout.userInput) {
1194
+ getUserInput(agent.agentInfo.id);
1195
+ }
1196
+ };
1197
+ const setUserInput = (userInput) => {
1198
+ if (agent.agentInfo.agentType === 1 /* FLOW */) {
1199
+ agent.agentInfo.userInput = userInput;
1129
1200
  }
1130
1201
  };
1131
1202
  const getAgentInfo = async (id) => {
@@ -1252,7 +1323,8 @@ function createChatStore() {
1252
1323
  /** 当前激活的会话信息 */
1253
1324
  active: {
1254
1325
  id: "",
1255
- spec: {}
1326
+ spec: {},
1327
+ userInput: []
1256
1328
  },
1257
1329
  /** 每个会话的消息存储,以会话ID为键 */
1258
1330
  messages: {},
@@ -1284,9 +1356,12 @@ function createChatStore() {
1284
1356
  };
1285
1357
  const setConversationSpec = (spec) => {
1286
1358
  if (common.isObject(spec)) {
1287
- Object.assign(conversation.active.spec, spec);
1359
+ Object.assign(conversation.active.spec || {}, spec);
1288
1360
  }
1289
1361
  };
1362
+ const setConversationUserInput = (userInput) => {
1363
+ conversation.active.userInput = userInput;
1364
+ };
1290
1365
  const feedback = async (executionId, feedback2, index) => {
1291
1366
  try {
1292
1367
  conversation.feedback.loading = true;
@@ -1503,11 +1578,22 @@ function createChatStore() {
1503
1578
  conversation.messages[msg.conversationId].loading = false;
1504
1579
  const messages = conversation.messages[msg.conversationId]?.message;
1505
1580
  if (messages) {
1581
+ const idx = findExecutionMsgIndex(msg, messages);
1582
+ const contentItem = msg.content[0];
1506
1583
  messages.forEach((item) => {
1507
1584
  if (item.executionId === msg.executionId) {
1508
1585
  item.generating = false;
1509
1586
  }
1510
1587
  });
1588
+ if (contentItem?.type === "runFailed") {
1589
+ if (idx !== -1) {
1590
+ const prevContent = messages[idx]?.content || [];
1591
+ messages[idx].content = [...prevContent, contentItem];
1592
+ } else {
1593
+ const finalMsg = { ...msg, generating: false };
1594
+ messages.push(finalMsg);
1595
+ }
1596
+ }
1511
1597
  }
1512
1598
  config.hooks?.onAfterAcceptMessage?.(msg);
1513
1599
  }
@@ -1671,9 +1757,9 @@ function createChatStore() {
1671
1757
  }
1672
1758
  }
1673
1759
  }
1674
- function processMessageContent(message2) {
1760
+ function processMessageContent(message3) {
1675
1761
  const newMessage = {
1676
- ...message2,
1762
+ ...message3,
1677
1763
  agentId: agent.agentInfo.id
1678
1764
  };
1679
1765
  const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
@@ -1721,14 +1807,14 @@ function createChatStore() {
1721
1807
  }
1722
1808
  processMessageContent(newMessage);
1723
1809
  };
1724
- const sendMessage = async (message2, msgFiles = [], params) => {
1810
+ const sendMessage = async (message3, msgFiles = [], params) => {
1725
1811
  const conversationId = conversation.active.id;
1726
1812
  if (conversation.messages[conversationId].loading) return;
1727
1813
  let msgContent = "", files;
1728
1814
  const references = conversation.messages[conversationId].references;
1729
- if (message2) {
1730
- msgContent = message2;
1731
- files = msgFiles;
1815
+ if (message3) {
1816
+ msgContent = message3;
1817
+ files = [...msgFiles, ...conversation.messages[conversationId].files || []];
1732
1818
  } else {
1733
1819
  if (references?.type === 1 && references?.content?.msgContent) {
1734
1820
  msgContent = references.content.msgContent + "\n\n";
@@ -1739,6 +1825,22 @@ function createChatStore() {
1739
1825
  if (!msgContent) return;
1740
1826
  const canProceed = await config.hooks?.onBeforeSend?.(msgContent, files || []);
1741
1827
  if (canProceed === false) return;
1828
+ if (conversation.active.userInput?.length) {
1829
+ const invalid = conversation.active.userInput.some((item) => {
1830
+ const isRequired = item.rules?.some((r) => r.type === "required");
1831
+ if (isRequired) {
1832
+ if (item.type === "BOOLEAN") {
1833
+ return common.isNullOrUnDef(item.value);
1834
+ }
1835
+ return common.isNullOrUnDef(item.value) || item.value === "";
1836
+ }
1837
+ return false;
1838
+ });
1839
+ if (invalid) {
1840
+ antd.message.error("\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570");
1841
+ return;
1842
+ }
1843
+ }
1742
1844
  conversation.messages[conversationId].loading = true;
1743
1845
  const idx = conversations.list.items.findIndex((item) => item.id === conversationId);
1744
1846
  if (idx !== -1 && !conversations.list.items[idx].label) {
@@ -1757,15 +1859,16 @@ function createChatStore() {
1757
1859
  responseMode: 2
1758
1860
  };
1759
1861
  const extraParams = common.deepCopy(config.params?.params || {});
1760
- Object.assign(extraParams, message2 ? {} : { ...references?.params }, params);
1862
+ const userInputParams = variablesToObject(conversation.active.userInput || []);
1863
+ Object.assign(extraParams, message3 ? {} : { ...references?.params }, params, userInputParams);
1761
1864
  sendParams.params = extraParams;
1762
- if (!message2) {
1865
+ if (!message3) {
1763
1866
  setContent("");
1764
1867
  setContentParams();
1765
- setFileList([]);
1766
1868
  setReferences();
1767
- setHeaderOpen(false);
1768
1869
  }
1870
+ setFileList([]);
1871
+ setHeaderOpen(false);
1769
1872
  try {
1770
1873
  const dealedParams = await config.hooks?.onHandleSendParams?.(sendParams);
1771
1874
  await config.services.request.sendMessageStream(dealedParams || sendParams, agent.agentInfo?.id || "");
@@ -1823,7 +1926,7 @@ function createChatStore() {
1823
1926
  /** 设置智能体 */
1824
1927
  setAgent,
1825
1928
  /** 设置智能体用户输入 */
1826
- // setUserInput,
1929
+ setUserInput,
1827
1930
  /** 设置会话配置 */
1828
1931
  setConversationSpec,
1829
1932
  /** 历史会话状态 */
@@ -1857,9 +1960,11 @@ function createChatStore() {
1857
1960
  /** 接收消息 */
1858
1961
  acceptMessage,
1859
1962
  /** 获取智能体用户输入 */
1860
- // getUserInput,
1963
+ getUserInput,
1861
1964
  /** 消息反馈 */
1862
- feedback
1965
+ feedback,
1966
+ /** 设置会话用户输入 */
1967
+ setConversationUserInput
1863
1968
  };
1864
1969
  }
1865
1970
  var AuthImage = ({ path, size, shape = "square" }) => {
@@ -1953,6 +2058,7 @@ var styles_module_default2 = {
1953
2058
  chatWelcome: "styles_module_chatWelcome",
1954
2059
  promptItem: "styles_module_promptItem",
1955
2060
  bubbleList: "styles_module_bubbleList",
2061
+ userInputCollapse: "styles_module_userInputCollapse",
1956
2062
  logoArea: "styles_module_logoArea",
1957
2063
  logoContainer: "styles_module_logoContainer",
1958
2064
  staticHalo: "styles_module_staticHalo",
@@ -2525,6 +2631,7 @@ var AgentNavigate_default = React10.memo(({ data }) => {
2525
2631
  }, [data]);
2526
2632
  const handleClick = () => {
2527
2633
  if (!content?.emit) return;
2634
+ common.emit(content.emit, { ...content.data, name: "luya-web-drawer" }, "nearest");
2528
2635
  };
2529
2636
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: handleClick, style: { padding: 0 }, type: "link", children: content?.name || "\u70B9\u51FB\u6B64\u5904" });
2530
2637
  });
@@ -2686,12 +2793,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
2686
2793
  }, [paramsStr]);
2687
2794
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Drawer, { title, push: false, size: "100%", open, onClose, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, children: content ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown__default.default, { content }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Empty, { className: "m-t-32" }) }) });
2688
2795
  };
2689
- var IndexQuote_default = ({ data, loading, message: message2 }) => {
2796
+ var IndexQuote_default = ({ data, loading, message: message3 }) => {
2690
2797
  const [open, setOpen] = React10.useState(false);
2691
2798
  const citation = React10.useMemo(() => {
2692
- const citations = message2.content?.find((item) => item.type === "citation")?.citations ?? [];
2799
+ const citations = message3.content?.find((item) => item.type === "citation")?.citations ?? [];
2693
2800
  return citations?.find((item) => String(item.citationId) === String(data.citationId));
2694
- }, [data.citationId, message2.content]);
2801
+ }, [data.citationId, message3.content]);
2695
2802
  const onClick = () => {
2696
2803
  if (!citation?.citationUrl) return;
2697
2804
  if (common.isExternal(citation.citationUrl)) {
@@ -2706,7 +2813,7 @@ var IndexQuote_default = ({ data, loading, message: message2 }) => {
2706
2813
  open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
2707
2814
  ] });
2708
2815
  };
2709
- var MarkImg_default = ({ data, loading, message: message2, ...rest }) => {
2816
+ var MarkImg_default = ({ data, loading, message: message3, ...rest }) => {
2710
2817
  const getPreviewFileUrl = (src) => {
2711
2818
  return common.buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, src);
2712
2819
  };
@@ -2733,11 +2840,9 @@ var MdEdit_default = ({ data, loading }) => {
2733
2840
  !loading && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
2734
2841
  ] });
2735
2842
  };
2736
- var PreviewLink_default = ({ data, loading, message: message2, ...rest }) => {
2843
+ var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
2737
2844
  const chatStore = useChatStore();
2738
- const getLinkFileName = (href) => {
2739
- const url = new URL(href, window.location.origin);
2740
- const path = url.searchParams.get("path") || url.pathname;
2845
+ const getLinkFileName = (path) => {
2741
2846
  const lastSegment = path.split("/").pop();
2742
2847
  if (!lastSegment) {
2743
2848
  return "link";
@@ -2748,25 +2853,13 @@ var PreviewLink_default = ({ data, loading, message: message2, ...rest }) => {
2748
2853
  return lastSegment;
2749
2854
  }
2750
2855
  };
2751
- const getPreviewFileUrl = (href) => {
2752
- return common.buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, href);
2753
- };
2754
- const handlePreviewLink = (href) => {
2755
- const fileName = getLinkFileName(href);
2756
- const suffix = common.getFileSuffixName(fileName);
2757
- chatStore.setPreview({
2758
- fileUrl: getPreviewFileUrl(href),
2759
- fileName,
2760
- suffix
2761
- });
2762
- };
2763
- const handlePathToUrl = (href) => {
2764
- const fileName = getLinkFileName(href);
2856
+ const handlePreviewByPath = (path) => {
2857
+ const fileName = getLinkFileName(path);
2765
2858
  const suffix = common.getFileSuffixName(fileName);
2766
2859
  chatStore.setPreview({
2767
2860
  fileUrl: chatStore.config.services.request.getPreviewUrl({
2768
- path: href,
2769
- workspaceId: message2.conversationId
2861
+ path,
2862
+ workspaceId: message3.conversationId
2770
2863
  }),
2771
2864
  fileName,
2772
2865
  suffix
@@ -2779,12 +2872,18 @@ var PreviewLink_default = ({ data, loading, message: message2, ...rest }) => {
2779
2872
  return;
2780
2873
  }
2781
2874
  e.preventDefault();
2782
- if (String(rest.href).startsWith("/luya")) {
2783
- handlePreviewLink(href);
2875
+ if (String(rest.href).startsWith("/luya") || String(rest.href).startsWith("/agents")) {
2876
+ const url = new URL(href, window.location.origin);
2877
+ const path = url.searchParams.get("path");
2878
+ if (!path) {
2879
+ window.open(href, "_blank");
2880
+ return;
2881
+ }
2882
+ handlePreviewByPath(path);
2784
2883
  return;
2785
2884
  }
2786
2885
  if (String(rest.href).startsWith("/workspace")) {
2787
- handlePathToUrl(href);
2886
+ handlePreviewByPath(href);
2788
2887
  return;
2789
2888
  }
2790
2889
  window.open(href, "_blank");
@@ -2873,7 +2972,7 @@ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
2873
2972
  return WrappedComponent;
2874
2973
  };
2875
2974
  var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
2876
- var XMarkdown_default = React10.memo(({ message: message2, components = {}, content = "", ...rest }) => {
2975
+ var XMarkdown_default = React10.memo(({ message: message3, components = {}, content = "", ...rest }) => {
2877
2976
  const config = React10.useMemo(() => getMarkdownConfig(), []);
2878
2977
  const formattedContent = React10.useMemo(() => formatMixedContent(content), [content]);
2879
2978
  const newComponents = React10.useMemo(
@@ -2899,9 +2998,9 @@ var XMarkdown_default = React10.memo(({ message: message2, components = {}, cont
2899
2998
  [formattedContent, payloadTagPattern]
2900
2999
  );
2901
3000
  const payloadMapRef = React10.useRef(payloadMap);
2902
- const messageRef = React10.useRef(message2);
3001
+ const messageRef = React10.useRef(message3);
2903
3002
  payloadMapRef.current = payloadMap;
2904
- messageRef.current = message2;
3003
+ messageRef.current = message3;
2905
3004
  const markdownComponents = React10.useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
2906
3005
  return /* @__PURE__ */ jsxRuntime.jsx(
2907
3006
  XMarkdown__default.default,
@@ -3293,11 +3392,8 @@ var A2uiComponents = {
3293
3392
 
3294
3393
  // src/components/CustomComponents/A2uiRuntime/controller/extract.ts
3295
3394
  var A2UI_TAG_REGEX = /<A2UI\s+id="([^"]*)"\s*>([\s\S]*?)<\/A2UI>/g;
3296
- function hasA2uiTag(text) {
3297
- return typeof text === "string" && text.includes("<A2UI");
3298
- }
3299
3395
  function parseA2uiTagsFromText(text) {
3300
- if (!hasA2uiTag(text)) return [];
3396
+ if (typeof text !== "string" || !text.includes("<A2UI")) return [];
3301
3397
  const tags = [];
3302
3398
  const regex = new RegExp(A2UI_TAG_REGEX);
3303
3399
  let match;
@@ -3315,88 +3411,42 @@ function parseA2uiTagsFromText(text) {
3315
3411
  return tags;
3316
3412
  }
3317
3413
  function stripA2uiTags(text) {
3318
- if (!hasA2uiTag(text)) return text;
3319
- let result = text.replace(A2UI_TAG_REGEX, "");
3320
- result = result.replace(/<A2UI\b[\s\S]*$/, "");
3321
- return result.trim();
3322
- }
3323
- function splitA2uiTextSegments(text) {
3324
- if (typeof text !== "string" || !text.includes("<A2UI")) {
3325
- return text ? [{ type: "text", content: text }] : [];
3326
- }
3327
- const segments = [];
3328
- const regex = new RegExp(A2UI_TAG_REGEX);
3329
- let lastIndex = 0;
3330
- let match;
3331
- while ((match = regex.exec(text)) !== null) {
3332
- if (match.index > lastIndex) {
3333
- const before = text.slice(lastIndex, match.index);
3334
- if (before) segments.push({ type: "text", content: before });
3335
- }
3336
- const json = match[2].trim();
3337
- if (json) {
3338
- try {
3339
- const parsed = JSON.parse(json);
3340
- const commands = Array.isArray(parsed) ? parsed : [parsed];
3341
- const surfaceIds = commands.map((cmd) => String(cmd?.createSurface?.surfaceId || "").trim()).filter(Boolean);
3342
- if (surfaceIds.length) {
3343
- segments.push({ type: "a2ui", surfaceIds });
3344
- }
3345
- } catch {
3346
- }
3347
- }
3348
- lastIndex = regex.lastIndex;
3349
- }
3350
- if (lastIndex < text.length) {
3351
- let remaining = text.slice(lastIndex);
3352
- remaining = remaining.replace(/<A2UI\b[\s\S]*$/, "");
3353
- if (remaining) segments.push({ type: "text", content: remaining });
3354
- }
3355
- return segments.length ? segments : [];
3414
+ if (typeof text !== "string" || !text.includes("<A2UI")) return text;
3415
+ return text.replace(A2UI_TAG_REGEX, "").trim();
3356
3416
  }
3357
- function extractInlineSurfaceIdsFromMessage(message2) {
3358
- const surfaceIds = /* @__PURE__ */ new Set();
3359
- const items = Array.isArray(message2?.content) ? message2.content : [];
3360
- for (const item of items) {
3361
- if (item?.type !== "text") continue;
3362
- const text = item.messageContent || item.text || "";
3363
- if (typeof text !== "string" || !text.includes("<A2UI")) continue;
3364
- const tags = parseA2uiTagsFromText(text);
3365
- for (const tag of tags) {
3366
- for (const cmd of tag.commands) {
3367
- const sid = String(cmd?.createSurface?.surfaceId || "").trim();
3368
- if (sid) surfaceIds.add(sid);
3369
- }
3370
- }
3417
+ function extractItemTextForA2ui(item) {
3418
+ if (!item || item.type !== "toolCall") return "";
3419
+ const result = item.result;
3420
+ if (typeof result === "string") return result;
3421
+ if (result && typeof result === "object" && typeof result.stdout === "string") {
3422
+ return result.stdout;
3371
3423
  }
3372
- return surfaceIds;
3424
+ return "";
3373
3425
  }
3374
3426
  function extractDismissedSurfaceIdsFromMessages(messages) {
3375
3427
  const lastCreateIndexBySurface = /* @__PURE__ */ new Map();
3376
3428
  const lastActionIndexBySurface = /* @__PURE__ */ new Map();
3377
3429
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
3378
- const message2 = messages[messageIndex];
3379
- const items = Array.isArray(message2?.content) ? message2.content : [];
3430
+ const message3 = messages[messageIndex];
3431
+ const items = Array.isArray(message3?.content) ? message3.content : [];
3380
3432
  for (const item of items) {
3381
- if (message2?.role !== 1) {
3433
+ if (message3?.role !== 1) {
3382
3434
  if (item?.type === "a2uiCommand" && item.command) {
3383
3435
  const surfaceId = String(item.command?.createSurface?.surfaceId || "").trim();
3384
3436
  if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
3385
3437
  }
3386
- if (item?.type === "text") {
3387
- const text = item.messageContent || item.text || "";
3388
- if (typeof text === "string" && text.includes("<A2UI")) {
3389
- const tags = parseA2uiTagsFromText(text);
3390
- for (const tag of tags) {
3391
- for (const cmd of tag.commands) {
3392
- const surfaceId = String(cmd?.createSurface?.surfaceId || "").trim();
3393
- if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
3394
- }
3438
+ const text = extractItemTextForA2ui(item);
3439
+ if (typeof text === "string" && text.includes("<A2UI")) {
3440
+ const tags = parseA2uiTagsFromText(text);
3441
+ for (const tag of tags) {
3442
+ for (const cmd of tag.commands) {
3443
+ const surfaceId = String(cmd?.createSurface?.surfaceId || "").trim();
3444
+ if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
3395
3445
  }
3396
3446
  }
3397
3447
  }
3398
3448
  }
3399
- if (message2?.role === 1 && item?.type === "text") {
3449
+ if (message3?.role === 1 && item?.type === "text") {
3400
3450
  const text = item.messageContent || item.text || "";
3401
3451
  if (typeof text !== "string" || !text.includes("a2ui_action.v1")) continue;
3402
3452
  try {
@@ -3918,28 +3968,6 @@ function sanitizeA2uiCommands(commands) {
3918
3968
  return rest;
3919
3969
  });
3920
3970
  }
3921
- function diffConversationMessages(messages, prevCursors) {
3922
- if (messages.length < prevCursors.length) {
3923
- return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
3924
- }
3925
- const nextCursors = [];
3926
- const pendingItems = [];
3927
- for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
3928
- const message2 = messages[messageIndex];
3929
- const messageId = String(message2?.messageId ?? messageIndex);
3930
- const items = Array.isArray(message2?.content) ? message2.content : [];
3931
- const prevCursor = prevCursors[messageIndex];
3932
- const startIndex = prevCursor ? prevCursor.contentLength : 0;
3933
- if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
3934
- return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
3935
- }
3936
- for (let itemIndex = startIndex; itemIndex < items.length; itemIndex += 1) {
3937
- pendingItems.push({ messageIndex, messageId, item: items[itemIndex] });
3938
- }
3939
- nextCursors.push({ messageId, contentLength: items.length });
3940
- }
3941
- return { shouldReplayAll: false, nextCursors, pendingItems };
3942
- }
3943
3971
  function initializeWizardSurface(state, surfaceId, effects, nextWizardSteps) {
3944
3972
  const wizard = state.wizardSchemaBySurface[surfaceId];
3945
3973
  const createCommandIndex = state.latestCreateCommandIndexBySurface[surfaceId];
@@ -3959,6 +3987,10 @@ function initializeWizardSurface(state, surfaceId, effects, nextWizardSteps) {
3959
3987
  function processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps) {
3960
3988
  nextState.serverCommands.push(cmd);
3961
3989
  nextState.lastA2uiHost = { id: messageId, index: messageIndex };
3990
+ const wizardSchema = normalizeWizardSchema(cmd);
3991
+ if (wizardSchema) {
3992
+ nextState.wizardSchemaBySurface[wizardSchema.surfaceId] = wizardSchema;
3993
+ }
3962
3994
  const surfaceId = extractSurfaceId2(cmd);
3963
3995
  if (!surfaceId) return;
3964
3996
  if (cmd?.createSurface) {
@@ -3969,6 +4001,11 @@ function processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, de
3969
4001
  if (cmd?.createSurface) {
3970
4002
  nextState.latestCreateCommandIndexBySurface[surfaceId] = nextState.serverCommands.length - 1;
3971
4003
  nextState.optimisticallyDismissedSurfaceIds = nextState.optimisticallyDismissedSurfaceIds.filter((id) => id !== surfaceId);
4004
+ const schemaSource = cmd.createSurface.schema ?? cmd.createSurface.wizard ?? cmd.createSurface.plan;
4005
+ const schema = normalizeWizardSchema(schemaSource) ?? normalizeWizardSchema(cmd.createSurface);
4006
+ if (schema) {
4007
+ nextState.wizardSchemaBySurface[surfaceId] = schema;
4008
+ }
3972
4009
  initializeWizardSurface(nextState, surfaceId, effects, nextWizardSteps);
3973
4010
  }
3974
4011
  if (cmd?.updateDataModel) {
@@ -3985,16 +4022,37 @@ function processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, de
3985
4022
  delete nextState.modelPathBySurface[surfaceId];
3986
4023
  }
3987
4024
  }
4025
+ function diffConversationMessages(messages, prevCursors) {
4026
+ if (messages.length < prevCursors.length) {
4027
+ return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
4028
+ }
4029
+ const nextCursors = [];
4030
+ const pendingItems = [];
4031
+ for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
4032
+ const message3 = messages[messageIndex];
4033
+ const messageId = String(message3?.messageId ?? messageIndex);
4034
+ const items = Array.isArray(message3?.content) ? message3.content : [];
4035
+ const prevCursor = prevCursors[messageIndex];
4036
+ const startIndex = prevCursor ? prevCursor.contentLength : 0;
4037
+ if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
4038
+ return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
4039
+ }
4040
+ for (let itemIndex = startIndex; itemIndex < items.length; itemIndex += 1) {
4041
+ pendingItems.push({ messageIndex, messageId, item: items[itemIndex] });
4042
+ }
4043
+ nextCursors.push({ messageId, contentLength: items.length });
4044
+ }
4045
+ return { shouldReplayAll: false, nextCursors, pendingItems };
4046
+ }
3988
4047
  function scanA2uiTagsFromMessages(messages, processedTagIds) {
3989
4048
  const newTags = [];
3990
4049
  const newTagIds = [];
3991
4050
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
3992
- const message2 = messages[messageIndex];
3993
- const messageId = String(message2?.messageId ?? messageIndex);
3994
- const items = Array.isArray(message2?.content) ? message2.content : [];
4051
+ const message3 = messages[messageIndex];
4052
+ const messageId = String(message3?.messageId ?? messageIndex);
4053
+ const items = Array.isArray(message3?.content) ? message3.content : [];
3995
4054
  for (const item of items) {
3996
- if (item?.type !== "text") continue;
3997
- const text = item.messageContent || item.text || "";
4055
+ const text = extractItemTextForA2ui(item);
3998
4056
  if (typeof text !== "string" || !text.includes("<A2UI")) continue;
3999
4057
  const tags = parseA2uiTagsFromText(text);
4000
4058
  for (const tag of tags) {
@@ -4009,14 +4067,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
4009
4067
  }
4010
4068
  function reduceA2uiRuntimeMessages(state, messages) {
4011
4069
  const { shouldReplayAll, pendingItems, nextCursors } = diffConversationMessages(messages || [], state.processedMessageCursors);
4012
- const itemsToProcess = shouldReplayAll ? messages.flatMap((message2, messageIndex) => {
4013
- const messageId = String(message2?.messageId ?? messageIndex);
4014
- const items = Array.isArray(message2?.content) ? message2.content : [];
4015
- return items.map((item) => ({ messageIndex, messageId, item }));
4016
- }) : pendingItems;
4017
4070
  const tagProcessedSet = new Set(shouldReplayAll ? [] : state.processedTagIds);
4018
4071
  const { newTags, newTagIds } = scanA2uiTagsFromMessages(messages || [], tagProcessedSet);
4019
- if (!shouldReplayAll && itemsToProcess.length === 0 && newTags.length === 0) {
4072
+ if (!shouldReplayAll && pendingItems.length === 0 && newTags.length === 0) {
4020
4073
  return { state, effects: [] };
4021
4074
  }
4022
4075
  const nextState = shouldReplayAll ? createA2uiRuntimeState() : { ...state };
@@ -4035,7 +4088,7 @@ function reduceA2uiRuntimeMessages(state, messages) {
4035
4088
  const effects = shouldReplayAll ? [{ type: "reset-model-store" }] : [];
4036
4089
  const deletedSurfaceIds = /* @__PURE__ */ new Set();
4037
4090
  const nextWizardSteps = {};
4038
- itemsToProcess.forEach(({ item, messageIndex, messageId }) => {
4091
+ pendingItems.forEach(({ item, messageIndex, messageId }) => {
4039
4092
  if (item?.type === "a2uiSchema") {
4040
4093
  const schema = normalizeWizardSchema(item.schema);
4041
4094
  if (schema) {
@@ -4053,9 +4106,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
4053
4106
  processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps);
4054
4107
  }
4055
4108
  });
4056
- nextState.processedMessageCursors = shouldReplayAll ? messages.map((message2, messageIndex) => ({
4057
- messageId: String(message2?.messageId ?? messageIndex),
4058
- contentLength: Array.isArray(message2?.content) ? message2.content.length : 0
4109
+ nextState.processedMessageCursors = shouldReplayAll ? messages.map((message3, messageIndex) => ({
4110
+ messageId: String(message3?.messageId ?? messageIndex),
4111
+ contentLength: Array.isArray(message3?.content) ? message3.content.length : 0
4059
4112
  })) : nextCursors;
4060
4113
  nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
4061
4114
  if (deletedSurfaceIds.size) {
@@ -4204,11 +4257,9 @@ var A2uiRuntimeContext = React10__namespace.default.createContext({
4204
4257
  function useA2uiRuntimeView() {
4205
4258
  return React10__namespace.default.useContext(A2uiRuntimeContext);
4206
4259
  }
4207
- function A2uiMessageCards({ messageIndex, message: message2 }) {
4260
+ function A2uiMessageCards({ messageIndex }) {
4208
4261
  const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
4209
- const allSurfaceIds = surfaceIdsByMessageIndex[messageIndex] || [];
4210
- const inlineSurfaceIds = message2 ? extractInlineSurfaceIdsFromMessage(message2) : /* @__PURE__ */ new Set();
4211
- const surfaceIds = allSurfaceIds.filter((id) => !inlineSurfaceIds.has(id));
4262
+ const surfaceIds = surfaceIdsByMessageIndex[messageIndex] || [];
4212
4263
  if (!surfaceIds.length) return null;
4213
4264
  return /* @__PURE__ */ jsxRuntime.jsx("div", { children: surfaceIds.map((surfaceId) => /* @__PURE__ */ jsxRuntime.jsx(XCard.Card, { id: surfaceId }, surfaceId)) });
4214
4265
  }
@@ -4405,8 +4456,8 @@ function readContextModelPath(context) {
4405
4456
  function buildLatestCommandIndexBySurface(messages) {
4406
4457
  const indexBySurface = {};
4407
4458
  let commandIndex = -1;
4408
- for (const message2 of messages) {
4409
- const items = Array.isArray(message2?.content) ? message2.content : [];
4459
+ for (const message3 of messages) {
4460
+ const items = Array.isArray(message3?.content) ? message3.content : [];
4410
4461
  for (const item of items) {
4411
4462
  if (item?.type === "a2uiCommand" && item.command) {
4412
4463
  commandIndex += 1;
@@ -4414,16 +4465,14 @@ function buildLatestCommandIndexBySurface(messages) {
4414
4465
  if (surfaceId) indexBySurface[surfaceId] = commandIndex;
4415
4466
  continue;
4416
4467
  }
4417
- if (item?.type === "text") {
4418
- const text = item.messageContent || item.text || "";
4419
- if (typeof text !== "string" || !text.includes("<A2UI")) continue;
4420
- const tags = parseA2uiTagsFromText(text);
4421
- for (const tag of tags) {
4422
- for (const cmd of tag.commands) {
4423
- commandIndex += 1;
4424
- const surfaceId = extractSurfaceId3(cmd);
4425
- if (surfaceId) indexBySurface[surfaceId] = commandIndex;
4426
- }
4468
+ const text = extractItemTextForA2ui(item);
4469
+ if (typeof text !== "string" || !text.includes("<A2UI")) continue;
4470
+ const tags = parseA2uiTagsFromText(text);
4471
+ for (const tag of tags) {
4472
+ for (const cmd of tag.commands) {
4473
+ commandIndex += 1;
4474
+ const surfaceId = extractSurfaceId3(cmd);
4475
+ if (surfaceId) indexBySurface[surfaceId] = commandIndex;
4427
4476
  }
4428
4477
  }
4429
4478
  }
@@ -4562,6 +4611,8 @@ var RunStartedNode = React10__namespace.default.memo(({ loading }) => {
4562
4611
  if (!loading) return null;
4563
4612
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, align: "center", className: style_module_default2.runStartedNode, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, { style: { color: "#1677ff" } }) });
4564
4613
  });
4614
+ var RESOURCE_MARKDOWN_TAG = "resourcetag";
4615
+ var RESOURCE_TOKEN_REGEX = /(\w+):\/\/([^?\s]+)\?name=([^&\s]+)&label=([^\s]+)/g;
4565
4616
  function QuestionSummary({ content }) {
4566
4617
  const answer = content.replace(/^Question:\s*/, "").trim() || "\u5DF2\u56DE\u7B54";
4567
4618
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "inline-flex", flexDirection: "column", gap: 4 }, children: [
@@ -4569,38 +4620,41 @@ function QuestionSummary({ content }) {
4569
4620
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, color: "#262626", lineHeight: 1.6, whiteSpace: "pre-wrap" }, children: answer })
4570
4621
  ] });
4571
4622
  }
4623
+ function MessageResourceTag({ data }) {
4624
+ const resource = data;
4625
+ if (!resource) return null;
4626
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadonlyResourceTag, { resource });
4627
+ }
4628
+ function transformResourceText(content) {
4629
+ return content.replace(RESOURCE_TOKEN_REGEX, (_, resourceType, resourceId, resourceName, resourceLabel) => {
4630
+ const resource = {
4631
+ resourceType: decodeURIComponent(resourceType),
4632
+ resourceId: decodeURIComponent(resourceId),
4633
+ resourceName: decodeURIComponent(resourceName),
4634
+ resourceLabel: decodeURIComponent(resourceLabel)
4635
+ };
4636
+ return `<${RESOURCE_MARKDOWN_TAG}>${JSON.stringify(resource)}</${RESOURCE_MARKDOWN_TAG}>`;
4637
+ });
4638
+ }
4572
4639
  var TextNode2 = React10__namespace.default.memo(
4573
4640
  ({
4574
4641
  item,
4575
4642
  role,
4576
4643
  customComponents,
4577
- message: message2,
4578
- messageIndex = -1
4644
+ message: message3
4579
4645
  }) => {
4580
- const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
4581
- const rawContent = toA2uiDisplayText(role, item?.messageContent);
4582
- const segments = splitA2uiTextSegments(rawContent);
4583
- const visibleSurfaceIds = messageIndex >= 0 ? new Set(surfaceIdsByMessageIndex[messageIndex] || []) : null;
4584
- const firstSeg = segments[0];
4585
- const isPureText = segments.length === 0 || segments.length === 1 && firstSeg.type === "text";
4586
- if (isPureText) {
4587
- const content = firstSeg && firstSeg.type === "text" ? firstSeg.content : "";
4588
- if (typeof content === "string" && content.startsWith("Question:")) {
4589
- return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
4590
- }
4591
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4592
- !!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
4593
- !!content && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message2, components: customComponents, content })
4594
- ] });
4646
+ const content = toA2uiDisplayText(role, item?.messageContent);
4647
+ const markdownComponents = {
4648
+ [RESOURCE_MARKDOWN_TAG]: MessageResourceTag,
4649
+ ...customComponents
4650
+ };
4651
+ if (typeof content === "string" && content.startsWith("Question:")) {
4652
+ return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
4595
4653
  }
4654
+ const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
4596
4655
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4597
4656
  !!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
4598
- segments.map((seg, i) => {
4599
- if (seg.type === "text") {
4600
- return seg.content.trim() ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message2, components: customComponents, content: seg.content }, `text-${i}`) : null;
4601
- }
4602
- return seg.surfaceIds.filter((sid) => !visibleSurfaceIds || visibleSurfaceIds.has(sid)).map((sid) => /* @__PURE__ */ jsxRuntime.jsx(XCard.Card, { id: sid }, `a2ui-${i}-${sid}`));
4603
- })
4657
+ !!markdownContent && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: markdownComponents, content: markdownContent })
4604
4658
  ] });
4605
4659
  }
4606
4660
  );
@@ -4698,6 +4752,15 @@ var getToolRenderConfig = (toolName) => {
4698
4752
  alwaysShowContent: false
4699
4753
  };
4700
4754
  };
4755
+ function stripA2uiTagsFromResult(result) {
4756
+ if (!result || typeof result !== "object" || Array.isArray(result)) return result;
4757
+ const cleaned = {};
4758
+ for (const [key, value] of Object.entries(result)) {
4759
+ cleaned[key] = typeof value === "string" && value.includes("<A2UI") ? stripA2uiTags(value) : value;
4760
+ }
4761
+ const hasVisible = Object.values(cleaned).some((v) => v !== "" && v !== null && v !== void 0);
4762
+ return hasVisible ? cleaned : null;
4763
+ }
4701
4764
  var formatContent = (content) => {
4702
4765
  try {
4703
4766
  if (!content) return { text: "", isJson: false, parsed: null };
@@ -4708,9 +4771,11 @@ var formatContent = (content) => {
4708
4771
  if (typeof parsed === "object" && parsed !== null) {
4709
4772
  return { text: JSON.stringify(parsed, null, 2), isJson: true, parsed };
4710
4773
  }
4711
- return { text: content, isJson: false, parsed: null };
4774
+ const stripped = content.includes("<A2UI") ? stripA2uiTags(content) : content;
4775
+ return { text: stripped, isJson: false, parsed: null };
4712
4776
  } catch {
4713
- return { text: typeof content === "string" ? content : "", isJson: false, parsed: null };
4777
+ const text = typeof content === "string" ? content.includes("<A2UI") ? stripA2uiTags(content) : content : "";
4778
+ return { text, isJson: false, parsed: null };
4714
4779
  }
4715
4780
  };
4716
4781
  var ToolCallItem = ({ item }) => {
@@ -4724,7 +4789,12 @@ var ToolCallItem = ({ item }) => {
4724
4789
  return "running";
4725
4790
  }, [item.status, item.errorMessage, item.result]);
4726
4791
  const argsContent = React10.useMemo(() => formatContent(item.arguments || item.content), [item.arguments, item.content]);
4727
- const resultContent = React10.useMemo(() => item.result ? formatContent(item.result) : null, [item.result]);
4792
+ const resultContent = React10.useMemo(() => {
4793
+ if (!item.result) return null;
4794
+ const cleanedResult = stripA2uiTagsFromResult(item.result);
4795
+ if (!cleanedResult) return null;
4796
+ return formatContent(cleanedResult);
4797
+ }, [item.result]);
4728
4798
  const hasContent = React10.useMemo(() => {
4729
4799
  if (renderConfig.disableExpandOnError && status === "error") return false;
4730
4800
  let alwaysShow = false;
@@ -4815,10 +4885,10 @@ var ToolCallItem = ({ item }) => {
4815
4885
  );
4816
4886
  };
4817
4887
  var tool_call_item_default = ToolCallItem;
4818
- var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "files", "plan"];
4819
- var MessageRender_default = React10__namespace.default.memo(({ role, message: message2, messageIndex = -1, loading, containerRef, customComponents }) => {
4888
+ var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "runFailed", "files", "plan"];
4889
+ var MessageRender_default = React10__namespace.default.memo(({ role, message: message3, messageIndex = -1, loading, containerRef, customComponents }) => {
4820
4890
  const content = React10.useMemo(() => {
4821
- return (message2.content || []).filter((item) => {
4891
+ return (message3.content || []).filter((item) => {
4822
4892
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
4823
4893
  return false;
4824
4894
  }
@@ -4830,18 +4900,16 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
4830
4900
  }
4831
4901
  if (item.type === "text") {
4832
4902
  const rawText = item.messageContent || item.text || "";
4833
- const visibleText = stripA2uiTags(rawText);
4834
- const hasA2uiTag2 = typeof rawText === "string" && rawText.includes("<A2UI");
4835
- return !!visibleText.trim() || !!item.reasoningContent || hasA2uiTag2;
4903
+ return !!rawText.trim() || !!item.reasoningContent;
4836
4904
  }
4837
4905
  return true;
4838
4906
  });
4839
- }, [loading, message2.content]);
4907
+ }, [loading, message3.content]);
4840
4908
  const quoteMsg = React10.useMemo(() => {
4841
4909
  const quoteMsg2 = {};
4842
- if (message2.params) {
4910
+ if (message3.params) {
4843
4911
  try {
4844
- const citation = JSON.parse(message2.params).citation;
4912
+ const citation = JSON.parse(message3.params).citation;
4845
4913
  if (citation) {
4846
4914
  quoteMsg2.messageContent = citation;
4847
4915
  }
@@ -4849,11 +4917,18 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
4849
4917
  }
4850
4918
  }
4851
4919
  return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
4852
- }, [message2.params, message2.quoteMsg]);
4920
+ }, [message3.params, message3.quoteMsg]);
4853
4921
  if (content.length === 0) return null;
4922
+ const lastToolCallIndex = (() => {
4923
+ let lastIdx = -1;
4924
+ content.forEach((item, i) => {
4925
+ if (item.type === "toolCall" || item.type === "toolResult") lastIdx = i;
4926
+ });
4927
+ return lastIdx;
4928
+ })();
4854
4929
  return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, vertical: true, gap: 8, children: [
4855
- content.map((item, index) => {
4856
- return /* @__PURE__ */ jsxRuntime.jsx(
4930
+ content.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React10__namespace.default.Fragment, { children: [
4931
+ /* @__PURE__ */ jsxRuntime.jsx(
4857
4932
  xV2.Bubble,
4858
4933
  {
4859
4934
  role: role.user,
@@ -4862,17 +4937,26 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
4862
4937
  content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4863
4938
  item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
4864
4939
  (item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
4865
- item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(TextNode2, { item, role: message2.role, customComponents, message: message2, messageIndex }, `message-${index}`),
4866
- item.type === "stepError" && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message2, components: customComponents, content: item.errorMessage }) : null),
4940
+ item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(
4941
+ TextNode2,
4942
+ {
4943
+ item,
4944
+ role: message3.role,
4945
+ customComponents,
4946
+ message: message3,
4947
+ messageIndex
4948
+ },
4949
+ `message-${index}`
4950
+ ),
4951
+ (item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: customComponents, content: item.errorMessage }) : null),
4867
4952
  item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
4868
4953
  item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
4869
4954
  ] })
4870
- },
4871
- `message-${index}`
4872
- );
4873
- }),
4874
- quoteMsg && /* @__PURE__ */ jsxRuntime.jsx(QuoteMsgNode, { quoteMsg, role }),
4875
- messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message2 }) : null
4955
+ }
4956
+ ),
4957
+ index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
4958
+ ] }, `message-${index}`)),
4959
+ quoteMsg && /* @__PURE__ */ jsxRuntime.jsx(QuoteMsgNode, { quoteMsg, role })
4876
4960
  ] });
4877
4961
  });
4878
4962
  var WelcomeItem_default = ({ icon = true, title = true, description = true, prompts = true }) => {
@@ -4965,13 +5049,13 @@ var BubbleListItems_default = ({
4965
5049
  const messageRefs = React10.useRef({});
4966
5050
  const chatRecords = React10.useMemo(() => {
4967
5051
  const chatRecords2 = [];
4968
- conversationMessages.forEach((message2, messageIndex) => {
4969
- const role = getRole(message2.role);
5052
+ conversationMessages.forEach((message3, messageIndex) => {
5053
+ const role = getRole(message3.role);
4970
5054
  const isLeftBubble = role.user === "agent";
4971
- const isMessageLoading = !!message2.generating;
4972
- const baseKey = `${message2.executionId}-${messageIndex}`;
5055
+ const isMessageLoading = !!message3.generating;
5056
+ const baseKey = `${message3.executionId}-${messageIndex}`;
4973
5057
  const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, children: [
4974
- message2.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
5058
+ message3.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
4975
5059
  /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 4, children: role.user === "agent" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4976
5060
  /* @__PURE__ */ jsxRuntime.jsx(
4977
5061
  antd.Button,
@@ -4991,21 +5075,21 @@ var BubbleListItems_default = ({
4991
5075
  /* @__PURE__ */ jsxRuntime.jsx(
4992
5076
  antd.Button,
4993
5077
  {
4994
- color: message2.feedback === 1 ? "primary" : "default",
5078
+ color: message3.feedback === 1 ? "primary" : "default",
4995
5079
  size: "small",
4996
5080
  variant: "text",
4997
5081
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LikeOutlined, {}),
4998
- onClick: () => chatStore.feedback(message2.executionId, 1, messageIndex)
5082
+ onClick: () => chatStore.feedback(message3.executionId, 1, messageIndex)
4999
5083
  }
5000
5084
  ),
5001
5085
  /* @__PURE__ */ jsxRuntime.jsx(
5002
5086
  antd.Button,
5003
5087
  {
5004
- color: message2.feedback === 2 ? "primary" : "default",
5088
+ color: message3.feedback === 2 ? "primary" : "default",
5005
5089
  size: "small",
5006
5090
  variant: "text",
5007
5091
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DislikeOutlined, {}),
5008
- onClick: () => chatStore.feedback(message2.executionId, 2, messageIndex)
5092
+ onClick: () => chatStore.feedback(message3.executionId, 2, messageIndex)
5009
5093
  }
5010
5094
  ),
5011
5095
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5013,7 +5097,7 @@ var BubbleListItems_default = ({
5013
5097
  {
5014
5098
  control: agentActions,
5015
5099
  ctx: {
5016
- message: message2,
5100
+ message: message3,
5017
5101
  get dom() {
5018
5102
  return messageRefs.current[baseKey];
5019
5103
  }
@@ -5031,7 +5115,7 @@ var BubbleListItems_default = ({
5031
5115
  MessageRender_default,
5032
5116
  {
5033
5117
  role,
5034
- message: message2,
5118
+ message: message3,
5035
5119
  messageIndex,
5036
5120
  customComponents,
5037
5121
  loading: isMessageLoading,
@@ -5610,6 +5694,313 @@ var ChatSenderHeader = () => {
5610
5694
  ] });
5611
5695
  };
5612
5696
  var ChatSenderHeader_default = ChatSenderHeader;
5697
+ var MonacoEditor = ({ value = "", onChange, placeholder, height = 200, readOnly = false, style }) => {
5698
+ const handleKeyDownCapture = React10.useCallback((e) => {
5699
+ if (e.key === " " || e.code === "Space") {
5700
+ e.stopPropagation();
5701
+ }
5702
+ }, []);
5703
+ const handleKeyUpCapture = React10.useCallback((e) => {
5704
+ if (e.key === " " || e.code === "Space") {
5705
+ e.stopPropagation();
5706
+ }
5707
+ }, []);
5708
+ const handleScriptChange = React10.useCallback(
5709
+ (event) => {
5710
+ onChange?.(event.target.value || "");
5711
+ },
5712
+ [onChange]
5713
+ );
5714
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style, onKeyDownCapture: handleKeyDownCapture, onKeyUpCapture: handleKeyUpCapture, children: /* @__PURE__ */ jsxRuntime.jsx(
5715
+ antd.Input.TextArea,
5716
+ {
5717
+ value,
5718
+ onChange: handleScriptChange,
5719
+ readOnly,
5720
+ placeholder,
5721
+ autoSize: false,
5722
+ style: {
5723
+ height,
5724
+ resize: "vertical",
5725
+ fontFamily: 'Monaco, Menlo, Consolas, "Courier New", monospace',
5726
+ ...style
5727
+ }
5728
+ }
5729
+ ) });
5730
+ };
5731
+ var MonacoEditor_default = MonacoEditor;
5732
+ var { Text: Text8 } = antd.Typography;
5733
+ var FormFileUpload = ({ value, onChange, multiple = false }) => {
5734
+ const { token } = antd.theme.useToken();
5735
+ const fileList = Array.isArray(value) ? value : value ? [value] : [];
5736
+ const chatStore = useChatStore();
5737
+ const conversationState = valtio.useSnapshot(chatStore.conversation);
5738
+ const agentState = valtio.useSnapshot(chatStore.agent);
5739
+ const configState = valtio.useSnapshot(chatStore.config);
5740
+ const customRequest = async (options) => {
5741
+ const { file, onSuccess, onError } = options;
5742
+ try {
5743
+ const formData = new FormData();
5744
+ formData.append("file", file);
5745
+ const params = {
5746
+ workspaceType: "conversation" /* CONVERSATION */,
5747
+ agentId: agentState.agentInfo.id,
5748
+ workspaceId: conversationState.active.id
5749
+ };
5750
+ const res = await configState.services.request.chatUpload(params, formData);
5751
+ if (res.code === 200 && res.data?.length) {
5752
+ const uploadedFile = res.data[0];
5753
+ onSuccess(uploadedFile);
5754
+ if (multiple) {
5755
+ onChange?.([...fileList, uploadedFile]);
5756
+ } else {
5757
+ onChange?.([uploadedFile]);
5758
+ }
5759
+ } else {
5760
+ antd.message.error(res.message || "\u4E0A\u4F20\u5931\u8D25");
5761
+ onError(new Error(res.message));
5762
+ }
5763
+ } catch (error) {
5764
+ onError(error);
5765
+ }
5766
+ };
5767
+ const handleRemove = (fileToRemove) => {
5768
+ const newList = fileList.filter((f) => f.id !== fileToRemove.id);
5769
+ onChange?.(newList.length > 0 ? newList : void 0);
5770
+ };
5771
+ return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 12, style: { width: "100%" }, children: [
5772
+ !multiple && fileList.length >= 1 ? null : /* @__PURE__ */ jsxRuntime.jsx(antd.Upload, { multiple, customRequest, showUploadList: false, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CloudUploadOutlined, {}), children: "\u4ECE\u672C\u5730\u4E0A\u4F20" }) }),
5773
+ fileList.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, children: fileList.map((file) => /* @__PURE__ */ jsxRuntime.jsxs(
5774
+ antd.Flex,
5775
+ {
5776
+ align: "center",
5777
+ justify: "space-between",
5778
+ style: {
5779
+ padding: "8px 12px",
5780
+ backgroundColor: token.colorFillAlter,
5781
+ borderRadius: token.borderRadiusLG || 8,
5782
+ border: `1px solid ${token.colorBorderSecondary}`
5783
+ },
5784
+ children: [
5785
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 12, style: { overflow: "hidden", flex: 1 }, children: [
5786
+ /* @__PURE__ */ jsxRuntime.jsx(
5787
+ "div",
5788
+ {
5789
+ style: {
5790
+ width: 40,
5791
+ height: 40,
5792
+ backgroundColor: "#000",
5793
+ borderRadius: token.borderRadiusSM || 4,
5794
+ display: "flex",
5795
+ alignItems: "center",
5796
+ justifyContent: "center",
5797
+ flexShrink: 0
5798
+ },
5799
+ children: getFileIcon(file.extension || common.getFileSuffixName(file.name), 20)
5800
+ }
5801
+ ),
5802
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "hidden", display: "flex", flexDirection: "column", flex: 1 }, children: [
5803
+ /* @__PURE__ */ jsxRuntime.jsx(Text8, { ellipsis: true, style: { width: "100%", fontSize: 14, fontWeight: 500 }, children: file.name }),
5804
+ /* @__PURE__ */ jsxRuntime.jsxs(Text8, { type: "secondary", style: { fontSize: 12 }, children: [
5805
+ (file.extension || common.getFileSuffixName(file.name)).toUpperCase(),
5806
+ " \u2022 ",
5807
+ formatFileSize(file.size)
5808
+ ] })
5809
+ ] })
5810
+ ] }),
5811
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}), onClick: () => handleRemove(file), style: { color: token.colorTextSecondary } })
5812
+ ]
5813
+ },
5814
+ file.id || file.uid
5815
+ )) })
5816
+ ] });
5817
+ };
5818
+ var FormMonacoEditor = ({ value, onChange }) => {
5819
+ const { token } = antd.theme.useToken();
5820
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { backgroundColor: token.colorFillAlter, padding: 8, borderRadius: token.borderRadius }, children: /* @__PURE__ */ jsxRuntime.jsx(MonacoEditor_default, { language: "json", placeholder: "\u8BF7\u8F93\u5165\u503C...", height: 80, value, onChange }) });
5821
+ };
5822
+ var UserInputPanel = () => {
5823
+ const chatStore = useChatStore();
5824
+ const agentState = valtio.useSnapshot(chatStore.agent);
5825
+ const [form] = antd.Form.useForm();
5826
+ const [activeKey, setActiveKey] = React10.useState(["1"]);
5827
+ const inputs = React10.useMemo(() => {
5828
+ if (agentState.agentInfo.userInput?.length > 0) {
5829
+ return agentState.agentInfo.userInput;
5830
+ }
5831
+ }, [agentState.agentInfo.userInput]);
5832
+ React10.useEffect(() => {
5833
+ if (inputs.length > 0) {
5834
+ const initialValues = inputs.reduce((acc, cur) => {
5835
+ let value = cur.value;
5836
+ acc[cur.name] = value;
5837
+ return acc;
5838
+ }, {});
5839
+ form.setFieldsValue(initialValues);
5840
+ }
5841
+ }, [inputs, form]);
5842
+ const handleValuesChange = (changedValues) => {
5843
+ if (agentState.agentInfo.userInput?.length > 0) {
5844
+ const newInput = agentState.agentInfo.userInput.map((v) => {
5845
+ if (v.name in changedValues) {
5846
+ const newValue = changedValues[v.name];
5847
+ return { ...v, value: newValue };
5848
+ }
5849
+ return v;
5850
+ });
5851
+ chatStore.setConversationUserInput(newInput);
5852
+ return;
5853
+ }
5854
+ };
5855
+ const handleStartChat = () => {
5856
+ form.validateFields().then(() => {
5857
+ setActiveKey([]);
5858
+ }).catch(() => {
5859
+ antd.message.error("\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570");
5860
+ });
5861
+ };
5862
+ const renderFormItem = (item) => {
5863
+ const itemStyle = { marginBottom: 0 };
5864
+ const commonProps = {
5865
+ label: item.name,
5866
+ name: item.name,
5867
+ style: itemStyle,
5868
+ rules: item.rules?.map((r) => {
5869
+ const valStr = String(r.value || "");
5870
+ if (r.type === "required") return { required: true, message: r.message };
5871
+ if (r.type === "email") return { type: "email", message: r.message };
5872
+ if (r.type === "pattern") return { pattern: new RegExp(valStr), message: r.message };
5873
+ if (r.type === "max" || r.type === "min") {
5874
+ return {
5875
+ validator: (_, val) => {
5876
+ if (val === void 0 || val === null || val === "") return Promise.resolve();
5877
+ const numVal = Number(val);
5878
+ if (isNaN(numVal)) return Promise.resolve();
5879
+ if (r.type === "max" && numVal > Number(valStr)) return Promise.reject(new Error(r.message));
5880
+ if (r.type === "min" && numVal < Number(valStr)) return Promise.reject(new Error(r.message));
5881
+ return Promise.resolve();
5882
+ }
5883
+ };
5884
+ }
5885
+ if (r.type === "length") {
5886
+ const [min, max] = valStr.split(",").map((v) => v ? Number(v) : void 0);
5887
+ return {
5888
+ validator: (_, val) => {
5889
+ if (val === void 0 || val === null || val === "") return Promise.resolve();
5890
+ const strVal = String(val);
5891
+ if (min !== void 0 && strVal.length < min) return Promise.reject(new Error(r.message));
5892
+ if (max !== void 0 && strVal.length > max) return Promise.reject(new Error(r.message));
5893
+ return Promise.resolve();
5894
+ }
5895
+ };
5896
+ }
5897
+ if (r.type === "size") {
5898
+ const [min, max] = valStr.split(",").map((v) => v ? Number(v) : void 0);
5899
+ return {
5900
+ validator: (_, val) => {
5901
+ if (val === void 0 || val === null || val === "") return Promise.resolve();
5902
+ let len = 0;
5903
+ if (Array.isArray(val)) {
5904
+ len = val.length;
5905
+ } else if (typeof val === "string") {
5906
+ try {
5907
+ const parsed = JSON.parse(val);
5908
+ if (Array.isArray(parsed)) len = parsed.length;
5909
+ else return Promise.resolve();
5910
+ } catch (e) {
5911
+ return Promise.resolve();
5912
+ }
5913
+ } else {
5914
+ return Promise.resolve();
5915
+ }
5916
+ if (min !== void 0 && len < min) return Promise.reject(new Error(r.message));
5917
+ if (max !== void 0 && len > max) return Promise.reject(new Error(r.message));
5918
+ return Promise.resolve();
5919
+ }
5920
+ };
5921
+ }
5922
+ if (r.type === "enum") {
5923
+ const options = valStr.split(",").map((s) => s.trim());
5924
+ return {
5925
+ validator: (_, val) => {
5926
+ if (val === void 0 || val === null || val === "") return Promise.resolve();
5927
+ if (options.includes(String(val))) return Promise.resolve();
5928
+ return Promise.reject(new Error(r.message));
5929
+ }
5930
+ };
5931
+ }
5932
+ return {};
5933
+ })
5934
+ };
5935
+ if (["STRING", "LONG"].includes(item.type)) {
5936
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "\u8BF7\u8F93\u5165\u503C" }) });
5937
+ }
5938
+ if (["NUMBER"].includes(item.type)) {
5939
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.InputNumber, { style: { width: "100%" }, placeholder: "\u8BF7\u8F93\u5165\u6570\u503C" }) });
5940
+ }
5941
+ if (item.type === "BOOLEAN") {
5942
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { style: itemStyle, name: item.name, valuePropName: "checked", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", children: [
5943
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.name }),
5944
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Switch, { size: "small" })
5945
+ ] }) });
5946
+ }
5947
+ if (item.type === "FILE") {
5948
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormFileUpload, { multiple: false }) });
5949
+ }
5950
+ if (item.type === "ARRAY_FILE") {
5951
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormFileUpload, { multiple: true }) });
5952
+ }
5953
+ if (["OBJECT", "ARRAY", "ARRAY_STRING", "ARRAY_NUMBER", "ARRAY_DECIMAL", "ARRAY_BOOLEAN", "ARRAY_OBJECT"].includes(item.type)) {
5954
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormMonacoEditor, {}) });
5955
+ }
5956
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "\u8BF7\u8F93\u5165\u503C" }) });
5957
+ };
5958
+ const genExtra = () => {
5959
+ if (activeKey.includes("1")) return null;
5960
+ return /* @__PURE__ */ jsxRuntime.jsx(
5961
+ antd.Button,
5962
+ {
5963
+ type: "text",
5964
+ size: "small",
5965
+ onClick: (e) => {
5966
+ e.stopPropagation();
5967
+ setActiveKey(["1"]);
5968
+ },
5969
+ children: "\u7F16\u8F91"
5970
+ }
5971
+ );
5972
+ };
5973
+ const items = [
5974
+ {
5975
+ key: "1",
5976
+ label: "\u53C2\u6570\u8BBE\u7F6E",
5977
+ extra: genExtra(),
5978
+ children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5979
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Form, { form, layout: "vertical", onValuesChange: handleValuesChange, style: { maxHeight: 500, overflow: "auto", paddingRight: 16 }, children: inputs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 12, children: inputs.map((item) => /* @__PURE__ */ jsxRuntime.jsx(React10__namespace.default.Fragment, { children: renderFormItem(item) }, item.name)) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "10px", color: "#999", textAlign: "center" }, children: "\u6682\u65E0\u7528\u6237\u8F93\u5165\u5B57\u6BB5" }) }),
5980
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", justify: "center", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "primary", onClick: handleStartChat, children: "\u5F00\u59CB\u4F1A\u8BDD" }) })
5981
+ ] })
5982
+ }
5983
+ ];
5984
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.userInputCollapse, children: /* @__PURE__ */ jsxRuntime.jsx(
5985
+ antd.Collapse,
5986
+ {
5987
+ activeKey,
5988
+ onChange: (keys) => {
5989
+ const newKeys = typeof keys === "string" ? [keys] : keys;
5990
+ setActiveKey(newKeys);
5991
+ },
5992
+ items,
5993
+ className: "m-16",
5994
+ styles: {
5995
+ body: {
5996
+ paddingRight: 0,
5997
+ paddingBottom: 10
5998
+ }
5999
+ }
6000
+ }
6001
+ ) });
6002
+ };
6003
+ var UserInputPanel_default = UserInputPanel;
5613
6004
 
5614
6005
  // src/ui/layouts/components/styles.module.less
5615
6006
  var styles_module_default5 = {
@@ -5634,9 +6025,11 @@ var ChatMainPanel = React10.memo(
5634
6025
  []
5635
6026
  );
5636
6027
  const configState = valtio.useSnapshot(chatStore.config);
6028
+ const agentState = valtio.useSnapshot(chatStore.agent);
5637
6029
  return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default("height-full"), children: [
5638
6030
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
5639
6031
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", vertical: true, gap: 24, className: classNames2__default.default("height-full", styles_module_default5.bodyWidth), children: [
6032
+ common.shouldRender(agentState.agentInfo.userInput && agentState.agentInfo.userInput.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.userInput, DefaultComponent: UserInputPanel_default }),
5640
6033
  common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
5641
6034
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.senderHeader, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(ChatSenderHeader_default, {}) }),
5642
6035
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: styles_module_default5.inputContainer, vertical: true, gap: 8, children: [
@@ -5715,7 +6108,7 @@ var index_module_default3 = {
5715
6108
  animatedSplitter: "index_module_animatedSplitter",
5716
6109
  hideSplitterBar: "index_module_hideSplitterBar"
5717
6110
  };
5718
- var layouts_default = React10.forwardRef(({ theme: theme4, params, hooks, layout, config, services }, _ref) => {
6111
+ var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout, config, services }, _ref) => {
5719
6112
  const chatStore = React10.useMemo(() => createChatStore(), []);
5720
6113
  const senderRef = React10.useRef(null);
5721
6114
  React10.useImperativeHandle(
@@ -5762,6 +6155,11 @@ var layouts_default = React10.forwardRef(({ theme: theme4, params, hooks, layout
5762
6155
  chatStore.setAgent({ ...agentState.agentInfo, config: config.agent.config || {} });
5763
6156
  }
5764
6157
  }, [agentState.agentInfo.id, config.agent?.config]);
6158
+ common.useDeepEffect(() => {
6159
+ if (agentState.agentInfo.id) {
6160
+ chatStore.setUserInput(config.agent.userInput);
6161
+ }
6162
+ }, [agentState.agentInfo.id, config.agent?.userInput]);
5765
6163
  common.useDeepEffect(() => {
5766
6164
  if (config?.agent?.id) {
5767
6165
  chatStore.getAgentInfo(config.agent.id);
@@ -5788,20 +6186,20 @@ var layouts_default = React10.forwardRef(({ theme: theme4, params, hooks, layout
5788
6186
  }, [hasPreView]);
5789
6187
  common.useWebSocket({
5790
6188
  url: configState.services.websocketUrls?.[0],
5791
- onMessage: (message2) => chatStore.acceptMessage(message2.payload),
6189
+ onMessage: (message3) => chatStore.acceptMessage(message3.payload),
5792
6190
  clientHeartbeat: false,
5793
6191
  reconnectInterval: 1e4
5794
6192
  });
5795
6193
  common.useWebSocket({
5796
6194
  url: configState.services.websocketUrls?.[1],
5797
- onMessage: (message2) => chatStore.acceptMessage(message2.payload),
6195
+ onMessage: (message3) => chatStore.acceptMessage(message3.payload),
5798
6196
  clientHeartbeat: false,
5799
6197
  reconnectInterval: 1e4
5800
6198
  });
5801
6199
  React10.useEffect(() => {
5802
6200
  hooks?.onBeforeInit?.();
5803
6201
  }, []);
5804
- return /* @__PURE__ */ jsxRuntime.jsx(xV2.XProvider, { theme: { cssVar: {}, ...theme4 }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: configState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default(index_module_default3.chatLayout, "zero-chat-layout", "height-full"), children: [
6202
+ return /* @__PURE__ */ jsxRuntime.jsx(xV2.XProvider, { theme: { cssVar: {}, ...theme5 }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: configState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default(index_module_default3.chatLayout, "zero-chat-layout", "height-full"), children: [
5805
6203
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
5806
6204
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, className: "full-scroll", children: [
5807
6205
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.leftPanel }),