@myun/gimi-chat 0.9.63 → 0.9.65

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.
Files changed (52) hide show
  1. package/dist/apis/useApi.d.ts +0 -6
  2. package/dist/apis/useApi.js +1 -45
  3. package/dist/components/ai-chat-dialogue/index copy.js +1 -1
  4. package/dist/components/ai-chat-dialogue/index.js +2 -4
  5. package/dist/components/answer-item/index.d.ts +1 -2
  6. package/dist/components/answer-item/index.js +8 -179
  7. package/dist/components/answer-item/index.module.css +0 -35
  8. package/dist/components/ask-card/index.d.ts +1 -1
  9. package/dist/components/chat-input/extension/index.d.ts +0 -1
  10. package/dist/components/chat-input/extension/index.js +1 -2
  11. package/dist/components/chat-input/index.js +24 -145
  12. package/dist/components/file-card/index.js +1 -2
  13. package/dist/components/file-card/index.module.css +0 -1
  14. package/dist/components/knowledge-trace/tryWatch.js +1 -1
  15. package/dist/components/message-list/index.js +3 -15
  16. package/dist/components/message-list/index.module.css +0 -3
  17. package/dist/components/templates/CommonChat.js +1 -3
  18. package/dist/hooks/useChatActions.d.ts +1 -2
  19. package/dist/hooks/useChatActions.js +12 -52
  20. package/dist/hooks/useChatStream.d.ts +1 -6
  21. package/dist/hooks/useChatStream.js +5 -97
  22. package/dist/hooks/useCommonChatAPI.d.ts +1 -1
  23. package/dist/hooks/useCommonChatAPI.js +58 -212
  24. package/dist/i18n/locales/en-US.d.ts +0 -6
  25. package/dist/i18n/locales/en-US.js +1 -7
  26. package/dist/i18n/locales/zh-CN.d.ts +0 -6
  27. package/dist/i18n/locales/zh-CN.js +1 -7
  28. package/dist/interfaces/chatMessage.d.ts +0 -40
  29. package/dist/umd/index.min.js +1 -1
  30. package/dist/utils/tools.d.ts +0 -7
  31. package/dist/utils/tools.js +1 -38
  32. package/package.json +2 -4
  33. package/dist/components/answer-item/component/artifacts/index.d.ts +0 -13
  34. package/dist/components/answer-item/component/artifacts/index.js +0 -52
  35. package/dist/components/answer-item/component/artifacts/index.module.css +0 -24
  36. package/dist/components/answer-item/component/tool-list/index.d.ts +0 -7
  37. package/dist/components/answer-item/component/tool-list/index.js +0 -117
  38. package/dist/components/answer-item/component/tool-list/index.module.css +0 -97
  39. package/dist/components/chat-input/extension/skill/MentionList.d.ts +0 -31
  40. package/dist/components/chat-input/extension/skill/MentionList.js +0 -199
  41. package/dist/components/chat-input/extension/skill/ReferSlot.d.ts +0 -3
  42. package/dist/components/chat-input/extension/skill/ReferSlot.js +0 -100
  43. package/dist/components/chat-input/extension/skill/data.d.ts +0 -10
  44. package/dist/components/chat-input/extension/skill/data.js +0 -49
  45. package/dist/components/chat-input/extension/skill/index.d.ts +0 -7
  46. package/dist/components/chat-input/extension/skill/index.js +0 -5
  47. package/dist/components/chat-input/extension/skill/index.less +0 -117
  48. package/dist/components/chat-input/extension/skill/suggestion.d.ts +0 -16
  49. package/dist/components/chat-input/extension/skill/suggestion.js +0 -206
  50. package/dist/components/message-list/skill-tag/index.d.ts +0 -5
  51. package/dist/components/message-list/skill-tag/index.js +0 -23
  52. package/dist/components/message-list/skill-tag/index.module.css +0 -21
@@ -1,6 +1,5 @@
1
1
  import { IChatMessageItem } from "../interfaces/chatMessage";
2
2
  import { FileItem } from "../types/file";
3
- export declare const maxInputLength = 10000;
4
3
  export declare function downloadExcelByUrl(url: string, fileName?: string): Promise<void>;
5
4
  export declare function parseMessageContent(str: string): {
6
5
  moduleInfo: any | null;
@@ -29,12 +28,6 @@ export declare const retryWithExponentialBackoff: <T>(fn: () => Promise<T>, opti
29
28
  * @returns 格式化后的中文时间字符串
30
29
  */
31
30
  export declare function formatSecondsToChinese(seconds: number): number;
32
- /**
33
- * 将毫秒数格式化为可读时长字符串
34
- * @param ms - 毫秒数(非负数)
35
- * @returns 格式化后的时长字符串(32333 -> "32s",1203000 -> "20m3s",60000 -> "1m0s")
36
- */
37
- export declare function formatDurationMs(ms: number): string;
38
31
  export declare function replaceBraces(str: string): string;
39
32
  /**
40
33
  * 将字节数转换为KB或MB格式的字符串
@@ -16,9 +16,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
16
16
  import { FileStatus } from "../interfaces/fileInterface";
17
17
  import { set, cloneDeep } from 'lodash';
18
18
  import { Toast } from "@douyinfe/semi-ui";
19
-
20
- // 最大输入长度
21
- export var maxInputLength = 10000;
22
19
  export function downloadExcelByUrl(_x) {
23
20
  return _downloadExcelByUrl.apply(this, arguments);
24
21
  }
@@ -289,22 +286,6 @@ export function formatSecondsToChinese(seconds) {
289
286
  var minutes = Math.ceil(totalSeconds / 60);
290
287
  return minutes;
291
288
  }
292
-
293
- /**
294
- * 将毫秒数格式化为可读时长字符串
295
- * @param ms - 毫秒数(非负数)
296
- * @returns 格式化后的时长字符串(32333 -> "32s",1203000 -> "20m3s",60000 -> "1m0s")
297
- */
298
- export function formatDurationMs(ms) {
299
- // 边界值处理:确保输入为非负数
300
- if (typeof ms !== 'number' || isNaN(ms) || ms < 0) {
301
- return '0s';
302
- }
303
- var totalSeconds = Math.floor(ms / 1000);
304
- var minutes = Math.floor(totalSeconds / 60);
305
- var seconds = totalSeconds % 60;
306
- return minutes > 0 ? "".concat(minutes, "m").concat(seconds, "s") : "".concat(seconds, "s");
307
- }
308
289
  export function replaceBraces(str) {
309
290
  if (str === null || str === '') {
310
291
  return str === '' ? '' : String(str);
@@ -461,16 +442,7 @@ export function formatFields(dataList, chatList) {
461
442
  dataList.forEach(function (item, index) {
462
443
  if (item.role === 1 && item.chatId !== null && roleZeroMap.has(item.chatId)) {
463
444
  var _roleZeroData$related;
464
- // 当前处于用户交互确认
465
- var isPendingUserConfirm = item.moduleType === "user_confirm" && (item === null || item === void 0 ? void 0 : item.pendingUserConfirm);
466
445
  var roleZeroData = roleZeroMap.get(item.chatId);
467
- var artifacts = [];
468
- try {
469
- var _item$attachedEvents;
470
- artifacts = JSON.parse(((_item$attachedEvents = item.attachedEvents) === null || _item$attachedEvents === void 0 || (_item$attachedEvents = _item$attachedEvents[0]) === null || _item$attachedEvents === void 0 ? void 0 : _item$attachedEvents.eventData) || '{}').artifacts || [];
471
- } catch (error) {
472
- console.log('error', error);
473
- }
474
446
  item.relatedCount = roleZeroData.relatedCount;
475
447
  item.relatedCourseRecommendation = roleZeroData.relatedCourseRecommendation ? JSON.parse(roleZeroData.relatedCourseRecommendation) : [];
476
448
  item.questionId = roleZeroData.questionId;
@@ -487,7 +459,7 @@ export function formatFields(dataList, chatList) {
487
459
  var _parseMessageContent2 = parseMessageContent(item.content || ''),
488
460
  moduleInfo = _parseMessageContent2.moduleInfo,
489
461
  content = _parseMessageContent2.content;
490
- item.stop = isPendingUserConfirm ? 0 : item.contentState ? 0 : 1; // 推理状态 0 推理完成 1 停止
462
+ item.stop = item.contentState ? 0 : 1; // 推理状态 0 推理完成 1 停止
491
463
  // item.moduleType = item.content ? JSON.parse(item.content).moduleType : null;
492
464
  item.moduleInfo = moduleInfo;
493
465
  if (content) {
@@ -498,15 +470,6 @@ export function formatFields(dataList, chatList) {
498
470
  item.selectValue = getSelectValue(item.content, moduleInfo, isLastItem, nextItem);
499
471
  item.reTryed = checkHasRetry(item.skillResult, index === dataList.length - 1); // 最新的一个skill生成结果失败,才可以重试
500
472
  item.disableUploadFile = getDisableUploadFile(item.content, moduleInfo, isLastItem);
501
- item.artifacts = artifacts;
502
- item.totalTokens = item.totalTokens || 0;
503
- item.thinkingInfo = {
504
- status: "COMPLETED",
505
- toolName: "已完成",
506
- collapse: !isPendingUserConfirm,
507
- loaded: false,
508
- needInit: isPendingUserConfirm
509
- };
510
473
  }
511
474
  });
512
475
  return dataList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myun/gimi-chat",
3
- "version": "0.9.63",
3
+ "version": "0.9.65",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -23,14 +23,12 @@
23
23
  "dependencies": {
24
24
  "@douyinfe/semi-icons": "^2.90.0",
25
25
  "@douyinfe/semi-ui": "^2.90.0",
26
- "@gaodun.com/gplayer": "3.3.12",
27
26
  "@microsoft/fetch-event-source": "^2.0.1",
28
27
  "@myun/gimi-design": "0.1.35",
28
+ "@gaodun.com/gplayer": "3.3.12",
29
29
  "@reduxjs/toolkit": "^2.11.2",
30
30
  "@tiptap/core": "^3.15.3",
31
- "@tiptap/extension-mention": "^3.30.1",
32
31
  "@tiptap/react": "^3.15.3",
33
- "@tiptap/suggestion": "3.30.1",
34
32
  "@volcengine/rtc": "^4.68.0",
35
33
  "classnames": "^2.2.6",
36
34
  "crypto-js": "^4.2.0",
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- interface Artifact {
3
- artifactId: string;
4
- fileName: string;
5
- relativePath: string;
6
- contentType: string;
7
- fileSize: number;
8
- fileAddr: string;
9
- }
10
- declare const Artifacts: ({ artifacts }: {
11
- artifacts: Artifact[];
12
- }) => React.JSX.Element;
13
- export default Artifacts;
@@ -1,52 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useState } from 'react';
8
- import { FileCard } from "../../../file-card";
9
- import IconFont from "../../../iconfont-com";
10
- import styles from "./index.module.css";
11
- import classNames from 'classnames';
12
- var formatFileSize = function formatFileSize(size) {
13
- if (size <= 0) return '0B';
14
- var units = ['B', 'KB', 'MB', 'GB', 'TB'];
15
- var i = Math.floor(Math.log(size) / Math.log(1024));
16
- var value = size / Math.pow(1024, i);
17
- return "".concat(parseFloat(value.toFixed(1))).concat(units[i]);
18
- };
19
- var Artifacts = function Artifacts(_ref) {
20
- var artifacts = _ref.artifacts;
21
- var _useState = useState(false),
22
- _useState2 = _slicedToArray(_useState, 2),
23
- showContent = _useState2[0],
24
- setShowContent = _useState2[1];
25
- return /*#__PURE__*/React.createElement("div", {
26
- className: classNames(styles.main, showContent && styles.show)
27
- }, /*#__PURE__*/React.createElement("div", {
28
- className: styles.toolItemLabel,
29
- onClick: function onClick() {
30
- return setShowContent(!showContent);
31
- }
32
- }, /*#__PURE__*/React.createElement("div", {
33
- className: styles.toolName
34
- }, "\u67E5\u770B\u6240\u6709\u4EA7\u7269"), /*#__PURE__*/React.createElement(IconFont, {
35
- className: styles.icon,
36
- type: showContent ? "icon-a-jiantoucu2x-copy1" : "icon-a-jiantoucu2x",
37
- size: 14
38
- })), /*#__PURE__*/React.createElement("div", {
39
- className: styles.list
40
- }, artifacts.map(function (item) {
41
- return /*#__PURE__*/React.createElement(FileCard, {
42
- fileName: item.fileName,
43
- downloadUrl: item.fileAddr,
44
- size: formatFileSize(item.fileSize),
45
- fileType: item.fileName.split('.').pop() || '',
46
- model: "sidebar",
47
- disablePreview: true,
48
- key: item.artifactId
49
- });
50
- })));
51
- };
52
- export default Artifacts;
@@ -1,24 +0,0 @@
1
- .main .toolItemLabel {
2
- display: flex;
3
- align-items: center;
4
- width: fit-content;
5
- cursor: pointer;
6
- margin-bottom: 8px;
7
- }
8
- .main .toolItemLabel:hover .icon {
9
- color: var(--theme-neutral, #626262) !important;
10
- }
11
- .main .toolItemLabel:hover .toolName {
12
- color: var(--theme-neutral, #626262);
13
- }
14
- .main .toolItemLabel .icon, .main .toolItemLabel .toolName {
15
- color: var(--theme-mediumNeutral, #B3B2B2);
16
- }
17
- .main.show .list {
18
- display: flex;
19
- }
20
- .main .list {
21
- display: none;
22
- flex-wrap: wrap;
23
- gap: 10px;
24
- }
@@ -1,7 +0,0 @@
1
- import React from "react";
2
- import { ToolItem } from "../../../../interfaces/chatMessage";
3
- declare const ToolList: ({ toolList, handleClickConfirm }: {
4
- toolList: ToolItem[];
5
- handleClickConfirm: (item: any, confirmed: boolean) => void;
6
- }) => React.JSX.Element;
7
- export default ToolList;
@@ -1,117 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
- import React, { useMemo, useState } from "react";
12
- import { MMarkdown } from '@myun/gimi-design';
13
- import IconFont from "../../../iconfont-com";
14
- import styles from "./index.module.css";
15
- import classNames from "classnames";
16
- var ToolItemCom = function ToolItemCom(_ref) {
17
- var item = _ref.item;
18
- var _useState = useState(false),
19
- _useState2 = _slicedToArray(_useState, 2),
20
- showContent = _useState2[0],
21
- setShowContent = _useState2[1];
22
- var content = useMemo(function () {
23
- // item.content 可能是:普通文本 / 单层 JSON / 双层 JSON 字符串
24
- // 逐层 parse,直到结果不是字符串或 parse 失败为止
25
- var result = item.content || '';
26
- for (var depth = 0; depth < 2 && typeof result === 'string'; depth++) {
27
- try {
28
- result = JSON.parse(result);
29
- } catch (_unused) {
30
- break;
31
- }
32
- }
33
- // parse 到底是字符串直接用;如果是对象,取里面的文本字段渲染
34
- if (typeof result === 'string') return result;
35
- if (result && typeof result.content === 'string') return result.content;
36
- // 兜底:对象序列化
37
- return JSON.stringify(result, null, 2);
38
- }, [item.content]);
39
- return /*#__PURE__*/React.createElement("div", {
40
- className: styles.toolItem
41
- }, /*#__PURE__*/React.createElement("div", {
42
- className: styles.toolItemLabel,
43
- onClick: function onClick() {
44
- return item.content && setShowContent(!showContent);
45
- }
46
- }, item.status === "COMPLETED" && /*#__PURE__*/React.createElement("img", {
47
- className: styles.toolIcon,
48
- src: "https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202608/28/43776_20260828150320.png"
49
- }), /*#__PURE__*/React.createElement("div", {
50
- className: classNames(styles.toolName, _defineProperty({}, styles.running, item.status === "RUNNING" || item.status === "STARTED"))
51
- }, item.toolName), item.status === "COMPLETED" && item.content && /*#__PURE__*/React.createElement(IconFont, {
52
- className: classNames(styles.icon, _defineProperty({}, styles.hasContent, showContent)),
53
- type: showContent ? "icon-a-jiantoucu2x-copy1" : "icon-a-jiantoucu2x",
54
- size: 12,
55
- extraStyle: {
56
- color: !showContent ? "var(--theme-neutral, #626262)" : "var(--theme-mediumNeutral, #B3B2B2)"
57
- }
58
- })), item.content && showContent && /*#__PURE__*/React.createElement("div", {
59
- className: styles.toolItemContent
60
- }, /*#__PURE__*/React.createElement(MMarkdown, {
61
- content: content
62
- })));
63
- };
64
- var ConfirmToolItem = function ConfirmToolItem(_ref2) {
65
- var _item$data;
66
- var item = _ref2.item,
67
- handleClickConfirm = _ref2.handleClickConfirm;
68
- var confirmTextMap = {
69
- PENDING: "等待人工确认",
70
- CONFIRMED: "用户已同意",
71
- REJECTED: "用户已拒绝",
72
- PARTIAL: "用户已同意部分"
73
- };
74
- var handleConfirmResult = function handleConfirmResult(confirmed) {
75
- handleClickConfirm(item, confirmed);
76
- };
77
- return /*#__PURE__*/React.createElement("div", {
78
- className: styles.toolItem
79
- }, /*#__PURE__*/React.createElement("div", {
80
- className: styles.toolItemLabel
81
- }, /*#__PURE__*/React.createElement("div", {
82
- className: classNames(styles.toolName, _defineProperty({}, styles.running, item.status === "RUNNING" || item.status === "STARTED"))
83
- }, confirmTextMap[item.confirmStatus || "PENDING"])), item.confirmStatus === "PENDING" && /*#__PURE__*/React.createElement("div", {
84
- className: styles.confirmContent
85
- }, /*#__PURE__*/React.createElement("div", {
86
- className: styles.confirmDesc
87
- }, ((_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.message) || ''), /*#__PURE__*/React.createElement("div", {
88
- className: styles.confirmActions
89
- }, /*#__PURE__*/React.createElement("div", {
90
- className: styles.confirmBtn,
91
- onClick: function onClick() {
92
- return handleConfirmResult(true);
93
- }
94
- }, "\u5141\u8BB8\u4E00\u6B21"), /*#__PURE__*/React.createElement("div", {
95
- className: styles.confirmBtn,
96
- onClick: function onClick() {
97
- return handleConfirmResult(false);
98
- }
99
- }, "\u62D2\u7EDD"))));
100
- };
101
- var ToolList = function ToolList(_ref3) {
102
- var toolList = _ref3.toolList,
103
- handleClickConfirm = _ref3.handleClickConfirm;
104
- return /*#__PURE__*/React.createElement("div", {
105
- className: styles.toolList
106
- }, toolList.map(function (item) {
107
- return item.moduleType === "user_confirm" ? /*#__PURE__*/React.createElement(ConfirmToolItem, {
108
- key: item.id,
109
- item: item,
110
- handleClickConfirm: handleClickConfirm
111
- }) : /*#__PURE__*/React.createElement(ToolItemCom, {
112
- key: item.id,
113
- item: item
114
- });
115
- }));
116
- };
117
- export default ToolList;
@@ -1,97 +0,0 @@
1
- .toolItem .toolItemLabel {
2
- display: flex;
3
- align-items: center;
4
- width: fit-content;
5
- cursor: pointer;
6
- margin-bottom: 8px;
7
- }
8
- .toolItem .toolItemLabel:hover .icon {
9
- display: block;
10
- color: var(--theme-neutral, #626262) !important;
11
- }
12
- .toolItem .toolItemLabel:hover .toolName {
13
- color: var(--theme-neutral, #626262);
14
- }
15
- .toolItem .toolItemLabel .toolIcon {
16
- width: 12px;
17
- height: 12px;
18
- margin-right: 4px;
19
- }
20
- .toolItem .toolItemLabel .toolName {
21
- color: var(--theme-mediumNeutral, #B3B2B2);
22
- font-size: 13px;
23
- }
24
- .toolItem .toolItemLabel .toolName.running {
25
- position: relative;
26
- }
27
- .toolItem .toolItemLabel .toolName.running::after {
28
- content: "";
29
- position: absolute;
30
- top: 0;
31
- left: -150%;
32
- width: 100%;
33
- height: 20px;
34
- background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
35
- transform: skewX(-25deg);
36
- animation: shine 2s infinite;
37
- }
38
- .toolItem .toolItemLabel .icon {
39
- display: none;
40
- }
41
- .toolItem .toolItemLabel .icon.hasContent {
42
- display: block;
43
- }
44
- .toolItem .toolItemContent {
45
- max-height: 188px;
46
- padding: 0 24px 0 16px;
47
- overflow-y: auto;
48
- border-radius: 16px;
49
- border: 1px solid var(--theme-lightNeutral, #EDEDEB);
50
- background: #FCFCFC;
51
- }
52
- .toolItem .confirmContent {
53
- width: clamp(360px, 90%, 600px);
54
- flex-shrink: 0;
55
- padding: 20px;
56
- border-radius: 16px;
57
- border: 1px solid var(--theme-lightNeutral, #E9EBF2);
58
- background: linear-gradient(180deg, var(--theme-primary-pale, #F0F8FF) 0%, #fff 100%);
59
- margin-top: 12px;
60
- }
61
- .toolItem .confirmContent .confirmDesc {
62
- color: var(--theme-neutral, #626262);
63
- font-size: 13px;
64
- line-height: 1.4;
65
- margin-bottom: 16px;
66
- }
67
- .toolItem .confirmContent .confirmActions {
68
- display: flex;
69
- flex-direction: column;
70
- gap: 16px;
71
- }
72
- .toolItem .confirmContent .confirmBtn {
73
- height: 44px;
74
- border-radius: 22px;
75
- border: 1px solid #E3E3E1;
76
- background: #FFFFFF;
77
- color: #221813;
78
- font-size: 14px;
79
- font-weight: 600;
80
- display: flex;
81
- align-items: center;
82
- justify-content: center;
83
- cursor: pointer;
84
- transition: opacity 0.2s;
85
- }
86
- .toolItem .confirmContent .confirmBtn:hover {
87
- opacity: 0.85;
88
- }
89
-
90
- @keyframes shine {
91
- 0% {
92
- left: -60%;
93
- }
94
- 100% {
95
- left: 80%;
96
- }
97
- }
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import type { IUseApi } from '../../../../apis/useApi';
3
- import './index.less';
4
- export interface SkillItem {
5
- imageUrl: string;
6
- toolDesc: string;
7
- toolCategoryDesc: string;
8
- toolName: string;
9
- toolStatus: number;
10
- toolId: number;
11
- }
12
- export interface MentionListRef {
13
- onKeyDown: (props: {
14
- event: KeyboardEvent;
15
- exitCb?: () => void;
16
- }) => boolean;
17
- }
18
- interface MentionListProps {
19
- items: SkillItem[];
20
- command: (props: {
21
- item?: SkillItem;
22
- allowHotKeySend?: boolean;
23
- }) => void;
24
- editor?: any;
25
- query?: string;
26
- agentId?: number;
27
- apiService?: IUseApi | null;
28
- getCurrentTextLength?: () => number;
29
- }
30
- declare const MentionList: React.ForwardRefExoticComponent<MentionListProps & React.RefAttributes<MentionListRef>>;
31
- export default MentionList;
@@ -1,199 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
8
- import { Toast } from '@douyinfe/semi-ui';
9
- import AiLoading from "../../../../components/ai-loading";
10
- import "./index.less";
11
- import { useTranslation } from 'react-i18next';
12
- import { maxInputLength } from "../../../../utils/tools";
13
- var MentionList = /*#__PURE__*/forwardRef(function (_ref, ref) {
14
- var command = _ref.command,
15
- query = _ref.query,
16
- agentId = _ref.agentId,
17
- apiService = _ref.apiService,
18
- getCurrentTextLength = _ref.getCurrentTextLength;
19
- var _useState = useState(0),
20
- _useState2 = _slicedToArray(_useState, 2),
21
- selectedIndex = _useState2[0],
22
- setSelectedIndex = _useState2[1];
23
- var _useState3 = useState([]),
24
- _useState4 = _slicedToArray(_useState3, 2),
25
- skillList = _useState4[0],
26
- setSkillList = _useState4[1];
27
- var _useState5 = useState([]),
28
- _useState6 = _slicedToArray(_useState5, 2),
29
- filterOptions = _useState6[0],
30
- setFilterOptions = _useState6[1];
31
- var _useState7 = useState(false),
32
- _useState8 = _slicedToArray(_useState7, 2),
33
- loading = _useState8[0],
34
- setLoading = _useState8[1];
35
- var _useTranslation = useTranslation(),
36
- t = _useTranslation.t;
37
-
38
- // 选项面板渲染,则 Enter 快捷键应该用于选项面板中,不能用于 AIChatInput 的发送
39
- useEffect(function () {
40
- try {
41
- command({
42
- allowHotKeySend: false
43
- });
44
- } catch (e) {
45
- console.error('[skill] MentionList command error:', e);
46
- }
47
- // 选项面板卸载,则 Enter 快捷键应该用于 AIChatInput 的发送
48
- return function () {
49
- command({
50
- allowHotKeySend: true
51
- });
52
- };
53
- }, [command]);
54
-
55
- // 拉取当前智能体技能列表
56
- useEffect(function () {
57
- if (!apiService || !agentId) {
58
- setSkillList([]);
59
- setFilterOptions([]);
60
- return;
61
- }
62
- var cancelled = false;
63
- setLoading(true);
64
- apiService.getAgentSkillList(agentId).then(function (res) {
65
- var _ref2, _result$data;
66
- if (cancelled) return;
67
- // FetchResponse 结构: { message, result, status }
68
- var result = res === null || res === void 0 ? void 0 : res.result;
69
- var list = Array.isArray(result) ? result : (_ref2 = (_result$data = result === null || result === void 0 ? void 0 : result.data) !== null && _result$data !== void 0 ? _result$data : result === null || result === void 0 ? void 0 : result.list) !== null && _ref2 !== void 0 ? _ref2 : [];
70
- setSkillList(list);
71
- setFilterOptions(list);
72
- setSelectedIndex(0);
73
- }).catch(function (e) {
74
- if (!cancelled) console.error('[skill] getAgentSkillList error:', e);
75
- }).finally(function () {
76
- if (!cancelled) setLoading(false);
77
- });
78
- return function () {
79
- cancelled = true;
80
- };
81
- }, [apiService, agentId]);
82
-
83
- // query 变化或数据更新时手动 filter
84
- useEffect(function () {
85
- var filter = query && query.length ? skillList.filter(function (item) {
86
- return item.toolName.toLowerCase().includes((query || '').toLowerCase());
87
- }) : skillList;
88
- setFilterOptions(filter);
89
- setSelectedIndex(0);
90
- }, [query, skillList]);
91
- var upHandler = function upHandler() {
92
- setSelectedIndex(function (i) {
93
- return filterOptions.length ? (i + filterOptions.length - 1) % filterOptions.length : 0;
94
- });
95
- };
96
- var downHandler = function downHandler() {
97
- setSelectedIndex(function (i) {
98
- return filterOptions.length ? (i + 1) % filterOptions.length : 0;
99
- });
100
- };
101
- var selectItem = function selectItem(id) {
102
- var item = filterOptions[id];
103
- if (item) {
104
- if (getCurrentTextLength) {
105
- var _item$toolId, _item$toolCategoryDes, _item$toolName;
106
- var serialized = "<skilltool>".concat(JSON.stringify({
107
- toolId: (_item$toolId = item.toolId) !== null && _item$toolId !== void 0 ? _item$toolId : '',
108
- toolType: (_item$toolCategoryDes = item.toolCategoryDesc) !== null && _item$toolCategoryDes !== void 0 ? _item$toolCategoryDes : '',
109
- toolName: (_item$toolName = item.toolName) !== null && _item$toolName !== void 0 ? _item$toolName : ''
110
- }), "</skilltool>");
111
- var currentLen = getCurrentTextLength();
112
- if (currentLen + serialized.length > maxInputLength) {
113
- Toast.warning(t('common.skillExceedLimit'));
114
- return;
115
- }
116
- }
117
- command({
118
- item: item
119
- });
120
- }
121
- };
122
- var onKeyDown = function onKeyDown(_ref3) {
123
- var event = _ref3.event,
124
- exitCb = _ref3.exitCb;
125
- if (event.key === 'ArrowUp') {
126
- upHandler();
127
- return true;
128
- }
129
- if (event.key === 'ArrowDown') {
130
- downHandler();
131
- return true;
132
- }
133
- if (event.key === 'Enter') {
134
- selectItem(selectedIndex);
135
- return true;
136
- }
137
- if (event.key === 'Escape') {
138
- exitCb && exitCb();
139
- return true;
140
- }
141
- return false;
142
- };
143
-
144
- // 暴露给 ReactRenderer(component.ref),键盘事件由 suggestion 转发进来
145
- var onKeyDownRef = useRef(onKeyDown);
146
- onKeyDownRef.current = onKeyDown;
147
- useImperativeHandle(ref, function () {
148
- return {
149
- onKeyDown: function onKeyDown(args) {
150
- return onKeyDownRef.current(args);
151
- }
152
- };
153
- }, []);
154
- var renderItem = function renderItem(item) {
155
- return /*#__PURE__*/React.createElement("div", {
156
- className: "skillItem"
157
- }, /*#__PURE__*/React.createElement("img", {
158
- src: "https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202608/27/50553_20260827090545.png",
159
- className: "icon",
160
- alt: ""
161
- }), /*#__PURE__*/React.createElement("span", {
162
- className: "name"
163
- }, item.toolName || ''), /*#__PURE__*/React.createElement("span", {
164
- className: "toolDesc"
165
- }, item.toolDesc || ''));
166
- };
167
- return /*#__PURE__*/React.createElement("div", {
168
- className: "ai-chat-input-custom-extension-dropdown-menu",
169
- style: {
170
- width: '100%'
171
- }
172
- }, /*#__PURE__*/React.createElement("div", {
173
- className: "skillTitle"
174
- }, t('common.selectSkill')), loading ? /*#__PURE__*/React.createElement("div", {
175
- style: {
176
- margin: '20px'
177
- }
178
- }, /*#__PURE__*/React.createElement(AiLoading, null)) : filterOptions.length ? /*#__PURE__*/React.createElement("div", {
179
- className: "ai-chat-input-custom-extension-dropdown-wrap"
180
- }, filterOptions.map(function (item, index) {
181
- return (
182
- /*#__PURE__*/
183
- // eslint-disable-next-line jsx-a11y/click-events-have-keyEvents
184
- React.createElement("div", {
185
- key: item.toolId || index,
186
- className: index === selectedIndex ? 'is-selected optionItem' : 'optionItem',
187
- onClick: function onClick() {
188
- return selectItem(index);
189
- },
190
- onMouseEnter: function onMouseEnter() {
191
- setSelectedIndex(index);
192
- }
193
- }, renderItem(item))
194
- );
195
- })) : /*#__PURE__*/React.createElement("div", {
196
- className: "item"
197
- }, t('common.noSkill')));
198
- });
199
- export default MentionList;
@@ -1,3 +0,0 @@
1
- import { Node } from '@tiptap/core';
2
- declare const ReferSlot: Node<any, any>;
3
- export default ReferSlot;