@zero-library/chat-copilot 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -4,11 +4,22 @@ var icons = require('@ant-design/icons');
4
4
  var xV2 = require('@ant-design/x-v2');
5
5
  var common = require('@zero-library/common');
6
6
  var antd = require('antd');
7
- var React7 = require('react');
7
+ var React10 = require('react');
8
8
  var valtio = require('valtio');
9
9
  var jsxRuntime = require('react/jsx-runtime');
10
- var classNames2 = require('classnames');
10
+ var LexicalComposer = require('@lexical/react/LexicalComposer');
11
+ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
12
+ var LexicalContentEditable = require('@lexical/react/LexicalContentEditable');
13
+ var LexicalErrorBoundary = require('@lexical/react/LexicalErrorBoundary');
14
+ var LexicalHistoryPlugin = require('@lexical/react/LexicalHistoryPlugin');
15
+ var LexicalOnChangePlugin = require('@lexical/react/LexicalOnChangePlugin');
16
+ var LexicalRichTextPlugin = require('@lexical/react/LexicalRichTextPlugin');
17
+ var lexical = require('lexical');
18
+ var LexicalTypeaheadMenuPlugin = require('@lexical/react/LexicalTypeaheadMenuPlugin');
19
+ var utils = require('@lexical/utils');
20
+ var ReactDOM = require('react-dom');
11
21
  var dayjs = require('dayjs');
22
+ var classNames2 = require('classnames');
12
23
  var InfiniteScroll = require('react-infinite-scroll-component');
13
24
  var xCard = require('@ant-design/x-card');
14
25
  require('@ant-design/x-markdown/themes/light.css');
@@ -17,20 +28,39 @@ var Latex = require('@ant-design/x-markdown/plugins/Latex');
17
28
 
18
29
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
19
30
 
20
- var React7__default = /*#__PURE__*/_interopDefault(React7);
21
- var classNames2__default = /*#__PURE__*/_interopDefault(classNames2);
31
+ function _interopNamespace(e) {
32
+ if (e && e.__esModule) return e;
33
+ var n = Object.create(null);
34
+ if (e) {
35
+ Object.keys(e).forEach(function (k) {
36
+ if (k !== 'default') {
37
+ var d = Object.getOwnPropertyDescriptor(e, k);
38
+ Object.defineProperty(n, k, d.get ? d : {
39
+ enumerable: true,
40
+ get: function () { return e[k]; }
41
+ });
42
+ }
43
+ });
44
+ }
45
+ n.default = e;
46
+ return Object.freeze(n);
47
+ }
48
+
49
+ var React10__namespace = /*#__PURE__*/_interopNamespace(React10);
50
+ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
22
51
  var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
52
+ var classNames2__default = /*#__PURE__*/_interopDefault(classNames2);
23
53
  var InfiniteScroll__default = /*#__PURE__*/_interopDefault(InfiniteScroll);
24
54
  var XMarkdown__default = /*#__PURE__*/_interopDefault(XMarkdown);
25
55
  var Latex__default = /*#__PURE__*/_interopDefault(Latex);
26
56
 
27
57
  // src/components/Attachments.tsx
28
- var ChatContext = React7.createContext(null);
58
+ var ChatContext = React10.createContext(null);
29
59
  function ChatProvider({ store, children }) {
30
- return React7__default.default.createElement(ChatContext.Provider, { value: store }, children);
60
+ return React10__namespace.default.createElement(ChatContext.Provider, { value: store }, children);
31
61
  }
32
62
  function useChatStore() {
33
- const store = React7.useContext(ChatContext);
63
+ const store = React10.useContext(ChatContext);
34
64
  if (!store) {
35
65
  throw new Error("useChatStore must be used within ChatProvider");
36
66
  }
@@ -41,13 +71,13 @@ function useChatStore() {
41
71
  var styles_module_default = {
42
72
  chatAttachments: "styles_module_chatAttachments",
43
73
  chatSender: "styles_module_chatSender"};
44
- var Attachments_default = React7.forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
74
+ var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
45
75
  const { message: message2 } = antd.App.useApp();
46
76
  const chatStore = useChatStore();
47
- const agentState = valtio.useSnapshot(chatStore.agent);
48
- const fileListRef = React7.useRef([]);
77
+ valtio.useSnapshot(chatStore.agent);
78
+ const fileListRef = React10.useRef([]);
49
79
  const [attachedFiles, setAttachedFiles, getAttachedFiles] = common.useRefState([]);
50
- React7.useEffect(() => {
80
+ React10.useEffect(() => {
51
81
  if (JSON.stringify(fileList) !== JSON.stringify(fileListRef.current)) {
52
82
  fileListRef.current = fileList;
53
83
  const mapped = fileList.map((file) => ({
@@ -59,7 +89,7 @@ var Attachments_default = React7.forwardRef(({ fileUpload, fileUploadConfig, fil
59
89
  setAttachedFiles(mapped);
60
90
  }
61
91
  }, [fileList]);
62
- React7.useEffect(() => {
92
+ React10.useEffect(() => {
63
93
  const files = attachedFiles.filter((file) => file.status === "done").map((file) => {
64
94
  const f = { ...file };
65
95
  delete f.status;
@@ -128,7 +158,7 @@ var Attachments_default = React7.forwardRef(({ fileUpload, fileUploadConfig, fil
128
158
  const uploadedFile = data[0];
129
159
  let previewUrl = uploadedFile.id;
130
160
  if (uploadedFile.conversationId && uploadedFile.path) {
131
- previewUrl = chatStore.config.services.request.getPreviewUrl(agentState.agentInfo.id, uploadedFile.conversationId, uploadedFile.path);
161
+ previewUrl = chatStore.config.services.request.getPreviewUrl(uploadedFile.conversationId, uploadedFile.path);
132
162
  }
133
163
  setAttachedFiles(
134
164
  getAttachedFiles().map((f) => {
@@ -163,7 +193,7 @@ var Attachments_default = React7.forwardRef(({ fileUpload, fileUploadConfig, fil
163
193
  chatStore.config.params.convMeta?.libraryId;
164
194
  file.path;
165
195
  };
166
- React7.useImperativeHandle(
196
+ React10.useImperativeHandle(
167
197
  ref,
168
198
  () => ({
169
199
  validateFile: () => {
@@ -183,7 +213,7 @@ var Attachments_default = React7.forwardRef(({ fileUpload, fileUploadConfig, fil
183
213
  }),
184
214
  []
185
215
  );
186
- const acceptStr = React7.useMemo(() => {
216
+ const acceptStr = React10.useMemo(() => {
187
217
  const allTypes = fileUploadConfig?.allowedTypes.map((type) => `.${type}`) || [];
188
218
  return allTypes.length ? allTypes.join(",") : void 0;
189
219
  }, [fileUploadConfig]);
@@ -213,10 +243,534 @@ var Attachments_default = React7.forwardRef(({ fileUpload, fileUploadConfig, fil
213
243
  }
214
244
  );
215
245
  });
216
- var ChatSender_default = React7.forwardRef(
246
+
247
+ // src/components/ChatInput/index.module.less
248
+ var index_module_default = {
249
+ fileMenu: "index_module_fileMenu",
250
+ fileMenuItem: "index_module_fileMenuItem",
251
+ fileMenuItemActive: "index_module_fileMenuItemActive",
252
+ fileName: "index_module_fileName",
253
+ resourceSelect: "index_module_resourceSelect",
254
+ promptEditorInputContainer: "index_module_promptEditorInputContainer",
255
+ promptEditorContent: "index_module_promptEditorContent",
256
+ promptEditorPlaceholder: "index_module_promptEditorPlaceholder",
257
+ resourceTag: "index_module_resourceTag"
258
+ };
259
+
260
+ // src/core/constants.ts
261
+ var CONV_MODE = {
262
+ PROD: 1};
263
+ var classifyTime = (timestamp) => {
264
+ const now = dayjs__default.default();
265
+ const target = dayjs__default.default(timestamp);
266
+ if (target.isSame(now, "day")) {
267
+ return "\u4ECA\u5929";
268
+ }
269
+ const diffInDays = now.diff(target, "day");
270
+ if (diffInDays < 7) {
271
+ return "\u6700\u8FD1 7 \u5929";
272
+ } else if (diffInDays < 30) {
273
+ return "\u6700\u8FD1 30 \u5929";
274
+ } else if (diffInDays < 180) {
275
+ return "\u6700\u8FD1\u534A\u5E74";
276
+ } else {
277
+ return "\u66F4\u65E9";
278
+ }
279
+ };
280
+ var getChatSocketUrl = (baseURL, params) => {
281
+ return common.buildUrlParams(params, common.getWebSocketUrl(`${baseURL}/ws`), "comma");
282
+ };
283
+ var getFileIcon = (extension, fontSize = 24) => {
284
+ const baseStyle = { fontSize };
285
+ const createIcon = (Icon, color) => React10__namespace.default.createElement(Icon, { style: { ...baseStyle, color } });
286
+ if (["png", "jpg", "jpeg", "gif", "bmp", "webp", "svg"].includes(extension)) {
287
+ return createIcon(icons.FileImageOutlined, "#22c55e");
288
+ }
289
+ if (["pdf"].includes(extension)) {
290
+ return createIcon(icons.FilePdfOutlined, "#ef4444");
291
+ }
292
+ if (["doc", "docx"].includes(extension)) {
293
+ return createIcon(icons.FileWordOutlined, "#2563eb");
294
+ }
295
+ if (["xls", "xlsx", "csv"].includes(extension)) {
296
+ return createIcon(icons.FileExcelOutlined, "#16a34a");
297
+ }
298
+ if (["ppt", "pptx"].includes(extension)) {
299
+ return createIcon(icons.FilePptOutlined, "#f59e0b");
300
+ }
301
+ if (["zip", "rar", "7z", "tar", "gz"].includes(extension)) {
302
+ return createIcon(icons.FileZipOutlined, "#8b5cf6");
303
+ }
304
+ if (["txt", "md", "log", "json", "yaml", "yml", "xml", "ini", "conf"].includes(extension)) {
305
+ return createIcon(icons.FileTextOutlined, "#64748b");
306
+ }
307
+ return createIcon(icons.FileUnknownOutlined, "#94a3b8");
308
+ };
309
+ function FilePickerMenu({
310
+ options,
311
+ selectedIndex,
312
+ onSelect,
313
+ onHover
314
+ }) {
315
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.fileMenu, role: "listbox", children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(
316
+ "div",
317
+ {
318
+ role: "option",
319
+ "aria-selected": index === selectedIndex,
320
+ className: `${index_module_default.fileMenuItem} ${index === selectedIndex ? index_module_default.fileMenuItemActive : ""}`,
321
+ onMouseEnter: () => onHover(index),
322
+ onClick: () => onSelect(option),
323
+ children: [
324
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFileIcon(option.ext || common.getFileSuffixName(option.label), 14) }),
325
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default.fileName, children: option.label })
326
+ ]
327
+ },
328
+ option.value
329
+ )) });
330
+ }
331
+ function ResourcePickerMenu({
332
+ anchorElementRef,
333
+ children
334
+ }) {
335
+ const menuRef = React10.useRef(null);
336
+ const [placement, setPlacement] = React10.useState("bottom");
337
+ React10.useLayoutEffect(() => {
338
+ const anchor = anchorElementRef.current;
339
+ const menu = menuRef.current;
340
+ if (!anchor || !menu) return;
341
+ const updatePlacement = () => {
342
+ const anchorRect = anchor.getBoundingClientRect();
343
+ const menuHeight = Math.min(menu.scrollHeight, 256);
344
+ const spaceBelow = window.innerHeight - anchorRect.bottom;
345
+ const spaceAbove = anchorRect.top;
346
+ setPlacement(spaceBelow < menuHeight + 8 && spaceAbove > spaceBelow ? "top" : "bottom");
347
+ };
348
+ updatePlacement();
349
+ window.addEventListener("resize", updatePlacement);
350
+ return () => window.removeEventListener("resize", updatePlacement);
351
+ }, [anchorElementRef, children]);
352
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: menuRef, className: index_module_default.resourceSelect, "data-placement": placement, onMouseDown: (event) => event.preventDefault(), children });
353
+ }
354
+ function formatResourceName(resourceName) {
355
+ const lastDotIndex = resourceName.lastIndexOf(".");
356
+ const hasExtension = lastDotIndex > 0 && lastDotIndex < resourceName.length - 1;
357
+ const name = hasExtension ? resourceName.slice(0, lastDotIndex) : resourceName;
358
+ const extension = hasExtension ? resourceName.slice(lastDotIndex) : "";
359
+ if (name.length <= 6) return `${name}${extension}`;
360
+ return `${name.slice(0, 3)}***${name.slice(-3)}${extension}`;
361
+ }
362
+ function ResourceTag({ resource }) {
363
+ const [editor] = LexicalComposerContext.useLexicalComposerContext();
364
+ const handleClose = (event) => {
365
+ event.preventDefault();
366
+ event.stopPropagation();
367
+ editor.update(() => {
368
+ const node = lexical.$getNodeByKey(resource.nodeKey);
369
+ node?.remove();
370
+ });
371
+ };
372
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.resourceTag, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Tag, { closeIcon: true, color: "blue", onClose: handleClose, children: [
373
+ resource.resourceLabel,
374
+ "\uFF1A",
375
+ formatResourceName(resource.resourceName)
376
+ ] }) });
377
+ }
378
+ var EMPTY_CASCADE_OPTION_VALUE = "__empty__";
379
+ var VariableNode = class _VariableNode extends lexical.DecoratorNode {
380
+ __resourceLabel;
381
+ __resourceType;
382
+ __resourceName;
383
+ __resourceId;
384
+ /**
385
+ * 返回当前自定义节点的唯一类型标识,供 Lexical 注册和反序列化使用。
386
+ */
387
+ static getType() {
388
+ return "variable";
389
+ }
390
+ /**
391
+ * 基于现有节点创建一个内容完全一致的新节点实例。
392
+ */
393
+ static clone(node) {
394
+ return new _VariableNode(node.__resourceLabel, node.__resourceName, node.__resourceType, node.__resourceId, node.__key);
395
+ }
396
+ /**
397
+ * 初始化变量节点,并保存标签展示与序列化所需的资源信息。
398
+ */
399
+ constructor(resourceLabel, resourceName, resourceType, resourceId, key) {
400
+ super(key);
401
+ this.__resourceLabel = resourceLabel;
402
+ this.__resourceType = resourceType;
403
+ this.__resourceName = resourceName;
404
+ this.__resourceId = resourceId;
405
+ }
406
+ /**
407
+ * 创建节点对应的宿主 DOM,用于承载后续的 React 装饰器内容。
408
+ */
409
+ createDOM() {
410
+ const span = document.createElement("span");
411
+ span.style.display = "inline-block";
412
+ span.style.verticalAlign = "middle";
413
+ return span;
414
+ }
415
+ /**
416
+ * 当前节点的 DOM 不依赖增量更新,始终交由 Lexical 复用现有 DOM。
417
+ */
418
+ updateDOM() {
419
+ return false;
420
+ }
421
+ /**
422
+ * 声明当前节点是行内节点,这样它可以和普通文本一起排版。
423
+ */
424
+ isInline() {
425
+ return true;
426
+ }
427
+ /**
428
+ * 将序列化结果恢复为变量节点实例,支持编辑器内容反解析。
429
+ */
430
+ static importJSON(serializedNode) {
431
+ return $createVariableNode(serializedNode.resourceLabel, serializedNode.resourceName, serializedNode.resourceType, serializedNode.resourceId);
432
+ }
433
+ /**
434
+ * 导出节点的业务字段,供 Lexical 持久化和回显使用。
435
+ */
436
+ exportJSON() {
437
+ return {
438
+ resourceLabel: this.__resourceLabel,
439
+ resourceName: this.__resourceName,
440
+ resourceType: this.__resourceType,
441
+ resourceId: this.__resourceId,
442
+ type: "variable",
443
+ version: 1
444
+ };
445
+ }
446
+ /**
447
+ * 生成节点的纯文本表达,便于发送、存储和重新初始化编辑器内容。
448
+ */
449
+ getTextContent() {
450
+ return `${this.__resourceType}://${this.__resourceId}?name=${this.__resourceName}&label=${this.__resourceLabel}`;
451
+ }
452
+ /**
453
+ * 将变量节点渲染为可交互的资源标签组件。
454
+ */
455
+ decorate() {
456
+ const resource = {
457
+ resourceLabel: this.__resourceLabel,
458
+ resourceName: this.__resourceName,
459
+ resourceType: this.__resourceType,
460
+ resourceId: this.__resourceId,
461
+ nodeKey: this.getKey()
462
+ };
463
+ return /* @__PURE__ */ jsxRuntime.jsx(ResourceTag, { resource });
464
+ }
465
+ };
466
+ function $createVariableNode(resourceLabel, resourceName, resourceType, resourceId) {
467
+ return new VariableNode(resourceLabel, resourceName, resourceType, resourceId);
468
+ }
469
+ var CascadeOption = class extends LexicalTypeaheadMenuPlugin.MenuOption {
470
+ category;
471
+ item;
472
+ /**
473
+ * 将级联菜单中的父子节点包装成 Lexical 菜单选项对象。
474
+ */
475
+ constructor(category, item) {
476
+ super(`${category.value}:${item.value}`);
477
+ this.category = category;
478
+ this.item = item;
479
+ }
480
+ };
481
+ var FileOption = class extends LexicalTypeaheadMenuPlugin.MenuOption {
482
+ file;
483
+ /**
484
+ * 将文件列表项包装成 Lexical 菜单选项对象。
485
+ */
486
+ constructor(file) {
487
+ super(file.value);
488
+ this.file = file;
489
+ }
490
+ };
491
+ function VariablePickerPlugin({ commandConfig = {} }) {
492
+ const [editor] = LexicalComposerContext.useLexicalComposerContext();
493
+ const chatStore = useChatStore();
494
+ const [commandDataSource, setCommandDataSource] = React10.useState(commandConfig);
495
+ const [queryString, setQueryString] = React10.useState(null);
496
+ const [isEditorFocused, setIsEditorFocused] = React10.useState(false);
497
+ const blurTimerRef = React10.useRef(null);
498
+ React10.useEffect(() => {
499
+ const unregister = utils.mergeRegister(
500
+ editor.registerCommand(
501
+ lexical.FOCUS_COMMAND,
502
+ () => {
503
+ if (blurTimerRef.current) clearTimeout(blurTimerRef.current);
504
+ setIsEditorFocused(true);
505
+ return false;
506
+ },
507
+ lexical.COMMAND_PRIORITY_LOW
508
+ ),
509
+ editor.registerCommand(
510
+ lexical.BLUR_COMMAND,
511
+ () => {
512
+ setIsEditorFocused(false);
513
+ return false;
514
+ },
515
+ lexical.COMMAND_PRIORITY_LOW
516
+ )
517
+ );
518
+ return () => {
519
+ if (blurTimerRef.current) clearTimeout(blurTimerRef.current);
520
+ unregister();
521
+ };
522
+ }, [editor]);
523
+ React10.useEffect(() => {
524
+ setCommandDataSource(commandConfig);
525
+ }, [commandConfig]);
526
+ const commandKey = queryString?.[0] || "";
527
+ const categoryConfig = React10.useMemo(
528
+ () => ({
529
+ skill: {
530
+ load: () => chatStore.config.services.request.listSkills(),
531
+ getLabel: (item) => item.aliasName || item.name
532
+ },
533
+ knowledge: {
534
+ load: () => chatStore.config.services.request.listLibrarys({ libraryType: 1 /* KNOWLEDGE */ }),
535
+ getLabel: (item) => item.name
536
+ },
537
+ datasource: {
538
+ load: () => chatStore.config.services.request.listDataSources(),
539
+ getLabel: (item) => item.name
540
+ }
541
+ }),
542
+ [chatStore]
543
+ );
544
+ const commandOptions = React10.useMemo(() => {
545
+ if (!isEditorFocused) return [];
546
+ return (commandDataSource[commandKey]?.dataSource || []).flatMap(
547
+ (category) => category.children?.filter((item) => !item.disabled).map((item) => new CascadeOption(category, item)) || []
548
+ );
549
+ }, [commandDataSource, commandKey, isEditorFocused]);
550
+ const formatDataSource = React10.useCallback(
551
+ (items, category) => {
552
+ const currentCategoryConfig = categoryConfig[category.value];
553
+ if (!items.length) {
554
+ return [
555
+ {
556
+ value: EMPTY_CASCADE_OPTION_VALUE,
557
+ label: "\u6682\u65E0\u6570\u636E",
558
+ isLeaf: true,
559
+ disabled: true
560
+ }
561
+ ];
562
+ }
563
+ return items.map((item) => ({
564
+ value: item.id,
565
+ label: currentCategoryConfig?.getLabel(item) || item.name
566
+ }));
567
+ },
568
+ [categoryConfig]
569
+ );
570
+ const loadData = React10.useCallback(
571
+ (selectedOptions) => {
572
+ const category = selectedOptions[selectedOptions.length - 1];
573
+ if (!category || category.children?.length || category.isLeaf) return;
574
+ const currentCategoryConfig = categoryConfig[category.value];
575
+ if (!currentCategoryConfig) return;
576
+ currentCategoryConfig.load().then((response) => {
577
+ const items = response.data || [];
578
+ setCommandDataSource((current) => ({
579
+ ...current,
580
+ [commandKey]: {
581
+ ...current[commandKey],
582
+ dataSource: current[commandKey]?.dataSource?.map(
583
+ (item) => item.value === category.value ? { ...item, children: formatDataSource(items, category) } : item
584
+ ) || []
585
+ }
586
+ }));
587
+ });
588
+ },
589
+ [categoryConfig, commandKey, formatDataSource]
590
+ );
591
+ const onSelectOption = React10.useCallback(
592
+ (selectedOption, nodeToReplace, closeMenu, matchingString) => {
593
+ const resource = selectedOption instanceof FileOption ? selectedOption.file : selectedOption.item;
594
+ const resourceLabel = selectedOption instanceof FileOption ? "\u6587\u4EF6" : selectedOption.category.label;
595
+ const resourceType = selectedOption instanceof FileOption ? "file" : selectedOption.category.value;
596
+ editor.update(() => {
597
+ const variableNode = $createVariableNode(resourceLabel, resource.label, resourceType, resource.value);
598
+ if (nodeToReplace) {
599
+ nodeToReplace.replace(variableNode);
600
+ variableNode.selectNext();
601
+ }
602
+ });
603
+ closeMenu();
604
+ },
605
+ [commandDataSource, editor]
606
+ );
607
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
608
+ LexicalTypeaheadMenuPlugin.LexicalTypeaheadMenuPlugin,
609
+ {
610
+ onQueryChange: (query) => setQueryString(query),
611
+ onSelectOption,
612
+ triggerFn: (text) => {
613
+ const match = new RegExp(
614
+ `(?:${Object.keys(commandConfig).map((key) => key.replace(/[.*+?^${}()|[\\]\\]/g, "\\$&")).join("|")})([^\\s]*)$`
615
+ ).exec(text);
616
+ if (!match) return null;
617
+ return { leadOffset: match.index, matchingString: match[0], replaceableString: match[0] };
618
+ },
619
+ options: commandOptions.map((option) => new CascadeOption(option.category, option.item)),
620
+ menuRenderFn: (anchorElementRef, { selectedIndex, setHighlightedIndex, selectOptionAndCleanUp }, matchingString) => {
621
+ if (!isEditorFocused || !anchorElementRef.current) return null;
622
+ return ReactDOM__namespace.createPortal(
623
+ /* @__PURE__ */ jsxRuntime.jsxs(ResourcePickerMenu, { anchorElementRef, children: [
624
+ commandDataSource[matchingString]?.component === "cascade" && /* @__PURE__ */ jsxRuntime.jsx(
625
+ antd.Cascader.Panel,
626
+ {
627
+ options: commandDataSource[matchingString]?.dataSource,
628
+ expandTrigger: "hover",
629
+ loadData,
630
+ onChange: (value) => {
631
+ const [categoryValue, itemValue] = value;
632
+ const option = commandOptions.find(
633
+ (currentOption) => currentOption.category.value === categoryValue && currentOption.item.value === itemValue
634
+ );
635
+ if (option) selectOptionAndCleanUp(option);
636
+ }
637
+ }
638
+ ),
639
+ commandDataSource[matchingString]?.component === "list" && /* @__PURE__ */ jsxRuntime.jsx(
640
+ FilePickerMenu,
641
+ {
642
+ options: commandDataSource[matchingString]?.dataSource || [],
643
+ selectedIndex: selectedIndex ?? 0,
644
+ onHover: setHighlightedIndex,
645
+ onSelect: (option) => selectOptionAndCleanUp(new FileOption(option))
646
+ }
647
+ )
648
+ ] }),
649
+ anchorElementRef.current
650
+ );
651
+ }
652
+ }
653
+ ) });
654
+ }
655
+ function InitialStatePlugin({ value }) {
656
+ const [editor] = LexicalComposerContext.useLexicalComposerContext();
657
+ function parseAndAppendNodes(paragraph, value2) {
658
+ const variableRegex = /\/(\w+):\/\/([^?\s]+)\?name=([^&\s]+)&label=([^\s]+)/g;
659
+ let lastIndex = 0;
660
+ let match;
661
+ while ((match = variableRegex.exec(value2)) !== null) {
662
+ if (match.index > lastIndex) {
663
+ paragraph.append(lexical.$createTextNode(value2.substring(lastIndex, match.index)));
664
+ }
665
+ paragraph.append($createVariableNode(decodeURIComponent(match[4]), decodeURIComponent(match[3]), match[1], match[2]));
666
+ lastIndex = variableRegex.lastIndex;
667
+ }
668
+ if (lastIndex < value2.length) {
669
+ paragraph.append(lexical.$createTextNode(value2.substring(lastIndex)));
670
+ }
671
+ }
672
+ React10.useEffect(() => {
673
+ if (value === null || value === void 0) return;
674
+ editor.update(() => {
675
+ const root = lexical.$getRoot();
676
+ const currentText = root.getTextContent();
677
+ if (currentText === value) {
678
+ return;
679
+ }
680
+ root.clear();
681
+ const paragraph = lexical.$createParagraphNode();
682
+ parseAndAppendNodes(paragraph, value);
683
+ root.append(paragraph);
684
+ });
685
+ }, [editor, value]);
686
+ return null;
687
+ }
688
+ var ChatInput = React10__namespace.forwardRef(
217
689
  ({
690
+ value = "",
691
+ commandConfig,
692
+ onChange,
218
693
  placeholder,
694
+ className,
695
+ style,
696
+ disabled,
697
+ readOnly,
698
+ onFocus,
699
+ onBlur,
700
+ onKeyDown,
701
+ onKeyUp,
702
+ onPaste,
703
+ onCompositionStart,
704
+ onCompositionEnd
705
+ }, ref) => {
706
+ const contentEditableRef = React10.useRef(null);
707
+ const stringValue = typeof value === "string" ? value : "";
708
+ const initialConfig = {
709
+ namespace: "ChatInput",
710
+ onError: (error) => console.error(error),
711
+ nodes: [VariableNode],
712
+ editable: !disabled && !readOnly
713
+ };
714
+ React10.useImperativeHandle(ref, () => ({
715
+ focus: () => contentEditableRef.current?.focus(),
716
+ blur: () => contentEditableRef.current?.blur(),
717
+ nativeElement: contentEditableRef.current
718
+ }));
719
+ const handleOnChange = (editorState) => {
720
+ editorState.read(() => {
721
+ const nextValue = lexical.$getRoot().getTextContent();
722
+ if (nextValue !== stringValue && onChange) {
723
+ onChange({ target: { value: nextValue } });
724
+ }
725
+ });
726
+ };
727
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.promptEditorInputContainer, onClick: () => contentEditableRef.current?.focus(), children: /* @__PURE__ */ jsxRuntime.jsxs(LexicalComposer.LexicalComposer, { initialConfig, children: [
728
+ /* @__PURE__ */ jsxRuntime.jsx(
729
+ LexicalRichTextPlugin.RichTextPlugin,
730
+ {
731
+ contentEditable: /* @__PURE__ */ jsxRuntime.jsx(
732
+ LexicalContentEditable.ContentEditable,
733
+ {
734
+ ref: contentEditableRef,
735
+ className: [`${className || ""}`, "ant-sender-input", index_module_default.promptEditorContent].filter(Boolean).join(" "),
736
+ style,
737
+ contentEditable: !disabled && !readOnly,
738
+ suppressContentEditableWarning: true,
739
+ role: "textbox",
740
+ "aria-multiline": "true",
741
+ tabIndex: !disabled && !readOnly ? 0 : -1,
742
+ onMouseDown: (event) => {
743
+ if (!disabled && !readOnly) {
744
+ event.stopPropagation();
745
+ }
746
+ },
747
+ onFocus: (event) => onFocus?.(event),
748
+ onBlur: (event) => onBlur?.(event),
749
+ onKeyDown: (event) => onKeyDown?.(event),
750
+ onKeyUp: (event) => onKeyUp?.(event),
751
+ onPaste: (event) => onPaste?.(event),
752
+ onCompositionStart: (event) => onCompositionStart?.(event),
753
+ onCompositionEnd: (event) => {
754
+ onCompositionEnd?.(event);
755
+ }
756
+ }
757
+ ),
758
+ placeholder: !stringValue && placeholder ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.promptEditorPlaceholder, children: placeholder }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.promptEditorPlaceholder, children: "\u4ECA\u5929\u80FD\u5E2E\u4F60\u505A\u4EC0\u4E48\uFF1F" }),
759
+ ErrorBoundary: LexicalErrorBoundary.LexicalErrorBoundary
760
+ }
761
+ ),
762
+ /* @__PURE__ */ jsxRuntime.jsx(LexicalHistoryPlugin.HistoryPlugin, {}),
763
+ /* @__PURE__ */ jsxRuntime.jsx(VariablePickerPlugin, { commandConfig }),
764
+ /* @__PURE__ */ jsxRuntime.jsx(LexicalOnChangePlugin.OnChangePlugin, { onChange: handleOnChange }),
765
+ /* @__PURE__ */ jsxRuntime.jsx(InitialStatePlugin, { value: stringValue })
766
+ ] }) });
767
+ }
768
+ );
769
+ var ChatInput_default = ChatInput;
770
+ var ChatSender_default = React10.forwardRef(
771
+ ({
219
772
  content,
773
+ commandConfig = {},
220
774
  fileList = [],
221
775
  headerOpen = false,
222
776
  loading = false,
@@ -232,10 +786,10 @@ var ChatSender_default = React7.forwardRef(
232
786
  sendBtnProps,
233
787
  fileUpload
234
788
  }, ref) => {
235
- const senderRef = React7.useRef(null);
789
+ const senderRef = React10.useRef(null);
236
790
  const { inputValue, setInputValue } = common.useSyncInput(content || "", onContentChange);
237
791
  const attachmentsNode = fileUpload?.config?.enabled && /* @__PURE__ */ jsxRuntime.jsx(antd.Badge, { dot: !!fileList?.length && !headerOpen, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PaperClipOutlined, {}), onClick: () => onHeaderOpenChange(!headerOpen) }) });
238
- const attachmentsRef = React7.useRef();
792
+ const attachmentsRef = React10.useRef();
239
793
  const senderHeader = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
240
794
  /* @__PURE__ */ jsxRuntime.jsx(xV2.Sender.Header, { title: "\u9009\u62E9\u6587\u4EF6", open: headerOpen, onOpenChange: onHeaderOpenChange, children: /* @__PURE__ */ jsxRuntime.jsx(
241
795
  Attachments_default,
@@ -255,14 +809,20 @@ var ChatSender_default = React7.forwardRef(
255
809
  onSend();
256
810
  }
257
811
  };
258
- const isFocusedRef = React7.useRef(false);
259
- React7.useEffect(() => {
812
+ const isFocusedRef = React10.useRef(false);
813
+ const commandConfigRef = React10.useRef(commandConfig);
814
+ commandConfigRef.current = commandConfig;
815
+ const inputComponent = React10.useCallback(
816
+ (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(ChatInput_default, { ...inputProps, commandConfig: commandConfigRef.current }),
817
+ []
818
+ );
819
+ React10.useEffect(() => {
260
820
  if (!content) return;
261
821
  if (!isFocusedRef.current) {
262
822
  senderRef.current?.focus({ cursor: "end" });
263
823
  }
264
824
  }, [content]);
265
- React7.useImperativeHandle(
825
+ React10.useImperativeHandle(
266
826
  ref,
267
827
  () => ({
268
828
  focus: (options) => {
@@ -277,6 +837,7 @@ var ChatSender_default = React7.forwardRef(
277
837
  /* @__PURE__ */ jsxRuntime.jsx(
278
838
  xV2.Sender,
279
839
  {
840
+ components: { input: inputComponent },
280
841
  className: styles_module_default.chatSender,
281
842
  ref: senderRef,
282
843
  value: inputValue,
@@ -305,37 +866,12 @@ var ChatSender_default = React7.forwardRef(
305
866
  ] }),
306
867
  /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: extraFooterBelow })
307
868
  ] });
308
- },
309
- placeholder: placeholder || "\u6709\u4EC0\u4E48\u6211\u80FD\u5E2E\u60A8\u7684\u5417\uFF1F"
869
+ }
310
870
  }
311
871
  )
312
872
  );
313
873
  }
314
874
  );
315
- var classifyTime = (timestamp) => {
316
- const now = dayjs__default.default();
317
- const target = dayjs__default.default(timestamp);
318
- if (target.isSame(now, "day")) {
319
- return "\u4ECA\u5929";
320
- }
321
- const diffInDays = now.diff(target, "day");
322
- if (diffInDays < 7) {
323
- return "\u6700\u8FD1 7 \u5929";
324
- } else if (diffInDays < 30) {
325
- return "\u6700\u8FD1 30 \u5929";
326
- } else if (diffInDays < 180) {
327
- return "\u6700\u8FD1\u534A\u5E74";
328
- } else {
329
- return "\u66F4\u65E9";
330
- }
331
- };
332
- var getChatSocketUrl = (baseURL, params) => {
333
- return common.buildUrlParams(params, common.getWebSocketUrl(`${baseURL}/ws`), "comma");
334
- };
335
-
336
- // src/core/constants.ts
337
- var CONV_MODE = {
338
- PROD: 1};
339
875
  var TOKEN_KEY = "NS-TOKEN";
340
876
  var tokenManager = common.createTokenManager({
341
877
  key: TOKEN_KEY
@@ -344,8 +880,6 @@ var redirectUrl = () => {
344
880
  const path = localStorage.getItem("SIGNPATH");
345
881
  common.emit("jumpLink", { url: `/uc${path || "/sign-in"}` });
346
882
  };
347
-
348
- // src/services/index.ts
349
883
  var createChatService = (request, config) => {
350
884
  const fetchModelList = () => {
351
885
  return request.get(`/providers/models/type/llm`);
@@ -377,8 +911,8 @@ var createChatService = (request, config) => {
377
911
  const feedbackUpdate = (params) => {
378
912
  return request.put(`/agents/messages/${params.executionId}/feedback`, params);
379
913
  };
380
- const chatUpload = (agentId, data, conversationId, signal) => {
381
- return request.post(`/agents/${agentId}/${conversationId}/files`, data, {
914
+ const chatUpload = (params, data, signal) => {
915
+ return request.post(common.buildUrlParams(params, "/files/upload"), data, {
382
916
  headers: {
383
917
  "Content-Type": "multipart/form-data"
384
918
  },
@@ -386,8 +920,14 @@ var createChatService = (request, config) => {
386
920
  signal
387
921
  });
388
922
  };
389
- const getPreviewUrl = (agentId, conversationId, path) => {
390
- return `${config?.baseURL}/agents/${agentId}/${conversationId}/files/download?path=${path}&${TOKEN_KEY}=${tokenManager.get()}`;
923
+ const getPreviewUrl = (conversationId, path) => {
924
+ const params = {
925
+ path,
926
+ [TOKEN_KEY]: tokenManager.get(),
927
+ workspaceId: conversationId,
928
+ workspaceType: "conversation" /* CONVERSATION */
929
+ };
930
+ return common.buildUrlParams(params, `${config?.baseURL}/files/access`);
391
931
  };
392
932
  const docQuery = (params) => {
393
933
  return request.get(`/library/cloud/document?${params}`);
@@ -401,8 +941,11 @@ var createChatService = (request, config) => {
401
941
  const listTags = (params) => {
402
942
  return request.get(`/tags`, { tagType: params.tagType });
403
943
  };
944
+ const listDataSources = () => {
945
+ return request.get(`/datasource`);
946
+ };
404
947
  const getAgentAvatar = (path) => {
405
- return request.get(`/files/download?path=${path}`, void 0, { responseType: "blob" });
948
+ return request.get(`/files/access?path=${path}&workspaceType=${"global" /* GLOBAL */}`, void 0, { responseType: "blob" });
406
949
  };
407
950
  return {
408
951
  fetchModelList,
@@ -420,6 +963,7 @@ var createChatService = (request, config) => {
420
963
  docQuery,
421
964
  listSkills,
422
965
  listLibrarys,
966
+ listDataSources,
423
967
  listTags,
424
968
  getAgentAvatar
425
969
  };
@@ -1292,9 +1836,9 @@ function createChatStore() {
1292
1836
  }
1293
1837
  var AuthImage = ({ path, size, shape = "square" }) => {
1294
1838
  const chatStore = useChatStore();
1295
- const [imgSrc, setImgSrc] = React7.useState(null);
1296
- const blobUrlRef = React7.useRef(null);
1297
- React7.useEffect(() => {
1839
+ const [imgSrc, setImgSrc] = React10.useState(null);
1840
+ const blobUrlRef = React10.useRef(null);
1841
+ React10.useEffect(() => {
1298
1842
  if (!path) {
1299
1843
  return;
1300
1844
  }
@@ -1396,7 +1940,7 @@ var ConversationList_default = () => {
1396
1940
  const chatStore = useChatStore();
1397
1941
  const conversationsState = valtio.useSnapshot(chatStore.conversations);
1398
1942
  const conversationState = valtio.useSnapshot(chatStore.conversation);
1399
- const conversationList = React7.useMemo(() => {
1943
+ const conversationList = React10.useMemo(() => {
1400
1944
  return conversationsState.list.items.filter((item) => item.label);
1401
1945
  }, [conversationsState.list.items]);
1402
1946
  const menuConfig = (conversation) => ({
@@ -1880,11 +2424,11 @@ function exportJsonFile(data, fileName) {
1880
2424
  exportTextFile(json, fileName, "application/json;charset=utf-8");
1881
2425
  }
1882
2426
  var ChartViewer = ({ artifactId, title, payload }) => {
1883
- const containerRef = React7__default.default.useRef(null);
1884
- const [containerWidth, setContainerWidth] = React7__default.default.useState(0);
2427
+ const containerRef = React10__namespace.default.useRef(null);
2428
+ const [containerWidth, setContainerWidth] = React10__namespace.default.useState(0);
1885
2429
  const spec = payload?.spec;
1886
2430
  const needsContainerWidth = true;
1887
- React7__default.default.useLayoutEffect(() => {
2431
+ React10__namespace.default.useLayoutEffect(() => {
1888
2432
  const el = containerRef.current;
1889
2433
  if (!el) return;
1890
2434
  let frame = 0;
@@ -1934,9 +2478,9 @@ var ChartViewer = ({ artifactId, title, payload }) => {
1934
2478
  }
1935
2479
  );
1936
2480
  };
1937
- var AgentNavigate_default = React7.memo(({ data }) => {
1938
- const [content, setContent] = React7.useState(null);
1939
- React7.useEffect(() => {
2481
+ var AgentNavigate_default = React10.memo(({ data }) => {
2482
+ const [content, setContent] = React10.useState(null);
2483
+ React10.useEffect(() => {
1940
2484
  if (!data) {
1941
2485
  return;
1942
2486
  }
@@ -2098,8 +2642,8 @@ var FileView_default = ({ data, loading }) => {
2098
2642
  var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
2099
2643
  const chatStore = useChatStore();
2100
2644
  const configState = valtio.useSnapshot(chatStore.config);
2101
- const [content, setContent] = React7.useState("");
2102
- const [loading, setLoading] = React7.useState(false);
2645
+ const [content, setContent] = React10.useState("");
2646
+ const [loading, setLoading] = React10.useState(false);
2103
2647
  const getContent = async () => {
2104
2648
  try {
2105
2649
  setLoading(true);
@@ -2109,14 +2653,14 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
2109
2653
  setLoading(false);
2110
2654
  }
2111
2655
  };
2112
- React7.useEffect(() => {
2656
+ React10.useEffect(() => {
2113
2657
  getContent();
2114
2658
  }, [paramsStr]);
2115
2659
  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" }) }) });
2116
2660
  };
2117
2661
  var IndexQuote_default = ({ data, loading, message: message2 }) => {
2118
- const [open, setOpen] = React7.useState(false);
2119
- const citation = React7.useMemo(() => {
2662
+ const [open, setOpen] = React10.useState(false);
2663
+ const citation = React10.useMemo(() => {
2120
2664
  const citations = message2.content?.find((item) => item.type === "citation")?.citations ?? [];
2121
2665
  return citations?.find((item) => String(item.citationId) === String(data.citationId));
2122
2666
  }, [data.citationId, message2.content]);
@@ -2138,7 +2682,7 @@ var MarkImg_default = ({ data, loading, message: message2, ...rest }) => {
2138
2682
  const getPreviewFileUrl = (src) => {
2139
2683
  return common.buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, src);
2140
2684
  };
2141
- const previewSrc = React7.useMemo(() => {
2685
+ const previewSrc = React10.useMemo(() => {
2142
2686
  if (String(rest.src).startsWith("/luya")) {
2143
2687
  return getPreviewFileUrl(rest.src);
2144
2688
  }
@@ -2148,12 +2692,12 @@ var MarkImg_default = ({ data, loading, message: message2, ...rest }) => {
2148
2692
  };
2149
2693
  var MdEdit_default = ({ data, loading }) => {
2150
2694
  const chatStore = useChatStore();
2151
- const [value, setValue] = React7.useState("");
2695
+ const [value, setValue] = React10.useState("");
2152
2696
  const btnText = data.btnText || "\u7EE7\u7EED";
2153
2697
  const onOk = () => {
2154
2698
  chatStore.sendMessage(btnText, [], { citation: value });
2155
2699
  };
2156
- React7.useEffect(() => {
2700
+ React10.useEffect(() => {
2157
2701
  setValue(data.content);
2158
2702
  }, [data.content]);
2159
2703
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default3.mdEdit, children: [
@@ -2192,7 +2736,7 @@ var PreviewLink_default = ({ data, loading, message: message2, ...rest }) => {
2192
2736
  const fileName = getLinkFileName(href);
2193
2737
  const suffix = common.getFileSuffixName(fileName);
2194
2738
  chatStore.setPreview({
2195
- fileUrl: chatStore.config.services.request.getPreviewUrl(message2.agentId, message2.conversationId, href),
2739
+ fileUrl: chatStore.config.services.request.getPreviewUrl(message2.conversationId, href),
2196
2740
  fileName,
2197
2741
  suffix
2198
2742
  });
@@ -2298,10 +2842,10 @@ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
2298
2842
  return WrappedComponent;
2299
2843
  };
2300
2844
  var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
2301
- var XMarkdown_default = React7.memo(({ message: message2, components = {}, content = "", ...rest }) => {
2302
- const config = React7.useMemo(() => getMarkdownConfig(), []);
2303
- const formattedContent = React7.useMemo(() => formatMixedContent(content), [content]);
2304
- const newComponents = React7.useMemo(
2845
+ var XMarkdown_default = React10.memo(({ message: message2, components = {}, content = "", ...rest }) => {
2846
+ const config = React10.useMemo(() => getMarkdownConfig(), []);
2847
+ const formattedContent = React10.useMemo(() => formatMixedContent(content), [content]);
2848
+ const newComponents = React10.useMemo(
2305
2849
  () => ({
2306
2850
  think: Think_default,
2307
2851
  code: CodeHighlight_default,
@@ -2318,16 +2862,16 @@ var XMarkdown_default = React7.memo(({ message: message2, components = {}, conte
2318
2862
  }),
2319
2863
  [components]
2320
2864
  );
2321
- const payloadTagPattern = React7.useMemo(() => Object.keys(newComponents).join("|"), [newComponents]);
2322
- const { content: processedContent, payloadMap } = React7.useMemo(
2865
+ const payloadTagPattern = React10.useMemo(() => Object.keys(newComponents).join("|"), [newComponents]);
2866
+ const { content: processedContent, payloadMap } = React10.useMemo(
2323
2867
  () => preprocessCustomTagPayloads(formattedContent, payloadTagPattern),
2324
2868
  [formattedContent, payloadTagPattern]
2325
2869
  );
2326
- const payloadMapRef = React7.useRef(payloadMap);
2327
- const messageRef = React7.useRef(message2);
2870
+ const payloadMapRef = React10.useRef(payloadMap);
2871
+ const messageRef = React10.useRef(message2);
2328
2872
  payloadMapRef.current = payloadMap;
2329
2873
  messageRef.current = message2;
2330
- const markdownComponents = React7.useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
2874
+ const markdownComponents = React10.useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
2331
2875
  return /* @__PURE__ */ jsxRuntime.jsx(
2332
2876
  XMarkdown__default.default,
2333
2877
  {
@@ -2525,8 +3069,8 @@ function useBoundFieldState({
2525
3069
  const valuePath = decodeBindPathToken(bindPathToken) ?? pathFromValue(value);
2526
3070
  const cachedValue = readCachedValue(readPathValue(valuePath));
2527
3071
  const externalValue = readExternalValue(value);
2528
- const dirtyRef = React7__default.default.useRef(false);
2529
- const [localValue, setLocalValue] = React7__default.default.useState(() => {
3072
+ const dirtyRef = React10__namespace.default.useRef(false);
3073
+ const [localValue, setLocalValue] = React10__namespace.default.useState(() => {
2530
3074
  if (valuePath && cachedValue !== void 0) {
2531
3075
  return cachedValue;
2532
3076
  }
@@ -2539,10 +3083,10 @@ function useBoundFieldState({
2539
3083
  if (cachedValue !== void 0) return cachedValue;
2540
3084
  return defaultValue;
2541
3085
  });
2542
- React7__default.default.useEffect(() => {
3086
+ React10__namespace.default.useEffect(() => {
2543
3087
  dirtyRef.current = false;
2544
3088
  }, [valuePath]);
2545
- React7__default.default.useEffect(() => {
3089
+ React10__namespace.default.useEffect(() => {
2546
3090
  if (valuePath && cachedValue !== void 0) {
2547
3091
  setLocalValue(cachedValue);
2548
3092
  return;
@@ -2566,10 +3110,10 @@ function useBoundFieldState({
2566
3110
  setLocalValue(cachedValue);
2567
3111
  }
2568
3112
  }, [cachedValue, externalValue, preferCachedOverExternal, valuePath]);
2569
- React7__default.default.useEffect(() => {
3113
+ React10__namespace.default.useEffect(() => {
2570
3114
  rememberPathValue(valuePath, localValue);
2571
3115
  }, [valuePath, localValue]);
2572
- const updateLocalValue = React7__default.default.useCallback(
3116
+ const updateLocalValue = React10__namespace.default.useCallback(
2573
3117
  (nextValue) => {
2574
3118
  dirtyRef.current = true;
2575
3119
  setLocalValue(nextValue);
@@ -2589,7 +3133,7 @@ function emitFieldChange(nextValue, valuePath, updateLocalValue, onDataChange, o
2589
3133
  onChange?.(nextValue);
2590
3134
  }
2591
3135
  function useControlId(id) {
2592
- const autoId = React7__default.default.useId();
3136
+ const autoId = React10__namespace.default.useId();
2593
3137
  return id ?? autoId;
2594
3138
  }
2595
3139
  function readActionEvent(action) {
@@ -2690,7 +3234,7 @@ var Button9 = ({ label, variant = "default", onClick, action, onAction }) => {
2690
3234
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: variant === "primary" ? "primary" : "default", danger: variant === "danger", onClick: handleClick, style: { borderRadius: 8 }, children: label });
2691
3235
  };
2692
3236
  var Divider = () => /* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { style: { margin: "8px 0" } });
2693
- var Tag2 = ({ text, color }) => /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color, children: text });
3237
+ var Tag3 = ({ text, color }) => /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color, children: text });
2694
3238
  var Progress = ({
2695
3239
  percent,
2696
3240
  status = "normal",
@@ -2708,7 +3252,7 @@ var A2uiComponents = {
2708
3252
  Switch,
2709
3253
  Button: Button9,
2710
3254
  Divider,
2711
- Tag: Tag2,
3255
+ Tag: Tag3,
2712
3256
  Progress,
2713
3257
  ArtifactCard,
2714
3258
  TableViewer,
@@ -3406,23 +3950,23 @@ function applyA2uiRuntimeEffects(effects) {
3406
3950
  }
3407
3951
  function useA2uiController(params) {
3408
3952
  const { conversationId, conversationMessages, dismissedSurfaceIds } = params;
3409
- const runtimeRef = React7.useRef(createA2uiRuntimeState());
3410
- const [runtimeState, setRuntimeState] = React7.useState(() => createA2uiRuntimeState());
3411
- React7.useEffect(() => {
3953
+ const runtimeRef = React10.useRef(createA2uiRuntimeState());
3954
+ const [runtimeState, setRuntimeState] = React10.useState(() => createA2uiRuntimeState());
3955
+ React10.useEffect(() => {
3412
3956
  const nextState = createA2uiRuntimeState();
3413
3957
  runtimeRef.current = nextState;
3414
3958
  setRuntimeState(nextState);
3415
3959
  clearAllModelValues();
3416
3960
  }, [conversationId]);
3417
- React7.useEffect(() => {
3961
+ React10.useEffect(() => {
3418
3962
  const result = reduceA2uiRuntimeMessages(runtimeRef.current, conversationMessages || []);
3419
3963
  if (result.state === runtimeRef.current && result.effects.length === 0) return;
3420
3964
  runtimeRef.current = result.state;
3421
3965
  applyA2uiRuntimeEffects(result.effects);
3422
3966
  setRuntimeState(result.state);
3423
3967
  }, [conversationMessages, conversationId]);
3424
- const view = React7.useMemo(() => selectA2uiRuntimeView(runtimeState, dismissedSurfaceIds), [runtimeState, dismissedSurfaceIds]);
3425
- const handleRuntimeAction = React7.useCallback((payload) => {
3968
+ const view = React10.useMemo(() => selectA2uiRuntimeView(runtimeState, dismissedSurfaceIds), [runtimeState, dismissedSurfaceIds]);
3969
+ const handleRuntimeAction = React10.useCallback((payload) => {
3426
3970
  const surfaceId = String(payload?.surfaceId || payload?.cardId || "");
3427
3971
  const name = String(payload?.name || payload?.event?.name || "").trim();
3428
3972
  const rawContext = payload?.context || payload?.event?.context || {};
@@ -3443,7 +3987,7 @@ function useA2uiController(params) {
3443
3987
  handleRuntimeAction
3444
3988
  };
3445
3989
  }
3446
- var A2uiRuntimeContext = React7__default.default.createContext({
3990
+ var A2uiRuntimeContext = React10__namespace.default.createContext({
3447
3991
  commands: [],
3448
3992
  onAction: () => void 0,
3449
3993
  surfaceIdsByMessageIndex: {}
@@ -3451,7 +3995,7 @@ var A2uiRuntimeContext = React7__default.default.createContext({
3451
3995
 
3452
3996
  // src/components/CustomComponents/A2uiRuntime/renderer/useA2uiRuntimeView.ts
3453
3997
  function useA2uiRuntimeView() {
3454
- return React7__default.default.useContext(A2uiRuntimeContext);
3998
+ return React10__namespace.default.useContext(A2uiRuntimeContext);
3455
3999
  }
3456
4000
  function A2uiMessageCards({ messageIndex }) {
3457
4001
  const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
@@ -3665,19 +4209,19 @@ function A2uiRuntimeProvider({ messages, children }) {
3665
4209
  const chatStore = useChatStore();
3666
4210
  const conversationState = valtio.useSnapshot(chatStore.conversation);
3667
4211
  const conversationId = conversationState.active.id;
3668
- const processedMessageCursorsRef = React7__default.default.useRef([]);
3669
- const latestCommandIndexBySurfaceRef = React7__default.default.useRef({});
3670
- const commandIndexRef = React7__default.default.useRef(-1);
3671
- const [latestCommandIndexBySurface, setLatestCommandIndexBySurface] = React7__default.default.useState({});
3672
- const [dismissedAtBySurface, setDismissedAtBySurface] = React7__default.default.useState({});
3673
- React7__default.default.useEffect(() => {
4212
+ const processedMessageCursorsRef = React10__namespace.default.useRef([]);
4213
+ const latestCommandIndexBySurfaceRef = React10__namespace.default.useRef({});
4214
+ const commandIndexRef = React10__namespace.default.useRef(-1);
4215
+ const [latestCommandIndexBySurface, setLatestCommandIndexBySurface] = React10__namespace.default.useState({});
4216
+ const [dismissedAtBySurface, setDismissedAtBySurface] = React10__namespace.default.useState({});
4217
+ React10__namespace.default.useEffect(() => {
3674
4218
  processedMessageCursorsRef.current = [];
3675
4219
  latestCommandIndexBySurfaceRef.current = {};
3676
4220
  commandIndexRef.current = -1;
3677
4221
  setLatestCommandIndexBySurface({});
3678
4222
  setDismissedAtBySurface({});
3679
4223
  }, [conversationId]);
3680
- React7__default.default.useEffect(() => {
4224
+ React10__namespace.default.useEffect(() => {
3681
4225
  const { shouldReplayAll, nextCursors, pendingItems } = diffMessages(messages, processedMessageCursorsRef.current);
3682
4226
  const itemsToProcess = shouldReplayAll ? messages.flatMap((message2) => {
3683
4227
  const items = Array.isArray(message2?.content) ? message2.content : [];
@@ -3700,10 +4244,10 @@ function A2uiRuntimeProvider({ messages, children }) {
3700
4244
  commandIndexRef.current = nextCommandIndex;
3701
4245
  setLatestCommandIndexBySurface(nextLatestCommandIndexBySurface);
3702
4246
  }, [messages]);
3703
- const dismissedSurfaceIds = React7__default.default.useMemo(() => {
4247
+ const dismissedSurfaceIds = React10__namespace.default.useMemo(() => {
3704
4248
  return Object.entries(dismissedAtBySurface).filter(([surfaceId, dismissedAt]) => (latestCommandIndexBySurface[surfaceId] ?? -1) <= dismissedAt).map(([surfaceId]) => surfaceId);
3705
4249
  }, [dismissedAtBySurface, latestCommandIndexBySurface]);
3706
- const dispatchA2uiAction = React7__default.default.useCallback(
4250
+ const dispatchA2uiAction = React10__namespace.default.useCallback(
3707
4251
  async (payload) => {
3708
4252
  const actionPayload = normalizeA2uiActionPayload(payload);
3709
4253
  if (!actionPayload.name) return;
@@ -3730,7 +4274,7 @@ function A2uiRuntimeProvider({ messages, children }) {
3730
4274
  conversationMessages: messages,
3731
4275
  dismissedSurfaceIds
3732
4276
  });
3733
- const onAction = React7__default.default.useCallback(
4277
+ const onAction = React10__namespace.default.useCallback(
3734
4278
  (payload) => {
3735
4279
  const result = handleRuntimeAction(payload);
3736
4280
  if (result.handled || !result.name) return;
@@ -3743,7 +4287,7 @@ function A2uiRuntimeProvider({ messages, children }) {
3743
4287
  },
3744
4288
  [commands, dispatchA2uiAction, handleRuntimeAction, runtimeState.modelPathBySurface]
3745
4289
  );
3746
- const contextValue = React7__default.default.useMemo(
4290
+ const contextValue = React10__namespace.default.useMemo(
3747
4291
  () => ({ commands, onAction, surfaceIdsByMessageIndex: anchoredSurfaceIdsByMessageIndex }),
3748
4292
  [anchoredSurfaceIdsByMessageIndex, commands, onAction]
3749
4293
  );
@@ -3752,14 +4296,14 @@ function A2uiRuntimeProvider({ messages, children }) {
3752
4296
  function A2uiRenderer(props) {
3753
4297
  return /* @__PURE__ */ jsxRuntime.jsx(A2uiRuntimeProvider, { ...props });
3754
4298
  }
3755
- var FilesNode = React7__default.default.memo(({ item }) => {
4299
+ var FilesNode = React10__namespace.default.memo(({ item }) => {
3756
4300
  const chatStore = useChatStore();
3757
4301
  const configState = valtio.useSnapshot(chatStore.config);
3758
- const agentState = valtio.useSnapshot(chatStore.agent);
4302
+ valtio.useSnapshot(chatStore.agent);
3759
4303
  const conversationState = valtio.useSnapshot(chatStore.conversation);
3760
- const fileItems = React7.useMemo(() => {
4304
+ const fileItems = React10.useMemo(() => {
3761
4305
  return (item.files || []).map((file) => {
3762
- const previewUrl = configState.services.request.getPreviewUrl(agentState.agentInfo.id, conversationState.active.id, file.path);
4306
+ const previewUrl = configState.services.request.getPreviewUrl(conversationState.active.id, file.path);
3763
4307
  let fileType = "file";
3764
4308
  const ext = file.ext?.toLowerCase() || "";
3765
4309
  if (["jpg", "jpeg", "png", "gif", "bmp", "webp", "svg", "webp"].includes(ext)) {
@@ -3783,7 +4327,7 @@ var FilesNode = React7__default.default.memo(({ item }) => {
3783
4327
  // src/components/CustomComponents/MessageNode/style.module.less
3784
4328
  var style_module_default2 = {
3785
4329
  runStartedNode: "style_module_runStartedNode"};
3786
- var QuoteMsgNode = React7__default.default.memo(({ quoteMsg, role }) => {
4330
+ var QuoteMsgNode = React10__namespace.default.memo(({ quoteMsg, role }) => {
3787
4331
  if (!quoteMsg || !quoteMsg.messageContent) return null;
3788
4332
  return /* @__PURE__ */ jsxRuntime.jsx(
3789
4333
  xV2.Bubble,
@@ -3813,7 +4357,7 @@ var QuoteMsgNode = React7__default.default.memo(({ quoteMsg, role }) => {
3813
4357
  }
3814
4358
  );
3815
4359
  });
3816
- var RunStartedNode = React7__default.default.memo(({ loading }) => {
4360
+ var RunStartedNode = React10__namespace.default.memo(({ loading }) => {
3817
4361
  if (!loading) return null;
3818
4362
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, align: "center", className: style_module_default2.runStartedNode, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, { style: { color: "#1677ff" } }) });
3819
4363
  });
@@ -3824,7 +4368,7 @@ function QuestionSummary({ content }) {
3824
4368
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, color: "#262626", lineHeight: 1.6, whiteSpace: "pre-wrap" }, children: answer })
3825
4369
  ] });
3826
4370
  }
3827
- var TextNode = React7__default.default.memo(
4371
+ var TextNode2 = React10__namespace.default.memo(
3828
4372
  ({ item, role, customComponents, message: message2 }) => {
3829
4373
  const content = toA2uiDisplayText(role, item?.messageContent);
3830
4374
  if (typeof content === "string" && content.startsWith("Question:")) {
@@ -3838,7 +4382,7 @@ var TextNode = React7__default.default.memo(
3838
4382
  );
3839
4383
 
3840
4384
  // src/components/CustomComponents/ToolRenders/index.module.less
3841
- var index_module_default = {
4385
+ var index_module_default2 = {
3842
4386
  iconContainer: "index_module_iconContainer",
3843
4387
  toolName: "index_module_toolName",
3844
4388
  duration: "index_module_duration",
@@ -3856,21 +4400,21 @@ var index_module_default = {
3856
4400
  };
3857
4401
  var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
3858
4402
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3859
- (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default.sectionBlock, children: [
3860
- /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
3861
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
4403
+ (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
4404
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
4405
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
3862
4406
  ${argsContent.text}
3863
4407
  \`\`\`` : argsContent.text }) })
3864
4408
  ] }),
3865
- item.result && resultContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default.sectionBlock, children: [
3866
- /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
3867
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
4409
+ item.result && resultContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
4410
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
4411
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
3868
4412
  ${resultContent.text}
3869
4413
  \`\`\`` : resultContent.text }) })
3870
4414
  ] }),
3871
- errorMessage && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default.sectionBlock, children: [
3872
- /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
3873
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: `\`\`\`
4415
+ errorMessage && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
4416
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
4417
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: `\`\`\`
3874
4418
  ${errorMessage}
3875
4419
  \`\`\`` }) })
3876
4420
  ] })
@@ -3892,18 +4436,18 @@ var TodoWriteRender = ({ args, result }) => {
3892
4436
  }
3893
4437
  };
3894
4438
  if (!todos || todos.length === 0) {
3895
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { type: "secondary", className: index_module_default.emptyText, children: "\u6682\u65E0\u4EFB\u52A1" });
4439
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { type: "secondary", className: index_module_default2.emptyText, children: "\u6682\u65E0\u4EFB\u52A1" });
3896
4440
  }
3897
4441
  return /* @__PURE__ */ jsxRuntime.jsx(
3898
4442
  antd.List,
3899
4443
  {
3900
4444
  size: "small",
3901
4445
  dataSource: todos,
3902
- renderItem: (item) => /* @__PURE__ */ jsxRuntime.jsxs(antd.List.Item, { className: index_module_default.todoItem, children: [
3903
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.statusIconWrapper, children: getStatusIcon(item.status) }),
3904
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.todoContent, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: `${index_module_default.todoText} ${item.status === "completed" ? index_module_default.completed : ""}`, children: item.title || item.content }) })
4446
+ renderItem: (item) => /* @__PURE__ */ jsxRuntime.jsxs(antd.List.Item, { className: index_module_default2.todoItem, children: [
4447
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.statusIconWrapper, children: getStatusIcon(item.status) }),
4448
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.todoContent, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: `${index_module_default2.todoText} ${item.status === "completed" ? index_module_default2.completed : ""}`, children: item.title || item.content }) })
3905
4449
  ] }),
3906
- className: index_module_default.todoList
4450
+ className: index_module_default2.todoList
3907
4451
  }
3908
4452
  );
3909
4453
  };
@@ -3949,15 +4493,15 @@ var ToolCallItem = ({ item }) => {
3949
4493
  const { token } = antd.theme.useToken();
3950
4494
  const renderConfig = getToolRenderConfig(item.toolName);
3951
4495
  const CustomRender = renderConfig.component;
3952
- const status = React7.useMemo(() => {
4496
+ const status = React10.useMemo(() => {
3953
4497
  if (item.status) return item.status;
3954
4498
  if (item.errorMessage) return "error";
3955
4499
  if (item.result) return "success";
3956
4500
  return "running";
3957
4501
  }, [item.status, item.errorMessage, item.result]);
3958
- const argsContent = React7.useMemo(() => formatContent(item.arguments || item.content), [item.arguments, item.content]);
3959
- const resultContent = React7.useMemo(() => item.result ? formatContent(item.result) : null, [item.result]);
3960
- const hasContent = React7.useMemo(() => {
4502
+ const argsContent = React10.useMemo(() => formatContent(item.arguments || item.content), [item.arguments, item.content]);
4503
+ const resultContent = React10.useMemo(() => item.result ? formatContent(item.result) : null, [item.result]);
4504
+ const hasContent = React10.useMemo(() => {
3961
4505
  if (renderConfig.disableExpandOnError && status === "error") return false;
3962
4506
  let alwaysShow = false;
3963
4507
  if (typeof renderConfig.alwaysShowContent === "function") {
@@ -3968,7 +4512,7 @@ var ToolCallItem = ({ item }) => {
3968
4512
  if (alwaysShow) return true;
3969
4513
  return Boolean(item.errorMessage);
3970
4514
  }, [renderConfig.disableExpandOnError, renderConfig.alwaysShowContent, item.errorMessage, status, argsContent.parsed, resultContent?.parsed]);
3971
- const isDefaultExpanded = React7.useMemo(() => {
4515
+ const isDefaultExpanded = React10.useMemo(() => {
3972
4516
  if (typeof renderConfig.defaultExpanded === "function") {
3973
4517
  return renderConfig.defaultExpanded(argsContent.parsed, resultContent?.parsed);
3974
4518
  }
@@ -4022,10 +4566,10 @@ var ToolCallItem = ({ item }) => {
4022
4566
  key: item.toolCallId || "fallback-key",
4023
4567
  showArrow: hasContent,
4024
4568
  label: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
4025
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.iconContainer, children: renderIcon() }),
4026
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default.toolName, children: item.title || item.toolName || "Unknown Tool" }),
4027
- (status === "running" || status === "pending") && /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
4028
- item.duration && /* @__PURE__ */ jsxRuntime.jsxs(antd.Typography.Text, { className: index_module_default.duration, children: [
4569
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.iconContainer, children: renderIcon() }),
4570
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.toolName, children: item.title || item.toolName || "Unknown Tool" }),
4571
+ (status === "running" || status === "pending") && /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
4572
+ item.duration && /* @__PURE__ */ jsxRuntime.jsxs(antd.Typography.Text, { className: index_module_default2.duration, children: [
4029
4573
  item.duration,
4030
4574
  "ms"
4031
4575
  ] })
@@ -4048,8 +4592,8 @@ var ToolCallItem = ({ item }) => {
4048
4592
  };
4049
4593
  var tool_call_item_default = ToolCallItem;
4050
4594
  var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "files", "plan"];
4051
- var MessageRender_default = React7__default.default.memo(({ role, message: message2, messageIndex = -1, loading, containerRef, customComponents }) => {
4052
- const content = React7.useMemo(() => {
4595
+ var MessageRender_default = React10__namespace.default.memo(({ role, message: message2, messageIndex = -1, loading, containerRef, customComponents }) => {
4596
+ const content = React10.useMemo(() => {
4053
4597
  return (message2.content || []).filter((item) => {
4054
4598
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
4055
4599
  return false;
@@ -4063,7 +4607,7 @@ var MessageRender_default = React7__default.default.memo(({ role, message: messa
4063
4607
  return true;
4064
4608
  });
4065
4609
  }, [loading, message2.content]);
4066
- const quoteMsg = React7.useMemo(() => {
4610
+ const quoteMsg = React10.useMemo(() => {
4067
4611
  const quoteMsg2 = {};
4068
4612
  if (message2.params) {
4069
4613
  try {
@@ -4088,7 +4632,7 @@ var MessageRender_default = React7__default.default.memo(({ role, message: messa
4088
4632
  content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4089
4633
  item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
4090
4634
  (item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
4091
- item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(TextNode, { item, role: message2.role, customComponents, message: message2 }, `message-${index}`),
4635
+ item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(TextNode2, { item, role: message2.role, customComponents, message: message2 }, `message-${index}`),
4092
4636
  item.type === "stepError" && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message2, components: customComponents, content: item.errorMessage }) : null),
4093
4637
  item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
4094
4638
  item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
@@ -4104,7 +4648,7 @@ var MessageRender_default = React7__default.default.memo(({ role, message: messa
4104
4648
  var WelcomeItem_default = ({ icon = true, title = true, description = true, prompts = true }) => {
4105
4649
  const chatStore = useChatStore();
4106
4650
  const agentState = valtio.useSnapshot(chatStore.agent);
4107
- const recommendQuestions = React7.useMemo(() => {
4651
+ const recommendQuestions = React10.useMemo(() => {
4108
4652
  return agentState.agentInfo?.config?.onboarding?.guiding?.map((item, index) => ({
4109
4653
  key: String(index),
4110
4654
  description: item
@@ -4161,7 +4705,7 @@ var BubbleListItems_default = ({
4161
4705
  const chatStore = useChatStore();
4162
4706
  const agentState = valtio.useSnapshot(chatStore.agent);
4163
4707
  const conversationState = valtio.useSnapshot(chatStore.conversation);
4164
- const conversationRoles = React7.useMemo(() => {
4708
+ const conversationRoles = React10.useMemo(() => {
4165
4709
  const roles = {};
4166
4710
  if (agentState.agentInfo?.id) {
4167
4711
  roles.agent = {
@@ -4179,7 +4723,7 @@ var BubbleListItems_default = ({
4179
4723
  };
4180
4724
  return roles;
4181
4725
  }, [agentState.agentInfo.id]);
4182
- const chatMessage = React7.useMemo(
4726
+ const chatMessage = React10.useMemo(
4183
4727
  () => conversationState.messages[conversationState.active.id] || {},
4184
4728
  [conversationState.messages[conversationState.active.id]]
4185
4729
  );
@@ -4188,8 +4732,8 @@ var BubbleListItems_default = ({
4188
4732
  const roleKey = Object.keys(conversationRoles).find((key) => conversationRoles[key].role === role);
4189
4733
  return conversationRoles[roleKey] || {};
4190
4734
  };
4191
- const messageRefs = React7.useRef({});
4192
- const chatRecords = React7.useMemo(() => {
4735
+ const messageRefs = React10.useRef({});
4736
+ const chatRecords = React10.useMemo(() => {
4193
4737
  const chatRecords2 = [];
4194
4738
  conversationMessages.forEach((message2, messageIndex) => {
4195
4739
  const role = getRole(message2.role);
@@ -4276,7 +4820,7 @@ var BubbleListItems_default = ({
4276
4820
  });
4277
4821
  return chatRecords2;
4278
4822
  }, [agentActions, chatStore, conversationMessages, conversationRoles, conversationState.active.id]);
4279
- const firstMessagesRecord = React7.useMemo(() => {
4823
+ const firstMessagesRecord = React10.useMemo(() => {
4280
4824
  return (firstMessages || []).map((firstMessage, index) => {
4281
4825
  const { member, content, contentRender, ...args } = firstMessage;
4282
4826
  const roleObj = getRole(member);
@@ -4296,7 +4840,7 @@ var BubbleListItems_default = ({
4296
4840
  };
4297
4841
  });
4298
4842
  }, [firstMessages, conversationRoles]);
4299
- const welcomeMessageRecord = React7.useMemo(() => {
4843
+ const welcomeMessageRecord = React10.useMemo(() => {
4300
4844
  const isExist = common.shouldRender(welcomeMessage);
4301
4845
  return isExist ? [
4302
4846
  {
@@ -4306,7 +4850,7 @@ var BubbleListItems_default = ({
4306
4850
  }
4307
4851
  ] : [];
4308
4852
  }, [welcomeMessage, agentState.agentInfo.id]);
4309
- const bubbleListItems = React7.useMemo(() => {
4853
+ const bubbleListItems = React10.useMemo(() => {
4310
4854
  const list = [];
4311
4855
  list.push(...firstMessagesRecord);
4312
4856
  list.push(...chatRecords);
@@ -4315,21 +4859,21 @@ var BubbleListItems_default = ({
4315
4859
  }
4316
4860
  return [...welcomeMessageRecord];
4317
4861
  }, [chatRecords, welcomeMessageRecord, firstMessagesRecord]);
4318
- const listRef = React7.useRef(null);
4319
- const autoScrollRef = React7.useRef(true);
4862
+ const listRef = React10.useRef(null);
4863
+ const autoScrollRef = React10.useRef(true);
4320
4864
  const handleScroll = (el) => {
4321
4865
  const target = el.target;
4322
4866
  const distanceToBottom = target.scrollHeight - target.scrollTop - target.clientHeight;
4323
4867
  autoScrollRef.current = distanceToBottom < 90;
4324
4868
  };
4325
- React7.useEffect(() => {
4869
+ React10.useEffect(() => {
4326
4870
  const latestMessage = conversationMessages[conversationMessages?.length - 1];
4327
4871
  if (!latestMessage) return;
4328
4872
  if (latestMessage.generating) {
4329
4873
  autoScrollRef.current = true;
4330
4874
  }
4331
4875
  }, [conversationMessages?.length]);
4332
- React7.useEffect(() => {
4876
+ React10.useEffect(() => {
4333
4877
  const el = listRef.current?.nativeElement;
4334
4878
  if (!el || !bubbleListItems.length) return;
4335
4879
  if (autoScrollRef.current) {
@@ -4362,17 +4906,17 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
4362
4906
  const chatStore = useChatStore();
4363
4907
  const conversationState = valtio.useSnapshot(chatStore.conversation);
4364
4908
  const { token } = antd.theme.useToken();
4365
- const tagsContainerRef = React7.useRef(null);
4909
+ const tagsContainerRef = React10.useRef(null);
4366
4910
  const isSkill = type === "skill";
4367
- const [loading, setLoading] = React7.useState(false);
4368
- const [resources, setResources] = React7.useState([]);
4369
- const [categories, setCategories] = React7.useState([]);
4370
- const [selectedCategoryIds, setSelectedCategoryIds] = React7.useState([ALL_CATEGORY_ID]);
4371
- const [selectedIds, setSelectedIds] = React7.useState([]);
4372
- const [searchText, setSearchText] = React7.useState("");
4373
- const [tagsExpanded, setTagsExpanded] = React7.useState(false);
4374
- const [showExpandBtn, setShowExpandBtn] = React7.useState(false);
4375
- React7.useEffect(() => {
4911
+ const [loading, setLoading] = React10.useState(false);
4912
+ const [resources, setResources] = React10.useState([]);
4913
+ const [categories, setCategories] = React10.useState([]);
4914
+ const [selectedCategoryIds, setSelectedCategoryIds] = React10.useState([ALL_CATEGORY_ID]);
4915
+ const [selectedIds, setSelectedIds] = React10.useState([]);
4916
+ const [searchText, setSearchText] = React10.useState("");
4917
+ const [tagsExpanded, setTagsExpanded] = React10.useState(false);
4918
+ const [showExpandBtn, setShowExpandBtn] = React10.useState(false);
4919
+ React10.useEffect(() => {
4376
4920
  if (!open) {
4377
4921
  setResources([]);
4378
4922
  setCategories([]);
@@ -4415,7 +4959,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
4415
4959
  canceled = true;
4416
4960
  };
4417
4961
  }, [open, isSkill, chatStore, conversationState.active.spec]);
4418
- React7.useEffect(() => {
4962
+ React10.useEffect(() => {
4419
4963
  if (!open) return;
4420
4964
  const checkHeight = () => {
4421
4965
  if (tagsContainerRef.current) {
@@ -4427,7 +4971,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
4427
4971
  if (tagsContainerRef.current) observer.observe(tagsContainerRef.current);
4428
4972
  return () => observer.disconnect();
4429
4973
  }, [open, selectedIds]);
4430
- const filteredResources = React7.useMemo(() => {
4974
+ const filteredResources = React10.useMemo(() => {
4431
4975
  return resources.filter((item) => {
4432
4976
  const matchCategory = selectedCategoryIds.includes(ALL_CATEGORY_ID) || item.tagIds?.some((id) => selectedCategoryIds.includes(id));
4433
4977
  const searchLower = searchText.trim().toLowerCase();
@@ -4590,7 +5134,7 @@ var { Text: Text5 } = antd.Typography;
4590
5134
  var KnowledgeBtn_default = ({}) => {
4591
5135
  const chatStore = useChatStore();
4592
5136
  const conversationState = valtio.useSnapshot(chatStore.conversation);
4593
- const [modalOpen, setModalOpen] = React7.useState(false);
5137
+ const [modalOpen, setModalOpen] = React10.useState(false);
4594
5138
  const knowledgeCount = conversationState.active.spec?.knowledge?.items?.length ?? 0;
4595
5139
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4596
5140
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: style_module_default.resourceBtn, onClick: () => setModalOpen(true), children: [
@@ -4618,7 +5162,7 @@ var getModelIcon = (iconName) => {
4618
5162
  var ModelSelect_default = ({}) => {
4619
5163
  const chatStore = useChatStore();
4620
5164
  const agentState = valtio.useSnapshot(chatStore.agent);
4621
- const [models, setModels] = React7.useState([]);
5165
+ const [models, setModels] = React10.useState([]);
4622
5166
  const modelOptions = models.map((item) => ({
4623
5167
  label: item.providerLabel || item.providerName,
4624
5168
  title: item.providerLabel || item.providerName,
@@ -4632,7 +5176,7 @@ var ModelSelect_default = ({}) => {
4632
5176
  }))
4633
5177
  }));
4634
5178
  const selectedModelValue = modelOptions.find((item) => item.value === agentState.model.providerName)?.options.find((item) => item.value === agentState.model.modelName)?.value || void 0;
4635
- React7.useEffect(() => {
5179
+ React10.useEffect(() => {
4636
5180
  if (!selectedModelValue && models.length > 0 && models[0].models?.length > 0) {
4637
5181
  const firstProvider = models[0];
4638
5182
  const firstModel = firstProvider.models[0];
@@ -4663,7 +5207,7 @@ var ModelSelect_default = ({}) => {
4663
5207
  /* @__PURE__ */ jsxRuntime.jsx(Text6, { children: model.label })
4664
5208
  ] });
4665
5209
  };
4666
- React7.useEffect(() => {
5210
+ React10.useEffect(() => {
4667
5211
  const getModels = async () => {
4668
5212
  const { data } = await chatStore.config.services.request.fetchModelList();
4669
5213
  setModels(data || []);
@@ -4708,7 +5252,7 @@ var { Text: Text7 } = antd.Typography;
4708
5252
  var SkillBtn_default = ({}) => {
4709
5253
  const chatStore = useChatStore();
4710
5254
  const conversationState = valtio.useSnapshot(chatStore.conversation);
4711
- const [modalOpen, setModalOpen] = React7.useState(false);
5255
+ const [modalOpen, setModalOpen] = React10.useState(false);
4712
5256
  const skillsCount = conversationState.active.spec?.skills?.items?.length ?? 0;
4713
5257
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4714
5258
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: style_module_default.resourceBtn, onClick: () => setModalOpen(true), children: [
@@ -4722,7 +5266,7 @@ var SkillBtn_default = ({}) => {
4722
5266
  modalOpen && /* @__PURE__ */ jsxRuntime.jsx(ResourceSelectorModal_default, { open: modalOpen, type: "skill", onCancel: () => setModalOpen(false) })
4723
5267
  ] });
4724
5268
  };
4725
- var ChatSender_default2 = React7.forwardRef(
5269
+ var ChatSender_default2 = React10.forwardRef(
4726
5270
  ({
4727
5271
  placeholder,
4728
5272
  extraBtn = false,
@@ -4732,18 +5276,26 @@ var ChatSender_default2 = React7.forwardRef(
4732
5276
  reasonBtn = true,
4733
5277
  skillsBtn = false,
4734
5278
  knowledgeBtn = false,
4735
- modelSelect = false
5279
+ modelSelect = false,
5280
+ commandConfig = {}
4736
5281
  }, ref) => {
4737
5282
  const chatStore = useChatStore();
4738
5283
  const configState = valtio.useSnapshot(chatStore.config);
4739
5284
  const agentState = valtio.useSnapshot(chatStore.agent);
4740
5285
  const conversationState = valtio.useSnapshot(chatStore.conversation);
4741
- const fileUploadRequest = (formData, signal) => configState.services.request.chatUpload(agentState.agentInfo.id, formData, conversationState.active.id, signal);
4742
- const chatMessage = React7.useMemo(
5286
+ const fileUploadRequest = (formData, signal) => {
5287
+ const params = {
5288
+ workspaceType: "conversation" /* CONVERSATION */,
5289
+ agentId: agentState.agentInfo.id,
5290
+ workspaceId: conversationState.active.id
5291
+ };
5292
+ return configState.services.request.chatUpload(params, formData, signal);
5293
+ };
5294
+ const chatMessage = React10.useMemo(
4743
5295
  () => conversationState.messages[conversationState.active.id] || {},
4744
5296
  [conversationState.messages[conversationState.active.id]]
4745
5297
  );
4746
- const referenceContent = React7.useMemo(() => {
5298
+ const referenceContent = React10.useMemo(() => {
4747
5299
  const content = chatMessage.references?.content?.name;
4748
5300
  if (content) {
4749
5301
  return common.markdownToText(content);
@@ -4758,6 +5310,7 @@ var ChatSender_default2 = React7.forwardRef(
4758
5310
  ChatSender_default,
4759
5311
  {
4760
5312
  ref,
5313
+ commandConfig,
4761
5314
  placeholder,
4762
5315
  content: chatMessage.content,
4763
5316
  fileList: chatMessage.files,
@@ -4837,11 +5390,11 @@ var styles_module_default5 = {
4837
5390
  previewHeaderTitle: "styles_module_previewHeaderTitle",
4838
5391
  actionIcon: "styles_module_actionIcon"
4839
5392
  };
4840
- var ChatMainPanel = React7.memo(
4841
- React7.forwardRef((_props, ref) => {
5393
+ var ChatMainPanel = React10.memo(
5394
+ React10.forwardRef((_props, ref) => {
4842
5395
  const chatStore = useChatStore();
4843
- const senderRef = React7.useRef(null);
4844
- React7.useImperativeHandle(
5396
+ const senderRef = React10.useRef(null);
5397
+ React10.useImperativeHandle(
4845
5398
  ref,
4846
5399
  () => ({
4847
5400
  focus: (options) => {
@@ -4872,9 +5425,9 @@ var ChatMainPanel = React7.memo(
4872
5425
  })
4873
5426
  );
4874
5427
  var ChatMainPanel_default = ChatMainPanel;
4875
- var ChatPreviewPanel = React7.memo(({ file }) => {
5428
+ var ChatPreviewPanel = React10.memo(({ file }) => {
4876
5429
  const chatStore = useChatStore();
4877
- const preview = React7.useMemo(() => {
5430
+ const preview = React10.useMemo(() => {
4878
5431
  const urlFile = file;
4879
5432
  if (urlFile.fileUrl) {
4880
5433
  return {
@@ -4927,15 +5480,15 @@ var ChatPreviewPanel = React7.memo(({ file }) => {
4927
5480
  var ChatPreviewPanel_default = ChatPreviewPanel;
4928
5481
 
4929
5482
  // src/ui/layouts/index.module.less
4930
- var index_module_default2 = {
5483
+ var index_module_default3 = {
4931
5484
  chatLayout: "index_module_chatLayout",
4932
5485
  animatedSplitter: "index_module_animatedSplitter",
4933
5486
  hideSplitterBar: "index_module_hideSplitterBar"
4934
5487
  };
4935
- var layouts_default = React7.forwardRef(({ theme: theme4, params, hooks, layout, config, services }, _ref) => {
4936
- const chatStore = React7.useMemo(() => createChatStore(), []);
4937
- const senderRef = React7.useRef(null);
4938
- React7.useImperativeHandle(
5488
+ var layouts_default = React10.forwardRef(({ theme: theme4, params, hooks, layout, config, services }, _ref) => {
5489
+ const chatStore = React10.useMemo(() => createChatStore(), []);
5490
+ const senderRef = React10.useRef(null);
5491
+ React10.useImperativeHandle(
4939
5492
  _ref,
4940
5493
  () => ({
4941
5494
  sendMessage: chatStore.sendMessage,
@@ -4956,14 +5509,14 @@ var layouts_default = React7.forwardRef(({ theme: theme4, params, hooks, layout,
4956
5509
  );
4957
5510
  const configState = valtio.useSnapshot(chatStore.config);
4958
5511
  const agentState = valtio.useSnapshot(chatStore.agent);
4959
- const containerRef = React7.useRef(null);
4960
- React7.useEffect(() => {
5512
+ const containerRef = React10.useRef(null);
5513
+ React10.useEffect(() => {
4961
5514
  chatStore.setHooks(hooks);
4962
5515
  }, [hooks]);
4963
- React7.useEffect(() => {
5516
+ React10.useEffect(() => {
4964
5517
  chatStore.setLayout(layout);
4965
5518
  }, [layout]);
4966
- React7.useEffect(() => {
5519
+ React10.useEffect(() => {
4967
5520
  chatStore.setParams(params);
4968
5521
  }, [params]);
4969
5522
  common.useDeepEffect(() => {
@@ -4989,14 +5542,14 @@ var layouts_default = React7.forwardRef(({ theme: theme4, params, hooks, layout,
4989
5542
  chatStore.initConversation(config);
4990
5543
  }
4991
5544
  }, [agentState.agentInfo.id, config.conversationId]);
4992
- const hasPreView = React7.useMemo(() => {
5545
+ const hasPreView = React10.useMemo(() => {
4993
5546
  return common.shouldRender(configState.layout.preview) && (!!configState.preview.file.fileUrl || !!configState.preview.file.content);
4994
5547
  }, [configState.layout.preview, configState.preview.file]);
4995
- const [sizes, setSizes] = React7.useState([0, "100%"]);
5548
+ const [sizes, setSizes] = React10.useState([0, "100%"]);
4996
5549
  const setSplitterSizes = (sizes2) => {
4997
5550
  setSizes(sizes2);
4998
5551
  };
4999
- React7.useEffect(() => {
5552
+ React10.useEffect(() => {
5000
5553
  if (hasPreView) {
5001
5554
  setSplitterSizes(["50%", "50%"]);
5002
5555
  } else {
@@ -5015,15 +5568,15 @@ var layouts_default = React7.forwardRef(({ theme: theme4, params, hooks, layout,
5015
5568
  clientHeartbeat: false,
5016
5569
  reconnectInterval: 1e4
5017
5570
  });
5018
- React7.useEffect(() => {
5571
+ React10.useEffect(() => {
5019
5572
  hooks?.onBeforeInit?.();
5020
5573
  }, []);
5021
- 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_default2.chatLayout, "zero-chat-layout", "height-full"), children: [
5574
+ 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: [
5022
5575
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
5023
5576
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, className: "full-scroll", children: [
5024
5577
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.leftPanel }),
5025
5578
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.conversationList, DefaultComponent: ConversationListPanel_default }),
5026
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter, { className: classNames2__default.default("flex-1", index_module_default2.animatedSplitter, { [index_module_default2.hideSplitterBar]: !hasPreView }), children: [
5579
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter, { className: classNames2__default.default("flex-1", index_module_default3.animatedSplitter, { [index_module_default3.hideSplitterBar]: !hasPreView }), children: [
5027
5580
  /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxRuntime.jsx(ChatMainPanel_default, { ref: senderRef }) }),
5028
5581
  /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, min: 600, size: sizes[0], children: /* @__PURE__ */ jsxRuntime.jsx(ChatPreviewPanel_default, { file: configState.preview.file }) })
5029
5582
  ] })