@zero-library/chat-copilot 3.1.2 → 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.esm.js CHANGED
@@ -1,12 +1,24 @@
1
- import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, LoadingOutlined, EnterOutlined, DownloadOutlined, CloseOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, PlayCircleOutlined, DotChartOutlined, 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
- import { useRefState, useDebounce, useSyncInput, createTokenManager, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, isBoolean, UserAvatar, htmlToMarkdown, copyText, FileIcon, LazyComponent, deepCopy, transforms, deepMerge, buildUrlParams, createRequest, HttpStatus, isArray, isString, isExternal, transform, emit, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
- import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Image as Image$1, Popover, Skeleton, Alert, Modal, Checkbox, Input, Empty, message, Drawer, 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';
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, 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
+ fileMenu: "index_module_fileMenu",
221
+ fileMenuItem: "index_module_fileMenuItem",
222
+ fileMenuItemActive: "index_module_fileMenuItemActive",
223
+ fileName: "index_module_fileName",
224
+ resourceSelect: "index_module_resourceSelect",
225
+ promptEditorInputContainer: "index_module_promptEditorInputContainer",
226
+ promptEditorContent: "index_module_promptEditorContent",
227
+ promptEditorPlaceholder: "index_module_promptEditorPlaceholder",
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 (!isEditorFocused || !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
  });
@@ -2278,16 +2804,16 @@ function preprocessCustomTagPayloads(content = "", payloadTagPattern) {
2278
2804
  payloadMap
2279
2805
  };
2280
2806
  }
2281
- var adaptMarkdownComponent = (Component, payloadMap = /* @__PURE__ */ new Map(), message2) => {
2807
+ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
2282
2808
  const WrappedComponent = ({ children, streamStatus, ...rest }) => {
2283
- const rawData = resolveMappedMarkdownPayload(children, payloadMap);
2284
- return /* @__PURE__ */ jsx(Component, { message: message2, ...rest, data: rawData, loading: streamStatus === "loading" });
2809
+ const rawData = resolveMappedMarkdownPayload(children, payloadMapRef.current);
2810
+ return /* @__PURE__ */ jsx(Component, { message: messageRef.current, ...rest, data: rawData, loading: streamStatus === "loading" });
2285
2811
  };
2286
2812
  WrappedComponent.displayName = `AdaptedMarkdownComponent(${Component.displayName || Component.name || "Anonymous"})`;
2287
2813
  return WrappedComponent;
2288
2814
  };
2289
- var adaptMarkdownComponents = (components, payloadMap = /* @__PURE__ */ new Map(), message2) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMap, message2)]));
2290
- var XMarkdown_default = ({ message: message2, components = {}, content = "", ...rest }) => {
2815
+ var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
2816
+ var XMarkdown_default = memo(({ message: message2, components = {}, content = "", ...rest }) => {
2291
2817
  const config = useMemo(() => getMarkdownConfig(), []);
2292
2818
  const formattedContent = useMemo(() => formatMixedContent(content), [content]);
2293
2819
  const newComponents = useMemo(
@@ -2307,13 +2833,16 @@ var XMarkdown_default = ({ message: message2, components = {}, content = "", ...
2307
2833
  }),
2308
2834
  [components]
2309
2835
  );
2310
- const componentKeys = useMemo(() => Object.keys(newComponents), [newComponents]);
2311
- const payloadTagPattern = useMemo(() => componentKeys.join("|"), [componentKeys]);
2836
+ const payloadTagPattern = useMemo(() => Object.keys(newComponents).join("|"), [newComponents]);
2312
2837
  const { content: processedContent, payloadMap } = useMemo(
2313
2838
  () => preprocessCustomTagPayloads(formattedContent, payloadTagPattern),
2314
2839
  [formattedContent, payloadTagPattern]
2315
2840
  );
2316
- const markdownComponents = useMemo(() => adaptMarkdownComponents(newComponents, payloadMap, message2), [componentKeys, message2, payloadMap]);
2841
+ const payloadMapRef = useRef(payloadMap);
2842
+ const messageRef = useRef(message2);
2843
+ payloadMapRef.current = payloadMap;
2844
+ messageRef.current = message2;
2845
+ const markdownComponents = useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
2317
2846
  return /* @__PURE__ */ jsx(
2318
2847
  XMarkdown,
2319
2848
  {
@@ -2324,7 +2853,7 @@ var XMarkdown_default = ({ message: message2, components = {}, content = "", ...
2324
2853
  components: markdownComponents
2325
2854
  }
2326
2855
  );
2327
- };
2856
+ });
2328
2857
  var ReportViewer = ({ artifactId, title, payload }) => {
2329
2858
  const markdown = typeof payload?.markdown === "string" ? payload.markdown : null;
2330
2859
  if (!markdown) {
@@ -2511,8 +3040,8 @@ function useBoundFieldState({
2511
3040
  const valuePath = decodeBindPathToken(bindPathToken) ?? pathFromValue(value);
2512
3041
  const cachedValue = readCachedValue(readPathValue(valuePath));
2513
3042
  const externalValue = readExternalValue(value);
2514
- const dirtyRef = React7.useRef(false);
2515
- const [localValue, setLocalValue] = React7.useState(() => {
3043
+ const dirtyRef = React10__default.useRef(false);
3044
+ const [localValue, setLocalValue] = React10__default.useState(() => {
2516
3045
  if (valuePath && cachedValue !== void 0) {
2517
3046
  return cachedValue;
2518
3047
  }
@@ -2525,10 +3054,10 @@ function useBoundFieldState({
2525
3054
  if (cachedValue !== void 0) return cachedValue;
2526
3055
  return defaultValue;
2527
3056
  });
2528
- React7.useEffect(() => {
3057
+ React10__default.useEffect(() => {
2529
3058
  dirtyRef.current = false;
2530
3059
  }, [valuePath]);
2531
- React7.useEffect(() => {
3060
+ React10__default.useEffect(() => {
2532
3061
  if (valuePath && cachedValue !== void 0) {
2533
3062
  setLocalValue(cachedValue);
2534
3063
  return;
@@ -2552,10 +3081,10 @@ function useBoundFieldState({
2552
3081
  setLocalValue(cachedValue);
2553
3082
  }
2554
3083
  }, [cachedValue, externalValue, preferCachedOverExternal, valuePath]);
2555
- React7.useEffect(() => {
3084
+ React10__default.useEffect(() => {
2556
3085
  rememberPathValue(valuePath, localValue);
2557
3086
  }, [valuePath, localValue]);
2558
- const updateLocalValue = React7.useCallback(
3087
+ const updateLocalValue = React10__default.useCallback(
2559
3088
  (nextValue) => {
2560
3089
  dirtyRef.current = true;
2561
3090
  setLocalValue(nextValue);
@@ -2575,7 +3104,7 @@ function emitFieldChange(nextValue, valuePath, updateLocalValue, onDataChange, o
2575
3104
  onChange?.(nextValue);
2576
3105
  }
2577
3106
  function useControlId(id) {
2578
- const autoId = React7.useId();
3107
+ const autoId = React10__default.useId();
2579
3108
  return id ?? autoId;
2580
3109
  }
2581
3110
  function readActionEvent(action) {
@@ -2676,7 +3205,7 @@ var Button9 = ({ label, variant = "default", onClick, action, onAction }) => {
2676
3205
  return /* @__PURE__ */ jsx(Button, { type: variant === "primary" ? "primary" : "default", danger: variant === "danger", onClick: handleClick, style: { borderRadius: 8 }, children: label });
2677
3206
  };
2678
3207
  var Divider = () => /* @__PURE__ */ jsx(Divider$1, { style: { margin: "8px 0" } });
2679
- var Tag2 = ({ text, color }) => /* @__PURE__ */ jsx(Tag, { color, children: text });
3208
+ var Tag3 = ({ text, color }) => /* @__PURE__ */ jsx(Tag, { color, children: text });
2680
3209
  var Progress = ({
2681
3210
  percent,
2682
3211
  status = "normal",
@@ -2694,7 +3223,7 @@ var A2uiComponents = {
2694
3223
  Switch,
2695
3224
  Button: Button9,
2696
3225
  Divider,
2697
- Tag: Tag2,
3226
+ Tag: Tag3,
2698
3227
  Progress,
2699
3228
  ArtifactCard,
2700
3229
  TableViewer,
@@ -3429,7 +3958,7 @@ function useA2uiController(params) {
3429
3958
  handleRuntimeAction
3430
3959
  };
3431
3960
  }
3432
- var A2uiRuntimeContext = React7.createContext({
3961
+ var A2uiRuntimeContext = React10__default.createContext({
3433
3962
  commands: [],
3434
3963
  onAction: () => void 0,
3435
3964
  surfaceIdsByMessageIndex: {}
@@ -3437,7 +3966,7 @@ var A2uiRuntimeContext = React7.createContext({
3437
3966
 
3438
3967
  // src/components/CustomComponents/A2uiRuntime/renderer/useA2uiRuntimeView.ts
3439
3968
  function useA2uiRuntimeView() {
3440
- return React7.useContext(A2uiRuntimeContext);
3969
+ return React10__default.useContext(A2uiRuntimeContext);
3441
3970
  }
3442
3971
  function A2uiMessageCards({ messageIndex }) {
3443
3972
  const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
@@ -3651,19 +4180,19 @@ function A2uiRuntimeProvider({ messages, children }) {
3651
4180
  const chatStore = useChatStore();
3652
4181
  const conversationState = useSnapshot(chatStore.conversation);
3653
4182
  const conversationId = conversationState.active.id;
3654
- const processedMessageCursorsRef = React7.useRef([]);
3655
- const latestCommandIndexBySurfaceRef = React7.useRef({});
3656
- const commandIndexRef = React7.useRef(-1);
3657
- const [latestCommandIndexBySurface, setLatestCommandIndexBySurface] = React7.useState({});
3658
- const [dismissedAtBySurface, setDismissedAtBySurface] = React7.useState({});
3659
- 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(() => {
3660
4189
  processedMessageCursorsRef.current = [];
3661
4190
  latestCommandIndexBySurfaceRef.current = {};
3662
4191
  commandIndexRef.current = -1;
3663
4192
  setLatestCommandIndexBySurface({});
3664
4193
  setDismissedAtBySurface({});
3665
4194
  }, [conversationId]);
3666
- React7.useEffect(() => {
4195
+ React10__default.useEffect(() => {
3667
4196
  const { shouldReplayAll, nextCursors, pendingItems } = diffMessages(messages, processedMessageCursorsRef.current);
3668
4197
  const itemsToProcess = shouldReplayAll ? messages.flatMap((message2) => {
3669
4198
  const items = Array.isArray(message2?.content) ? message2.content : [];
@@ -3686,10 +4215,10 @@ function A2uiRuntimeProvider({ messages, children }) {
3686
4215
  commandIndexRef.current = nextCommandIndex;
3687
4216
  setLatestCommandIndexBySurface(nextLatestCommandIndexBySurface);
3688
4217
  }, [messages]);
3689
- const dismissedSurfaceIds = React7.useMemo(() => {
4218
+ const dismissedSurfaceIds = React10__default.useMemo(() => {
3690
4219
  return Object.entries(dismissedAtBySurface).filter(([surfaceId, dismissedAt]) => (latestCommandIndexBySurface[surfaceId] ?? -1) <= dismissedAt).map(([surfaceId]) => surfaceId);
3691
4220
  }, [dismissedAtBySurface, latestCommandIndexBySurface]);
3692
- const dispatchA2uiAction = React7.useCallback(
4221
+ const dispatchA2uiAction = React10__default.useCallback(
3693
4222
  async (payload) => {
3694
4223
  const actionPayload = normalizeA2uiActionPayload(payload);
3695
4224
  if (!actionPayload.name) return;
@@ -3716,7 +4245,7 @@ function A2uiRuntimeProvider({ messages, children }) {
3716
4245
  conversationMessages: messages,
3717
4246
  dismissedSurfaceIds
3718
4247
  });
3719
- const onAction = React7.useCallback(
4248
+ const onAction = React10__default.useCallback(
3720
4249
  (payload) => {
3721
4250
  const result = handleRuntimeAction(payload);
3722
4251
  if (result.handled || !result.name) return;
@@ -3729,7 +4258,7 @@ function A2uiRuntimeProvider({ messages, children }) {
3729
4258
  },
3730
4259
  [commands, dispatchA2uiAction, handleRuntimeAction, runtimeState.modelPathBySurface]
3731
4260
  );
3732
- const contextValue = React7.useMemo(
4261
+ const contextValue = React10__default.useMemo(
3733
4262
  () => ({ commands, onAction, surfaceIdsByMessageIndex: anchoredSurfaceIdsByMessageIndex }),
3734
4263
  [anchoredSurfaceIdsByMessageIndex, commands, onAction]
3735
4264
  );
@@ -3738,14 +4267,14 @@ function A2uiRuntimeProvider({ messages, children }) {
3738
4267
  function A2uiRenderer(props) {
3739
4268
  return /* @__PURE__ */ jsx(A2uiRuntimeProvider, { ...props });
3740
4269
  }
3741
- var FilesNode = React7.memo(({ item }) => {
4270
+ var FilesNode = React10__default.memo(({ item }) => {
3742
4271
  const chatStore = useChatStore();
3743
4272
  const configState = useSnapshot(chatStore.config);
3744
- const agentState = useSnapshot(chatStore.agent);
4273
+ useSnapshot(chatStore.agent);
3745
4274
  const conversationState = useSnapshot(chatStore.conversation);
3746
4275
  const fileItems = useMemo(() => {
3747
4276
  return (item.files || []).map((file) => {
3748
- 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);
3749
4278
  let fileType = "file";
3750
4279
  const ext = file.ext?.toLowerCase() || "";
3751
4280
  if (["jpg", "jpeg", "png", "gif", "bmp", "webp", "svg", "webp"].includes(ext)) {
@@ -3769,7 +4298,7 @@ var FilesNode = React7.memo(({ item }) => {
3769
4298
  // src/components/CustomComponents/MessageNode/style.module.less
3770
4299
  var style_module_default2 = {
3771
4300
  runStartedNode: "style_module_runStartedNode"};
3772
- var QuoteMsgNode = React7.memo(({ quoteMsg, role }) => {
4301
+ var QuoteMsgNode = React10__default.memo(({ quoteMsg, role }) => {
3773
4302
  if (!quoteMsg || !quoteMsg.messageContent) return null;
3774
4303
  return /* @__PURE__ */ jsx(
3775
4304
  Bubble,
@@ -3799,7 +4328,7 @@ var QuoteMsgNode = React7.memo(({ quoteMsg, role }) => {
3799
4328
  }
3800
4329
  );
3801
4330
  });
3802
- var RunStartedNode = React7.memo(({ loading }) => {
4331
+ var RunStartedNode = React10__default.memo(({ loading }) => {
3803
4332
  if (!loading) return null;
3804
4333
  return /* @__PURE__ */ jsx(Flex, { gap: 8, align: "center", className: style_module_default2.runStartedNode, children: /* @__PURE__ */ jsx(LoadingOutlined, { style: { color: "#1677ff" } }) });
3805
4334
  });
@@ -3810,7 +4339,7 @@ function QuestionSummary({ content }) {
3810
4339
  /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#262626", lineHeight: 1.6, whiteSpace: "pre-wrap" }, children: answer })
3811
4340
  ] });
3812
4341
  }
3813
- var TextNode = React7.memo(
4342
+ var TextNode2 = React10__default.memo(
3814
4343
  ({ item, role, customComponents, message: message2 }) => {
3815
4344
  const content = toA2uiDisplayText(role, item?.messageContent);
3816
4345
  if (typeof content === "string" && content.startsWith("Question:")) {
@@ -3824,7 +4353,7 @@ var TextNode = React7.memo(
3824
4353
  );
3825
4354
 
3826
4355
  // src/components/CustomComponents/ToolRenders/index.module.less
3827
- var index_module_default = {
4356
+ var index_module_default2 = {
3828
4357
  iconContainer: "index_module_iconContainer",
3829
4358
  toolName: "index_module_toolName",
3830
4359
  duration: "index_module_duration",
@@ -3842,21 +4371,21 @@ var index_module_default = {
3842
4371
  };
3843
4372
  var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
3844
4373
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3845
- (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
3846
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
3847
- /* @__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
3848
4377
  ${argsContent.text}
3849
4378
  \`\`\`` : argsContent.text }) })
3850
4379
  ] }),
3851
- item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
3852
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
3853
- /* @__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
3854
4383
  ${resultContent.text}
3855
4384
  \`\`\`` : resultContent.text }) })
3856
4385
  ] }),
3857
- errorMessage && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
3858
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
3859
- /* @__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: `\`\`\`
3860
4389
  ${errorMessage}
3861
4390
  \`\`\`` }) })
3862
4391
  ] })
@@ -3878,18 +4407,18 @@ var TodoWriteRender = ({ args, result }) => {
3878
4407
  }
3879
4408
  };
3880
4409
  if (!todos || todos.length === 0) {
3881
- 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" });
3882
4411
  }
3883
4412
  return /* @__PURE__ */ jsx(
3884
4413
  List,
3885
4414
  {
3886
4415
  size: "small",
3887
4416
  dataSource: todos,
3888
- renderItem: (item) => /* @__PURE__ */ jsxs(List.Item, { className: index_module_default.todoItem, children: [
3889
- /* @__PURE__ */ jsx("div", { className: index_module_default.statusIconWrapper, children: getStatusIcon(item.status) }),
3890
- /* @__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 }) })
3891
4420
  ] }),
3892
- className: index_module_default.todoList
4421
+ className: index_module_default2.todoList
3893
4422
  }
3894
4423
  );
3895
4424
  };
@@ -4008,10 +4537,10 @@ var ToolCallItem = ({ item }) => {
4008
4537
  key: item.toolCallId || "fallback-key",
4009
4538
  showArrow: hasContent,
4010
4539
  label: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
4011
- /* @__PURE__ */ jsx("div", { className: index_module_default.iconContainer, children: renderIcon() }),
4012
- /* @__PURE__ */ jsx("span", { className: index_module_default.toolName, children: item.title || item.toolName || "Unknown Tool" }),
4013
- (status === "running" || status === "pending") && /* @__PURE__ */ jsx("div", { className: index_module_default.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
4014
- 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: [
4015
4544
  item.duration,
4016
4545
  "ms"
4017
4546
  ] })
@@ -4034,7 +4563,7 @@ var ToolCallItem = ({ item }) => {
4034
4563
  };
4035
4564
  var tool_call_item_default = ToolCallItem;
4036
4565
  var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "files", "plan"];
4037
- 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 }) => {
4038
4567
  const content = useMemo(() => {
4039
4568
  return (message2.content || []).filter((item) => {
4040
4569
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
@@ -4074,7 +4603,7 @@ var MessageRender_default = React7.memo(({ role, message: message2, messageIndex
4074
4603
  content: /* @__PURE__ */ jsxs(Fragment, { children: [
4075
4604
  item.type === "runStarted" && /* @__PURE__ */ jsx(RunStartedNode, { loading }, `flow-start-${index}`),
4076
4605
  (item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
4077
- 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}`),
4078
4607
  item.type === "stepError" && (item.errorMessage ? /* @__PURE__ */ jsx(XMarkdown_default, { message: message2, components: customComponents, content: item.errorMessage }) : null),
4079
4608
  item.type === "files" && /* @__PURE__ */ jsx(FilesNode, { item }, `files-${index}`),
4080
4609
  item.type === "plan" && /* @__PURE__ */ jsx(A2uiPlanNode, { item }, `plan-${index}`)
@@ -4142,7 +4671,7 @@ var BubbleListItems_default = ({
4142
4671
  welcomeMessage = true,
4143
4672
  avatar = { user: false, agent: true },
4144
4673
  agentActions = false,
4145
- customComponents = {}
4674
+ customComponents
4146
4675
  }) => {
4147
4676
  const chatStore = useChatStore();
4148
4677
  const agentState = useSnapshot(chatStore.agent);
@@ -4718,13 +5247,21 @@ var ChatSender_default2 = forwardRef(
4718
5247
  reasonBtn = true,
4719
5248
  skillsBtn = false,
4720
5249
  knowledgeBtn = false,
4721
- modelSelect = false
5250
+ modelSelect = false,
5251
+ commandConfig = {}
4722
5252
  }, ref) => {
4723
5253
  const chatStore = useChatStore();
4724
5254
  const configState = useSnapshot(chatStore.config);
4725
5255
  const agentState = useSnapshot(chatStore.agent);
4726
5256
  const conversationState = useSnapshot(chatStore.conversation);
4727
- 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
+ };
4728
5265
  const chatMessage = useMemo(
4729
5266
  () => conversationState.messages[conversationState.active.id] || {},
4730
5267
  [conversationState.messages[conversationState.active.id]]
@@ -4744,6 +5281,7 @@ var ChatSender_default2 = forwardRef(
4744
5281
  ChatSender_default,
4745
5282
  {
4746
5283
  ref,
5284
+ commandConfig,
4747
5285
  placeholder,
4748
5286
  content: chatMessage.content,
4749
5287
  fileList: chatMessage.files,
@@ -4913,7 +5451,7 @@ var ChatPreviewPanel = memo(({ file }) => {
4913
5451
  var ChatPreviewPanel_default = ChatPreviewPanel;
4914
5452
 
4915
5453
  // src/ui/layouts/index.module.less
4916
- var index_module_default2 = {
5454
+ var index_module_default3 = {
4917
5455
  chatLayout: "index_module_chatLayout",
4918
5456
  animatedSplitter: "index_module_animatedSplitter",
4919
5457
  hideSplitterBar: "index_module_hideSplitterBar"
@@ -5004,12 +5542,12 @@ var layouts_default = forwardRef(({ theme: theme4, params, hooks, layout, config
5004
5542
  useEffect(() => {
5005
5543
  hooks?.onBeforeInit?.();
5006
5544
  }, []);
5007
- 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: [
5008
5546
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
5009
5547
  /* @__PURE__ */ jsxs(Flex, { ref: containerRef, className: "full-scroll", children: [
5010
5548
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.leftPanel }),
5011
5549
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.conversationList, DefaultComponent: ConversationListPanel_default }),
5012
- /* @__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: [
5013
5551
  /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsx(ChatMainPanel_default, { ref: senderRef }) }),
5014
5552
  /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, min: 600, size: sizes[0], children: /* @__PURE__ */ jsx(ChatPreviewPanel_default, { file: configState.preview.file }) })
5015
5553
  ] })