@myun/gimi-chat 0.9.65 → 0.9.67

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 (54) hide show
  1. package/dist/apis/useApi.d.ts +6 -0
  2. package/dist/apis/useApi.js +45 -1
  3. package/dist/components/ai-chat-dialogue/index copy.js +1 -1
  4. package/dist/components/ai-chat-dialogue/index.js +4 -2
  5. package/dist/components/answer-item/component/artifacts/index.d.ts +13 -0
  6. package/dist/components/answer-item/component/artifacts/index.js +52 -0
  7. package/dist/components/answer-item/component/artifacts/index.module.css +24 -0
  8. package/dist/components/answer-item/component/tool-list/index.d.ts +7 -0
  9. package/dist/components/answer-item/component/tool-list/index.js +117 -0
  10. package/dist/components/answer-item/component/tool-list/index.module.css +97 -0
  11. package/dist/components/answer-item/index.d.ts +2 -1
  12. package/dist/components/answer-item/index.js +179 -8
  13. package/dist/components/answer-item/index.module.css +35 -0
  14. package/dist/components/ask-card/index.d.ts +1 -1
  15. package/dist/components/chat-input/extension/index.d.ts +1 -0
  16. package/dist/components/chat-input/extension/index.js +2 -1
  17. package/dist/components/chat-input/extension/skill/MentionList.d.ts +32 -0
  18. package/dist/components/chat-input/extension/skill/MentionList.js +206 -0
  19. package/dist/components/chat-input/extension/skill/ReferSlot.d.ts +3 -0
  20. package/dist/components/chat-input/extension/skill/ReferSlot.js +100 -0
  21. package/dist/components/chat-input/extension/skill/data.d.ts +10 -0
  22. package/dist/components/chat-input/extension/skill/data.js +49 -0
  23. package/dist/components/chat-input/extension/skill/index.d.ts +7 -0
  24. package/dist/components/chat-input/extension/skill/index.js +5 -0
  25. package/dist/components/chat-input/extension/skill/index.less +117 -0
  26. package/dist/components/chat-input/extension/skill/suggestion.d.ts +16 -0
  27. package/dist/components/chat-input/extension/skill/suggestion.js +228 -0
  28. package/dist/components/chat-input/index.js +145 -24
  29. package/dist/components/chat-input/index.module.css +6 -0
  30. package/dist/components/file-card/index.js +2 -1
  31. package/dist/components/file-card/index.module.css +1 -0
  32. package/dist/components/knowledge-trace/KnowledgeIconComponent.js +6 -1
  33. package/dist/components/knowledge-trace/tryWatch.js +2 -2
  34. package/dist/components/message-list/index.js +15 -3
  35. package/dist/components/message-list/index.module.css +3 -0
  36. package/dist/components/message-list/skill-tag/index.d.ts +5 -0
  37. package/dist/components/message-list/skill-tag/index.js +23 -0
  38. package/dist/components/message-list/skill-tag/index.module.css +22 -0
  39. package/dist/components/templates/CommonChat.js +3 -1
  40. package/dist/hooks/useChatActions.d.ts +2 -1
  41. package/dist/hooks/useChatActions.js +52 -12
  42. package/dist/hooks/useChatStream.d.ts +6 -1
  43. package/dist/hooks/useChatStream.js +97 -5
  44. package/dist/hooks/useCommonChatAPI.d.ts +1 -1
  45. package/dist/hooks/useCommonChatAPI.js +212 -58
  46. package/dist/i18n/locales/en-US.d.ts +7 -0
  47. package/dist/i18n/locales/en-US.js +8 -1
  48. package/dist/i18n/locales/zh-CN.d.ts +7 -0
  49. package/dist/i18n/locales/zh-CN.js +8 -1
  50. package/dist/interfaces/chatMessage.d.ts +40 -0
  51. package/dist/umd/index.min.js +1 -1
  52. package/dist/utils/tools.d.ts +7 -0
  53. package/dist/utils/tools.js +38 -1
  54. package/package.json +4 -2
@@ -24,12 +24,14 @@ import { useTranslation } from 'react-i18next';
24
24
  import { Toast } from "@douyinfe/semi-ui";
25
25
  import { useAppDispatch, useAppSelector } from "../store/hooks";
26
26
  import { setMessageList, setFileList, setConversationId, setAgentDetail, setBusinessParams, setAutoLoadConversation, updateState, closeSidebar } from "../store/slices/gimiMenuSlice";
27
+ import { getToolNameByStatus } from "./useChatStream";
27
28
  import { fileValidation, getTimeZone, parseMessageContent, processString } from "../utils/tools";
28
29
  import { filterPropmptFromUserInput } from "../utils/tools";
29
30
  import { useChatMessage } from "./useChatMessage";
30
31
  import { useChatStream } from "./useChatStream";
31
32
  import { useLastEventId } from "./useLastEventId";
32
33
  import useScroll from "./useScroll";
34
+ // 获取推荐课程
33
35
  import { useChatRecommend } from "./useChatRecommend";
34
36
  import { set, cloneDeep } from 'lodash';
35
37
  import { FileStatus } from "../interfaces/fileInterface";
@@ -244,7 +246,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
244
246
 
245
247
  // 打断ai输出
246
248
  var handleInterrupt = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
247
- var uid, _parseMessageContent, content, _item, newMessageList, _newMessageList;
249
+ var uid, _parseMessageContent, content, _item, newMessageList, lastToolList, _newMessageList;
248
250
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
249
251
  while (1) switch (_context2.prev = _context2.next) {
250
252
  case 0:
@@ -294,6 +296,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
294
296
  }));
295
297
  }
296
298
  } else {
299
+ lastToolList = _toConsumableArray(messageList[messageList.length - 1].toolList || []);
297
300
  _newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, messageList[messageList.length - 1]), {}, {
298
301
  loading: false,
299
302
  reasoningLoading: false,
@@ -301,7 +304,16 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
301
304
  reasoningStatus: content ? 2 : 3,
302
305
  msgLoading: false,
303
306
  relatedResourceList: [],
304
- mcp: null
307
+ mcp: null,
308
+ thinkingInfo: {
309
+ status: "COMPLETED",
310
+ toolName: t('chatApi.completed'),
311
+ collapse: true,
312
+ loaded: false
313
+ },
314
+ toolList: _toConsumableArray(lastToolList.filter(function (v) {
315
+ return v.moduleType !== "agent" && v.moduleType !== 'end';
316
+ }))
305
317
  })]);
306
318
  dispatch(setMessageList({
307
319
  messageList: _newMessageList
@@ -342,8 +354,68 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
342
354
  messageList: newMessageList
343
355
  }));
344
356
  }, [dispatch]);
357
+ var handleToolStreamRs = React.useCallback(function (dataObj) {
358
+ // 只处理工作流模式下的 tool_result,其他情况暂不处理
359
+ if (dataObj.moduleType === 'tool_result' && dataObj.name !== 'executeWorkflow') return;
360
+ setStatus(2);
361
+ var messageList = messageListRef.current;
362
+ var lastMessage = messageList[messageList.length - 1];
363
+ var curToolList = _toConsumableArray((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.toolList) || []);
364
+ var curToolIndex = curToolList.findIndex(function (item) {
365
+ return (item === null || item === void 0 ? void 0 : item.id) === dataObj.id;
366
+ });
367
+
368
+ // 为新节点类型根据 status 生成 toolName
369
+ var isNewNodeType = !['tool_invocation', 'tool_result', "agent"].includes(dataObj.moduleType);
370
+ var toolName = isNewNodeType ? getToolNameByStatus(dataObj.moduleType, dataObj.status) : dataObj.toolName;
371
+ if (curToolIndex >= 0) {
372
+ curToolList[curToolIndex] = _objectSpread(_objectSpread({}, curToolList[curToolIndex]), {}, {
373
+ content: dataObj.moduleType === 'thinking' ? dataObj.reasoningContent : dataObj.content || '',
374
+ // tool_invocation 更新 toolName 和 status,新节点类型也更新
375
+ toolName: dataObj.moduleType === 'tool_invocation' ? dataObj.toolName || '' : isNewNodeType ? toolName : curToolList[curToolIndex].toolName,
376
+ status: dataObj.moduleType === 'tool_invocation' || isNewNodeType ? dataObj.status : curToolList[curToolIndex].status
377
+ });
378
+ } else {
379
+ // 新增工具时,为新节点类型补充 toolName
380
+ // agent 类类型,保持只有一个 agent
381
+ // tool_result只是工具的结果,不能新增
382
+ if (dataObj.moduleType === 'agent' && curToolList.length > 0 || dataObj.moduleType === 'tool_result') return;
383
+ curToolList = curToolList.filter(function (tool) {
384
+ return tool.moduleType !== 'agent';
385
+ });
386
+ curToolList = [].concat(_toConsumableArray(curToolList), [_objectSpread(_objectSpread({}, dataObj), {}, {
387
+ toolName: toolName || dataObj.toolName
388
+ })]);
389
+ }
390
+ var newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
391
+ moduleType: dataObj.moduleType,
392
+ toolList: _toConsumableArray(curToolList)
393
+ })]);
394
+ dispatch(setMessageList({
395
+ messageList: newMessageList
396
+ }));
397
+ }, [dispatch]);
398
+ var handleArtifactStreamRs = React.useCallback(function (dataObj) {
399
+ setStatus(2);
400
+ var messageList = messageListRef.current;
401
+ var lastMessage = messageList[messageList.length - 1];
402
+ var newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
403
+ moduleType: dataObj.moduleType,
404
+ artifacts: dataObj.artifacts || []
405
+ })]);
406
+ messageListRef.current = newMessageList;
407
+ dispatch(setMessageList({
408
+ messageList: newMessageList
409
+ }));
410
+ }, [dispatch]);
345
411
 
346
412
  // 发起会话 - 使用新的hook简化逻辑
413
+ // @param id 会话ID
414
+ // @param reSumeInfo 恢复信息
415
+ // @param onSseOpen 开启SSE回调
416
+ // @param onDataReceived 数据接收回调
417
+ // @param onComplete 完成回调
418
+ // @param onErrorComplete 错误完成回调
347
419
  var fetchChatStream = React.useCallback( /*#__PURE__*/function () {
348
420
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id, reSumeInfo, _onSseOpen, _onDataReceived, _onComplete, _onErrorComplete) {
349
421
  var fullResponse, reasoningResponse;
@@ -368,10 +440,10 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
368
440
  }
369
441
  _onDataReceived(response, type);
370
442
  },
371
- onComplete: function onComplete(response, type) {
443
+ onComplete: function onComplete(response, type, reasoning, dataObj) {
372
444
  if (type === 'end' || type === 'COMPLETED') {
373
445
  removeLastEventId(id);
374
- _onComplete(fullResponse, type, reasoningResponse);
446
+ _onComplete(fullResponse, type, reasoningResponse, dataObj);
375
447
  } else {
376
448
  moduleInfoRef.current = response;
377
449
  _onComplete(response, type);
@@ -382,6 +454,12 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
382
454
  },
383
455
  onMCPToolsStream: function onMCPToolsStream(dataObj) {
384
456
  handleMCPToolsStreamRs(dataObj);
457
+ },
458
+ onToolStream: function onToolStream(dataObj) {
459
+ handleToolStreamRs(dataObj);
460
+ },
461
+ onArtifactStream: function onArtifactStream(dataObj) {
462
+ handleArtifactStreamRs(dataObj);
385
463
  }
386
464
  });
387
465
  case 5:
@@ -393,7 +471,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
393
471
  return function (_x, _x2, _x3, _x4, _x5, _x6) {
394
472
  return _ref5.apply(this, arguments);
395
473
  };
396
- }(), [fetchChatStreamHook, setIgnoreOnMessage, removeLastEventId, handleMCPToolsStreamRs]);
474
+ }(), [fetchChatStreamHook, setIgnoreOnMessage, removeLastEventId, handleMCPToolsStreamRs, handleToolStreamRs, handleArtifactStreamRs]);
397
475
  var getRelatedCourses = React.useCallback( /*#__PURE__*/function () {
398
476
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(input) {
399
477
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -461,22 +539,69 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
461
539
  setMsgLoading(false);
462
540
  setStatus(2);
463
541
  var currentMessageList = messageListRef.current;
464
- var newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, type, response || ''), "loading", again ? false : true), "msgLoading", false), "vipLevel", vipLevelRef.current), "reasoningLoading", type === 'content' ? false : again ? false : true), "reasoningStatus", type === 'content' ? 2 : 1), "moduleInfo", null), "moduleType", 'end'), "mcp", null))]);
542
+ var lastToolList = _toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []);
543
+ if (lastToolList.findIndex(function (v) {
544
+ return v.moduleType === 'end';
545
+ }) < 0) {
546
+ lastToolList.push({
547
+ moduleType: 'end',
548
+ content: '',
549
+ status: "RUNNING",
550
+ toolName: t('chatApi.organizingAnswer'),
551
+ id: "".concat(new Date().getTime())
552
+ });
553
+ }
554
+ var newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, type, response || ''), "loading", again ? false : true), "msgLoading", false), "vipLevel", vipLevelRef.current), "reasoningLoading", type === 'content' ? false : again ? false : true), "reasoningStatus", type === 'content' ? 2 : 1), "moduleInfo", null), "moduleType", 'end'), "mcp", null), "toolList", lastToolList))]);
465
555
  dispatch(setMessageList({
466
556
  messageList: newMessageList
467
557
  }));
468
558
  }, /*#__PURE__*/function () {
469
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(Response, type, reasoningResponse) {
470
- var currentMessageList, newMessageList, agentDetail, userInput;
559
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(Response, type, reasoningResponse, dataObj) {
560
+ var currentMessageList, lastToolList, newMessageList, agentDetail, userInput;
471
561
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
472
562
  while (1) switch (_context5.prev = _context5.next) {
473
563
  case 0:
474
564
  // if (isSystemAuto) return;
475
565
  setIgnoreOnMessage(true);
476
566
  currentMessageList = messageListRef.current;
477
- newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
478
- moduleType: type
479
- }, type === 'end' ? 'content' : 'moduleInfo', Response), "reasoningResponse", type === 'end' ? reasoningResponse : ''), "loading", false), "reasoningLoading", false), "mcp", null))]);
567
+ lastToolList = _toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []);
568
+ newMessageList = [];
569
+ if (type === 'user_confirm') {
570
+ newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, {
571
+ moduleType: type,
572
+ moduleInfo: Response,
573
+ reasoningResponse: '',
574
+ loading: false,
575
+ reasoningLoading: false,
576
+ mcp: null,
577
+ thinkingInfo: {
578
+ status: "RUNNING",
579
+ toolName: t('chatApi.completed'),
580
+ collapse: false,
581
+ loaded: true
582
+ },
583
+ toolList: [].concat(_toConsumableArray(lastToolList), [{
584
+ moduleType: type,
585
+ content: '',
586
+ data: Response,
587
+ status: "RUNNING",
588
+ toolName: t('chatApi.waitingForConfirmation'),
589
+ confirmStatus: "PENDING",
590
+ id: "".concat(new Date().getTime())
591
+ }])
592
+ })]);
593
+ } else {
594
+ newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
595
+ moduleType: type
596
+ }, type === 'end' ? 'content' : 'moduleInfo', Response), "reasoningResponse", type === 'end' ? reasoningResponse : ''), "loading", false), "reasoningLoading", false), "mcp", null), "durationMs", (dataObj === null || dataObj === void 0 ? void 0 : dataObj.elapsed) || 0), "totalTokens", (dataObj === null || dataObj === void 0 ? void 0 : dataObj.totalTokens) || 0), "thinkingInfo", {
597
+ status: type === 'end' ? "COMPLETED" : "RUNNING",
598
+ toolName: t('chatApi.completed'),
599
+ collapse: true,
600
+ loaded: true
601
+ }), "toolList", _toConsumableArray(lastToolList.filter(function (v) {
602
+ return v.moduleType !== "agent" && v.moduleType !== 'end';
603
+ }))))]);
604
+ }
480
605
  dispatch(setMessageList({
481
606
  messageList: newMessageList
482
607
  }));
@@ -487,13 +612,13 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
487
612
  // 获取最新的agent详情,防止redux异步更新
488
613
  agentDetail = agentInfo || agentObjRef.current; // 获取推荐追问
489
614
  if (!((agentDetail === null || agentDetail === void 0 ? void 0 : agentDetail.isEnableRelated) === 1 && (type === 'end' || type === 'COMPLETED'))) {
490
- _context5.next = 10;
615
+ _context5.next = 12;
491
616
  break;
492
617
  }
493
618
  setMsgLoading(true);
494
- _context5.next = 10;
619
+ _context5.next = 12;
495
620
  return getRecommendList(newMessageList, lastId, statusRef.current);
496
- case 10:
621
+ case 12:
497
622
  // 获取相关课程
498
623
  userInput = newMessageList[newMessageList.length - 2].content;
499
624
  getRelatedCourses(userInput || '');
@@ -504,25 +629,35 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
504
629
  }
505
630
  setMsgLoading(false);
506
631
  onSendEnd === null || onSendEnd === void 0 || onSendEnd(newMessageList[newMessageList.length - 1]);
507
- case 15:
632
+ case 17:
508
633
  case "end":
509
634
  return _context5.stop();
510
635
  }
511
636
  }, _callee5);
512
637
  }));
513
- return function (_x10, _x11, _x12) {
638
+ return function (_x10, _x11, _x12, _x13) {
514
639
  return _ref8.apply(this, arguments);
515
640
  };
516
641
  }(), function () {
517
642
  setIgnoreOnMessage(true);
518
643
  var currentMessageList = messageListRef.current;
644
+ var lastToolList = [].concat(_toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []), [{
645
+ moduleType: 'FAILED',
646
+ content: '',
647
+ status: "COMPLETED",
648
+ toolName: '服务异常',
649
+ id: "".concat(new Date().getTime())
650
+ }]);
519
651
  var newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, {
520
652
  loading: false,
521
653
  reasoningLoading: false,
522
654
  stop: 0,
523
655
  reasoningStatus: 3,
524
656
  msgLoading: false,
525
- mcp: null
657
+ mcp: null,
658
+ toolList: _toConsumableArray(lastToolList.filter(function (v) {
659
+ return v.moduleType !== "agent" && v.moduleType !== 'end';
660
+ }))
526
661
  })]);
527
662
  dispatch(setMessageList({
528
663
  messageList: newMessageList
@@ -601,7 +736,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
601
736
  lastUserMessage = chatList.filter(function (item) {
602
737
  return item.role === 0;
603
738
  }).pop(); // 检查最后一条消息是否为未完成的AI消息
604
- if ((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === 1 && lastMessage.isCompleteOut === 0 && lastMessage.chatId) {
739
+ if ((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === 1 && lastMessage.isCompleteOut === 0 && lastMessage.chatId && lastMessage.moduleType !== 'user_confirm') {
605
740
  if (lastMessage.vipLevel === 1) {
606
741
  vipLevelRef.current = 1;
607
742
  }
@@ -618,7 +753,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
618
753
  reasoningContent: processString(lastMessage.reasoningContent || '')
619
754
  }, agentObjRef.current); // 调用续传接口
620
755
  }
621
- if (!((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === 1 && lastMessage.isCompleteOut === 1)) {
756
+ if (!((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === 1 && lastMessage.isCompleteOut === 1 && lastMessage.moduleType !== 'user_confirm')) {
622
757
  _context8.next = 10;
623
758
  break;
624
759
  }
@@ -643,7 +778,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
643
778
  }
644
779
  }, _callee8);
645
780
  }));
646
- return function (_x13) {
781
+ return function (_x14) {
647
782
  return _ref10.apply(this, arguments);
648
783
  };
649
784
  }(), [dispatch, streamChat, removeLastEventId, rewriteRecommendListFormHistory, getRelatedCourses]);
@@ -669,6 +804,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
669
804
  var isSystemAuto,
670
805
  conversationId,
671
806
  isAskFileSend,
807
+ skipCreateNewMessage,
672
808
  val,
673
809
  signal,
674
810
  currentBusinessParams,
@@ -688,6 +824,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
688
824
  isSystemAuto = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : false;
689
825
  conversationId = _args9.length > 2 ? _args9[2] : undefined;
690
826
  isAskFileSend = _args9.length > 3 ? _args9[3] : undefined;
827
+ skipCreateNewMessage = _args9.length > 4 ? _args9[4] : undefined;
691
828
  // 如果是ask卡片的file上传,发送content为''
692
829
  val = isAskFileSend ? '' : (_reverse$find = _toConsumableArray(messageList).reverse().find(function (item) {
693
830
  return item.role === 0;
@@ -702,7 +839,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
702
839
  signal = controllerRef.current.signal;
703
840
  step.current = 1;
704
841
  currentBusinessParams = _objectSpread({}, businessParamsRef.current || {});
705
- _context9.prev = 10;
842
+ _context9.prev = 11;
706
843
  params = _objectSpread({
707
844
  content: val,
708
845
  conversationId: conversationId || conversationIdRef.current,
@@ -736,7 +873,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
736
873
  if (isSystemAuto) {
737
874
  params.isSystemAuto = 1;
738
875
  }
739
- _context9.next = 20;
876
+ _context9.next = 21;
740
877
  return fetch("https://".concat(baseUrlRef.current, "/mbot/web/agent-message"), {
741
878
  method: 'POST',
742
879
  headers: {
@@ -748,15 +885,15 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
748
885
  signal: signal,
749
886
  body: JSON.stringify(params)
750
887
  });
751
- case 20:
888
+ case 21:
752
889
  _response = _context9.sent;
753
890
  if (!_response.ok) {
754
- _context9.next = 29;
891
+ _context9.next = 31;
755
892
  break;
756
893
  }
757
- _context9.next = 24;
894
+ _context9.next = 25;
758
895
  return _response.json();
759
- case 24:
896
+ case 25:
760
897
  responseMsg = _context9.sent;
761
898
  // 执行使用方定义的回调函数
762
899
  if (!onFirstSendSuccessCalledRef.current) {
@@ -769,14 +906,16 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
769
906
  dispatch(setFileList({
770
907
  fileList: []
771
908
  }));
909
+ inputModelRef.current = null; // 清空 inputModel,避免下次发送时残留
910
+
772
911
  if (responseMsg.status === 0) {
773
- result = responseMsg.result;
774
- aiChat = createAiChat(result); // 根据isSystemAuto决定是否添加AI消息到列表
775
- // if (!isSystemAuto) {
776
- dispatch(setMessageList({
777
- messageList: [].concat(_toConsumableArray(messageList), [aiChat])
778
- }));
779
- // }
912
+ result = responseMsg.result; // 如果 skipCreateNewMessage 为 true,不创建新消息,直接用当前最后一条
913
+ if (!skipCreateNewMessage) {
914
+ aiChat = createAiChat(result);
915
+ dispatch(setMessageList({
916
+ messageList: [].concat(_toConsumableArray(messageList), [aiChat])
917
+ }));
918
+ }
780
919
  // 继续流式处理聊天
781
920
  streamChat(result.id, false);
782
921
  } else {
@@ -788,12 +927,12 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
788
927
  setStatus(0);
789
928
  }
790
929
  }
791
- case 29:
792
- _context9.next = 34;
793
- break;
794
930
  case 31:
795
- _context9.prev = 31;
796
- _context9.t0 = _context9["catch"](10);
931
+ _context9.next = 36;
932
+ break;
933
+ case 33:
934
+ _context9.prev = 33;
935
+ _context9.t0 = _context9["catch"](11);
797
936
  if (_context9.t0.name === 'AbortError') {
798
937
  setMsgLoading(false);
799
938
  if (inputValue) {
@@ -810,17 +949,21 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
810
949
  setStatus(0);
811
950
  }
812
951
  }
813
- case 34:
952
+ case 36:
814
953
  case "end":
815
954
  return _context9.stop();
816
955
  }
817
- }, _callee9, null, [[10, 31]]);
956
+ }, _callee9, null, [[11, 33]]);
818
957
  }));
819
- return function (_x14) {
958
+ return function (_x15) {
820
959
  return _ref11.apply(this, arguments);
821
960
  };
822
961
  }(), [dispatch, inputValue, streamEsAbortRef]);
823
962
  var fillInputModel = React.useCallback(function (value, messageList) {
963
+ // 如果 inputModelRef 已经被设置(confirm/ask点击等),不要覆盖
964
+ if (inputModelRef.current) {
965
+ return;
966
+ }
824
967
  if ((messageList === null || messageList === void 0 ? void 0 : messageList.length) > 0 && value && messageList[messageList.length - 1].moduleType === 'ask') {
825
968
  var targetChatItem = _toConsumableArray(messageList).reverse().find(function (item) {
826
969
  return item.role === 1;
@@ -831,12 +974,15 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
831
974
  inputModelRef.current = _inputModel;
832
975
  }
833
976
  }, []);
977
+
978
+ // 点击发送按钮
834
979
  var handleSend = React.useCallback( /*#__PURE__*/function () {
835
980
  var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(val) {
836
981
  var _chatInputConfig$onBe;
837
982
  var agent,
838
983
  isSystemAuto,
839
984
  conversationId,
985
+ skipCreateNewMessage,
840
986
  value,
841
987
  fileValidationMsg,
842
988
  cleanVal,
@@ -852,39 +998,40 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
852
998
  agent = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : agentObj;
853
999
  isSystemAuto = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : false;
854
1000
  conversationId = _args10.length > 3 ? _args10[3] : undefined;
1001
+ skipCreateNewMessage = _args10.length > 4 ? _args10[4] : undefined;
855
1002
  value = val.trim();
856
1003
  if (!(!value && !isSystemAuto)) {
857
- _context10.next = 6;
1004
+ _context10.next = 7;
858
1005
  break;
859
1006
  }
860
1007
  return _context10.abrupt("return");
861
- case 6:
1008
+ case 7:
862
1009
  if (navigator.onLine) {
863
- _context10.next = 9;
1010
+ _context10.next = 10;
864
1011
  break;
865
1012
  }
866
1013
  Toast.error(t('common.networkUnavailable'));
867
1014
  return _context10.abrupt("return");
868
- case 9:
1015
+ case 10:
869
1016
  if (!(status === 2 || msgLoading)) {
870
- _context10.next = 12;
1017
+ _context10.next = 13;
871
1018
  break;
872
1019
  }
873
1020
  Toast.error(t('chatApi.aiResponding'));
874
1021
  return _context10.abrupt("return");
875
- case 12:
1022
+ case 13:
876
1023
  chatInputConfig === null || chatInputConfig === void 0 || (_chatInputConfig$onBe = chatInputConfig.onBeforeSend) === null || _chatInputConfig$onBe === void 0 || _chatInputConfig$onBe.call(chatInputConfig, value);
877
1024
 
878
1025
  // 设置inputModel
879
1026
  fillInputModel(value, messageListRef.current);
880
1027
  fileValidationMsg = fileValidation(fileListRef.current);
881
1028
  if (!fileValidationMsg) {
882
- _context10.next = 18;
1029
+ _context10.next = 19;
883
1030
  break;
884
1031
  }
885
1032
  Toast.error(fileValidationMsg);
886
1033
  return _context10.abrupt("return");
887
- case 18:
1034
+ case 19:
888
1035
  if (isPlaying) {
889
1036
  // 点击发送按钮时,先停止播放
890
1037
  stopTTSByText === null || stopTTSByText === void 0 || stopTTSByText();
@@ -909,19 +1056,19 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
909
1056
  dispatch(setMessageList({
910
1057
  messageList: newChatList
911
1058
  }));
912
- startChat(newChatList, isSystemAuto, conversationId);
1059
+ startChat(newChatList, isSystemAuto, conversationId, undefined, skipCreateNewMessage);
913
1060
  } else {
914
1061
  setMsgLoading(true);
915
1062
  // 系统自动上传,直接开始会话,不更新列表
916
- startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId);
1063
+ startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId, undefined, skipCreateNewMessage);
917
1064
  }
918
- case 24:
1065
+ case 25:
919
1066
  case "end":
920
1067
  return _context10.stop();
921
1068
  }
922
1069
  }, _callee10);
923
1070
  }));
924
- return function (_x15) {
1071
+ return function (_x16) {
925
1072
  return _ref12.apply(this, arguments);
926
1073
  };
927
1074
  }(), [dispatch, startChat, chatInputConfig, createUserChat, fillInputModel, isPlaying, status, stopTTSByText, msgLoading, agentObj]);
@@ -959,7 +1106,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
959
1106
  }
960
1107
  }, _callee11, null, [[2, 9]]);
961
1108
  }));
962
- return function (_x16) {
1109
+ return function (_x17) {
963
1110
  return _ref13.apply(this, arguments);
964
1111
  };
965
1112
  }(), [t]);
@@ -1042,7 +1189,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1042
1189
  }
1043
1190
  }, _callee12, null, [[0, 14]]);
1044
1191
  }));
1045
- return function (_x17) {
1192
+ return function (_x18) {
1046
1193
  return _ref14.apply(this, arguments);
1047
1194
  };
1048
1195
  }(), []);
@@ -1106,7 +1253,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1106
1253
  }
1107
1254
  }, _callee13, null, [[6, 14]]);
1108
1255
  }));
1109
- return function (_x18) {
1256
+ return function (_x19) {
1110
1257
  return _ref15.apply(this, arguments);
1111
1258
  };
1112
1259
  }(), [handleSend, platform, dispatch, createRoomId, onConversationCreated, getHeaderValue, t]);
@@ -1218,10 +1365,17 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1218
1365
  }, [dispatch, handleSend]);
1219
1366
  React.useEffect(function () {
1220
1367
  if ((messageList === null || messageList === void 0 ? void 0 : messageList.length) > 0) {
1221
- var _chatItem$moduleInfo, _chatItem$moduleInfo2;
1368
+ var _chatItem$toolList, _chatItem$moduleInfo, _chatItem$moduleInfo2;
1222
1369
  // 设置输入框是否可点击
1223
1370
  var chatItem = messageList[messageList.length - 1];
1224
- if (chatItem.moduleType === 'ask' && (chatItem === null || chatItem === void 0 || (_chatItem$moduleInfo = chatItem.moduleInfo) === null || _chatItem$moduleInfo === void 0 || (_chatItem$moduleInfo = _chatItem$moduleInfo.data) === null || _chatItem$moduleInfo === void 0 || (_chatItem$moduleInfo = _chatItem$moduleInfo.results) === null || _chatItem$moduleInfo === void 0 ? void 0 : _chatItem$moduleInfo.askShowInfo.answerType) === 1) {
1371
+
1372
+ // 检查是否有等待用户确认的 user_confirm
1373
+ var hasWaitingConfirm = (_chatItem$toolList = chatItem.toolList) === null || _chatItem$toolList === void 0 ? void 0 : _chatItem$toolList.some(function (tool) {
1374
+ return tool.moduleType === 'user_confirm' && tool.status === 'RUNNING';
1375
+ });
1376
+ if (hasWaitingConfirm) {
1377
+ setDisableSend(true);
1378
+ } else if (chatItem.moduleType === 'ask' && (chatItem === null || chatItem === void 0 || (_chatItem$moduleInfo = chatItem.moduleInfo) === null || _chatItem$moduleInfo === void 0 || (_chatItem$moduleInfo = _chatItem$moduleInfo.data) === null || _chatItem$moduleInfo === void 0 || (_chatItem$moduleInfo = _chatItem$moduleInfo.results) === null || _chatItem$moduleInfo === void 0 ? void 0 : _chatItem$moduleInfo.askShowInfo.answerType) === 1) {
1225
1379
  setDisableSend(true);
1226
1380
  } else if (chatItem.moduleType === 'skill' && (chatItem === null || chatItem === void 0 || (_chatItem$moduleInfo2 = chatItem.moduleInfo) === null || _chatItem$moduleInfo2 === void 0 || (_chatItem$moduleInfo2 = _chatItem$moduleInfo2.data) === null || _chatItem$moduleInfo2 === void 0 || (_chatItem$moduleInfo2 = _chatItem$moduleInfo2.results) === null || _chatItem$moduleInfo2 === void 0 ? void 0 : _chatItem$moduleInfo2.skillResult.requestStatus) !== 1) {
1227
1381
  setDisableSend(true);
@@ -59,6 +59,7 @@ declare const enUS: {
59
59
  'trace.document.trialInvalidDoc': string;
60
60
  'trace.document.trialFailed': string;
61
61
  'trace.tryFullTips': string;
62
+ 'trace.tryFullTipsNoEntitlement': string;
62
63
  'trace.tryFull': string;
63
64
  'trace.iconAlt': string;
64
65
  'trace.countByType': string;
@@ -97,6 +98,8 @@ declare const enUS: {
97
98
  'common.dataLoading': string;
98
99
  'common.pleaseWait': string;
99
100
  'common.empty': string;
101
+ 'common.noSkill': string;
102
+ 'common.skillExceedLimit': string;
100
103
  'common.delete': string;
101
104
  'common.cancel': string;
102
105
  'common.retry': string;
@@ -165,6 +168,9 @@ declare const enUS: {
165
168
  'chatApi.deleteSuccess': string;
166
169
  'chatApi.deleteFailed': string;
167
170
  'chatApi.noRequestToCancel': string;
171
+ 'chatApi.completed': string;
172
+ 'chatApi.organizingAnswer': string;
173
+ 'chatApi.waitingForConfirmation': string;
168
174
  'messageAction.copy': string;
169
175
  'messageAction.likeDone': string;
170
176
  'messageAction.like': string;
@@ -256,5 +262,6 @@ declare const enUS: {
256
262
  'informationDetail.applicableCountry': string;
257
263
  'informationDetail.signDate': string;
258
264
  'informationDetail.executeDate': string;
265
+ 'common.selectSkill': string;
259
266
  };
260
267
  export default enUS;
@@ -59,6 +59,7 @@ var enUS = {
59
59
  'trace.document.trialInvalidDoc': 'This document does not support trial preview',
60
60
  'trace.document.trialFailed': 'Failed to load trial preview',
61
61
  'trace.tryFullTips': 'You can preview part of the content. Click the button on the right to view the full content.',
62
+ 'trace.tryFullTipsNoEntitlement': 'No viewing rights. Please upgrade to Class A or reach out to your admin/instructor.',
62
63
  'trace.tryFull': 'View',
63
64
  'trace.iconAlt': 'Knowledge source icon',
64
65
  'trace.countByType': '{{count}} {{type}}',
@@ -97,6 +98,8 @@ var enUS = {
97
98
  'common.dataLoading': 'Data loading...',
98
99
  'common.pleaseWait': 'Please wait...',
99
100
  'common.empty': 'No content',
101
+ 'common.noSkill': 'No Skill',
102
+ 'common.skillExceedLimit': 'Adding this skill will exceed the 10000-character limit. Please shorten your input first.',
100
103
  'common.delete': 'Delete',
101
104
  'common.cancel': 'Cancel',
102
105
  'common.retry': 'Retry',
@@ -165,6 +168,9 @@ var enUS = {
165
168
  'chatApi.deleteSuccess': 'Conversation deleted successfully',
166
169
  'chatApi.deleteFailed': 'Failed to delete conversation',
167
170
  'chatApi.noRequestToCancel': 'No request to cancel',
171
+ 'chatApi.completed': 'Completed',
172
+ 'chatApi.organizingAnswer': 'Organizing answer',
173
+ 'chatApi.waitingForConfirmation': 'Waiting for confirmation',
168
174
  'messageAction.copy': 'Copy',
169
175
  'messageAction.likeDone': 'Liked',
170
176
  'messageAction.like': 'Like',
@@ -255,6 +261,7 @@ var enUS = {
255
261
  'informationDetail.taxPreferenceLabel': 'Tax Preference:',
256
262
  'informationDetail.applicableCountry': 'Applicable Country:',
257
263
  'informationDetail.signDate': 'Sign Date:',
258
- 'informationDetail.executeDate': 'Execute Date:'
264
+ 'informationDetail.executeDate': 'Execute Date:',
265
+ 'common.selectSkill': 'Select Skill'
259
266
  };
260
267
  export default enUS;