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