@zero-library/chat-copilot 3.1.3 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,12 +1,24 @@
1
- import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, LoadingOutlined, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined } from '@ant-design/icons';
1
+ import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, LoadingOutlined, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
2
2
  import { Attachments, Sender, FileCard, Bubble, Think, XProvider, Mermaid, CodeHighlighter, Welcome, Prompts, Conversations } from '@ant-design/x-v2';
3
3
  import { useRefState, useDebounce, useSyncInput, createTokenManager, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, transform, emit, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
- import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Drawer, Empty, Modal, Checkbox, Input, message, List, Card, Table, Progress as Progress$1, Switch as Switch$1 } from 'antd';
5
- import React7, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback } from 'react';
4
+ import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Cascader, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Drawer, Empty, Modal, Checkbox, Input, message, List, Card, Table, Progress as Progress$1, Switch as Switch$1 } from 'antd';
5
+ import * as React10 from 'react';
6
+ import React10__default, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useCallback, memo, useState, useContext, useLayoutEffect } from 'react';
6
7
  import { useSnapshot, proxy } from 'valtio';
7
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
- import classNames2 from 'classnames';
9
+ import { LexicalComposer } from '@lexical/react/LexicalComposer';
10
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
11
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable';
12
+ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
13
+ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
14
+ import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
15
+ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
16
+ import { DecoratorNode, FOCUS_COMMAND, COMMAND_PRIORITY_LOW, BLUR_COMMAND, $getRoot, $createParagraphNode, $createTextNode, $getNodeByKey } from 'lexical';
17
+ import { LexicalTypeaheadMenuPlugin, MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin';
18
+ import { mergeRegister } from '@lexical/utils';
19
+ import * as ReactDOM from 'react-dom';
9
20
  import dayjs from 'dayjs';
21
+ import classNames2 from 'classnames';
10
22
  import InfiniteScroll from 'react-infinite-scroll-component';
11
23
  import { XCard as XCard$1 } from '@ant-design/x-card';
12
24
  import '@ant-design/x-markdown/themes/light.css';
@@ -16,7 +28,7 @@ import Latex from '@ant-design/x-markdown/plugins/Latex';
16
28
  // src/components/Attachments.tsx
17
29
  var ChatContext = createContext(null);
18
30
  function ChatProvider({ store, children }) {
19
- return React7.createElement(ChatContext.Provider, { value: store }, children);
31
+ return React10__default.createElement(ChatContext.Provider, { value: store }, children);
20
32
  }
21
33
  function useChatStore() {
22
34
  const store = useContext(ChatContext);
@@ -33,7 +45,7 @@ var styles_module_default = {
33
45
  var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
34
46
  const { message: message2 } = App.useApp();
35
47
  const chatStore = useChatStore();
36
- const agentState = useSnapshot(chatStore.agent);
48
+ useSnapshot(chatStore.agent);
37
49
  const fileListRef = useRef([]);
38
50
  const [attachedFiles, setAttachedFiles, getAttachedFiles] = useRefState([]);
39
51
  useEffect(() => {
@@ -117,7 +129,7 @@ var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList =
117
129
  const uploadedFile = data[0];
118
130
  let previewUrl = uploadedFile.id;
119
131
  if (uploadedFile.conversationId && uploadedFile.path) {
120
- previewUrl = chatStore.config.services.request.getPreviewUrl(agentState.agentInfo.id, uploadedFile.conversationId, uploadedFile.path);
132
+ previewUrl = chatStore.config.services.request.getPreviewUrl(uploadedFile.conversationId, uploadedFile.path);
121
133
  }
122
134
  setAttachedFiles(
123
135
  getAttachedFiles().map((f) => {
@@ -202,10 +214,534 @@ var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList =
202
214
  }
203
215
  );
204
216
  });
205
- var ChatSender_default = forwardRef(
217
+
218
+ // src/components/ChatInput/index.module.less
219
+ var index_module_default = {
220
+ promptEditorInputContainer: "index_module_promptEditorInputContainer",
221
+ promptEditorContent: "index_module_promptEditorContent",
222
+ promptEditorPlaceholder: "index_module_promptEditorPlaceholder",
223
+ resourceSelect: "index_module_resourceSelect",
224
+ fileMenu: "index_module_fileMenu",
225
+ fileMenuItem: "index_module_fileMenuItem",
226
+ fileMenuItemActive: "index_module_fileMenuItemActive",
227
+ fileName: "index_module_fileName",
228
+ resourceTag: "index_module_resourceTag"
229
+ };
230
+
231
+ // src/core/constants.ts
232
+ var CONV_MODE = {
233
+ PROD: 1};
234
+ var classifyTime = (timestamp) => {
235
+ const now = dayjs();
236
+ const target = dayjs(timestamp);
237
+ if (target.isSame(now, "day")) {
238
+ return "\u4ECA\u5929";
239
+ }
240
+ const diffInDays = now.diff(target, "day");
241
+ if (diffInDays < 7) {
242
+ return "\u6700\u8FD1 7 \u5929";
243
+ } else if (diffInDays < 30) {
244
+ return "\u6700\u8FD1 30 \u5929";
245
+ } else if (diffInDays < 180) {
246
+ return "\u6700\u8FD1\u534A\u5E74";
247
+ } else {
248
+ return "\u66F4\u65E9";
249
+ }
250
+ };
251
+ var getChatSocketUrl = (baseURL, params) => {
252
+ return buildUrlParams(params, getWebSocketUrl(`${baseURL}/ws`), "comma");
253
+ };
254
+ var getFileIcon = (extension, fontSize = 24) => {
255
+ const baseStyle = { fontSize };
256
+ const createIcon = (Icon, color) => React10__default.createElement(Icon, { style: { ...baseStyle, color } });
257
+ if (["png", "jpg", "jpeg", "gif", "bmp", "webp", "svg"].includes(extension)) {
258
+ return createIcon(FileImageOutlined, "#22c55e");
259
+ }
260
+ if (["pdf"].includes(extension)) {
261
+ return createIcon(FilePdfOutlined, "#ef4444");
262
+ }
263
+ if (["doc", "docx"].includes(extension)) {
264
+ return createIcon(FileWordOutlined, "#2563eb");
265
+ }
266
+ if (["xls", "xlsx", "csv"].includes(extension)) {
267
+ return createIcon(FileExcelOutlined, "#16a34a");
268
+ }
269
+ if (["ppt", "pptx"].includes(extension)) {
270
+ return createIcon(FilePptOutlined, "#f59e0b");
271
+ }
272
+ if (["zip", "rar", "7z", "tar", "gz"].includes(extension)) {
273
+ return createIcon(FileZipOutlined, "#8b5cf6");
274
+ }
275
+ if (["txt", "md", "log", "json", "yaml", "yml", "xml", "ini", "conf"].includes(extension)) {
276
+ return createIcon(FileTextOutlined, "#64748b");
277
+ }
278
+ return createIcon(FileUnknownOutlined, "#94a3b8");
279
+ };
280
+ function FilePickerMenu({
281
+ options,
282
+ selectedIndex,
283
+ onSelect,
284
+ onHover
285
+ }) {
286
+ return /* @__PURE__ */ jsx("div", { className: index_module_default.fileMenu, role: "listbox", children: options.map((option, index) => /* @__PURE__ */ jsxs(
287
+ "div",
288
+ {
289
+ role: "option",
290
+ "aria-selected": index === selectedIndex,
291
+ className: `${index_module_default.fileMenuItem} ${index === selectedIndex ? index_module_default.fileMenuItemActive : ""}`,
292
+ onMouseEnter: () => onHover(index),
293
+ onClick: () => onSelect(option),
294
+ children: [
295
+ /* @__PURE__ */ jsx("span", { children: getFileIcon(option.ext || getFileSuffixName(option.label), 14) }),
296
+ /* @__PURE__ */ jsx("span", { className: index_module_default.fileName, children: option.label })
297
+ ]
298
+ },
299
+ option.value
300
+ )) });
301
+ }
302
+ function ResourcePickerMenu({
303
+ anchorElementRef,
304
+ children
305
+ }) {
306
+ const menuRef = useRef(null);
307
+ const [placement, setPlacement] = useState("bottom");
308
+ useLayoutEffect(() => {
309
+ const anchor = anchorElementRef.current;
310
+ const menu = menuRef.current;
311
+ if (!anchor || !menu) return;
312
+ const updatePlacement = () => {
313
+ const anchorRect = anchor.getBoundingClientRect();
314
+ const menuHeight = Math.min(menu.scrollHeight, 256);
315
+ const spaceBelow = window.innerHeight - anchorRect.bottom;
316
+ const spaceAbove = anchorRect.top;
317
+ setPlacement(spaceBelow < menuHeight + 8 && spaceAbove > spaceBelow ? "top" : "bottom");
318
+ };
319
+ updatePlacement();
320
+ window.addEventListener("resize", updatePlacement);
321
+ return () => window.removeEventListener("resize", updatePlacement);
322
+ }, [anchorElementRef, children]);
323
+ return /* @__PURE__ */ jsx("div", { ref: menuRef, className: index_module_default.resourceSelect, "data-placement": placement, onMouseDown: (event) => event.preventDefault(), children });
324
+ }
325
+ function formatResourceName(resourceName) {
326
+ const lastDotIndex = resourceName.lastIndexOf(".");
327
+ const hasExtension = lastDotIndex > 0 && lastDotIndex < resourceName.length - 1;
328
+ const name = hasExtension ? resourceName.slice(0, lastDotIndex) : resourceName;
329
+ const extension = hasExtension ? resourceName.slice(lastDotIndex) : "";
330
+ if (name.length <= 6) return `${name}${extension}`;
331
+ return `${name.slice(0, 3)}***${name.slice(-3)}${extension}`;
332
+ }
333
+ function ResourceTag({ resource }) {
334
+ const [editor] = useLexicalComposerContext();
335
+ const handleClose = (event) => {
336
+ event.preventDefault();
337
+ event.stopPropagation();
338
+ editor.update(() => {
339
+ const node = $getNodeByKey(resource.nodeKey);
340
+ node?.remove();
341
+ });
342
+ };
343
+ return /* @__PURE__ */ jsx("div", { className: index_module_default.resourceTag, children: /* @__PURE__ */ jsxs(Tag, { closeIcon: true, color: "blue", onClose: handleClose, children: [
344
+ resource.resourceLabel,
345
+ "\uFF1A",
346
+ formatResourceName(resource.resourceName)
347
+ ] }) });
348
+ }
349
+ var EMPTY_CASCADE_OPTION_VALUE = "__empty__";
350
+ var VariableNode = class _VariableNode extends DecoratorNode {
351
+ __resourceLabel;
352
+ __resourceType;
353
+ __resourceName;
354
+ __resourceId;
355
+ /**
356
+ * 返回当前自定义节点的唯一类型标识,供 Lexical 注册和反序列化使用。
357
+ */
358
+ static getType() {
359
+ return "variable";
360
+ }
361
+ /**
362
+ * 基于现有节点创建一个内容完全一致的新节点实例。
363
+ */
364
+ static clone(node) {
365
+ return new _VariableNode(node.__resourceLabel, node.__resourceName, node.__resourceType, node.__resourceId, node.__key);
366
+ }
367
+ /**
368
+ * 初始化变量节点,并保存标签展示与序列化所需的资源信息。
369
+ */
370
+ constructor(resourceLabel, resourceName, resourceType, resourceId, key) {
371
+ super(key);
372
+ this.__resourceLabel = resourceLabel;
373
+ this.__resourceType = resourceType;
374
+ this.__resourceName = resourceName;
375
+ this.__resourceId = resourceId;
376
+ }
377
+ /**
378
+ * 创建节点对应的宿主 DOM,用于承载后续的 React 装饰器内容。
379
+ */
380
+ createDOM() {
381
+ const span = document.createElement("span");
382
+ span.style.display = "inline-block";
383
+ span.style.verticalAlign = "middle";
384
+ return span;
385
+ }
386
+ /**
387
+ * 当前节点的 DOM 不依赖增量更新,始终交由 Lexical 复用现有 DOM。
388
+ */
389
+ updateDOM() {
390
+ return false;
391
+ }
392
+ /**
393
+ * 声明当前节点是行内节点,这样它可以和普通文本一起排版。
394
+ */
395
+ isInline() {
396
+ return true;
397
+ }
398
+ /**
399
+ * 将序列化结果恢复为变量节点实例,支持编辑器内容反解析。
400
+ */
401
+ static importJSON(serializedNode) {
402
+ return $createVariableNode(serializedNode.resourceLabel, serializedNode.resourceName, serializedNode.resourceType, serializedNode.resourceId);
403
+ }
404
+ /**
405
+ * 导出节点的业务字段,供 Lexical 持久化和回显使用。
406
+ */
407
+ exportJSON() {
408
+ return {
409
+ resourceLabel: this.__resourceLabel,
410
+ resourceName: this.__resourceName,
411
+ resourceType: this.__resourceType,
412
+ resourceId: this.__resourceId,
413
+ type: "variable",
414
+ version: 1
415
+ };
416
+ }
417
+ /**
418
+ * 生成节点的纯文本表达,便于发送、存储和重新初始化编辑器内容。
419
+ */
420
+ getTextContent() {
421
+ return `${this.__resourceType}://${this.__resourceId}?name=${this.__resourceName}&label=${this.__resourceLabel}`;
422
+ }
423
+ /**
424
+ * 将变量节点渲染为可交互的资源标签组件。
425
+ */
426
+ decorate() {
427
+ const resource = {
428
+ resourceLabel: this.__resourceLabel,
429
+ resourceName: this.__resourceName,
430
+ resourceType: this.__resourceType,
431
+ resourceId: this.__resourceId,
432
+ nodeKey: this.getKey()
433
+ };
434
+ return /* @__PURE__ */ jsx(ResourceTag, { resource });
435
+ }
436
+ };
437
+ function $createVariableNode(resourceLabel, resourceName, resourceType, resourceId) {
438
+ return new VariableNode(resourceLabel, resourceName, resourceType, resourceId);
439
+ }
440
+ var CascadeOption = class extends MenuOption {
441
+ category;
442
+ item;
443
+ /**
444
+ * 将级联菜单中的父子节点包装成 Lexical 菜单选项对象。
445
+ */
446
+ constructor(category, item) {
447
+ super(`${category.value}:${item.value}`);
448
+ this.category = category;
449
+ this.item = item;
450
+ }
451
+ };
452
+ var FileOption = class extends MenuOption {
453
+ file;
454
+ /**
455
+ * 将文件列表项包装成 Lexical 菜单选项对象。
456
+ */
457
+ constructor(file) {
458
+ super(file.value);
459
+ this.file = file;
460
+ }
461
+ };
462
+ function VariablePickerPlugin({ commandConfig = {} }) {
463
+ const [editor] = useLexicalComposerContext();
464
+ const chatStore = useChatStore();
465
+ const [commandDataSource, setCommandDataSource] = useState(commandConfig);
466
+ const [queryString, setQueryString] = useState(null);
467
+ const [isEditorFocused, setIsEditorFocused] = useState(false);
468
+ const blurTimerRef = useRef(null);
469
+ useEffect(() => {
470
+ const unregister = mergeRegister(
471
+ editor.registerCommand(
472
+ FOCUS_COMMAND,
473
+ () => {
474
+ if (blurTimerRef.current) clearTimeout(blurTimerRef.current);
475
+ setIsEditorFocused(true);
476
+ return false;
477
+ },
478
+ COMMAND_PRIORITY_LOW
479
+ ),
480
+ editor.registerCommand(
481
+ BLUR_COMMAND,
482
+ () => {
483
+ setIsEditorFocused(false);
484
+ return false;
485
+ },
486
+ COMMAND_PRIORITY_LOW
487
+ )
488
+ );
489
+ return () => {
490
+ if (blurTimerRef.current) clearTimeout(blurTimerRef.current);
491
+ unregister();
492
+ };
493
+ }, [editor]);
494
+ useEffect(() => {
495
+ setCommandDataSource(commandConfig);
496
+ }, [commandConfig]);
497
+ const commandKey = queryString?.[0] || "";
498
+ const categoryConfig = useMemo(
499
+ () => ({
500
+ skill: {
501
+ load: () => chatStore.config.services.request.listSkills(),
502
+ getLabel: (item) => item.aliasName || item.name
503
+ },
504
+ knowledge: {
505
+ load: () => chatStore.config.services.request.listLibrarys({ libraryType: 1 /* KNOWLEDGE */ }),
506
+ getLabel: (item) => item.name
507
+ },
508
+ datasource: {
509
+ load: () => chatStore.config.services.request.listDataSources(),
510
+ getLabel: (item) => item.name
511
+ }
512
+ }),
513
+ [chatStore]
514
+ );
515
+ const commandOptions = useMemo(() => {
516
+ if (!isEditorFocused) return [];
517
+ return (commandDataSource[commandKey]?.dataSource || []).flatMap(
518
+ (category) => category.children?.filter((item) => !item.disabled).map((item) => new CascadeOption(category, item)) || []
519
+ );
520
+ }, [commandDataSource, commandKey, isEditorFocused]);
521
+ const formatDataSource = useCallback(
522
+ (items, category) => {
523
+ const currentCategoryConfig = categoryConfig[category.value];
524
+ if (!items.length) {
525
+ return [
526
+ {
527
+ value: EMPTY_CASCADE_OPTION_VALUE,
528
+ label: "\u6682\u65E0\u6570\u636E",
529
+ isLeaf: true,
530
+ disabled: true
531
+ }
532
+ ];
533
+ }
534
+ return items.map((item) => ({
535
+ value: item.id,
536
+ label: currentCategoryConfig?.getLabel(item) || item.name
537
+ }));
538
+ },
539
+ [categoryConfig]
540
+ );
541
+ const loadData = useCallback(
542
+ (selectedOptions) => {
543
+ const category = selectedOptions[selectedOptions.length - 1];
544
+ if (!category || category.children?.length || category.isLeaf) return;
545
+ const currentCategoryConfig = categoryConfig[category.value];
546
+ if (!currentCategoryConfig) return;
547
+ currentCategoryConfig.load().then((response) => {
548
+ const items = response.data || [];
549
+ setCommandDataSource((current) => ({
550
+ ...current,
551
+ [commandKey]: {
552
+ ...current[commandKey],
553
+ dataSource: current[commandKey]?.dataSource?.map(
554
+ (item) => item.value === category.value ? { ...item, children: formatDataSource(items, category) } : item
555
+ ) || []
556
+ }
557
+ }));
558
+ });
559
+ },
560
+ [categoryConfig, commandKey, formatDataSource]
561
+ );
562
+ const onSelectOption = useCallback(
563
+ (selectedOption, nodeToReplace, closeMenu, matchingString) => {
564
+ const resource = selectedOption instanceof FileOption ? selectedOption.file : selectedOption.item;
565
+ const resourceLabel = selectedOption instanceof FileOption ? "\u6587\u4EF6" : selectedOption.category.label;
566
+ const resourceType = selectedOption instanceof FileOption ? "file" : selectedOption.category.value;
567
+ editor.update(() => {
568
+ const variableNode = $createVariableNode(resourceLabel, resource.label, resourceType, resource.value);
569
+ if (nodeToReplace) {
570
+ nodeToReplace.replace(variableNode);
571
+ variableNode.selectNext();
572
+ }
573
+ });
574
+ closeMenu();
575
+ },
576
+ [commandDataSource, editor]
577
+ );
578
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
579
+ LexicalTypeaheadMenuPlugin,
580
+ {
581
+ onQueryChange: (query) => setQueryString(query),
582
+ onSelectOption,
583
+ triggerFn: (text) => {
584
+ const match = new RegExp(
585
+ `(?:${Object.keys(commandConfig).map((key) => key.replace(/[.*+?^${}()|[\\]\\]/g, "\\$&")).join("|")})([^\\s]*)$`
586
+ ).exec(text);
587
+ if (!match) return null;
588
+ return { leadOffset: match.index, matchingString: match[0], replaceableString: match[0] };
589
+ },
590
+ options: commandOptions.map((option) => new CascadeOption(option.category, option.item)),
591
+ menuRenderFn: (anchorElementRef, { selectedIndex, setHighlightedIndex, selectOptionAndCleanUp }, matchingString) => {
592
+ if (!anchorElementRef.current) return null;
593
+ return ReactDOM.createPortal(
594
+ /* @__PURE__ */ jsxs(ResourcePickerMenu, { anchorElementRef, children: [
595
+ commandDataSource[matchingString]?.component === "cascade" && /* @__PURE__ */ jsx(
596
+ Cascader.Panel,
597
+ {
598
+ options: commandDataSource[matchingString]?.dataSource,
599
+ expandTrigger: "hover",
600
+ loadData,
601
+ onChange: (value) => {
602
+ const [categoryValue, itemValue] = value;
603
+ const option = commandOptions.find(
604
+ (currentOption) => currentOption.category.value === categoryValue && currentOption.item.value === itemValue
605
+ );
606
+ if (option) selectOptionAndCleanUp(option);
607
+ }
608
+ }
609
+ ),
610
+ commandDataSource[matchingString]?.component === "list" && /* @__PURE__ */ jsx(
611
+ FilePickerMenu,
612
+ {
613
+ options: commandDataSource[matchingString]?.dataSource || [],
614
+ selectedIndex: selectedIndex ?? 0,
615
+ onHover: setHighlightedIndex,
616
+ onSelect: (option) => selectOptionAndCleanUp(new FileOption(option))
617
+ }
618
+ )
619
+ ] }),
620
+ anchorElementRef.current
621
+ );
622
+ }
623
+ }
624
+ ) });
625
+ }
626
+ function InitialStatePlugin({ value }) {
627
+ const [editor] = useLexicalComposerContext();
628
+ function parseAndAppendNodes(paragraph, value2) {
629
+ const variableRegex = /\/(\w+):\/\/([^?\s]+)\?name=([^&\s]+)&label=([^\s]+)/g;
630
+ let lastIndex = 0;
631
+ let match;
632
+ while ((match = variableRegex.exec(value2)) !== null) {
633
+ if (match.index > lastIndex) {
634
+ paragraph.append($createTextNode(value2.substring(lastIndex, match.index)));
635
+ }
636
+ paragraph.append($createVariableNode(decodeURIComponent(match[4]), decodeURIComponent(match[3]), match[1], match[2]));
637
+ lastIndex = variableRegex.lastIndex;
638
+ }
639
+ if (lastIndex < value2.length) {
640
+ paragraph.append($createTextNode(value2.substring(lastIndex)));
641
+ }
642
+ }
643
+ useEffect(() => {
644
+ if (value === null || value === void 0) return;
645
+ editor.update(() => {
646
+ const root = $getRoot();
647
+ const currentText = root.getTextContent();
648
+ if (currentText === value) {
649
+ return;
650
+ }
651
+ root.clear();
652
+ const paragraph = $createParagraphNode();
653
+ parseAndAppendNodes(paragraph, value);
654
+ root.append(paragraph);
655
+ });
656
+ }, [editor, value]);
657
+ return null;
658
+ }
659
+ var ChatInput = React10.forwardRef(
206
660
  ({
661
+ value = "",
662
+ commandConfig,
663
+ onChange,
207
664
  placeholder,
665
+ className,
666
+ style,
667
+ disabled,
668
+ readOnly,
669
+ onFocus,
670
+ onBlur,
671
+ onKeyDown,
672
+ onKeyUp,
673
+ onPaste,
674
+ onCompositionStart,
675
+ onCompositionEnd
676
+ }, ref) => {
677
+ const contentEditableRef = useRef(null);
678
+ const stringValue = typeof value === "string" ? value : "";
679
+ const initialConfig = {
680
+ namespace: "ChatInput",
681
+ onError: (error) => console.error(error),
682
+ nodes: [VariableNode],
683
+ editable: !disabled && !readOnly
684
+ };
685
+ useImperativeHandle(ref, () => ({
686
+ focus: () => contentEditableRef.current?.focus(),
687
+ blur: () => contentEditableRef.current?.blur(),
688
+ nativeElement: contentEditableRef.current
689
+ }));
690
+ const handleOnChange = (editorState) => {
691
+ editorState.read(() => {
692
+ const nextValue = $getRoot().getTextContent();
693
+ if (nextValue !== stringValue && onChange) {
694
+ onChange({ target: { value: nextValue } });
695
+ }
696
+ });
697
+ };
698
+ return /* @__PURE__ */ jsx("div", { className: index_module_default.promptEditorInputContainer, onClick: () => contentEditableRef.current?.focus(), children: /* @__PURE__ */ jsxs(LexicalComposer, { initialConfig, children: [
699
+ /* @__PURE__ */ jsx(
700
+ RichTextPlugin,
701
+ {
702
+ contentEditable: /* @__PURE__ */ jsx(
703
+ ContentEditable,
704
+ {
705
+ ref: contentEditableRef,
706
+ className: [`${className || ""}`, "ant-sender-input", index_module_default.promptEditorContent].filter(Boolean).join(" "),
707
+ style,
708
+ contentEditable: !disabled && !readOnly,
709
+ suppressContentEditableWarning: true,
710
+ role: "textbox",
711
+ "aria-multiline": "true",
712
+ tabIndex: !disabled && !readOnly ? 0 : -1,
713
+ onMouseDown: (event) => {
714
+ if (!disabled && !readOnly) {
715
+ event.stopPropagation();
716
+ }
717
+ },
718
+ onFocus: (event) => onFocus?.(event),
719
+ onBlur: (event) => onBlur?.(event),
720
+ onKeyDown: (event) => onKeyDown?.(event),
721
+ onKeyUp: (event) => onKeyUp?.(event),
722
+ onPaste: (event) => onPaste?.(event),
723
+ onCompositionStart: (event) => onCompositionStart?.(event),
724
+ onCompositionEnd: (event) => {
725
+ onCompositionEnd?.(event);
726
+ }
727
+ }
728
+ ),
729
+ placeholder: !stringValue && placeholder ? /* @__PURE__ */ jsx("div", { className: index_module_default.promptEditorPlaceholder, children: placeholder }) : /* @__PURE__ */ jsx("div", { className: index_module_default.promptEditorPlaceholder, children: "\u4ECA\u5929\u80FD\u5E2E\u4F60\u505A\u4EC0\u4E48\uFF1F" }),
730
+ ErrorBoundary: LexicalErrorBoundary
731
+ }
732
+ ),
733
+ /* @__PURE__ */ jsx(HistoryPlugin, {}),
734
+ /* @__PURE__ */ jsx(VariablePickerPlugin, { commandConfig }),
735
+ /* @__PURE__ */ jsx(OnChangePlugin, { onChange: handleOnChange }),
736
+ /* @__PURE__ */ jsx(InitialStatePlugin, { value: stringValue })
737
+ ] }) });
738
+ }
739
+ );
740
+ var ChatInput_default = ChatInput;
741
+ var ChatSender_default = forwardRef(
742
+ ({
208
743
  content,
744
+ commandConfig = {},
209
745
  fileList = [],
210
746
  headerOpen = false,
211
747
  loading = false,
@@ -245,6 +781,12 @@ var ChatSender_default = forwardRef(
245
781
  }
246
782
  };
247
783
  const isFocusedRef = useRef(false);
784
+ const commandConfigRef = useRef(commandConfig);
785
+ commandConfigRef.current = commandConfig;
786
+ const inputComponent = useCallback(
787
+ (inputProps) => /* @__PURE__ */ jsx(ChatInput_default, { ...inputProps, commandConfig: commandConfigRef.current }),
788
+ []
789
+ );
248
790
  useEffect(() => {
249
791
  if (!content) return;
250
792
  if (!isFocusedRef.current) {
@@ -266,6 +808,7 @@ var ChatSender_default = forwardRef(
266
808
  /* @__PURE__ */ jsx(
267
809
  Sender,
268
810
  {
811
+ components: { input: inputComponent },
269
812
  className: styles_module_default.chatSender,
270
813
  ref: senderRef,
271
814
  value: inputValue,
@@ -294,37 +837,12 @@ var ChatSender_default = forwardRef(
294
837
  ] }),
295
838
  /* @__PURE__ */ jsx(Fragment, { children: extraFooterBelow })
296
839
  ] });
297
- },
298
- placeholder: placeholder || "\u6709\u4EC0\u4E48\u6211\u80FD\u5E2E\u60A8\u7684\u5417\uFF1F"
840
+ }
299
841
  }
300
842
  )
301
843
  );
302
844
  }
303
845
  );
304
- var classifyTime = (timestamp) => {
305
- const now = dayjs();
306
- const target = dayjs(timestamp);
307
- if (target.isSame(now, "day")) {
308
- return "\u4ECA\u5929";
309
- }
310
- const diffInDays = now.diff(target, "day");
311
- if (diffInDays < 7) {
312
- return "\u6700\u8FD1 7 \u5929";
313
- } else if (diffInDays < 30) {
314
- return "\u6700\u8FD1 30 \u5929";
315
- } else if (diffInDays < 180) {
316
- return "\u6700\u8FD1\u534A\u5E74";
317
- } else {
318
- return "\u66F4\u65E9";
319
- }
320
- };
321
- var getChatSocketUrl = (baseURL, params) => {
322
- return buildUrlParams(params, getWebSocketUrl(`${baseURL}/ws`), "comma");
323
- };
324
-
325
- // src/core/constants.ts
326
- var CONV_MODE = {
327
- PROD: 1};
328
846
  var TOKEN_KEY = "NS-TOKEN";
329
847
  var tokenManager = createTokenManager({
330
848
  key: TOKEN_KEY
@@ -333,8 +851,6 @@ var redirectUrl = () => {
333
851
  const path = localStorage.getItem("SIGNPATH");
334
852
  emit("jumpLink", { url: `/uc${path || "/sign-in"}` });
335
853
  };
336
-
337
- // src/services/index.ts
338
854
  var createChatService = (request, config) => {
339
855
  const fetchModelList = () => {
340
856
  return request.get(`/providers/models/type/llm`);
@@ -366,8 +882,8 @@ var createChatService = (request, config) => {
366
882
  const feedbackUpdate = (params) => {
367
883
  return request.put(`/agents/messages/${params.executionId}/feedback`, params);
368
884
  };
369
- const chatUpload = (agentId, data, conversationId, signal) => {
370
- return request.post(`/agents/${agentId}/${conversationId}/files`, data, {
885
+ const chatUpload = (params, data, signal) => {
886
+ return request.post(buildUrlParams(params, "/files/upload"), data, {
371
887
  headers: {
372
888
  "Content-Type": "multipart/form-data"
373
889
  },
@@ -375,8 +891,14 @@ var createChatService = (request, config) => {
375
891
  signal
376
892
  });
377
893
  };
378
- const getPreviewUrl = (agentId, conversationId, path) => {
379
- return `${config?.baseURL}/agents/${agentId}/${conversationId}/files/download?path=${path}&${TOKEN_KEY}=${tokenManager.get()}`;
894
+ const getPreviewUrl = (conversationId, path) => {
895
+ const params = {
896
+ path,
897
+ [TOKEN_KEY]: tokenManager.get(),
898
+ workspaceId: conversationId,
899
+ workspaceType: "conversation" /* CONVERSATION */
900
+ };
901
+ return buildUrlParams(params, `${config?.baseURL}/files/access`);
380
902
  };
381
903
  const docQuery = (params) => {
382
904
  return request.get(`/library/cloud/document?${params}`);
@@ -390,8 +912,11 @@ var createChatService = (request, config) => {
390
912
  const listTags = (params) => {
391
913
  return request.get(`/tags`, { tagType: params.tagType });
392
914
  };
915
+ const listDataSources = () => {
916
+ return request.get(`/datasource`);
917
+ };
393
918
  const getAgentAvatar = (path) => {
394
- return request.get(`/files/download?path=${path}`, void 0, { responseType: "blob" });
919
+ return request.get(`/files/access?path=${path}&workspaceType=${"global" /* GLOBAL */}`, void 0, { responseType: "blob" });
395
920
  };
396
921
  return {
397
922
  fetchModelList,
@@ -409,6 +934,7 @@ var createChatService = (request, config) => {
409
934
  docQuery,
410
935
  listSkills,
411
936
  listLibrarys,
937
+ listDataSources,
412
938
  listTags,
413
939
  getAgentAvatar
414
940
  };
@@ -1869,11 +2395,11 @@ function exportJsonFile(data, fileName) {
1869
2395
  exportTextFile(json, fileName, "application/json;charset=utf-8");
1870
2396
  }
1871
2397
  var ChartViewer = ({ artifactId, title, payload }) => {
1872
- const containerRef = React7.useRef(null);
1873
- const [containerWidth, setContainerWidth] = React7.useState(0);
2398
+ const containerRef = React10__default.useRef(null);
2399
+ const [containerWidth, setContainerWidth] = React10__default.useState(0);
1874
2400
  const spec = payload?.spec;
1875
2401
  const needsContainerWidth = true;
1876
- React7.useLayoutEffect(() => {
2402
+ React10__default.useLayoutEffect(() => {
1877
2403
  const el = containerRef.current;
1878
2404
  if (!el) return;
1879
2405
  let frame = 0;
@@ -2181,7 +2707,7 @@ var PreviewLink_default = ({ data, loading, message: message2, ...rest }) => {
2181
2707
  const fileName = getLinkFileName(href);
2182
2708
  const suffix = getFileSuffixName(fileName);
2183
2709
  chatStore.setPreview({
2184
- fileUrl: chatStore.config.services.request.getPreviewUrl(message2.agentId, message2.conversationId, href),
2710
+ fileUrl: chatStore.config.services.request.getPreviewUrl(message2.conversationId, href),
2185
2711
  fileName,
2186
2712
  suffix
2187
2713
  });
@@ -2514,8 +3040,8 @@ function useBoundFieldState({
2514
3040
  const valuePath = decodeBindPathToken(bindPathToken) ?? pathFromValue(value);
2515
3041
  const cachedValue = readCachedValue(readPathValue(valuePath));
2516
3042
  const externalValue = readExternalValue(value);
2517
- const dirtyRef = React7.useRef(false);
2518
- const [localValue, setLocalValue] = React7.useState(() => {
3043
+ const dirtyRef = React10__default.useRef(false);
3044
+ const [localValue, setLocalValue] = React10__default.useState(() => {
2519
3045
  if (valuePath && cachedValue !== void 0) {
2520
3046
  return cachedValue;
2521
3047
  }
@@ -2528,10 +3054,10 @@ function useBoundFieldState({
2528
3054
  if (cachedValue !== void 0) return cachedValue;
2529
3055
  return defaultValue;
2530
3056
  });
2531
- React7.useEffect(() => {
3057
+ React10__default.useEffect(() => {
2532
3058
  dirtyRef.current = false;
2533
3059
  }, [valuePath]);
2534
- React7.useEffect(() => {
3060
+ React10__default.useEffect(() => {
2535
3061
  if (valuePath && cachedValue !== void 0) {
2536
3062
  setLocalValue(cachedValue);
2537
3063
  return;
@@ -2555,10 +3081,10 @@ function useBoundFieldState({
2555
3081
  setLocalValue(cachedValue);
2556
3082
  }
2557
3083
  }, [cachedValue, externalValue, preferCachedOverExternal, valuePath]);
2558
- React7.useEffect(() => {
3084
+ React10__default.useEffect(() => {
2559
3085
  rememberPathValue(valuePath, localValue);
2560
3086
  }, [valuePath, localValue]);
2561
- const updateLocalValue = React7.useCallback(
3087
+ const updateLocalValue = React10__default.useCallback(
2562
3088
  (nextValue) => {
2563
3089
  dirtyRef.current = true;
2564
3090
  setLocalValue(nextValue);
@@ -2578,7 +3104,7 @@ function emitFieldChange(nextValue, valuePath, updateLocalValue, onDataChange, o
2578
3104
  onChange?.(nextValue);
2579
3105
  }
2580
3106
  function useControlId(id) {
2581
- const autoId = React7.useId();
3107
+ const autoId = React10__default.useId();
2582
3108
  return id ?? autoId;
2583
3109
  }
2584
3110
  function readActionEvent(action) {
@@ -2679,7 +3205,7 @@ var Button9 = ({ label, variant = "default", onClick, action, onAction }) => {
2679
3205
  return /* @__PURE__ */ jsx(Button, { type: variant === "primary" ? "primary" : "default", danger: variant === "danger", onClick: handleClick, style: { borderRadius: 8 }, children: label });
2680
3206
  };
2681
3207
  var Divider = () => /* @__PURE__ */ jsx(Divider$1, { style: { margin: "8px 0" } });
2682
- var Tag2 = ({ text, color }) => /* @__PURE__ */ jsx(Tag, { color, children: text });
3208
+ var Tag3 = ({ text, color }) => /* @__PURE__ */ jsx(Tag, { color, children: text });
2683
3209
  var Progress = ({
2684
3210
  percent,
2685
3211
  status = "normal",
@@ -2697,7 +3223,7 @@ var A2uiComponents = {
2697
3223
  Switch,
2698
3224
  Button: Button9,
2699
3225
  Divider,
2700
- Tag: Tag2,
3226
+ Tag: Tag3,
2701
3227
  Progress,
2702
3228
  ArtifactCard,
2703
3229
  TableViewer,
@@ -3432,7 +3958,7 @@ function useA2uiController(params) {
3432
3958
  handleRuntimeAction
3433
3959
  };
3434
3960
  }
3435
- var A2uiRuntimeContext = React7.createContext({
3961
+ var A2uiRuntimeContext = React10__default.createContext({
3436
3962
  commands: [],
3437
3963
  onAction: () => void 0,
3438
3964
  surfaceIdsByMessageIndex: {}
@@ -3440,7 +3966,7 @@ var A2uiRuntimeContext = React7.createContext({
3440
3966
 
3441
3967
  // src/components/CustomComponents/A2uiRuntime/renderer/useA2uiRuntimeView.ts
3442
3968
  function useA2uiRuntimeView() {
3443
- return React7.useContext(A2uiRuntimeContext);
3969
+ return React10__default.useContext(A2uiRuntimeContext);
3444
3970
  }
3445
3971
  function A2uiMessageCards({ messageIndex }) {
3446
3972
  const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
@@ -3654,19 +4180,19 @@ function A2uiRuntimeProvider({ messages, children }) {
3654
4180
  const chatStore = useChatStore();
3655
4181
  const conversationState = useSnapshot(chatStore.conversation);
3656
4182
  const conversationId = conversationState.active.id;
3657
- const processedMessageCursorsRef = React7.useRef([]);
3658
- const latestCommandIndexBySurfaceRef = React7.useRef({});
3659
- const commandIndexRef = React7.useRef(-1);
3660
- const [latestCommandIndexBySurface, setLatestCommandIndexBySurface] = React7.useState({});
3661
- const [dismissedAtBySurface, setDismissedAtBySurface] = React7.useState({});
3662
- React7.useEffect(() => {
4183
+ const processedMessageCursorsRef = React10__default.useRef([]);
4184
+ const latestCommandIndexBySurfaceRef = React10__default.useRef({});
4185
+ const commandIndexRef = React10__default.useRef(-1);
4186
+ const [latestCommandIndexBySurface, setLatestCommandIndexBySurface] = React10__default.useState({});
4187
+ const [dismissedAtBySurface, setDismissedAtBySurface] = React10__default.useState({});
4188
+ React10__default.useEffect(() => {
3663
4189
  processedMessageCursorsRef.current = [];
3664
4190
  latestCommandIndexBySurfaceRef.current = {};
3665
4191
  commandIndexRef.current = -1;
3666
4192
  setLatestCommandIndexBySurface({});
3667
4193
  setDismissedAtBySurface({});
3668
4194
  }, [conversationId]);
3669
- React7.useEffect(() => {
4195
+ React10__default.useEffect(() => {
3670
4196
  const { shouldReplayAll, nextCursors, pendingItems } = diffMessages(messages, processedMessageCursorsRef.current);
3671
4197
  const itemsToProcess = shouldReplayAll ? messages.flatMap((message2) => {
3672
4198
  const items = Array.isArray(message2?.content) ? message2.content : [];
@@ -3689,10 +4215,10 @@ function A2uiRuntimeProvider({ messages, children }) {
3689
4215
  commandIndexRef.current = nextCommandIndex;
3690
4216
  setLatestCommandIndexBySurface(nextLatestCommandIndexBySurface);
3691
4217
  }, [messages]);
3692
- const dismissedSurfaceIds = React7.useMemo(() => {
4218
+ const dismissedSurfaceIds = React10__default.useMemo(() => {
3693
4219
  return Object.entries(dismissedAtBySurface).filter(([surfaceId, dismissedAt]) => (latestCommandIndexBySurface[surfaceId] ?? -1) <= dismissedAt).map(([surfaceId]) => surfaceId);
3694
4220
  }, [dismissedAtBySurface, latestCommandIndexBySurface]);
3695
- const dispatchA2uiAction = React7.useCallback(
4221
+ const dispatchA2uiAction = React10__default.useCallback(
3696
4222
  async (payload) => {
3697
4223
  const actionPayload = normalizeA2uiActionPayload(payload);
3698
4224
  if (!actionPayload.name) return;
@@ -3719,7 +4245,7 @@ function A2uiRuntimeProvider({ messages, children }) {
3719
4245
  conversationMessages: messages,
3720
4246
  dismissedSurfaceIds
3721
4247
  });
3722
- const onAction = React7.useCallback(
4248
+ const onAction = React10__default.useCallback(
3723
4249
  (payload) => {
3724
4250
  const result = handleRuntimeAction(payload);
3725
4251
  if (result.handled || !result.name) return;
@@ -3732,7 +4258,7 @@ function A2uiRuntimeProvider({ messages, children }) {
3732
4258
  },
3733
4259
  [commands, dispatchA2uiAction, handleRuntimeAction, runtimeState.modelPathBySurface]
3734
4260
  );
3735
- const contextValue = React7.useMemo(
4261
+ const contextValue = React10__default.useMemo(
3736
4262
  () => ({ commands, onAction, surfaceIdsByMessageIndex: anchoredSurfaceIdsByMessageIndex }),
3737
4263
  [anchoredSurfaceIdsByMessageIndex, commands, onAction]
3738
4264
  );
@@ -3741,14 +4267,14 @@ function A2uiRuntimeProvider({ messages, children }) {
3741
4267
  function A2uiRenderer(props) {
3742
4268
  return /* @__PURE__ */ jsx(A2uiRuntimeProvider, { ...props });
3743
4269
  }
3744
- var FilesNode = React7.memo(({ item }) => {
4270
+ var FilesNode = React10__default.memo(({ item }) => {
3745
4271
  const chatStore = useChatStore();
3746
4272
  const configState = useSnapshot(chatStore.config);
3747
- const agentState = useSnapshot(chatStore.agent);
4273
+ useSnapshot(chatStore.agent);
3748
4274
  const conversationState = useSnapshot(chatStore.conversation);
3749
4275
  const fileItems = useMemo(() => {
3750
4276
  return (item.files || []).map((file) => {
3751
- const previewUrl = configState.services.request.getPreviewUrl(agentState.agentInfo.id, conversationState.active.id, file.path);
4277
+ const previewUrl = configState.services.request.getPreviewUrl(conversationState.active.id, file.path);
3752
4278
  let fileType = "file";
3753
4279
  const ext = file.ext?.toLowerCase() || "";
3754
4280
  if (["jpg", "jpeg", "png", "gif", "bmp", "webp", "svg", "webp"].includes(ext)) {
@@ -3772,7 +4298,7 @@ var FilesNode = React7.memo(({ item }) => {
3772
4298
  // src/components/CustomComponents/MessageNode/style.module.less
3773
4299
  var style_module_default2 = {
3774
4300
  runStartedNode: "style_module_runStartedNode"};
3775
- var QuoteMsgNode = React7.memo(({ quoteMsg, role }) => {
4301
+ var QuoteMsgNode = React10__default.memo(({ quoteMsg, role }) => {
3776
4302
  if (!quoteMsg || !quoteMsg.messageContent) return null;
3777
4303
  return /* @__PURE__ */ jsx(
3778
4304
  Bubble,
@@ -3802,7 +4328,7 @@ var QuoteMsgNode = React7.memo(({ quoteMsg, role }) => {
3802
4328
  }
3803
4329
  );
3804
4330
  });
3805
- var RunStartedNode = React7.memo(({ loading }) => {
4331
+ var RunStartedNode = React10__default.memo(({ loading }) => {
3806
4332
  if (!loading) return null;
3807
4333
  return /* @__PURE__ */ jsx(Flex, { gap: 8, align: "center", className: style_module_default2.runStartedNode, children: /* @__PURE__ */ jsx(LoadingOutlined, { style: { color: "#1677ff" } }) });
3808
4334
  });
@@ -3813,7 +4339,7 @@ function QuestionSummary({ content }) {
3813
4339
  /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#262626", lineHeight: 1.6, whiteSpace: "pre-wrap" }, children: answer })
3814
4340
  ] });
3815
4341
  }
3816
- var TextNode = React7.memo(
4342
+ var TextNode2 = React10__default.memo(
3817
4343
  ({ item, role, customComponents, message: message2 }) => {
3818
4344
  const content = toA2uiDisplayText(role, item?.messageContent);
3819
4345
  if (typeof content === "string" && content.startsWith("Question:")) {
@@ -3827,7 +4353,7 @@ var TextNode = React7.memo(
3827
4353
  );
3828
4354
 
3829
4355
  // src/components/CustomComponents/ToolRenders/index.module.less
3830
- var index_module_default = {
4356
+ var index_module_default2 = {
3831
4357
  iconContainer: "index_module_iconContainer",
3832
4358
  toolName: "index_module_toolName",
3833
4359
  duration: "index_module_duration",
@@ -3845,21 +4371,21 @@ var index_module_default = {
3845
4371
  };
3846
4372
  var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
3847
4373
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3848
- (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
3849
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
3850
- /* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
4374
+ (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4375
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
4376
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
3851
4377
  ${argsContent.text}
3852
4378
  \`\`\`` : argsContent.text }) })
3853
4379
  ] }),
3854
- item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
3855
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
3856
- /* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
4380
+ item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4381
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
4382
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
3857
4383
  ${resultContent.text}
3858
4384
  \`\`\`` : resultContent.text }) })
3859
4385
  ] }),
3860
- errorMessage && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
3861
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
3862
- /* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: `\`\`\`
4386
+ errorMessage && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4387
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
4388
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: `\`\`\`
3863
4389
  ${errorMessage}
3864
4390
  \`\`\`` }) })
3865
4391
  ] })
@@ -3881,18 +4407,18 @@ var TodoWriteRender = ({ args, result }) => {
3881
4407
  }
3882
4408
  };
3883
4409
  if (!todos || todos.length === 0) {
3884
- return /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", className: index_module_default.emptyText, children: "\u6682\u65E0\u4EFB\u52A1" });
4410
+ return /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", className: index_module_default2.emptyText, children: "\u6682\u65E0\u4EFB\u52A1" });
3885
4411
  }
3886
4412
  return /* @__PURE__ */ jsx(
3887
4413
  List,
3888
4414
  {
3889
4415
  size: "small",
3890
4416
  dataSource: todos,
3891
- renderItem: (item) => /* @__PURE__ */ jsxs(List.Item, { className: index_module_default.todoItem, children: [
3892
- /* @__PURE__ */ jsx("div", { className: index_module_default.statusIconWrapper, children: getStatusIcon(item.status) }),
3893
- /* @__PURE__ */ jsx("div", { className: index_module_default.todoContent, children: /* @__PURE__ */ jsx(Typography.Text, { className: `${index_module_default.todoText} ${item.status === "completed" ? index_module_default.completed : ""}`, children: item.title || item.content }) })
4417
+ renderItem: (item) => /* @__PURE__ */ jsxs(List.Item, { className: index_module_default2.todoItem, children: [
4418
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.statusIconWrapper, children: getStatusIcon(item.status) }),
4419
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.todoContent, children: /* @__PURE__ */ jsx(Typography.Text, { className: `${index_module_default2.todoText} ${item.status === "completed" ? index_module_default2.completed : ""}`, children: item.title || item.content }) })
3894
4420
  ] }),
3895
- className: index_module_default.todoList
4421
+ className: index_module_default2.todoList
3896
4422
  }
3897
4423
  );
3898
4424
  };
@@ -4011,10 +4537,10 @@ var ToolCallItem = ({ item }) => {
4011
4537
  key: item.toolCallId || "fallback-key",
4012
4538
  showArrow: hasContent,
4013
4539
  label: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
4014
- /* @__PURE__ */ jsx("div", { className: index_module_default.iconContainer, children: renderIcon() }),
4015
- /* @__PURE__ */ jsx("span", { className: index_module_default.toolName, children: item.title || item.toolName || "Unknown Tool" }),
4016
- (status === "running" || status === "pending") && /* @__PURE__ */ jsx("div", { className: index_module_default.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
4017
- item.duration && /* @__PURE__ */ jsxs(Typography.Text, { className: index_module_default.duration, children: [
4540
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.iconContainer, children: renderIcon() }),
4541
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.toolName, children: item.title || item.toolName || "Unknown Tool" }),
4542
+ (status === "running" || status === "pending") && /* @__PURE__ */ jsx("div", { className: index_module_default2.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
4543
+ item.duration && /* @__PURE__ */ jsxs(Typography.Text, { className: index_module_default2.duration, children: [
4018
4544
  item.duration,
4019
4545
  "ms"
4020
4546
  ] })
@@ -4037,7 +4563,7 @@ var ToolCallItem = ({ item }) => {
4037
4563
  };
4038
4564
  var tool_call_item_default = ToolCallItem;
4039
4565
  var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "files", "plan"];
4040
- var MessageRender_default = React7.memo(({ role, message: message2, messageIndex = -1, loading, containerRef, customComponents }) => {
4566
+ var MessageRender_default = React10__default.memo(({ role, message: message2, messageIndex = -1, loading, containerRef, customComponents }) => {
4041
4567
  const content = useMemo(() => {
4042
4568
  return (message2.content || []).filter((item) => {
4043
4569
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
@@ -4077,7 +4603,7 @@ var MessageRender_default = React7.memo(({ role, message: message2, messageIndex
4077
4603
  content: /* @__PURE__ */ jsxs(Fragment, { children: [
4078
4604
  item.type === "runStarted" && /* @__PURE__ */ jsx(RunStartedNode, { loading }, `flow-start-${index}`),
4079
4605
  (item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
4080
- item.type === "text" && /* @__PURE__ */ jsx(TextNode, { item, role: message2.role, customComponents, message: message2 }, `message-${index}`),
4606
+ item.type === "text" && /* @__PURE__ */ jsx(TextNode2, { item, role: message2.role, customComponents, message: message2 }, `message-${index}`),
4081
4607
  item.type === "stepError" && (item.errorMessage ? /* @__PURE__ */ jsx(XMarkdown_default, { message: message2, components: customComponents, content: item.errorMessage }) : null),
4082
4608
  item.type === "files" && /* @__PURE__ */ jsx(FilesNode, { item }, `files-${index}`),
4083
4609
  item.type === "plan" && /* @__PURE__ */ jsx(A2uiPlanNode, { item }, `plan-${index}`)
@@ -4721,13 +5247,21 @@ var ChatSender_default2 = forwardRef(
4721
5247
  reasonBtn = true,
4722
5248
  skillsBtn = false,
4723
5249
  knowledgeBtn = false,
4724
- modelSelect = false
5250
+ modelSelect = false,
5251
+ commandConfig = {}
4725
5252
  }, ref) => {
4726
5253
  const chatStore = useChatStore();
4727
5254
  const configState = useSnapshot(chatStore.config);
4728
5255
  const agentState = useSnapshot(chatStore.agent);
4729
5256
  const conversationState = useSnapshot(chatStore.conversation);
4730
- const fileUploadRequest = (formData, signal) => configState.services.request.chatUpload(agentState.agentInfo.id, formData, conversationState.active.id, signal);
5257
+ const fileUploadRequest = (formData, signal) => {
5258
+ const params = {
5259
+ workspaceType: "conversation" /* CONVERSATION */,
5260
+ agentId: agentState.agentInfo.id,
5261
+ workspaceId: conversationState.active.id
5262
+ };
5263
+ return configState.services.request.chatUpload(params, formData, signal);
5264
+ };
4731
5265
  const chatMessage = useMemo(
4732
5266
  () => conversationState.messages[conversationState.active.id] || {},
4733
5267
  [conversationState.messages[conversationState.active.id]]
@@ -4747,6 +5281,7 @@ var ChatSender_default2 = forwardRef(
4747
5281
  ChatSender_default,
4748
5282
  {
4749
5283
  ref,
5284
+ commandConfig,
4750
5285
  placeholder,
4751
5286
  content: chatMessage.content,
4752
5287
  fileList: chatMessage.files,
@@ -4916,7 +5451,7 @@ var ChatPreviewPanel = memo(({ file }) => {
4916
5451
  var ChatPreviewPanel_default = ChatPreviewPanel;
4917
5452
 
4918
5453
  // src/ui/layouts/index.module.less
4919
- var index_module_default2 = {
5454
+ var index_module_default3 = {
4920
5455
  chatLayout: "index_module_chatLayout",
4921
5456
  animatedSplitter: "index_module_animatedSplitter",
4922
5457
  hideSplitterBar: "index_module_hideSplitterBar"
@@ -5007,12 +5542,12 @@ var layouts_default = forwardRef(({ theme: theme4, params, hooks, layout, config
5007
5542
  useEffect(() => {
5008
5543
  hooks?.onBeforeInit?.();
5009
5544
  }, []);
5010
- return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: {}, ...theme4 }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: configState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2(index_module_default2.chatLayout, "zero-chat-layout", "height-full"), children: [
5545
+ return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: {}, ...theme4 }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: configState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2(index_module_default3.chatLayout, "zero-chat-layout", "height-full"), children: [
5011
5546
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
5012
5547
  /* @__PURE__ */ jsxs(Flex, { ref: containerRef, className: "full-scroll", children: [
5013
5548
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.leftPanel }),
5014
5549
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.conversationList, DefaultComponent: ConversationListPanel_default }),
5015
- /* @__PURE__ */ jsxs(Splitter, { className: classNames2("flex-1", index_module_default2.animatedSplitter, { [index_module_default2.hideSplitterBar]: !hasPreView }), children: [
5550
+ /* @__PURE__ */ jsxs(Splitter, { className: classNames2("flex-1", index_module_default3.animatedSplitter, { [index_module_default3.hideSplitterBar]: !hasPreView }), children: [
5016
5551
  /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsx(ChatMainPanel_default, { ref: senderRef }) }),
5017
5552
  /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, min: 600, size: sizes[0], children: /* @__PURE__ */ jsx(ChatPreviewPanel_default, { file: configState.preview.file }) })
5018
5553
  ] })