@glodon-aiot/chat-app-sdk 0.0.17 → 0.0.19

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/es/index.esm.js CHANGED
@@ -10547,6 +10547,250 @@ ___CSS_LOADER_EXPORT___.locals = {
10547
10547
  /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
10548
10548
 
10549
10549
 
10550
+ }),
10551
+ 94148: (function (module, __webpack_exports__, __webpack_require__) {
10552
+ __webpack_require__.d(__webpack_exports__, {
10553
+ A: () => (__WEBPACK_DEFAULT_EXPORT__)
10554
+ });
10555
+ /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(58623);
10556
+ /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
10557
+ /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34688);
10558
+ /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
10559
+ // Imports
10560
+
10561
+
10562
+ var ___CSS_LOADER_EXPORT___ = _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
10563
+ // Module
10564
+ ___CSS_LOADER_EXPORT___.push([module.id, `/* Comment Message Container */
10565
+ .ffe867e2c235a0c5 {
10566
+ display: flex;
10567
+ align-items: center;
10568
+ gap: 4px;
10569
+ }
10570
+ /* Icon selected state */
10571
+ .d07fb38c947809f8 {
10572
+ color: #b752ea !important;
10573
+ }
10574
+ /* IconButton selected state - ensure background doesn't highlight */
10575
+ .d9418402ebdc6c0f {
10576
+ background-color: transparent !important;
10577
+ }
10578
+ .d9418402ebdc6c0f:hover {
10579
+ background-color: transparent !important;
10580
+ }
10581
+ /* Feedback Dialog Styles */
10582
+ .b29fb4268fffc847 {
10583
+ position: absolute;
10584
+ top: 0;
10585
+ left: 0;
10586
+ right: 0;
10587
+ bottom: 0;
10588
+ background-color: rgba(0, 0, 0, 0.5);
10589
+ display: flex;
10590
+ align-items: center;
10591
+ justify-content: center;
10592
+ z-index: 10000;
10593
+ }
10594
+ /* 当容器是 document.body 时,使用 fixed 定位 */
10595
+ .b29fb4268fffc847[data-container-is-body="true"] {
10596
+ position: fixed;
10597
+ top: 0;
10598
+ left: 0;
10599
+ right: 0;
10600
+ bottom: 0;
10601
+ }
10602
+ .a82c68467fbd9ba4 {
10603
+ background: #fff;
10604
+ border-radius: 8px;
10605
+ width: 90%;
10606
+ max-width: 480px;
10607
+ min-width: 320px;
10608
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
10609
+ display: flex;
10610
+ flex-direction: column;
10611
+ max-height: 90vh;
10612
+ }
10613
+ .a82c68467fbd9ba4 .fe9b5896dd607d27 {
10614
+ display: flex;
10615
+ align-items: center;
10616
+ justify-content: space-between;
10617
+ padding: 16px 20px;
10618
+ border-bottom: 1px solid #e8e8e8;
10619
+ }
10620
+ .a82c68467fbd9ba4 .f15e6e77acfff31a {
10621
+ margin: 0;
10622
+ font-size: 16px;
10623
+ font-weight: 600;
10624
+ color: #333;
10625
+ }
10626
+ .a82c68467fbd9ba4 .ec213d35312b7d7e {
10627
+ background: none;
10628
+ border: none;
10629
+ font-size: 24px;
10630
+ line-height: 1;
10631
+ color: #999;
10632
+ cursor: pointer;
10633
+ padding: 0;
10634
+ width: 24px;
10635
+ height: 24px;
10636
+ display: flex;
10637
+ align-items: center;
10638
+ justify-content: center;
10639
+ transition: color 0.2s;
10640
+ }
10641
+ .a82c68467fbd9ba4 .ec213d35312b7d7e:hover {
10642
+ color: #333;
10643
+ }
10644
+ .a82c68467fbd9ba4 .dc3fb716e09637a3 {
10645
+ padding: 20px;
10646
+ flex: 1;
10647
+ overflow-y: auto;
10648
+ }
10649
+ .a82c68467fbd9ba4 .dab8560c96fa0283 {
10650
+ display: flex;
10651
+ flex-wrap: wrap;
10652
+ gap: 12px;
10653
+ margin-bottom: 20px;
10654
+ }
10655
+ .a82c68467fbd9ba4 .d36e84632eb09d08 {
10656
+ padding: 8px 16px;
10657
+ border: 1px solid #d9d9d9;
10658
+ border-radius: 4px;
10659
+ background: #fff;
10660
+ color: #333;
10661
+ font-size: 14px;
10662
+ cursor: pointer;
10663
+ transition: all 0.2s;
10664
+ }
10665
+ .a82c68467fbd9ba4 .d36e84632eb09d08:hover {
10666
+ border-color: #999;
10667
+ color: #666;
10668
+ }
10669
+ .a82c68467fbd9ba4 .b8dbe31e00feb69b {
10670
+ border-color: #b752ea;
10671
+ background: #fff;
10672
+ color: #b752ea;
10673
+ }
10674
+ .a82c68467fbd9ba4 .b8dbe31e00feb69b:hover {
10675
+ border-color: #999;
10676
+ color: #666;
10677
+ }
10678
+ .a82c68467fbd9ba4 .df277aeb58f67270 {
10679
+ margin-top: 16px;
10680
+ }
10681
+ .a82c68467fbd9ba4 .d79bf5aef0816574 {
10682
+ padding: 5px 8px;
10683
+ width: 100%;
10684
+ border: 1px solid #d9d9d9;
10685
+ border-radius: 4px;
10686
+ font-size: 14px;
10687
+ font-family: inherit;
10688
+ resize: vertical;
10689
+ min-height: 80px;
10690
+ box-sizing: border-box;
10691
+ resize: none;
10692
+ }
10693
+ .a82c68467fbd9ba4 .d79bf5aef0816574:focus {
10694
+ outline: none;
10695
+ border: 1px solid #b752ea;
10696
+ box-shadow: 0 0 0 2px rgba(183, 82, 234, 0.1);
10697
+ }
10698
+ .a82c68467fbd9ba4 .d79bf5aef0816574::-moz-placeholder {
10699
+ color: #999;
10700
+ }
10701
+ .a82c68467fbd9ba4 .d79bf5aef0816574::placeholder {
10702
+ color: #999;
10703
+ }
10704
+ .a82c68467fbd9ba4 .ddce66c2730266a9 {
10705
+ display: flex;
10706
+ justify-content: flex-end;
10707
+ gap: 12px;
10708
+ padding: 16px 20px;
10709
+ border-top: 1px solid #e8e8e8;
10710
+ }
10711
+ .a82c68467fbd9ba4 .cbb043ea2499271a,
10712
+ .a82c68467fbd9ba4 .c55955936e93afa3 {
10713
+ padding: 8px 20px;
10714
+ border-radius: 4px;
10715
+ font-size: 14px;
10716
+ cursor: pointer;
10717
+ transition: all 0.2s;
10718
+ border: none;
10719
+ }
10720
+ .a82c68467fbd9ba4 .cbb043ea2499271a {
10721
+ background: #fff;
10722
+ color: #333;
10723
+ border: 1px solid #d9d9d9;
10724
+ }
10725
+ .a82c68467fbd9ba4 .cbb043ea2499271a:hover {
10726
+ border-color: #999;
10727
+ color: #666;
10728
+ }
10729
+ .a82c68467fbd9ba4 .c55955936e93afa3 {
10730
+ background: #b752ea;
10731
+ color: #fff;
10732
+ }
10733
+ .a82c68467fbd9ba4 .c55955936e93afa3:hover:not(:disabled) {
10734
+ background: #9d3ac2;
10735
+ }
10736
+ .a82c68467fbd9ba4 .c55955936e93afa3:disabled {
10737
+ background: #d9d9d9;
10738
+ color: #999;
10739
+ cursor: not-allowed;
10740
+ }
10741
+ /* Responsive styles */
10742
+ @media (max-width: 768px) {
10743
+ .a82c68467fbd9ba4 {
10744
+ width: 95%;
10745
+ max-width: 95%;
10746
+ }
10747
+ .dab8560c96fa0283 {
10748
+ flex-direction: column;
10749
+ }
10750
+ .d36e84632eb09d08 {
10751
+ width: 100%;
10752
+ }
10753
+ }
10754
+ `, ""]);
10755
+ // Exports
10756
+ ___CSS_LOADER_EXPORT___.locals = {
10757
+ "container": `ffe867e2c235a0c5`,
10758
+ "icon-selected": `d07fb38c947809f8`,
10759
+ "iconSelected": `d07fb38c947809f8`,
10760
+ "icon-button-selected": `d9418402ebdc6c0f`,
10761
+ "iconButtonSelected": `d9418402ebdc6c0f`,
10762
+ "feedback-overlay": `b29fb4268fffc847`,
10763
+ "feedbackOverlay": `b29fb4268fffc847`,
10764
+ "feedback-dialog": `a82c68467fbd9ba4`,
10765
+ "feedbackDialog": `a82c68467fbd9ba4`,
10766
+ "feedback-header": `fe9b5896dd607d27`,
10767
+ "feedbackHeader": `fe9b5896dd607d27`,
10768
+ "feedback-title": `f15e6e77acfff31a`,
10769
+ "feedbackTitle": `f15e6e77acfff31a`,
10770
+ "feedback-close": `ec213d35312b7d7e`,
10771
+ "feedbackClose": `ec213d35312b7d7e`,
10772
+ "feedback-content": `dc3fb716e09637a3`,
10773
+ "feedbackContent": `dc3fb716e09637a3`,
10774
+ "feedback-types": `dab8560c96fa0283`,
10775
+ "feedbackTypes": `dab8560c96fa0283`,
10776
+ "feedback-type-btn": `d36e84632eb09d08`,
10777
+ "feedbackTypeBtn": `d36e84632eb09d08`,
10778
+ "feedback-type-btn-selected": `b8dbe31e00feb69b`,
10779
+ "feedbackTypeBtnSelected": `b8dbe31e00feb69b`,
10780
+ "feedback-comment": `df277aeb58f67270`,
10781
+ "feedbackComment": `df277aeb58f67270`,
10782
+ "feedback-textarea": `d79bf5aef0816574`,
10783
+ "feedbackTextarea": `d79bf5aef0816574`,
10784
+ "feedback-footer": `ddce66c2730266a9`,
10785
+ "feedbackFooter": `ddce66c2730266a9`,
10786
+ "feedback-btn-cancel": `cbb043ea2499271a`,
10787
+ "feedbackBtnCancel": `cbb043ea2499271a`,
10788
+ "feedback-btn-confirm": `c55955936e93afa3`,
10789
+ "feedbackBtnConfirm": `c55955936e93afa3`
10790
+ };
10791
+ /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
10792
+
10793
+
10550
10794
  }),
10551
10795
  58678: (function (module, __webpack_exports__, __webpack_require__) {
10552
10796
  __webpack_require__.d(__webpack_exports__, {
@@ -14475,9 +14719,6 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.coze-chat-sdk * {
14475
14719
  -webkit-font-smoothing: antialiased;
14476
14720
  -moz-osx-font-smoothing: grayscale;
14477
14721
  }
14478
- .coze-chat-sdk textarea {
14479
- padding: 0;
14480
- }
14481
14722
  .coze-chat-sdk a:focus,
14482
14723
  .coze-chat-sdk input:focus,
14483
14724
  .coze-chat-sdk p:focus,
@@ -265847,6 +266088,9 @@ axios_axiosInstance.interceptors.response.use((response)=>{
265847
266088
  axios_axiosInstance.interceptors.request.use(async (config)=>{
265848
266089
  var _config_method, _config_headers;
265849
266090
  const setHeader = (key, value)=>{
266091
+ if (!config.headers) {
266092
+ return;
266093
+ }
265850
266094
  if (typeof config.headers.set === 'function') {
265851
266095
  config.headers.set(key, value);
265852
266096
  } else {
@@ -265854,6 +266098,9 @@ axios_axiosInstance.interceptors.request.use(async (config)=>{
265854
266098
  }
265855
266099
  };
265856
266100
  const getHeader = (key)=>{
266101
+ if (!config.headers) {
266102
+ return undefined;
266103
+ }
265857
266104
  if (typeof config.headers.get === 'function') {
265858
266105
  return config.headers.get(key);
265859
266106
  }
@@ -266311,6 +266558,9 @@ const useApiErrorResponseHook = (response)=>{
266311
266558
  };
266312
266559
  const useCsrfRequestHook = (config)=>{
266313
266560
  var _config_method;
266561
+ if (!config.headers) {
266562
+ return config;
266563
+ }
266314
266564
  config.headers.set('x-requested-with', 'XMLHttpRequest');
266315
266565
  if (((_config_method = config.method) === null || _config_method === void 0 ? void 0 : _config_method.toLowerCase()) === 'post' && !config.headers.get('content-type')) {
266316
266566
  // The new CSRF protection requires all post requests to have this header.
@@ -269575,7 +269825,7 @@ class HttpChunk extends CustomEventEmitter {
269575
269825
  dataClump: fetchDataHelper,
269576
269826
  body: channelFetchInfo.body,
269577
269827
  // 将 headers 数组转换为 Headers 对象,因为 fetch API 需要 Headers 对象或普通对象
269578
- headers: new Headers(channelFetchInfo.headers),
269828
+ headers: new Headers(Array.isArray(channelFetchInfo.headers) ? channelFetchInfo.headers : []),
269579
269829
  method: channelFetchInfo.method,
269580
269830
  signal: fetchDataHelper.abortSignal.signal,
269581
269831
  totalFetchTimeout: fetchDataHelper.totalFetchTimeout,
@@ -383888,9 +384138,11 @@ var suggestion_index_module_update = injectStylesIntoStyleTag_default()(suggesti
383888
384138
 
383889
384139
 
383890
384140
  const SuggestionInChat = ()=>{
384141
+ var _suggestionBatch_suggestions;
383891
384142
  const { useMessagesStore, useSuggestionsStore } = use_chat_area_context_useChatAreaStoreSet();
383892
384143
  const { enableMention } = usePreference();
383893
- // Before fixme, it is unreliable to directly take the last message for processing, and there are still problems after modification. Consider the suggestion stored in the sender_id
384144
+ // Before fixme, it is unreliable to directly take the last message for processing,
384145
+ // and there are still problems after modification. Consider the suggestion stored in the sender_id
383894
384146
  const latestGroup = useMessagesStore((state)=>state.messageGroupList.at(0));
383895
384147
  const senderId = useMessagesStore((state)=>{
383896
384148
  var _state_messages_find;
@@ -383900,10 +384152,14 @@ const SuggestionInChat = ()=>{
383900
384152
  // So it must not be possible to reverse index based on replyId
383901
384153
  const replyId = latestGroup === null || latestGroup === void 0 ? void 0 : latestGroup.groupId;
383902
384154
  const { latestSectionHasMessage } = useMessagesOverview();
383903
- const suggestionBatch = useSuggestionsStore((state)=>latestSectionHasMessage ? state.getSuggestions(replyId) : undefined);
384155
+ // Always try to get suggestions, even if latestSectionHasMessage is false
384156
+ // This ensures suggestions are displayed even when section state is temporarily inconsistent
384157
+ const suggestionBatch = useSuggestionsStore((state)=>state.getSuggestions(replyId));
383904
384158
  const { selectable, messageWidth, layout } = usePreference();
383905
384159
  const showBackground = useShowBackGround();
383906
- if (!latestSectionHasMessage) {
384160
+ // Only hide suggestions if there are no messages in the latest section AND no suggestions exist
384161
+ // This prevents suggestions from disappearing when section state is temporarily inconsistent
384162
+ if (!latestSectionHasMessage && !(suggestionBatch === null || suggestionBatch === void 0 ? void 0 : (_suggestionBatch_suggestions = suggestionBatch.suggestions) === null || _suggestionBatch_suggestions === void 0 ? void 0 : _suggestionBatch_suggestions.length)) {
383907
384163
  return null;
383908
384164
  }
383909
384165
  if (suggestionBatch === null || suggestionBatch === void 0 ? void 0 : suggestionBatch.isError) {
@@ -384190,20 +384446,17 @@ const MessageGroupWrapper = /*#__PURE__*/ (0,react.memo)((param)=>{
384190
384446
  const { useMessageMetaStore } = use_chat_area_context_useChatAreaStoreSet();
384191
384447
  const { messageGroupWrapper } = componentTypesMap;
384192
384448
  const Wrapper = messageGroupWrapper || BuiltinMessageGroupWrapper;
384193
- const { memberSet: { userMessageId }, groupId, showContextDivider, isLatest } = messageGroup;
384449
+ const { memberSet: { userMessageId }, groupId, isLatest } = messageGroup;
384194
384450
  const userMessageMeta = useMessageMetaStore((state)=>{
384195
384451
  if (!userMessageId) {
384196
384452
  return;
384197
384453
  }
384198
384454
  return message_findMessageById(state.metaList, userMessageId);
384199
384455
  }, lodash_es_isEqual);
384200
- // TODO: Current server level does not support interrupting local messages. Sending messages cannot be deleted. This status needs to be flagged
384456
+ // TODO: Current server level does not support interrupting local messages.
384457
+ // Sending messages cannot be deleted. This status needs to be flagged
384201
384458
  const isSendingMessage = Boolean(userMessageMeta === null || userMessageMeta === void 0 ? void 0 : userMessageMeta.isSending);
384202
384459
  const deleteMessageGroup = use_delete_message_group_useDeleteMessageGroup();
384203
- const { showClearContextDivider: showClearContextDividerByPreference } = usePreference();
384204
- console.log('showClearContextDividerByPreference', showClearContextDividerByPreference);
384205
- console.log('showContextDivider', showContextDivider);
384206
- const showContextDividerWithOnboarding = showClearContextDividerByPreference && showContextDivider;
384207
384460
  const customMessageGroupFooterPlugin = use_plugin_custom_components_usePluginCustomComponents('MessageGroupFooter').at(0);
384208
384461
  const renderFooter = ()=>{
384209
384462
  const usedFooter = customMessageGroupFooterPlugin;
@@ -384225,7 +384478,7 @@ const MessageGroupWrapper = /*#__PURE__*/ (0,react.memo)((param)=>{
384225
384478
  renderFooter === null || renderFooter === void 0 ? void 0 : renderFooter(),
384226
384479
  isLatest ? /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
384227
384480
  children: [
384228
- !showContextDividerWithOnboarding && /*#__PURE__*/ (0,jsx_runtime.jsx)(SuggestionInChat, {}),
384481
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(SuggestionInChat, {}),
384229
384482
  /*#__PURE__*/ (0,jsx_runtime.jsx)(WaitGenerating, {})
384230
384483
  ]
384231
384484
  }) : null,
@@ -404266,7 +404519,9 @@ class InitStoreService {
404266
404519
  }
404267
404520
  /**
404268
404521
  * Clear Store Set
404269
- */ clearStoreSet() {
404522
+ * @param options - Options for clearing store set
404523
+ * @param options.preserveSuggestions - If true, preserve suggestions during clear (useful for re-initialization)
404524
+ */ clearStoreSet(options) {
404270
404525
  if (!this.storeSet) {
404271
404526
  return;
404272
404527
  }
@@ -404279,7 +404534,11 @@ class InitStoreService {
404279
404534
  useWaitingStore.getState().clearAllUnsettledUnconditionally();
404280
404535
  useOnboardingStore.getState().clearOnboardingStore();
404281
404536
  useFileStore.getState().clear();
404282
- useSuggestionsStore.getState().clearSuggestions();
404537
+ // Preserve suggestions during re-initialization to avoid losing follow_up messages
404538
+ // that were received via streaming but not yet saved to message history
404539
+ if (!(options === null || options === void 0 ? void 0 : options.preserveSuggestions)) {
404540
+ useSuggestionsStore.getState().clearSuggestions();
404541
+ }
404283
404542
  useSelectionStore.getState().clearSelectedReplyIdList();
404284
404543
  useSenderInfoStore.getState().clearSenderInfoStore();
404285
404544
  useBatchFileUploadStore.getState().clearAllData();
@@ -404513,7 +404772,11 @@ class InitService {
404513
404772
  /**
404514
404773
  * Function to clear side effects
404515
404774
  */ clearInitSideEffect() {
404516
- this.initStoreService.clearStoreSet();
404775
+ // Preserve suggestions during re-initialization to avoid losing follow_up messages
404776
+ // that were received via streaming but not yet saved to message history
404777
+ this.initStoreService.clearStoreSet({
404778
+ preserveSuggestions: true
404779
+ });
404517
404780
  this.preInitStoreService.clearStoreSet();
404518
404781
  }
404519
404782
  /**
@@ -421117,6 +421380,22 @@ class MessageParser {
421117
421380
  console.error('onBeforeSendMessage: conversationId is empty after creation');
421118
421381
  throw new Error('conversationId is required for sending message');
421119
421382
  }
421383
+ // 更新会话列表中的 updated_at,确保每次发送消息时都会更新会话的更新时间
421384
+ // 这样会话列表可以正确排序,显示最近活跃的会话
421385
+ const existingConversation = refConversations.current.find((c)=>c.id === conversationId);
421386
+ if (existingConversation && refUpdateConversations.current) {
421387
+ const updatedConversation = {
421388
+ id: conversationId,
421389
+ updated_at: Math.floor(Date.now() / 1000)
421390
+ };
421391
+ refUpdateConversations.current([
421392
+ updatedConversation
421393
+ ], 'update');
421394
+ console.log('onBeforeSendMessage: Updated conversation updated_at in list', {
421395
+ conversationId,
421396
+ updated_at: updatedConversation.updated_at
421397
+ });
421398
+ }
421120
421399
  // 使用计算后的 API URL
421121
421400
  const url = `${finalApiUrl}/v1/workflows/chat?conversation_id=${conversationId}`;
421122
421401
  // 根据 chatType 选择正确的 parameters 来源
@@ -421140,14 +421419,18 @@ class MessageParser {
421140
421419
  hasBody: !!body,
421141
421420
  bodyLength: body === null || body === void 0 ? void 0 : body.length
421142
421421
  });
421422
+ // 确保 headers 是一个数组
421423
+ const headers = Array.isArray(requestConfig.headers) ? [
421424
+ ...requestConfig.headers
421425
+ ] : [];
421143
421426
  Object.keys((debug === null || debug === void 0 ? void 0 : debug.cozeApiRequestHeader) || {}).forEach((key)=>{
421144
421427
  var _debug_cozeApiRequestHeader;
421145
- requestConfig.headers.push([
421428
+ headers.push([
421146
421429
  key,
421147
421430
  (debug === null || debug === void 0 ? void 0 : (_debug_cozeApiRequestHeader = debug.cozeApiRequestHeader) === null || _debug_cozeApiRequestHeader === void 0 ? void 0 : _debug_cozeApiRequestHeader[key]) || ''
421148
421431
  ]);
421149
421432
  });
421150
- requestConfig.headers.push([
421433
+ headers.push([
421151
421434
  'Accept-Language',
421152
421435
  intl.language === 'zh-CN' ? 'zh' : 'en'
421153
421436
  ]);
@@ -421156,7 +421439,7 @@ class MessageParser {
421156
421439
  body,
421157
421440
  url,
421158
421441
  method: requestConfig.method || 'POST',
421159
- headers: requestConfig.headers || []
421442
+ headers
421160
421443
  };
421161
421444
  console.log('onBeforeSendMessage: Returning config', {
421162
421445
  url: finalConfig.url,
@@ -422952,6 +423235,651 @@ const QuoteMessage = (props)=>{
422952
423235
  };
422953
423236
  QuoteMessage.displayName = 'QuoteMessage';
422954
423237
 
423238
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/comment/context.tsx
423239
+ /*
423240
+ * Copyright 2025 coze-dev Authors
423241
+ *
423242
+ * Licensed under the Apache License, Version 2.0 (the "License");
423243
+ * you may not use this file except in compliance with the License.
423244
+ * You may obtain a copy of the License at
423245
+ *
423246
+ * http://www.apache.org/licenses/LICENSE-2.0
423247
+ *
423248
+ * Unless required by applicable law or agreed to in writing, software
423249
+ * distributed under the License is distributed on an "AS IS" BASIS,
423250
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423251
+ * See the License for the specific language governing permissions and
423252
+ * limitations under the License.
423253
+ */
423254
+ const CommentContext = /*#__PURE__*/ (0,react.createContext)({});
423255
+ const CommentProvider = CommentContext.Provider;
423256
+
423257
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/comment/index.ts
423258
+ /*
423259
+ * Copyright 2025 coze-dev Authors
423260
+ *
423261
+ * Licensed under the Apache License, Version 2.0 (the "License");
423262
+ * you may not use this file except in compliance with the License.
423263
+ * You may obtain a copy of the License at
423264
+ *
423265
+ * http://www.apache.org/licenses/LICENSE-2.0
423266
+ *
423267
+ * Unless required by applicable law or agreed to in writing, software
423268
+ * distributed under the License is distributed on an "AS IS" BASIS,
423269
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423270
+ * See the License for the specific language governing permissions and
423271
+ * limitations under the License.
423272
+ */
423273
+
423274
+ // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!../../../common/chat-area/chat-answer-action/src/components/comment-message/index.module.less
423275
+ var comment_message_index_module = __webpack_require__(94148);
423276
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/index.module.less
423277
+
423278
+
423279
+
423280
+
423281
+
423282
+
423283
+
423284
+
423285
+
423286
+
423287
+
423288
+ var comment_message_index_module_options = {};
423289
+
423290
+ comment_message_index_module_options.styleTagTransform = (styleTagTransform_default());
423291
+ comment_message_index_module_options.setAttributes = (setAttributesWithoutAttributes_default());
423292
+
423293
+ comment_message_index_module_options.insert = insertBySelector_default().bind(null, "head");
423294
+
423295
+ comment_message_index_module_options.domAPI = (styleDomAPI_default());
423296
+ comment_message_index_module_options.insertStyleElement = (insertStyleElement_default());
423297
+
423298
+ var comment_message_index_module_update = injectStylesIntoStyleTag_default()(comment_message_index_module/* ["default"] */.A, comment_message_index_module_options);
423299
+
423300
+
423301
+
423302
+
423303
+ /* ESM default export */ const components_comment_message_index_module = (comment_message_index_module/* ["default"] */.A && comment_message_index_module/* ["default"].locals */.A.locals ? comment_message_index_module/* ["default"].locals */.A.locals : undefined);
423304
+
423305
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/feedback-dialog.tsx
423306
+ /*
423307
+ * Copyright 2025 coze-dev Authors
423308
+ *
423309
+ * Licensed under the Apache License, Version 2.0 (the "License");
423310
+ * you may not use this file except in compliance with the License.
423311
+ * You may obtain a copy of the License at
423312
+ *
423313
+ * http://www.apache.org/licenses/LICENSE-2.0
423314
+ *
423315
+ * Unless required by applicable law or agreed to in writing, software
423316
+ * distributed under the License is distributed on an "AS IS" BASIS,
423317
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423318
+ * See the License for the specific language governing permissions and
423319
+ * limitations under the License.
423320
+ */
423321
+
423322
+
423323
+
423324
+
423325
+
423326
+ const DEFAULT_FEEDBACK_OPTIONS = [
423327
+ {
423328
+ value: 'HARMFUL',
423329
+ label: '有害/不安全'
423330
+ },
423331
+ {
423332
+ value: 'FALSE_INFO',
423333
+ label: '虚假信息'
423334
+ },
423335
+ {
423336
+ value: 'NOT_HELPFUL',
423337
+ label: '没有帮助'
423338
+ },
423339
+ {
423340
+ value: 'OTHER',
423341
+ label: '其他'
423342
+ }
423343
+ ];
423344
+ function findChatAreaContainer() {
423345
+ // 方式1: 尝试通过类名查找 coze-chat-sdk 容器
423346
+ let cozeChatSdk = document.querySelector('.coze-chat-sdk');
423347
+ // 方式2: 如果找不到,尝试查找包含 "coze-chat-sdk" 的类名(部分匹配)
423348
+ if (!cozeChatSdk) {
423349
+ const allElements = document.querySelectorAll('*');
423350
+ for (const el of allElements){
423351
+ const classList = Array.from(el.classList);
423352
+ if (classList.some((cls)=>cls.includes('coze-chat-sdk'))) {
423353
+ cozeChatSdk = el;
423354
+ break;
423355
+ }
423356
+ }
423357
+ }
423358
+ // 方式3: 如果还是找不到,使用 document.body 作为容器(使用 fixed 定位)
423359
+ return cozeChatSdk || document.body;
423360
+ }
423361
+ const FeedbackDialog = (param)=>{
423362
+ let { visible, onConfirm, onCancel, feedbackTypes } = param;
423363
+ const [selectedFeedbackType, setSelectedFeedbackType] = (0,react.useState)(null);
423364
+ const [comment, setComment] = (0,react.useState)('');
423365
+ const [container, setContainer] = (0,react.useState)(null);
423366
+ (0,react.useEffect)(()=>{
423367
+ setContainer(visible ? findChatAreaContainer() : null);
423368
+ }, [
423369
+ visible
423370
+ ]);
423371
+ if (!visible) {
423372
+ return null;
423373
+ }
423374
+ // 使用接口返回的反馈类型,如果没有则使用默认值
423375
+ const feedbackOptions = feedbackTypes && feedbackTypes.length > 0 ? feedbackTypes.map((item)=>({
423376
+ value: item.value,
423377
+ label: item.label
423378
+ })) : DEFAULT_FEEDBACK_OPTIONS;
423379
+ const handleConfirm = ()=>{
423380
+ onConfirm(selectedFeedbackType, comment);
423381
+ // 重置状态
423382
+ setSelectedFeedbackType(null);
423383
+ setComment('');
423384
+ };
423385
+ const handleCancel = ()=>{
423386
+ setSelectedFeedbackType(null);
423387
+ setComment('');
423388
+ onCancel();
423389
+ };
423390
+ const isBodyContainer = container === document.body;
423391
+ const modalContent = /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423392
+ className: components_comment_message_index_module["feedback-overlay"],
423393
+ "data-container-is-body": isBodyContainer,
423394
+ onClick: handleCancel,
423395
+ children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423396
+ className: components_comment_message_index_module["feedback-dialog"],
423397
+ onClick: (e)=>{
423398
+ e.stopPropagation();
423399
+ },
423400
+ children: [
423401
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423402
+ className: components_comment_message_index_module["feedback-header"],
423403
+ children: [
423404
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("h3", {
423405
+ className: components_comment_message_index_module["feedback-title"],
423406
+ children: "反馈意见"
423407
+ }),
423408
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423409
+ type: "button",
423410
+ className: components_comment_message_index_module["feedback-close"],
423411
+ onClick: handleCancel,
423412
+ "aria-label": "关闭",
423413
+ children: "\xd7"
423414
+ })
423415
+ ]
423416
+ }),
423417
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423418
+ className: components_comment_message_index_module["feedback-content"],
423419
+ children: [
423420
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423421
+ className: components_comment_message_index_module["feedback-types"],
423422
+ children: feedbackOptions.map((option)=>/*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423423
+ type: "button",
423424
+ className: classnames_default()(components_comment_message_index_module["feedback-type-btn"], {
423425
+ [components_comment_message_index_module["feedback-type-btn-selected"]]: selectedFeedbackType === option.value
423426
+ }),
423427
+ onClick: ()=>{
423428
+ setSelectedFeedbackType(option.value);
423429
+ },
423430
+ children: option.label
423431
+ }, option.value))
423432
+ }),
423433
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423434
+ className: components_comment_message_index_module["feedback-comment"],
423435
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)("textarea", {
423436
+ className: components_comment_message_index_module["feedback-textarea"],
423437
+ placeholder: "请告诉我们改进意见。",
423438
+ value: comment,
423439
+ onChange: (e)=>{
423440
+ setComment(e.target.value);
423441
+ },
423442
+ rows: 4
423443
+ })
423444
+ })
423445
+ ]
423446
+ }),
423447
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423448
+ className: components_comment_message_index_module["feedback-footer"],
423449
+ children: [
423450
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423451
+ type: "button",
423452
+ className: components_comment_message_index_module["feedback-btn-cancel"],
423453
+ onClick: handleCancel,
423454
+ children: "取消"
423455
+ }),
423456
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423457
+ type: "button",
423458
+ className: components_comment_message_index_module["feedback-btn-confirm"],
423459
+ onClick: handleConfirm,
423460
+ children: "确认"
423461
+ })
423462
+ ]
423463
+ })
423464
+ ]
423465
+ })
423466
+ });
423467
+ // 如果找到了容器,使用 Portal 渲染;否则直接渲染
423468
+ if (container) {
423469
+ return /*#__PURE__*/ (0,react_dom.createPortal)(modalContent, container);
423470
+ }
423471
+ return modalContent;
423472
+ };
423473
+
423474
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/index.tsx
423475
+ /*
423476
+ * Copyright 2025 coze-dev Authors
423477
+ *
423478
+ * Licensed under the Apache License, Version 2.0 (the "License");
423479
+ * you may not use this file except in compliance with the License.
423480
+ * You may obtain a copy of the License at
423481
+ *
423482
+ * http://www.apache.org/licenses/LICENSE-2.0
423483
+ *
423484
+ * Unless required by applicable law or agreed to in writing, software
423485
+ * distributed under the License is distributed on an "AS IS" BASIS,
423486
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423487
+ * See the License for the specific language governing permissions and
423488
+ * limitations under the License.
423489
+ */ /* eslint-disable @coze-arch/max-line-per-function -- 评论组件功能完整,拆分会影响可读性 */
423490
+
423491
+
423492
+
423493
+
423494
+
423495
+
423496
+
423497
+
423498
+
423499
+
423500
+ /**
423501
+ * 评论数据缓存
423502
+ * 使用 chatId 作为 key 来缓存每个消息的评论状态
423503
+ */ const commentCache = new Map();
423504
+ /**
423505
+ * 枚举数据缓存
423506
+ * 枚举数据通常不会变化,可以全局共享
423507
+ */ let enumsCache = null;
423508
+ /**
423509
+ * 缓存过期时间(毫秒)
423510
+ * 评论状态缓存 5 分钟,枚举数据缓存 30 分钟
423511
+ */ const COMMENT_CACHE_TTL = 5 * 60 * 1000; // 5 分钟
423512
+ const ENUMS_CACHE_TTL = 30 * 60 * 1000; // 30 分钟
423513
+ /**
423514
+ * 生成缓存 key
423515
+ */ function getCacheKey(chatId, appId, conversationId) {
423516
+ return `${appId}:${conversationId}:${chatId}`;
423517
+ }
423518
+ /**
423519
+ * 从枚举数据中获取点赞按钮文字
423520
+ */ function getLikeLabel(enumsData, currentComment) {
423521
+ if (!(enumsData === null || enumsData === void 0 ? void 0 : enumsData.comment_names)) {
423522
+ return currentComment === 'LIKE' ? '取消点赞' : '点赞';
423523
+ }
423524
+ const likeOption = enumsData.comment_names.find((item)=>item.value === 'LIKE');
423525
+ if (likeOption) {
423526
+ return currentComment === 'LIKE' ? `取消${likeOption.label}` : likeOption.label;
423527
+ }
423528
+ return currentComment === 'LIKE' ? '取消点赞' : '点赞';
423529
+ }
423530
+ /**
423531
+ * 从枚举数据中获取点踩按钮文字
423532
+ */ function getDislikeLabel(enumsData, currentComment) {
423533
+ if (!(enumsData === null || enumsData === void 0 ? void 0 : enumsData.comment_names)) {
423534
+ return currentComment === 'DISLIKE' ? '取消点踩' : '点踩';
423535
+ }
423536
+ const dislikeOption = enumsData.comment_names.find((item)=>item.value === 'DISLIKE');
423537
+ if (dislikeOption) {
423538
+ return currentComment === 'DISLIKE' ? `取消${dislikeOption.label}` : dislikeOption.label;
423539
+ }
423540
+ return currentComment === 'DISLIKE' ? '取消点踩' : '点踩';
423541
+ }
423542
+ /**
423543
+ * 查找 coze-chat-sdk 容器
423544
+ */ function findCozeChatSdkContainer() {
423545
+ // 方式1: 尝试通过类名查找
423546
+ let container = document.querySelector('.coze-chat-sdk');
423547
+ // 方式2: 如果找不到,尝试查找包含 "coze-chat-sdk" 的类名(部分匹配)
423548
+ if (!container) {
423549
+ const allElements = document.querySelectorAll('*');
423550
+ for (const el of allElements){
423551
+ const classList = Array.from(el.classList);
423552
+ if (classList.some((cls)=>cls.includes('coze-chat-sdk'))) {
423553
+ container = el;
423554
+ break;
423555
+ }
423556
+ }
423557
+ }
423558
+ // 方式3: 如果还是找不到,使用 document.body 作为容器
423559
+ return container || document.body;
423560
+ }
423561
+ const CommentMessage = (param)=>{
423562
+ let { className, isMustGroupLastAnswerMessage = true, ...props } = param;
423563
+ var _enumsData_feedback_types;
423564
+ const { message, meta } = message_box_useMessageBoxContext();
423565
+ const { commentApiService, extractMessageParams } = (0,react.useContext)(CommentContext);
423566
+ const { useGlobalInitStore } = use_chat_area_context_useChatAreaStoreSet();
423567
+ const conversationIdFromStore = useGlobalInitStore((state)=>state.conversationId);
423568
+ const [currentComment, setCurrentComment] = (0,react.useState)(null);
423569
+ const [showFeedbackDialog, setShowFeedbackDialog] = (0,react.useState)(false);
423570
+ const [loading, setLoading] = (0,react.useState)(false);
423571
+ const [enumsData, setEnumsData] = (0,react.useState)(null);
423572
+ const trigger = use_tooltip_trigger_useTooltipTrigger('hover');
423573
+ // 提取消息参数,优先使用 store 中的 conversationId
423574
+ const messageParams = extractMessageParams ? extractMessageParams(message, conversationIdFromStore || undefined) : null;
423575
+ // 在组件加载时获取枚举数据和查询当前消息的评论状态
423576
+ (0,react.useEffect)(()=>{
423577
+ if (!commentApiService || !messageParams) {
423578
+ return;
423579
+ }
423580
+ const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
423581
+ const fetchEnums = async ()=>{
423582
+ if (!(commentApiService === null || commentApiService === void 0 ? void 0 : commentApiService.getCommentEnums)) {
423583
+ return;
423584
+ }
423585
+ // 检查缓存
423586
+ const now = Date.now();
423587
+ if (enumsCache && enumsCache.data && now - enumsCache.timestamp < ENUMS_CACHE_TTL) {
423588
+ setEnumsData(enumsCache.data);
423589
+ return;
423590
+ }
423591
+ try {
423592
+ const response = await commentApiService.getCommentEnums();
423593
+ enumsCache = {
423594
+ data: response.data,
423595
+ timestamp: now
423596
+ };
423597
+ setEnumsData(response.data);
423598
+ } catch (error) {
423599
+ console.error('[Comment Message] Failed to fetch enums:', error);
423600
+ // 如果请求失败,尝试使用缓存数据
423601
+ if (enumsCache === null || enumsCache === void 0 ? void 0 : enumsCache.data) {
423602
+ setEnumsData(enumsCache.data);
423603
+ }
423604
+ }
423605
+ };
423606
+ const fetchCommentStatus = async ()=>{
423607
+ if (!(commentApiService === null || commentApiService === void 0 ? void 0 : commentApiService.getCommentsByChatID)) {
423608
+ return;
423609
+ }
423610
+ // 检查缓存
423611
+ const cached = commentCache.get(cacheKey);
423612
+ const now = Date.now();
423613
+ if (cached && now - cached.timestamp < COMMENT_CACHE_TTL) {
423614
+ setCurrentComment(cached.comment);
423615
+ return;
423616
+ }
423617
+ try {
423618
+ var _response_data_results, _response_data;
423619
+ const requestParams = {
423620
+ app_id: messageParams.appId,
423621
+ conversation_id: messageParams.conversationId,
423622
+ chat_ids: [
423623
+ messageParams.chatId
423624
+ ]
423625
+ };
423626
+ const response = await commentApiService.getCommentsByChatID(requestParams);
423627
+ const chatComments = (_response_data = response.data) === null || _response_data === void 0 ? void 0 : (_response_data_results = _response_data.results) === null || _response_data_results === void 0 ? void 0 : _response_data_results.find((item)=>item.chat_id === messageParams.chatId);
423628
+ let comment = null;
423629
+ if (chatComments === null || chatComments === void 0 ? void 0 : chatComments.comments.length) {
423630
+ const sortedComments = [
423631
+ ...chatComments.comments
423632
+ ].sort((a, b)=>b.created_at - a.created_at);
423633
+ const latestComment = sortedComments[0];
423634
+ if (latestComment) {
423635
+ comment = latestComment.name;
423636
+ }
423637
+ }
423638
+ // 更新缓存
423639
+ commentCache.set(cacheKey, {
423640
+ comment,
423641
+ timestamp: now
423642
+ });
423643
+ setCurrentComment(comment);
423644
+ } catch (error) {
423645
+ console.error('[Comment Message] Failed to fetch comment status:', error);
423646
+ // 如果请求失败,尝试使用缓存数据
423647
+ if (cached) {
423648
+ setCurrentComment(cached.comment);
423649
+ }
423650
+ }
423651
+ };
423652
+ fetchEnums();
423653
+ fetchCommentStatus();
423654
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- messageParams 是对象,使用其属性作为依赖
423655
+ }, [
423656
+ commentApiService,
423657
+ messageParams === null || messageParams === void 0 ? void 0 : messageParams.chatId,
423658
+ messageParams === null || messageParams === void 0 ? void 0 : messageParams.appId,
423659
+ messageParams === null || messageParams === void 0 ? void 0 : messageParams.conversationId
423660
+ ]);
423661
+ const handleLike = (0,react.useCallback)(async ()=>{
423662
+ if (loading || !commentApiService || !messageParams) {
423663
+ return;
423664
+ }
423665
+ setLoading(true);
423666
+ try {
423667
+ const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
423668
+ // 如果已经点赞,则取消点赞(再次点击)
423669
+ if (currentComment === 'LIKE') {
423670
+ if (commentApiService.cancelComment) {
423671
+ await commentApiService.cancelComment({
423672
+ chat_id: messageParams.chatId,
423673
+ app_id: messageParams.appId,
423674
+ conversation_id: messageParams.conversationId
423675
+ });
423676
+ }
423677
+ const newComment = null;
423678
+ setCurrentComment(newComment);
423679
+ // 更新缓存
423680
+ commentCache.set(cacheKey, {
423681
+ comment: newComment,
423682
+ timestamp: Date.now()
423683
+ });
423684
+ } else {
423685
+ await commentApiService.createComment({
423686
+ chat_id: messageParams.chatId,
423687
+ app_id: messageParams.appId,
423688
+ conversation_id: messageParams.conversationId,
423689
+ name: 'LIKE'
423690
+ });
423691
+ const newComment = 'LIKE';
423692
+ setCurrentComment(newComment);
423693
+ // 更新缓存
423694
+ commentCache.set(cacheKey, {
423695
+ comment: newComment,
423696
+ timestamp: Date.now()
423697
+ });
423698
+ // 显示成功提示
423699
+ const container = findCozeChatSdkContainer();
423700
+ esm_webpack_exports_Toast.success({
423701
+ content: '感谢您的反馈',
423702
+ getContainer: ()=>container,
423703
+ showClose: false
423704
+ });
423705
+ }
423706
+ } catch (error) {
423707
+ console.error('[Comment Message] Failed to handle like comment:', error);
423708
+ // 发生错误时保持当前状态
423709
+ } finally{
423710
+ setLoading(false);
423711
+ }
423712
+ }, [
423713
+ commentApiService,
423714
+ messageParams,
423715
+ currentComment,
423716
+ loading
423717
+ ]);
423718
+ const handleCancelDislike = (0,react.useCallback)(async ()=>{
423719
+ if (!commentApiService || !messageParams) {
423720
+ return;
423721
+ }
423722
+ setLoading(true);
423723
+ try {
423724
+ const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
423725
+ if (commentApiService.cancelComment) {
423726
+ await commentApiService.cancelComment({
423727
+ chat_id: messageParams.chatId,
423728
+ app_id: messageParams.appId,
423729
+ conversation_id: messageParams.conversationId
423730
+ });
423731
+ }
423732
+ const newComment = null;
423733
+ setCurrentComment(newComment);
423734
+ // 更新缓存
423735
+ commentCache.set(cacheKey, {
423736
+ comment: newComment,
423737
+ timestamp: Date.now()
423738
+ });
423739
+ } catch (error) {
423740
+ console.error('[Comment Message] Failed to cancel dislike comment:', error);
423741
+ // 发生错误时保持当前状态
423742
+ } finally{
423743
+ setLoading(false);
423744
+ }
423745
+ }, [
423746
+ commentApiService,
423747
+ messageParams
423748
+ ]);
423749
+ const handleDislike = (0,react.useCallback)(async ()=>{
423750
+ if (loading || !commentApiService || !messageParams) {
423751
+ return;
423752
+ }
423753
+ // 如果已经点踩,则取消点踩(再次点击)
423754
+ if (currentComment === 'DISLIKE') {
423755
+ await handleCancelDislike();
423756
+ return;
423757
+ }
423758
+ // 显示反馈对话框
423759
+ setShowFeedbackDialog(true);
423760
+ }, [
423761
+ commentApiService,
423762
+ messageParams,
423763
+ currentComment,
423764
+ loading,
423765
+ handleCancelDislike
423766
+ ]);
423767
+ const handleFeedbackConfirm = (0,react.useCallback)(async (feedbackType, comment)=>{
423768
+ if (loading || !commentApiService || !messageParams) {
423769
+ return;
423770
+ }
423771
+ setLoading(true);
423772
+ setShowFeedbackDialog(false);
423773
+ try {
423774
+ const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
423775
+ await commentApiService.createComment({
423776
+ chat_id: messageParams.chatId,
423777
+ app_id: messageParams.appId,
423778
+ conversation_id: messageParams.conversationId,
423779
+ name: 'DISLIKE',
423780
+ feedback_type: feedbackType || undefined,
423781
+ comment: comment || undefined
423782
+ });
423783
+ const newComment = 'DISLIKE';
423784
+ setCurrentComment(newComment);
423785
+ // 更新缓存
423786
+ commentCache.set(cacheKey, {
423787
+ comment: newComment,
423788
+ timestamp: Date.now()
423789
+ });
423790
+ // 显示成功提示
423791
+ const container = findCozeChatSdkContainer();
423792
+ esm_webpack_exports_Toast.success({
423793
+ content: '感谢您的反馈',
423794
+ getContainer: ()=>container,
423795
+ showClose: false
423796
+ });
423797
+ } catch (error) {
423798
+ console.error('[Comment Message] Failed to create dislike comment:', error);
423799
+ setCurrentComment(null);
423800
+ } finally{
423801
+ setLoading(false);
423802
+ }
423803
+ }, [
423804
+ commentApiService,
423805
+ messageParams,
423806
+ loading
423807
+ ]);
423808
+ const handleFeedbackCancel = (0,react.useCallback)(()=>{
423809
+ setShowFeedbackDialog(false);
423810
+ }, []);
423811
+ const iconClassNames = classnames_default()(className, 'w-[14px] h-[14px]');
423812
+ const likeIconClassNames = classnames_default()(iconClassNames, {
423813
+ [components_comment_message_index_module["icon-selected"]]: currentComment === 'LIKE'
423814
+ });
423815
+ const dislikeIconClassNames = classnames_default()(iconClassNames, {
423816
+ [components_comment_message_index_module["icon-selected"]]: currentComment === 'DISLIKE'
423817
+ });
423818
+ // 如果没有提供 API 服务,则不显示评论按钮
423819
+ if (!commentApiService || !extractMessageParams) {
423820
+ return null;
423821
+ }
423822
+ // 只在最终答案消息时显示
423823
+ if (!meta.isGroupLastAnswerMessage && isMustGroupLastAnswerMessage) {
423824
+ return null;
423825
+ }
423826
+ // 如果无法提取消息参数,则不显示
423827
+ if (!messageParams) {
423828
+ return null;
423829
+ }
423830
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
423831
+ children: [
423832
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(FeedbackDialog, {
423833
+ visible: showFeedbackDialog,
423834
+ onConfirm: handleFeedbackConfirm,
423835
+ onCancel: handleFeedbackCancel,
423836
+ feedbackTypes: (enumsData === null || enumsData === void 0 ? void 0 : (_enumsData_feedback_types = enumsData.feedback_types) === null || _enumsData_feedback_types === void 0 ? void 0 : _enumsData_feedback_types.DISLIKE) || undefined
423837
+ }),
423838
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423839
+ className: components_comment_message_index_module.container,
423840
+ children: [
423841
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Tooltip, {
423842
+ content: getLikeLabel(enumsData, currentComment),
423843
+ trigger: trigger,
423844
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_IconButton, {
423845
+ "data-testid": "chat-area.answer-action.comment-like-button",
423846
+ size: "small",
423847
+ icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozThumbsup, {
423848
+ className: likeIconClassNames
423849
+ }),
423850
+ color: "secondary",
423851
+ className: classnames_default()({
423852
+ [components_comment_message_index_module["icon-button-selected"]]: currentComment === 'LIKE'
423853
+ }),
423854
+ onClick: handleLike,
423855
+ disabled: loading,
423856
+ ...props
423857
+ })
423858
+ }),
423859
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Tooltip, {
423860
+ content: getDislikeLabel(enumsData, currentComment),
423861
+ trigger: trigger,
423862
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_IconButton, {
423863
+ "data-testid": "chat-area.answer-action.comment-dislike-button",
423864
+ size: "small",
423865
+ icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozThumbdown, {
423866
+ className: dislikeIconClassNames
423867
+ }),
423868
+ color: "secondary",
423869
+ className: classnames_default()({
423870
+ [components_comment_message_index_module["icon-button-selected"]]: currentComment === 'DISLIKE'
423871
+ }),
423872
+ onClick: handleDislike,
423873
+ disabled: loading,
423874
+ ...props
423875
+ })
423876
+ })
423877
+ ]
423878
+ })
423879
+ ]
423880
+ });
423881
+ };
423882
+
422955
423883
  ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/store/context.tsx
422956
423884
  /*
422957
423885
  * Copyright 2025 coze-dev Authors
@@ -423382,6 +424310,8 @@ const BotTriggerConfigButtonGroup = (param)=>{
423382
424310
 
423383
424311
 
423384
424312
 
424313
+
424314
+
423385
424315
 
423386
424316
 
423387
424317
  ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/plugin/hooks/use-cur-message-info.ts
@@ -423632,6 +424562,7 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
423632
424562
  const { isShowDelete, isNeedQuote } = useCurMessageInfo();
423633
424563
  const isShowHoverContainer = isShowDelete || !!showHoverText;
423634
424564
  const isShowQuote = message.type === 'answer' && !!showHoverText && isNeedQuote;
424565
+ const isShowComment = message.type === 'answer' && !!showHoverText;
423635
424566
  const { width: actionBarSize } = es_useSize(actionBarRef) || {};
423636
424567
  const actionBarLeft = (0,react.useMemo)(()=>{
423637
424568
  var _actionBarRef_current_closest, _actionBarRef_current;
@@ -423656,7 +424587,7 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
423656
424587
  return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
423657
424588
  children: [
423658
424589
  /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423659
- className: classnames_default()('w-full flex', isMultiMessage ? 'justify-start' : 'justify-end'),
424590
+ className: classnames_default()('w-full flex', 'justify-start'),
423660
424591
  style: {},
423661
424592
  children: /*#__PURE__*/ (0,jsx_runtime.jsxs)(ActionBarHoverContainer, {
423662
424593
  style: {
@@ -423673,6 +424604,9 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
423673
424604
  externalContent: showHoverText,
423674
424605
  isMustGroupLastAnswerMessage: false
423675
424606
  }) : null,
424607
+ isShowComment ? /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentMessage, {
424608
+ isMustGroupLastAnswerMessage: false
424609
+ }) : null,
423676
424610
  isShowDelete ? /*#__PURE__*/ (0,jsx_runtime.jsx)(delete_message_DeleteMessage, {}) : null,
423677
424611
  isShowQuote ? /*#__PURE__*/ (0,jsx_runtime.jsx)(QuoteMessage, {}) : null
423678
424612
  ]
@@ -423775,6 +424709,9 @@ const ChatMessageFooterContent = ()=>{
423775
424709
  isUseExternalContent: true,
423776
424710
  externalContent: lastMessageText
423777
424711
  }, "copy"),
424712
+ !!lastMessageText && /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentMessage, {
424713
+ className: buttonClass
424714
+ }, "comment"),
423778
424715
  isShowDelete && /*#__PURE__*/ (0,jsx_runtime.jsx)(delete_message_DeleteMessage, {
423779
424716
  className: classnames_default()(buttonClass)
423780
424717
  }, "delete"),
@@ -424298,6 +425235,154 @@ const useBgBackgroundPlugin = ()=>{
424298
425235
  };
424299
425236
  };
424300
425237
 
425238
+ ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/comment-provider.tsx
425239
+ /*
425240
+ * Copyright 2025 coze-dev Authors
425241
+ *
425242
+ * Licensed under the Apache License, Version 2.0 (the "License");
425243
+ * you may not use this file except in compliance with the License.
425244
+ * You may obtain a copy of the License at
425245
+ *
425246
+ * http://www.apache.org/licenses/LICENSE-2.0
425247
+ *
425248
+ * Unless required by applicable law or agreed to in writing, software
425249
+ * distributed under the License is distributed on an "AS IS" BASIS,
425250
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
425251
+ * See the License for the specific language governing permissions and
425252
+ * limitations under the License.
425253
+ */
425254
+
425255
+
425256
+
425257
+
425258
+
425259
+
425260
+ /**
425261
+ * 从消息对象中提取评论所需的参数
425262
+ */ function extractMessageParamsForBuilderChat(message, chatConfig, conversationIdFromContext) {
425263
+ var _msg_extra_info, _msg_extra_info1, _msg_extra_info2, _msg_extra_info3, _msg_extra_info4, _chatConfig_appInfo;
425264
+ if (!message || typeof message !== 'object') {
425265
+ return null;
425266
+ }
425267
+ const msg = message;
425268
+ // 从 extra_info 中提取
425269
+ const chatId = ((_msg_extra_info = msg.extra_info) === null || _msg_extra_info === void 0 ? void 0 : _msg_extra_info.chat_id) || ((_msg_extra_info1 = msg.extra_info) === null || _msg_extra_info1 === void 0 ? void 0 : _msg_extra_info1.coze_api_chat_id) || ((_msg_extra_info2 = msg.extra_info) === null || _msg_extra_info2 === void 0 ? void 0 : _msg_extra_info2.conversation_id) || msg.message_id || msg.reply_id;
425270
+ // conversationId 可以从多个地方获取(按优先级):
425271
+ // 1. conversationIdFromContext (从 chat area context 获取,最优先)
425272
+ // 2. extra_info.conversation_id
425273
+ // 3. section_id (作为 fallback,但通常 section_id 不等于 conversation_id)
425274
+ // 4. reply_id (最后的 fallback)
425275
+ const conversationId = conversationIdFromContext || ((_msg_extra_info3 = msg.extra_info) === null || _msg_extra_info3 === void 0 ? void 0 : _msg_extra_info3.conversation_id) || msg.section_id || msg.reply_id;
425276
+ // 从 chatConfig 中获取 app_id
425277
+ const appId = ((_msg_extra_info4 = msg.extra_info) === null || _msg_extra_info4 === void 0 ? void 0 : _msg_extra_info4.app_id) || (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo = chatConfig.appInfo) === null || _chatConfig_appInfo === void 0 ? void 0 : _chatConfig_appInfo.appId) || (chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.bot_id) || '';
425278
+ if (!chatId || !conversationId || !appId) {
425279
+ return null;
425280
+ }
425281
+ return {
425282
+ chatId: String(chatId),
425283
+ conversationId: String(conversationId),
425284
+ appId: String(appId)
425285
+ };
425286
+ }
425287
+ /**
425288
+ * 使用 fetch 直接调用评论 API(绕过 CozeAPI 的响应拦截器)
425289
+ */ async function requestCommentApi(config, endpoint) {
425290
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
425291
+ const url = `${config.apiUrl}${endpoint}`;
425292
+ const response = await fetch(url, {
425293
+ ...options,
425294
+ headers: {
425295
+ 'Content-Type': 'application/json',
425296
+ Authorization: `Bearer ${config.token}`,
425297
+ ...options.headers
425298
+ }
425299
+ });
425300
+ const data = await response.json();
425301
+ if (!response.ok) {
425302
+ const error = data;
425303
+ throw new Error(error.message || `HTTP error! status: ${response.status}`);
425304
+ }
425305
+ return data;
425306
+ }
425307
+ /**
425308
+ * 创建评论
425309
+ */ async function createCommentWithFetch(apiUrl, token, params) {
425310
+ return requestCommentApi({
425311
+ apiUrl,
425312
+ token
425313
+ }, '/api/workflow_api/comment/create', {
425314
+ method: 'POST',
425315
+ body: JSON.stringify(params)
425316
+ });
425317
+ }
425318
+ /**
425319
+ * 查询评论列表
425320
+ */ async function getCommentsByChatIDWithFetch(apiUrl, token, params) {
425321
+ return requestCommentApi({
425322
+ apiUrl,
425323
+ token
425324
+ }, '/api/workflow_api/comment/list', {
425325
+ method: 'POST',
425326
+ body: JSON.stringify(params)
425327
+ });
425328
+ }
425329
+ /**
425330
+ * 获取评论枚举值
425331
+ */ async function getCommentEnumsWithFetch(apiUrl, token) {
425332
+ return requestCommentApi({
425333
+ apiUrl,
425334
+ token
425335
+ }, '/api/workflow_api/comment/enums', {
425336
+ method: 'GET'
425337
+ });
425338
+ }
425339
+ /**
425340
+ * 取消评论
425341
+ */ async function cancelCommentWithFetch(apiUrl, token, params) {
425342
+ return requestCommentApi({
425343
+ apiUrl,
425344
+ token
425345
+ }, '/api/workflow_api/comment/cancel', {
425346
+ method: 'POST',
425347
+ body: JSON.stringify(params)
425348
+ });
425349
+ }
425350
+ /**
425351
+ * 为 BuilderChat 提供评论功能的 Provider
425352
+ */ const BuilderChatCommentProvider = (param)=>{
425353
+ let { children } = param;
425354
+ const { chatConfig } = context_useChatAppProps();
425355
+ const { token, apiUrl } = context_useChatAppStore(shallow_useShallow((s)=>({
425356
+ token: s.token,
425357
+ apiUrl: s.apiUrl
425358
+ })));
425359
+ const { useGlobalInitStore } = use_chat_area_context_useChatAreaStoreSet();
425360
+ const conversationIdFromStore = useGlobalInitStore((state)=>state.conversationId);
425361
+ const commentContextValue = (0,react.useMemo)(()=>{
425362
+ if (!token || !apiUrl) {
425363
+ return {};
425364
+ }
425365
+ return {
425366
+ commentApiService: {
425367
+ createComment: async (params)=>createCommentWithFetch(apiUrl, token, params),
425368
+ getCommentsByChatID: async (params)=>getCommentsByChatIDWithFetch(apiUrl, token, params),
425369
+ getCommentEnums: async ()=>getCommentEnumsWithFetch(apiUrl, token),
425370
+ cancelComment: async (params)=>cancelCommentWithFetch(apiUrl, token, params)
425371
+ },
425372
+ extractMessageParams: (message, conversationIdFromContext)=>extractMessageParamsForBuilderChat(message, chatConfig, conversationIdFromContext || conversationIdFromStore || undefined)
425373
+ };
425374
+ }, [
425375
+ token,
425376
+ apiUrl,
425377
+ chatConfig,
425378
+ conversationIdFromStore
425379
+ ]);
425380
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProvider, {
425381
+ value: commentContextValue,
425382
+ children: children
425383
+ });
425384
+ };
425385
+
424301
425386
  ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/chat-provider.tsx
424302
425387
  /*
424303
425388
  * Copyright 2025 coze-dev Authors
@@ -424337,6 +425422,7 @@ const useBgBackgroundPlugin = ()=>{
424337
425422
 
424338
425423
 
424339
425424
 
425425
+
424340
425426
 
424341
425427
 
424342
425428
  const ChatProviderFuncComp = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
@@ -424644,9 +425730,11 @@ const ChatProviderImpl = (param)=>{
424644
425730
  ],
424645
425731
  showBackground: isShowBackground,
424646
425732
  enableDragUpload: false,
424647
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ChatProviderFuncComp, {
424648
- ref: refChatFunc,
424649
- children: children
425733
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChatCommentProvider, {
425734
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ChatProviderFuncComp, {
425735
+ ref: refChatFunc,
425736
+ children: children
425737
+ })
424650
425738
  })
424651
425739
  });
424652
425740
  };
@@ -439195,6 +440283,169 @@ const BuilderChatWeb = /*#__PURE__*/ (0,react.forwardRef)((props, ref)=>{
439195
440283
 
439196
440284
  const BuilderChat = BuilderChatWeb;
439197
440285
 
440286
+ ;// CONCATENATED MODULE: ./src/util/extract-message-params.ts
440287
+ /*
440288
+ * Copyright 2025 coze-dev Authors
440289
+ *
440290
+ * Licensed under the Apache License, Version 2.0 (the "License");
440291
+ * you may not use this file except in compliance with the License.
440292
+ * You may obtain a copy of the License at
440293
+ *
440294
+ * http://www.apache.org/licenses/LICENSE-2.0
440295
+ *
440296
+ * Unless required by applicable law or agreed to in writing, software
440297
+ * distributed under the License is distributed on an "AS IS" BASIS,
440298
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440299
+ * See the License for the specific language governing permissions and
440300
+ * limitations under the License.
440301
+ */ /**
440302
+ * 从消息对象中提取评论所需的参数
440303
+ */ /* eslint-disable complexity -- 需要处理多个可选字段的提取逻辑 */ function extract_message_params_extractMessageParams(message, client, conversationIdFromContext) {
440304
+ var _msg_extra_info, _msg_extra_info1, _msg_extra_info2, _msg_extra_info3, _msg_extra_info4, _client_options_config_appInfo, _client_options_config, _client_options, _client_options_config1, _client_options1;
440305
+ if (!message || typeof message !== 'object') {
440306
+ return null;
440307
+ }
440308
+ const msg = message;
440309
+ // 从 extra_info 中提取
440310
+ const chatId = ((_msg_extra_info = msg.extra_info) === null || _msg_extra_info === void 0 ? void 0 : _msg_extra_info.chat_id) || ((_msg_extra_info1 = msg.extra_info) === null || _msg_extra_info1 === void 0 ? void 0 : _msg_extra_info1.coze_api_chat_id) || ((_msg_extra_info2 = msg.extra_info) === null || _msg_extra_info2 === void 0 ? void 0 : _msg_extra_info2.conversation_id) || msg.message_id || msg.reply_id;
440311
+ // conversationId 可以从多个地方获取(按优先级):
440312
+ // 1. conversationIdFromContext (从 chat area context 获取,最优先)
440313
+ // 2. extra_info.conversation_id
440314
+ // 3. section_id (作为 fallback,但通常 section_id 不等于 conversation_id)
440315
+ // 4. reply_id (最后的 fallback)
440316
+ const conversationId = conversationIdFromContext || ((_msg_extra_info3 = msg.extra_info) === null || _msg_extra_info3 === void 0 ? void 0 : _msg_extra_info3.conversation_id) || msg.section_id || msg.reply_id;
440317
+ // 从 client options 中获取 app_id
440318
+ const appId = ((_msg_extra_info4 = msg.extra_info) === null || _msg_extra_info4 === void 0 ? void 0 : _msg_extra_info4.app_id) || ((_client_options = client.options) === null || _client_options === void 0 ? void 0 : (_client_options_config = _client_options.config) === null || _client_options_config === void 0 ? void 0 : (_client_options_config_appInfo = _client_options_config.appInfo) === null || _client_options_config_appInfo === void 0 ? void 0 : _client_options_config_appInfo.appId) || ((_client_options1 = client.options) === null || _client_options1 === void 0 ? void 0 : (_client_options_config1 = _client_options1.config) === null || _client_options_config1 === void 0 ? void 0 : _client_options_config1.botId) || '';
440319
+ if (!chatId || !conversationId || !appId) {
440320
+ return null;
440321
+ }
440322
+ return {
440323
+ chatId: String(chatId),
440324
+ conversationId: String(conversationId),
440325
+ appId: String(appId)
440326
+ };
440327
+ }
440328
+
440329
+ ;// CONCATENATED MODULE: ./src/services/comment-api.ts
440330
+ /*
440331
+ * Copyright 2025 coze-dev Authors
440332
+ *
440333
+ * Licensed under the Apache License, Version 2.0 (the "License");
440334
+ * you may not use this file except in compliance with the License.
440335
+ * You may obtain a copy of the License at
440336
+ *
440337
+ * http://www.apache.org/licenses/LICENSE-2.0
440338
+ *
440339
+ * Unless required by applicable law or agreed to in writing, software
440340
+ * distributed under the License is distributed on an "AS IS" BASIS,
440341
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440342
+ * See the License for the specific language governing permissions and
440343
+ * limitations under the License.
440344
+ */
440345
+ /**
440346
+ * 获取认证 token
440347
+ */ async function comment_api_getAuthToken(client) {
440348
+ try {
440349
+ var _client_authClient_options_auth_onRefreshToken, _client_authClient_options_auth;
440350
+ const token = await ((_client_authClient_options_auth = client.authClient.options.auth) === null || _client_authClient_options_auth === void 0 ? void 0 : (_client_authClient_options_auth_onRefreshToken = _client_authClient_options_auth.onRefreshToken) === null || _client_authClient_options_auth_onRefreshToken === void 0 ? void 0 : _client_authClient_options_auth_onRefreshToken.call(_client_authClient_options_auth, ''));
440351
+ return token || null;
440352
+ } catch (error) {
440353
+ console.error('[Comment API] Failed to get auth token:', error);
440354
+ return null;
440355
+ }
440356
+ }
440357
+ /**
440358
+ * 发起 API 请求
440359
+ */ async function comment_api_request(client, endpoint) {
440360
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
440361
+ const token = await comment_api_getAuthToken(client);
440362
+ if (!token) {
440363
+ throw new Error('Authentication token is required');
440364
+ }
440365
+ const url = `${client.apiUrl}${endpoint}`;
440366
+ const response = await fetch(url, {
440367
+ ...options,
440368
+ headers: {
440369
+ 'Content-Type': 'application/json',
440370
+ Authorization: `Bearer ${token}`,
440371
+ ...options.headers
440372
+ }
440373
+ });
440374
+ const data = await response.json();
440375
+ if (!response.ok) {
440376
+ const error = data;
440377
+ throw new Error(error.message || `HTTP error! status: ${response.status}`);
440378
+ }
440379
+ return data;
440380
+ }
440381
+ /**
440382
+ * 创建评论(点赞/点踩)
440383
+ */ async function createComment(client, params) {
440384
+ return comment_api_request(client, '/api/workflow_api/comment/create', {
440385
+ method: 'POST',
440386
+ body: JSON.stringify(params)
440387
+ });
440388
+ }
440389
+ /**
440390
+ * 查询评论列表(支持单个或批量chat_id)
440391
+ */ async function getCommentsByChatID(client, params) {
440392
+ return comment_api_request(client, '/api/workflow_api/comment/list', {
440393
+ method: 'POST',
440394
+ body: JSON.stringify(params)
440395
+ });
440396
+ }
440397
+ /**
440398
+ * 获取评论相关枚举值
440399
+ */ async function getCommentEnums(client) {
440400
+ return comment_api_request(client, '/api/workflow_api/comment/enums', {
440401
+ method: 'GET'
440402
+ });
440403
+ }
440404
+ /**
440405
+ * 取消评论(取消点赞/点踩)
440406
+ */ async function cancelComment(client, params) {
440407
+ return comment_api_request(client, '/api/workflow_api/comment/cancel', {
440408
+ method: 'POST',
440409
+ body: JSON.stringify(params)
440410
+ });
440411
+ }
440412
+
440413
+ ;// CONCATENATED MODULE: ./src/components/comment/comment-provider.tsx
440414
+ /*
440415
+ * Copyright 2025 coze-dev Authors
440416
+ *
440417
+ * Licensed under the Apache License, Version 2.0 (the "License");
440418
+ * you may not use this file except in compliance with the License.
440419
+ * You may obtain a copy of the License at
440420
+ *
440421
+ * http://www.apache.org/licenses/LICENSE-2.0
440422
+ *
440423
+ * Unless required by applicable law or agreed to in writing, software
440424
+ * distributed under the License is distributed on an "AS IS" BASIS,
440425
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440426
+ * See the License for the specific language governing permissions and
440427
+ * limitations under the License.
440428
+ */
440429
+
440430
+
440431
+
440432
+ const CommentProviderWrapper = (param)=>{
440433
+ let { client, children } = param;
440434
+ const commentContextValue = {
440435
+ commentApiService: {
440436
+ createComment: async (params)=>createComment(client, params),
440437
+ getCommentsByChatID: async (params)=>getCommentsByChatID(client, params),
440438
+ getCommentEnums: async ()=>getCommentEnums(client),
440439
+ cancelComment: async (params)=>cancelComment(client, params)
440440
+ },
440441
+ extractMessageParams: (message, conversationIdFromContext)=>extract_message_params_extractMessageParams(message, client, conversationIdFromContext)
440442
+ };
440443
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProvider, {
440444
+ value: commentContextValue,
440445
+ children: children
440446
+ });
440447
+ };
440448
+
439198
440449
  // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!./src/components/widget/non-iframe-app/index.module.less
439199
440450
  var non_iframe_app_index_module = __webpack_require__(81562);
439200
440451
  ;// CONCATENATED MODULE: ./src/components/widget/non-iframe-app/index.module.less
@@ -439245,6 +440496,7 @@ var non_iframe_app_index_module_update = injectStylesIntoStyleTag_default()(non_
439245
440496
 
439246
440497
 
439247
440498
 
440499
+
439248
440500
  const NonIframeApp = (param)=>{
439249
440501
  let { client, onImageClick, uiKitCustomComponents, contentBox } = param;
439250
440502
  var _options_ui_header, _options_ui, _options_ui_chatBot, _options_ui1, _options_ui_chatBot1, _options_ui2, _options_ui_chatBot2, _options_ui3, _options_ui_chatBot3, _options_ui4, _options_ui_chatBot4, _options_ui5, _options_ui_chatBot5, _options_ui6, _options_ui_chatBot6, _options_ui7, _options_ui_header1, _options_ui8, _options_ui_base, _options_ui9, _options_ui10, _options_ui11, _options_ui_chatBot7, _options_ui12, _options_ui_input, _options_ui13, _options_ui_input1, _options_ui14, _options_ui_input2, _options_ui15, _options_ui_input3, _options_ui16, _options_ui_input4, _options_ui17, _options_ui_input5, _options_ui18, _options_ui19, _options_ui20, _options_ui21, _options_config_appInfo, _options_config, _options_config_appInfo1, _options_config1, _options_config_appInfo2, _options_config2, _options_config_appInfo3, _options_config3, _options_config_appInfo4, _options_config4, _options_ui_base1, _options_ui22, _options_config_appInfo5, _options_userInfo, _options_userInfo1, _options_userInfo2, _options_auth, _options_auth1;
@@ -439286,41 +440538,44 @@ const NonIframeApp = (param)=>{
439286
440538
  onboarding: options === null || options === void 0 ? void 0 : (_options_ui20 = options.ui) === null || _options_ui20 === void 0 ? void 0 : _options_ui20.onboarding,
439287
440539
  getMessageRenderIndex: options === null || options === void 0 ? void 0 : (_options_ui21 = options.ui) === null || _options_ui21 === void 0 ? void 0 : _options_ui21.getMessageRenderIndex
439288
440540
  };
439289
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChat, {
439290
- // 传递 apiUrl(需要在 BuilderChat props 中支持)
439291
- apiUrl: apiUrl,
439292
- workflow: {
439293
- id: options === null || options === void 0 ? void 0 : (_options_config = options.config) === null || _options_config === void 0 ? void 0 : (_options_config_appInfo = _options_config.appInfo) === null || _options_config_appInfo === void 0 ? void 0 : _options_config_appInfo.workflowId,
439294
- // 直接传递引用,不创建副本,这样参数更新会立即生效
439295
- parameters: (options === null || options === void 0 ? void 0 : (_options_config1 = options.config) === null || _options_config1 === void 0 ? void 0 : (_options_config_appInfo1 = _options_config1.appInfo) === null || _options_config_appInfo1 === void 0 ? void 0 : _options_config_appInfo1.parameters) || {}
439296
- },
439297
- project: {
439298
- type: 'app',
439299
- // 根据 appInfo.draft_mode 设置 mode:draft_mode: true -> 'draft', draft_mode: false -> 'websdk'
439300
- // 如果没有设置 draft_mode,则根据环境判断
439301
- mode: (options === null || options === void 0 ? void 0 : (_options_config2 = options.config) === null || _options_config2 === void 0 ? void 0 : (_options_config_appInfo2 = _options_config2.appInfo) === null || _options_config_appInfo2 === void 0 ? void 0 : _options_config_appInfo2.draft_mode) !== undefined ? options.config.appInfo.draft_mode ? 'draft' : 'websdk' : false ? 0 : 'websdk',
439302
- id: (options === null || options === void 0 ? void 0 : (_options_config3 = options.config) === null || _options_config3 === void 0 ? void 0 : (_options_config_appInfo3 = _options_config3.appInfo) === null || _options_config_appInfo3 === void 0 ? void 0 : _options_config_appInfo3.appId) || '',
439303
- conversationName: options === null || options === void 0 ? void 0 : (_options_config4 = options.config) === null || _options_config4 === void 0 ? void 0 : (_options_config_appInfo4 = _options_config4.appInfo) === null || _options_config_appInfo4 === void 0 ? void 0 : _options_config_appInfo4.conversationName,
439304
- layout: options === null || options === void 0 ? void 0 : (_options_ui22 = options.ui) === null || _options_ui22 === void 0 ? void 0 : (_options_ui_base1 = _options_ui22.base) === null || _options_ui_base1 === void 0 ? void 0 : _options_ui_base1.layout,
439305
- version: options === null || options === void 0 ? void 0 : (_options_config_appInfo5 = options.config.appInfo) === null || _options_config_appInfo5 === void 0 ? void 0 : _options_config_appInfo5.version
439306
- },
439307
- userInfo: {
439308
- url: (options === null || options === void 0 ? void 0 : (_options_userInfo = options.userInfo) === null || _options_userInfo === void 0 ? void 0 : _options_userInfo.url) || '',
439309
- nickname: (options === null || options === void 0 ? void 0 : (_options_userInfo1 = options.userInfo) === null || _options_userInfo1 === void 0 ? void 0 : _options_userInfo1.nickname) || '',
439310
- id: (options === null || options === void 0 ? void 0 : (_options_userInfo2 = options.userInfo) === null || _options_userInfo2 === void 0 ? void 0 : _options_userInfo2.id) || ''
439311
- },
439312
- areaUi: areaUi,
439313
- auth: {
439314
- type: 'external',
439315
- token: options === null || options === void 0 ? void 0 : (_options_auth = options.auth) === null || _options_auth === void 0 ? void 0 : _options_auth.token,
439316
- refreshToken: options === null || options === void 0 ? void 0 : (_options_auth1 = options.auth) === null || _options_auth1 === void 0 ? void 0 : _options_auth1.onRefreshToken
439317
- },
439318
- eventCallbacks: {
439319
- onImageClick,
439320
- onThemeChange: setThemeType
439321
- },
439322
- uiKitCustomComponents: uiKitCustomComponents,
439323
- contentBox: contentBox
440541
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProviderWrapper, {
440542
+ client: client,
440543
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChat, {
440544
+ // 传递 apiUrl(需要在 BuilderChat props 中支持)
440545
+ apiUrl: apiUrl,
440546
+ workflow: {
440547
+ id: options === null || options === void 0 ? void 0 : (_options_config = options.config) === null || _options_config === void 0 ? void 0 : (_options_config_appInfo = _options_config.appInfo) === null || _options_config_appInfo === void 0 ? void 0 : _options_config_appInfo.workflowId,
440548
+ // 直接传递引用,不创建副本,这样参数更新会立即生效
440549
+ parameters: (options === null || options === void 0 ? void 0 : (_options_config1 = options.config) === null || _options_config1 === void 0 ? void 0 : (_options_config_appInfo1 = _options_config1.appInfo) === null || _options_config_appInfo1 === void 0 ? void 0 : _options_config_appInfo1.parameters) || {}
440550
+ },
440551
+ project: {
440552
+ type: 'app',
440553
+ // 根据 appInfo.draft_mode 设置 mode:draft_mode: true -> 'draft', draft_mode: false -> 'websdk'
440554
+ // 如果没有设置 draft_mode,则根据环境判断
440555
+ mode: (options === null || options === void 0 ? void 0 : (_options_config2 = options.config) === null || _options_config2 === void 0 ? void 0 : (_options_config_appInfo2 = _options_config2.appInfo) === null || _options_config_appInfo2 === void 0 ? void 0 : _options_config_appInfo2.draft_mode) !== undefined ? options.config.appInfo.draft_mode ? 'draft' : 'websdk' : false ? 0 : 'websdk',
440556
+ id: (options === null || options === void 0 ? void 0 : (_options_config3 = options.config) === null || _options_config3 === void 0 ? void 0 : (_options_config_appInfo3 = _options_config3.appInfo) === null || _options_config_appInfo3 === void 0 ? void 0 : _options_config_appInfo3.appId) || '',
440557
+ conversationName: options === null || options === void 0 ? void 0 : (_options_config4 = options.config) === null || _options_config4 === void 0 ? void 0 : (_options_config_appInfo4 = _options_config4.appInfo) === null || _options_config_appInfo4 === void 0 ? void 0 : _options_config_appInfo4.conversationName,
440558
+ layout: options === null || options === void 0 ? void 0 : (_options_ui22 = options.ui) === null || _options_ui22 === void 0 ? void 0 : (_options_ui_base1 = _options_ui22.base) === null || _options_ui_base1 === void 0 ? void 0 : _options_ui_base1.layout,
440559
+ version: options === null || options === void 0 ? void 0 : (_options_config_appInfo5 = options.config.appInfo) === null || _options_config_appInfo5 === void 0 ? void 0 : _options_config_appInfo5.version
440560
+ },
440561
+ userInfo: {
440562
+ url: (options === null || options === void 0 ? void 0 : (_options_userInfo = options.userInfo) === null || _options_userInfo === void 0 ? void 0 : _options_userInfo.url) || '',
440563
+ nickname: (options === null || options === void 0 ? void 0 : (_options_userInfo1 = options.userInfo) === null || _options_userInfo1 === void 0 ? void 0 : _options_userInfo1.nickname) || '',
440564
+ id: (options === null || options === void 0 ? void 0 : (_options_userInfo2 = options.userInfo) === null || _options_userInfo2 === void 0 ? void 0 : _options_userInfo2.id) || ''
440565
+ },
440566
+ areaUi: areaUi,
440567
+ auth: {
440568
+ type: 'external',
440569
+ token: options === null || options === void 0 ? void 0 : (_options_auth = options.auth) === null || _options_auth === void 0 ? void 0 : _options_auth.token,
440570
+ refreshToken: options === null || options === void 0 ? void 0 : (_options_auth1 = options.auth) === null || _options_auth1 === void 0 ? void 0 : _options_auth1.onRefreshToken
440571
+ },
440572
+ eventCallbacks: {
440573
+ onImageClick,
440574
+ onThemeChange: setThemeType
440575
+ },
440576
+ uiKitCustomComponents: uiKitCustomComponents,
440577
+ contentBox: contentBox
440578
+ })
439324
440579
  });
439325
440580
  };
439326
440581