@glodon-aiot/chat-app-sdk 0.0.26 → 0.0.28
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 +1567 -474
- package/libs/cn/index.js +9 -9
- package/package.json +1 -1
package/es/index.esm.js
CHANGED
|
@@ -7414,7 +7414,7 @@ var ___CSS_LOADER_EXPORT___ = _common_temp_default_node_modules_pnpm_css_loader_
|
|
|
7414
7414
|
// Module
|
|
7415
7415
|
___CSS_LOADER_EXPORT___.push([
|
|
7416
7416
|
module.id,
|
|
7417
|
-
".d5141aa56d2a57c00935 {\n width: 100%;\n margin-top: 7px;\n text-align: left;\n}\n.d79b06a73340274bc426 {\n font-size: 14px;\n font-weight: 400;\n color: #666;\n margin-bottom: 8px;\n line-height: 20px;\n}\n.eda25befdf424f596ef1 {\n padding-right: 25px;\n padding-left:
|
|
7417
|
+
".d5141aa56d2a57c00935 {\n width: 100%;\n margin-top: 7px;\n text-align: left;\n}\n.d79b06a73340274bc426 {\n font-size: 14px;\n font-weight: 400;\n color: #666;\n margin-bottom: 8px;\n line-height: 20px;\n}\n.eda25befdf424f596ef1 {\n padding-right: 25px;\n padding-left: 25px;\n}\n.e98fa6d756df3cd56afc {\n padding-right: 10px;\n padding-left: 25px;\n}\n.ed28c7ac4d2c9165f95b {\n display: flex;\n gap: 8px;\n align-items: center;\n justify-content: center;\n width: -moz-fit-content;\n width: fit-content;\n font-size: 14px;\n font-weight: 400;\n font-style: normal;\n line-height: 20px;\n border-style: solid;\n border-width: 1px;\n}\n.ed28c7ac4d2c9165f95b svg {\n width: 14px;\n height: 14px;\n}\n.b23b4c693bd848c83e8f {\n width: 100%;\n margin-top: 8px;\n}\n.e40e4bebca37dd563842 {\n padding-left: 69px;\n}\n.e854b20ceb21944e2eef {\n padding-left: 44px;\n}\n.fc781d12eaaa0f3deaf9 {\n margin-left: 56px;\n}\n.ced572f6343196fb5030 {\n margin-left: 28px;\n}\n",
|
|
7418
7418
|
""
|
|
7419
7419
|
]);
|
|
7420
7420
|
// Exports
|
|
@@ -124578,7 +124578,7 @@ module.exports = __webpack_require__.p + "eda854fce5f3a1bd8af9.woff";}),
|
|
|
124578
124578
|
"48194": (function (module, __unused_webpack_exports, __webpack_require__) {
|
|
124579
124579
|
"use strict";
|
|
124580
124580
|
module.exports = __webpack_require__.p + "58548567678bf4ea8267.woff2";}),
|
|
124581
|
-
"
|
|
124581
|
+
"68913": (function (module, __unused_webpack___webpack_exports__, __webpack_require__) {
|
|
124582
124582
|
|
|
124583
124583
|
// UNUSED EXPORTS: WebChatClient
|
|
124584
124584
|
// NAMESPACE OBJECT: ../../../../../common/temp/default/node_modules/.pnpm/axios@1.12.2_debug@4.3.3/node_modules/axios/lib/platform/common/utils.js
|
|
@@ -133047,6 +133047,73 @@ const i18nConstructor = (/* unused pure expression or super */ null && (i18n_imp
|
|
|
133047
133047
|
/* harmony default export */ var intl_ = (intl_i18n);
|
|
133048
133048
|
|
|
133049
133049
|
|
|
133050
|
+
;// CONCATENATED MODULE: ../../../arch/i18n/src/index.ts
|
|
133051
|
+
/*
|
|
133052
|
+
* Copyright 2025 coze-dev Authors
|
|
133053
|
+
*
|
|
133054
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
133055
|
+
* you may not use this file except in compliance with the License.
|
|
133056
|
+
* You may obtain a copy of the License at
|
|
133057
|
+
*
|
|
133058
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
133059
|
+
*
|
|
133060
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
133061
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
133062
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
133063
|
+
* See the License for the specific language governing permissions and
|
|
133064
|
+
* limitations under the License.
|
|
133065
|
+
*/ /* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable max-params */ /* eslint-disable @typescript-eslint/no-explicit-any */ function src_define_property(obj, key, value) {
|
|
133066
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
133067
|
+
value: value,
|
|
133068
|
+
enumerable: true,
|
|
133069
|
+
configurable: true,
|
|
133070
|
+
writable: true
|
|
133071
|
+
});
|
|
133072
|
+
else obj[key] = value;
|
|
133073
|
+
return obj;
|
|
133074
|
+
}
|
|
133075
|
+
|
|
133076
|
+
// The exported const I18n = new FlowIntl () is functionally equivalent to I18n in '@edenx/plugin-starling-intl/runtime'
|
|
133077
|
+
// In fact, it is a layer of encapsulation for I18n in '@edenx/plugin-starling-intl/runtime', in order to further flexibly define the parameter type of I18n.t () in the future.
|
|
133078
|
+
// The parameter types of I18n.t () here are defined by the generic LocaleData, while the parameter types of I18n.t () in '@edenx/plugin-starling-intl/runtime' are defined by the generic string.
|
|
133079
|
+
class FlowIntl {
|
|
133080
|
+
init(config, callback) {
|
|
133081
|
+
return intl_i18n.init(config, callback);
|
|
133082
|
+
}
|
|
133083
|
+
use(plugin) {
|
|
133084
|
+
return intl_i18n.use(plugin);
|
|
133085
|
+
}
|
|
133086
|
+
get language() {
|
|
133087
|
+
return intl_i18n.language;
|
|
133088
|
+
}
|
|
133089
|
+
setLangWithPromise(lng) {
|
|
133090
|
+
return this.i18nInstance.changeLanguageWithPromise(lng);
|
|
133091
|
+
}
|
|
133092
|
+
setLang(lng, callback) {
|
|
133093
|
+
return intl_i18n.setLang(lng, callback);
|
|
133094
|
+
}
|
|
133095
|
+
getLanguages() {
|
|
133096
|
+
return intl_i18n.getLanguages();
|
|
133097
|
+
}
|
|
133098
|
+
dir() {
|
|
133099
|
+
return intl_i18n.dir();
|
|
133100
|
+
}
|
|
133101
|
+
addResourceBundle(lng, ns, resources, deep, overwrite) {
|
|
133102
|
+
return intl_i18n.addResourceBundle(lng, ns, resources, deep, overwrite);
|
|
133103
|
+
}
|
|
133104
|
+
t(keys, options, fallbackText) {
|
|
133105
|
+
// tecvan: fixme, hard to understand why this happens
|
|
133106
|
+
return intl_i18n.t(keys, options, fallbackText);
|
|
133107
|
+
}
|
|
133108
|
+
constructor(){
|
|
133109
|
+
src_define_property(this, "plugins", []);
|
|
133110
|
+
src_define_property(this, "i18nInstance", void 0);
|
|
133111
|
+
this.i18nInstance = intl_i18n.i18nInstance;
|
|
133112
|
+
}
|
|
133113
|
+
}
|
|
133114
|
+
const getUnReactiveLanguage = ()=>_I18n.language;
|
|
133115
|
+
const src_I18n = new FlowIntl();
|
|
133116
|
+
|
|
133050
133117
|
;// CONCATENATED MODULE: ../open-chat/src/util/error.ts
|
|
133051
133118
|
/*
|
|
133052
133119
|
* Copyright 2025 coze-dev Authors
|
|
@@ -133123,7 +133190,7 @@ const getServerError = (error)=>{
|
|
|
133123
133190
|
case 702242003:
|
|
133124
133191
|
return {
|
|
133125
133192
|
code,
|
|
133126
|
-
msg:
|
|
133193
|
+
msg: src_I18n.t("unbind_notification")
|
|
133127
133194
|
};
|
|
133128
133195
|
default:
|
|
133129
133196
|
}
|
|
@@ -296103,7 +296170,7 @@ const fallback_FallbackComponent = (param)=>{
|
|
|
296103
296170
|
className: "p-[12px]",
|
|
296104
296171
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
296105
296172
|
className: "text-[14px] font-medium text-[#222222]",
|
|
296106
|
-
children:
|
|
296173
|
+
children: src_I18n.t("message_content_error")
|
|
296107
296174
|
})
|
|
296108
296175
|
});
|
|
296109
296176
|
};
|
|
@@ -383839,10 +383906,16 @@ const UPLOAD_FILE_TIMEOUT = 60000;
|
|
|
383839
383906
|
const FILE_EXCEEDS_LIMIT_I18N_KEY = "files_exceeds_limit";
|
|
383840
383907
|
const getFileSizeReachLimitI18n = (param)=>{
|
|
383841
383908
|
let { limitText = "20MB" } = param;
|
|
383842
|
-
return
|
|
383909
|
+
return src_I18n.t("file_too_large", {
|
|
383843
383910
|
max_size: limitText
|
|
383844
383911
|
});
|
|
383845
383912
|
};
|
|
383913
|
+
// File upload limits
|
|
383914
|
+
const file_MAX_FILE_SIZE_MB = 50;
|
|
383915
|
+
const BYTES_PER_KB = 1024;
|
|
383916
|
+
const BYTES_PER_MB = BYTES_PER_KB * BYTES_PER_KB;
|
|
383917
|
+
const MAX_FILE_SIZE_BYTES = file_MAX_FILE_SIZE_MB * BYTES_PER_MB;
|
|
383918
|
+
const MAX_FILE_COUNT = 10;
|
|
383846
383919
|
|
|
383847
383920
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/utils/upload.ts
|
|
383848
383921
|
/*
|
|
@@ -384165,7 +384238,7 @@ const useValidateFileList = ()=>{
|
|
|
384165
384238
|
showClose: false
|
|
384166
384239
|
});
|
|
384167
384240
|
if (hasEmptyFile) es_toast_.warning({
|
|
384168
|
-
content:
|
|
384241
|
+
content: src_I18n.t("upload_empty_file"),
|
|
384169
384242
|
showClose: false
|
|
384170
384243
|
});
|
|
384171
384244
|
const filteredFileList = fileList.filter(isFileSizeNotExceed).filter(isNotEmptyFile);
|
|
@@ -384175,7 +384248,7 @@ const useValidateFileList = ()=>{
|
|
|
384175
384248
|
existingFileCount: useBatchFileUploadStore.getState().getExistingFileCount()
|
|
384176
384249
|
})) {
|
|
384177
384250
|
es_toast_.warning({
|
|
384178
|
-
content:
|
|
384251
|
+
content: src_I18n.t(FILE_EXCEEDS_LIMIT_I18N_KEY),
|
|
384179
384252
|
showClose: false
|
|
384180
384253
|
});
|
|
384181
384254
|
return [];
|
|
@@ -386216,9 +386289,9 @@ const getIsCardDisabled = (index, messageList)=>{
|
|
|
386216
386289
|
return isCardContent && isNotFirstAnswerQuestion;
|
|
386217
386290
|
};
|
|
386218
386291
|
const getToastI18nMap = ()=>({
|
|
386219
|
-
VOICE_NOT_RECOGNIZE:
|
|
386220
|
-
TOKEN_INSUFFICIENT_VOICE:
|
|
386221
|
-
PRO_TOKEN_INSUFFICIENT_VOICE:
|
|
386292
|
+
VOICE_NOT_RECOGNIZE: src_I18n.t("chat_voice_input_toast_no_content_recognized"),
|
|
386293
|
+
TOKEN_INSUFFICIENT_VOICE: src_I18n.t("coze_free_credits_insufficient"),
|
|
386294
|
+
PRO_TOKEN_INSUFFICIENT_VOICE: src_I18n.t("coze_pro_payment_overdue")
|
|
386222
386295
|
});
|
|
386223
386296
|
const toastBySendMessageResult = (result)=>{
|
|
386224
386297
|
if (result === "LOCKED" || typeof result === "undefined") return;
|
|
@@ -386705,7 +386778,7 @@ const CopywritingProvider = (param)=>{
|
|
|
386705
386778
|
let { children, ...rest } = param;
|
|
386706
386779
|
return /*#__PURE__*/ (0,jsx_runtime_.jsx)(CopywritingContext.Provider, {
|
|
386707
386780
|
value: lodash_es_merge_({}, getDefaultCopywriting(), {
|
|
386708
|
-
clearContextDividerText:
|
|
386781
|
+
clearContextDividerText: src_I18n.t("context_clear_finish")
|
|
386709
386782
|
}, rest),
|
|
386710
386783
|
children: children
|
|
386711
386784
|
});
|
|
@@ -410953,7 +411026,7 @@ const preview_Preview = (param)=>{
|
|
|
410953
411026
|
src: previewURL,
|
|
410954
411027
|
// disableDownload
|
|
410955
411028
|
onDownloadError: ()=>{
|
|
410956
|
-
UIToast.error(
|
|
411029
|
+
UIToast.error(src_I18n.t("image_download_not_supported"));
|
|
410957
411030
|
},
|
|
410958
411031
|
visible: Boolean(previewURL),
|
|
410959
411032
|
onVisibleChange: resetPreviewUrl
|
|
@@ -411192,7 +411265,7 @@ const useEventCallbacks = ()=>{
|
|
|
411192
411265
|
var _msg_content_obj_file_list_;
|
|
411193
411266
|
copy_to_clipboard_default()(((_msg_content_obj_file_list_ = msg.content_obj.file_list[fileIndex ?? 0]) === null || _msg_content_obj_file_list_ === void 0 ? void 0 : _msg_content_obj_file_list_.file_url) ?? "");
|
|
411194
411267
|
UIToast.success({
|
|
411195
|
-
content:
|
|
411268
|
+
content: src_I18n.t("copy_success") ?? "Copy Successfully"
|
|
411196
411269
|
});
|
|
411197
411270
|
}
|
|
411198
411271
|
},
|
|
@@ -412456,7 +412529,7 @@ const regenerate_message_regenerateMessage = async (param)=>{
|
|
|
412456
412529
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
412457
412530
|
* See the License for the specific language governing permissions and
|
|
412458
412531
|
* limitations under the License.
|
|
412459
|
-
*/ /* eslint-disable @typescript-eslint/no-empty-function */ /* eslint-disable @typescript-eslint/no-useless-constructor */ /* eslint-disable @typescript-eslint/no-explicit-any */ function
|
|
412532
|
+
*/ /* eslint-disable @typescript-eslint/no-empty-function */ /* eslint-disable @typescript-eslint/no-useless-constructor */ /* eslint-disable @typescript-eslint/no-explicit-any */ function websocket_manager_adapter_src_define_property(obj, key, value) {
|
|
412460
412533
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
412461
412534
|
value: value,
|
|
412462
412535
|
enumerable: true,
|
|
@@ -412486,7 +412559,7 @@ class Connection {
|
|
|
412486
412559
|
close() {}
|
|
412487
412560
|
destroy() {}
|
|
412488
412561
|
constructor(props, channel){
|
|
412489
|
-
|
|
412562
|
+
websocket_manager_adapter_src_define_property(this, "service", void 0);
|
|
412490
412563
|
}
|
|
412491
412564
|
}
|
|
412492
412565
|
class WebSocketManager {
|
|
@@ -412499,8 +412572,8 @@ class WebSocketManager {
|
|
|
412499
412572
|
* Create a new WS channel without reusing the existing channel
|
|
412500
412573
|
*/ createChannel(options) {}
|
|
412501
412574
|
constructor(){
|
|
412502
|
-
|
|
412503
|
-
|
|
412575
|
+
websocket_manager_adapter_src_define_property(this, "deviceId", "");
|
|
412576
|
+
websocket_manager_adapter_src_define_property(this, "channel", null);
|
|
412504
412577
|
}
|
|
412505
412578
|
}
|
|
412506
412579
|
/* harmony default export */ var websocket_manager_adapter_src_ = (new WebSocketManager());
|
|
@@ -414348,7 +414421,7 @@ const SuggestionInChat = ()=>{
|
|
|
414348
414421
|
children: [
|
|
414349
414422
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(IconAlertStroked, {}),
|
|
414350
414423
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
414351
|
-
children:
|
|
414424
|
+
children: src_I18n.t("bot_edit_auto_suggestion_customize_failed_to_generate")
|
|
414352
414425
|
})
|
|
414353
414426
|
]
|
|
414354
414427
|
})
|
|
@@ -414790,7 +414863,7 @@ const SendStatus = (props)=>{
|
|
|
414790
414863
|
}) : null,
|
|
414791
414864
|
meta.isFail ? /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Tooltip, {
|
|
414792
414865
|
trigger: layout === common_Layout.MOBILE ? "custom" : "hover",
|
|
414793
|
-
content:
|
|
414866
|
+
content: src_I18n.t("chat_tooltips_resend"),
|
|
414794
414867
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(IconAlertStroked, {
|
|
414795
414868
|
size: "small",
|
|
414796
414869
|
className: classnames_default()(components_send_message_box_index_module_["icon-fail"]),
|
|
@@ -414897,7 +414970,7 @@ const filterMixType = [
|
|
|
414897
414970
|
const getMixContent = (list)=>{
|
|
414898
414971
|
var _list_filter;
|
|
414899
414972
|
const info = list === null || list === void 0 ? void 0 : (_list_filter = list.filter((item)=>filterMixType.indexOf((item === null || item === void 0 ? void 0 : item.type) ?? "") > -1)) === null || _list_filter === void 0 ? void 0 : _list_filter.map((item)=>{
|
|
414900
|
-
if (item.type === types_ContentType.Image) return `[${
|
|
414973
|
+
if (item.type === types_ContentType.Image) return `[${src_I18n.t("editor_toolbar_image")}]`;
|
|
414901
414974
|
else if (item.type === types_ContentType.File) {
|
|
414902
414975
|
var _item_file, _item_file1;
|
|
414903
414976
|
// TODO: jq - If multiple are supported later, there may be problems.
|
|
@@ -414920,7 +414993,7 @@ const PluginAsyncQuote = (props)=>{
|
|
|
414920
414993
|
const isMix = (replyMessage === null || replyMessage === void 0 ? void 0 : replyMessage.content_type) === types_ContentType.Mix;
|
|
414921
414994
|
const isNormal = !(isImage || isFile || isMix);
|
|
414922
414995
|
const { content_obj = safe_json_parse_safeJSONParse(replyMessage.content) } = replyMessage ?? {};
|
|
414923
|
-
const imageContent = `[${
|
|
414996
|
+
const imageContent = `[${src_I18n.t("editor_toolbar_image")}]`;
|
|
414924
414997
|
const fileName = content_obj === null || content_obj === void 0 ? void 0 : (_content_obj_file_list = content_obj.file_list) === null || _content_obj_file_list === void 0 ? void 0 : (_content_obj_file_list_ = _content_obj_file_list[0]) === null || _content_obj_file_list_ === void 0 ? void 0 : _content_obj_file_list_.file_name;
|
|
414925
414998
|
const fileContent = fileName ? `[${fileName}]` : "";
|
|
414926
414999
|
const mixContent = getMixContent(content_obj === null || content_obj === void 0 ? void 0 : content_obj.item_list);
|
|
@@ -415321,8 +415394,8 @@ const getContentConfigs = ()=>({
|
|
|
415321
415394
|
enable: true,
|
|
415322
415395
|
copywriting: {
|
|
415323
415396
|
empty: {
|
|
415324
|
-
title:
|
|
415325
|
-
description:
|
|
415397
|
+
title: src_I18n.t("card_not_support_display_title"),
|
|
415398
|
+
description: src_I18n.t("card_not_support_display_content")
|
|
415326
415399
|
}
|
|
415327
415400
|
},
|
|
415328
415401
|
region: "cn-release"
|
|
@@ -415341,9 +415414,9 @@ const getContentConfigs = ()=>({
|
|
|
415341
415414
|
},
|
|
415342
415415
|
copywriting: {
|
|
415343
415416
|
tooltips: {
|
|
415344
|
-
cancel:
|
|
415345
|
-
copy:
|
|
415346
|
-
retry:
|
|
415417
|
+
cancel: src_I18n.t("bot_preview_file_cancel"),
|
|
415418
|
+
copy: src_I18n.t("bot_preview_file_copyURL"),
|
|
415419
|
+
retry: src_I18n.t("bot_preview_file_retry")
|
|
415347
415420
|
}
|
|
415348
415421
|
}
|
|
415349
415422
|
}
|
|
@@ -420348,7 +420421,7 @@ const LongStrValue = (param)=>{
|
|
|
420348
420421
|
!more && /*#__PURE__*/ (0,jsx_runtime_.jsx)(es_typography_.Text, {
|
|
420349
420422
|
link: true,
|
|
420350
420423
|
onClick: ()=>setMore(true),
|
|
420351
|
-
children:
|
|
420424
|
+
children: src_I18n.t("see_more")
|
|
420352
420425
|
})
|
|
420353
420426
|
]
|
|
420354
420427
|
});
|
|
@@ -420558,8 +420631,8 @@ const JsonField = (param)=>{
|
|
|
420558
420631
|
path
|
|
420559
420632
|
]);
|
|
420560
420633
|
const keyWithColon = (0,react_.useMemo)(()=>{
|
|
420561
|
-
if (isError) return
|
|
420562
|
-
if (isWarning) return
|
|
420634
|
+
if (isError) return src_I18n.t("workflow_detail_testrun_error_front");
|
|
420635
|
+
if (isWarning) return src_I18n.t("workflow_detail_testrun_warning_front");
|
|
420563
420636
|
return key ? `${key} : ` : "";
|
|
420564
420637
|
}, [
|
|
420565
420638
|
key,
|
|
@@ -424243,19 +424316,19 @@ var recall_slices_index_module_update = injectStylesIntoStyleTag_default()(recal
|
|
|
424243
424316
|
|
|
424244
424317
|
|
|
424245
424318
|
const getSourceTypeDescription = (sourceType)=>({
|
|
424246
|
-
[common_DocumentSource.Custom]:
|
|
424247
|
-
[common_DocumentSource.Document]:
|
|
424248
|
-
[common_DocumentSource.FeishuWeb]:
|
|
424249
|
-
[common_DocumentSource.Web]:
|
|
424250
|
-
[common_DocumentSource.FrontCrawl]:
|
|
424251
|
-
[common_DocumentSource.GoogleDrive]:
|
|
424252
|
-
[common_DocumentSource.Notion]:
|
|
424253
|
-
[common_DocumentSource.LarkWeb]:
|
|
424319
|
+
[common_DocumentSource.Custom]: src_I18n.t("chat-area-knowledge-custom-data-source"),
|
|
424320
|
+
[common_DocumentSource.Document]: src_I18n.t("chat-area-knowledge-local-data-source"),
|
|
424321
|
+
[common_DocumentSource.FeishuWeb]: src_I18n.t("chat-area-knowledge-feishu-data-source"),
|
|
424322
|
+
[common_DocumentSource.Web]: src_I18n.t("chat-area-knowledge-online-data-source"),
|
|
424323
|
+
[common_DocumentSource.FrontCrawl]: src_I18n.t("chat-area-knowledge-crawl-data-source"),
|
|
424324
|
+
[common_DocumentSource.GoogleDrive]: src_I18n.t("chat-area-knowledge-google-data-source"),
|
|
424325
|
+
[common_DocumentSource.Notion]: src_I18n.t("chat-area-knowledge-notion-data-source"),
|
|
424326
|
+
[common_DocumentSource.LarkWeb]: src_I18n.t("Lark_00002")
|
|
424254
424327
|
})[sourceType];
|
|
424255
424328
|
const getFormatTypeDescription = (formatType)=>({
|
|
424256
|
-
[common_FormatType.Table]:
|
|
424257
|
-
[common_FormatType.Text]:
|
|
424258
|
-
[common_FormatType.Image]:
|
|
424329
|
+
[common_FormatType.Table]: src_I18n.t("knowledge-dataset-type-table"),
|
|
424330
|
+
[common_FormatType.Text]: src_I18n.t("knowledge-dataset-type-text"),
|
|
424331
|
+
[common_FormatType.Image]: src_I18n.t("knowledge_photo_025")
|
|
424259
424332
|
})[formatType];
|
|
424260
424333
|
function RecallSlice(props) {
|
|
424261
424334
|
var _meta_document;
|
|
@@ -424353,11 +424426,11 @@ function RecallSlice(props) {
|
|
|
424353
424426
|
needCollapse ? isOpen ? /*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
424354
424427
|
className: plugins_recall_slices_index_module_["recall-slice-content-action"],
|
|
424355
424428
|
onClick: ()=>setIsOpen(false),
|
|
424356
|
-
children:
|
|
424429
|
+
children: src_I18n.t("collapse-chat-knowledge-source-header")
|
|
424357
424430
|
}) : /*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
424358
424431
|
className: plugins_recall_slices_index_module_["recall-slice-content-action"],
|
|
424359
424432
|
onClick: ()=>setIsOpen(true),
|
|
424360
|
-
children:
|
|
424433
|
+
children: src_I18n.t("view-all-chat-knowledge-source-header")
|
|
424361
424434
|
}) : null
|
|
424362
424435
|
]
|
|
424363
424436
|
})
|
|
@@ -424445,11 +424518,11 @@ function RecallSlices(props) {
|
|
|
424445
424518
|
|
|
424446
424519
|
|
|
424447
424520
|
|
|
424448
|
-
const getRecallEmptyText = ()=>
|
|
424521
|
+
const getRecallEmptyText = ()=>src_I18n.t("recall_knowledge_no_related_slices");
|
|
424449
424522
|
// BigInt with failed cloud search authentication
|
|
424450
424523
|
const KNOWLEDGE_OPEN_SEARCH_ERROR = 708882003;
|
|
424451
424524
|
const getMessageWithStatusCode = (statusCode)=>{
|
|
424452
|
-
if (statusCode === KNOWLEDGE_OPEN_SEARCH_ERROR) return
|
|
424525
|
+
if (statusCode === KNOWLEDGE_OPEN_SEARCH_ERROR) return src_I18n.t("knowledge_es_024");
|
|
424453
424526
|
return getRecallEmptyText();
|
|
424454
424527
|
};
|
|
424455
424528
|
const VerboseKnowledgeRecall = (param)=>{
|
|
@@ -424542,7 +424615,7 @@ const FAILED = "1";
|
|
|
424542
424615
|
const getIsMapKey = (name)=>name in specialPluginNameMap;
|
|
424543
424616
|
const getPluginNameText = (name)=>{
|
|
424544
424617
|
if (!getIsMapKey(name)) return null;
|
|
424545
|
-
const res = specialPluginNameMap[name][
|
|
424618
|
+
const res = specialPluginNameMap[name][src_I18n.language];
|
|
424546
424619
|
if (!res) return null;
|
|
424547
424620
|
return res;
|
|
424548
424621
|
};
|
|
@@ -424573,7 +424646,7 @@ const getFunctionCallMessageIconAndName = (param)=>{
|
|
|
424573
424646
|
if (plugin === "Browser" && plugin_request) return {
|
|
424574
424647
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozCompass, {}),
|
|
424575
424648
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(HeaderTitleText, {
|
|
424576
|
-
prefix: isLoading ?
|
|
424649
|
+
prefix: isLoading ? src_I18n.t("Visiting") : src_I18n.t("Visited"),
|
|
424577
424650
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
424578
424651
|
className: fuction_call_message_function_call_content_index_module_["message-tip-ellipsis"],
|
|
424579
424652
|
children: plugin_request
|
|
@@ -424583,13 +424656,13 @@ const getFunctionCallMessageIconAndName = (param)=>{
|
|
|
424583
424656
|
if (plugin === "Google Web Search") return {
|
|
424584
424657
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozMagnifier, {}),
|
|
424585
424658
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(HeaderTitleText, {
|
|
424586
|
-
prefix: isLoading ?
|
|
424659
|
+
prefix: isLoading ? src_I18n.t("Searching") : src_I18n.t("Searched"),
|
|
424587
424660
|
children: plugin_request
|
|
424588
424661
|
})
|
|
424589
424662
|
};
|
|
424590
424663
|
// Coze home related tips
|
|
424591
424664
|
const specialPluginNameText = getPluginNameText(name);
|
|
424592
|
-
const prefix = isLoading ?
|
|
424665
|
+
const prefix = isLoading ? src_I18n.t("Using") : src_I18n.t("Used");
|
|
424593
424666
|
return {
|
|
424594
424667
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozPlugin, {}),
|
|
424595
424668
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(HeaderTitleText, {
|
|
@@ -424650,7 +424723,7 @@ const getKnowledgeMessageHeaderConfig = (param)=>{
|
|
|
424650
424723
|
var _executeDisplayName_value1;
|
|
424651
424724
|
return {
|
|
424652
424725
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozKnowledge, {}),
|
|
424653
|
-
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value1 = executeDisplayName.value) === null || _executeDisplayName_value1 === void 0 ? void 0 : _executeDisplayName_value1.name_execute_failed) ||
|
|
424726
|
+
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value1 = executeDisplayName.value) === null || _executeDisplayName_value1 === void 0 ? void 0 : _executeDisplayName_value1.name_execute_failed) || src_I18n.t("bot_preview_searched_dataset"),
|
|
424654
424727
|
status: "fail"
|
|
424655
424728
|
};
|
|
424656
424729
|
}
|
|
@@ -424660,13 +424733,13 @@ const getKnowledgeMessageHeaderConfig = (param)=>{
|
|
|
424660
424733
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozLoading, {
|
|
424661
424734
|
className: "animate-spin"
|
|
424662
424735
|
}),
|
|
424663
|
-
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value2 = executeDisplayName.value) === null || _executeDisplayName_value2 === void 0 ? void 0 : _executeDisplayName_value2.name_executing) ||
|
|
424736
|
+
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value2 = executeDisplayName.value) === null || _executeDisplayName_value2 === void 0 ? void 0 : _executeDisplayName_value2.name_executing) || src_I18n.t("bot_preview_searched_dataset"),
|
|
424664
424737
|
status: "loading"
|
|
424665
424738
|
};
|
|
424666
424739
|
}
|
|
424667
424740
|
return {
|
|
424668
424741
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozKnowledge, {}),
|
|
424669
|
-
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value = executeDisplayName.value) === null || _executeDisplayName_value === void 0 ? void 0 : _executeDisplayName_value.name_executed) ||
|
|
424742
|
+
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value = executeDisplayName.value) === null || _executeDisplayName_value === void 0 ? void 0 : _executeDisplayName_value.name_executed) || src_I18n.t("bot_preview_searched_dataset"),
|
|
424670
424743
|
status: "default"
|
|
424671
424744
|
};
|
|
424672
424745
|
};
|
|
@@ -424691,7 +424764,7 @@ const getHooksMessageHeaderConfig = (param)=>{
|
|
|
424691
424764
|
if (HooksCallVerboseDataSchema.safeParse(hooksCallVerboseData).success) return {
|
|
424692
424765
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozPlugin, {}),
|
|
424693
424766
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(HeaderTitleText, {
|
|
424694
|
-
prefix:
|
|
424767
|
+
prefix: src_I18n.t("codedev_hook_run_log_invoked"),
|
|
424695
424768
|
children: hooksCallVerboseData.type
|
|
424696
424769
|
}),
|
|
424697
424770
|
status: "default"
|
|
@@ -424700,15 +424773,15 @@ const getHooksMessageHeaderConfig = (param)=>{
|
|
|
424700
424773
|
return {
|
|
424701
424774
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozPlugin, {}),
|
|
424702
424775
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(HeaderTitleText, {
|
|
424703
|
-
prefix:
|
|
424776
|
+
prefix: src_I18n.t("codedev_hook_invoked_failed")
|
|
424704
424777
|
}),
|
|
424705
424778
|
status: "default"
|
|
424706
424779
|
};
|
|
424707
424780
|
};
|
|
424708
424781
|
const getVerbosePreText = ()=>{
|
|
424709
424782
|
const text = {
|
|
424710
|
-
[types_VerboseMsgType.JUMP_TO]:
|
|
424711
|
-
[types_VerboseMsgType.BACK_WORD]:
|
|
424783
|
+
[types_VerboseMsgType.JUMP_TO]: src_I18n.t("agentflow_jump_running_process_jump"),
|
|
424784
|
+
[types_VerboseMsgType.BACK_WORD]: src_I18n.t("agentflow_jump_running_process_backtrack")
|
|
424712
424785
|
};
|
|
424713
424786
|
return text;
|
|
424714
424787
|
};
|
|
@@ -424729,13 +424802,13 @@ const getVerboseMessageHeaderConfig = (param)=>{
|
|
|
424729
424802
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozLoading, {
|
|
424730
424803
|
className: "animate-spin"
|
|
424731
424804
|
}),
|
|
424732
|
-
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value1 = executeDisplayName.value) === null || _executeDisplayName_value1 === void 0 ? void 0 : _executeDisplayName_value1.name_executing) ||
|
|
424805
|
+
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value1 = executeDisplayName.value) === null || _executeDisplayName_value1 === void 0 ? void 0 : _executeDisplayName_value1.name_executing) || src_I18n.t("ltm_240227_01"),
|
|
424733
424806
|
status: "loading"
|
|
424734
424807
|
};
|
|
424735
424808
|
}
|
|
424736
424809
|
return {
|
|
424737
424810
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozKnowledge, {}),
|
|
424738
|
-
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value = executeDisplayName.value) === null || _executeDisplayName_value === void 0 ? void 0 : _executeDisplayName_value.name_executed) ||
|
|
424811
|
+
title: (executeDisplayName === null || executeDisplayName === void 0 ? void 0 : (_executeDisplayName_value = executeDisplayName.value) === null || _executeDisplayName_value === void 0 ? void 0 : _executeDisplayName_value.name_executed) || src_I18n.t("ltm_240227_01"),
|
|
424739
424812
|
status: "default"
|
|
424740
424813
|
};
|
|
424741
424814
|
}
|
|
@@ -424814,27 +424887,27 @@ const getTopLevelOfTheNestedPanelHeaderConfig = (param)=>{
|
|
|
424814
424887
|
let { isPanelOpen, isRelatedChatComplete, isRelatedChatAllFunctionCallSuccess, isMessageFromOngoingChat, isFakeInterruptAnswer } = param;
|
|
424815
424888
|
if (isPanelOpen) return {
|
|
424816
424889
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozListDisorder, {}),
|
|
424817
|
-
title:
|
|
424890
|
+
title: src_I18n.t("bot_preview_hide_running_process"),
|
|
424818
424891
|
status: "default"
|
|
424819
424892
|
};
|
|
424820
424893
|
if (isRelatedChatComplete) return isRelatedChatAllFunctionCallSuccess ? {
|
|
424821
424894
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozCheckMarkCircle, {}),
|
|
424822
|
-
title:
|
|
424895
|
+
title: src_I18n.t("bot_preview_run_completed"),
|
|
424823
424896
|
status: "success"
|
|
424824
424897
|
} : {
|
|
424825
424898
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozWarningCircle, {}),
|
|
424826
|
-
title:
|
|
424899
|
+
title: src_I18n.t("bot_preview_run_completed"),
|
|
424827
424900
|
status: "fail"
|
|
424828
424901
|
};
|
|
424829
424902
|
else {
|
|
424830
424903
|
if (isFakeInterruptAnswer) return {
|
|
424831
424904
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozCheckMarkCircle, {}),
|
|
424832
|
-
title:
|
|
424905
|
+
title: src_I18n.t("bot_debug_question_wait"),
|
|
424833
424906
|
status: "success"
|
|
424834
424907
|
};
|
|
424835
424908
|
if (!isMessageFromOngoingChat) return {
|
|
424836
424909
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozWarningCircle, {}),
|
|
424837
|
-
title:
|
|
424910
|
+
title: src_I18n.t("bot_preview_run_terminated"),
|
|
424838
424911
|
status: "interrupt"
|
|
424839
424912
|
};
|
|
424840
424913
|
}
|
|
@@ -424905,11 +424978,11 @@ const getLLMTime = (messageUnit)=>{
|
|
|
424905
424978
|
const apiTime = getMessageTimeCost((_messageUnit_apiResponse = messageUnit.apiResponse) === null || _messageUnit_apiResponse === void 0 ? void 0 : _messageUnit_apiResponse.extra_info);
|
|
424906
424979
|
const subTimeList = [
|
|
424907
424980
|
{
|
|
424908
|
-
label:
|
|
424981
|
+
label: src_I18n.t("debug_area_time_label_model"),
|
|
424909
424982
|
value: llmTime
|
|
424910
424983
|
},
|
|
424911
424984
|
{
|
|
424912
|
-
label:
|
|
424985
|
+
label: src_I18n.t("debug_area_time_label_tool"),
|
|
424913
424986
|
value: apiTime
|
|
424914
424987
|
}
|
|
424915
424988
|
].filter((t)=>t.value);
|
|
@@ -424956,7 +425029,7 @@ const CollapsePanelHeader = (props)=>{
|
|
|
424956
425029
|
isTopLevelOfTheNestedPanel && !isPanelOpen && (hitMock || isRelatedChatComplete && hitMockSet) ? /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Tag, {
|
|
424957
425030
|
color: "primary",
|
|
424958
425031
|
className: "ml-[8px]",
|
|
424959
|
-
children:
|
|
425032
|
+
children: src_I18n.t("mockset")
|
|
424960
425033
|
}) : null
|
|
424961
425034
|
]
|
|
424962
425035
|
}),
|
|
@@ -425117,7 +425190,7 @@ const LLMAndAPIContent = (param)=>{
|
|
|
425117
425190
|
hitMock ? /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Tag, {
|
|
425118
425191
|
color: "primary",
|
|
425119
425192
|
className: "ml-[8px] mb-[8px] max-w-[144px]",
|
|
425120
|
-
children: `${
|
|
425193
|
+
children: `${src_I18n.t("mockset_label_tip", {
|
|
425121
425194
|
MockSetName: mockSetName
|
|
425122
425195
|
})}`
|
|
425123
425196
|
}) : null
|
|
@@ -425141,13 +425214,13 @@ const getVerboseContent = (llmContent)=>{
|
|
|
425141
425214
|
// backtracking node copy
|
|
425142
425215
|
case types_VerboseMsgType.BACK_WORD:
|
|
425143
425216
|
{
|
|
425144
|
-
const startMode =
|
|
425145
|
-
const previousMode =
|
|
425146
|
-
return `${
|
|
425217
|
+
const startMode = src_I18n.t("agentflow_transfer_ conversation_settings_backtrack_start");
|
|
425218
|
+
const previousMode = src_I18n.t("agentflow_transfer_ conversation_settings_backtrack_previous");
|
|
425219
|
+
return `${src_I18n.t("agentflow_jump_running_process_trigger_condition")}${(contentData === null || contentData === void 0 ? void 0 : contentData.restart) ? startMode : previousMode}`;
|
|
425147
425220
|
}
|
|
425148
425221
|
// jump node copy
|
|
425149
425222
|
case types_VerboseMsgType.JUMP_TO:
|
|
425150
|
-
return `${
|
|
425223
|
+
return `${src_I18n.t("agentflow_jump_running_process_trigger_condition")}${(contentData === null || contentData === void 0 ? void 0 : contentData.condition) ?? ""}`;
|
|
425151
425224
|
// long-term memory node copy
|
|
425152
425225
|
case types_VerboseMsgType.LONG_TERM_MEMORY:
|
|
425153
425226
|
return (contentData === null || contentData === void 0 ? void 0 : contentData.wraped_text) ?? "";
|
|
@@ -425195,7 +425268,7 @@ const renderHooksMessage = (messageUnit)=>{
|
|
|
425195
425268
|
});
|
|
425196
425269
|
}
|
|
425197
425270
|
return /*#__PURE__*/ (0,jsx_runtime_.jsx)(ProcessContent, {
|
|
425198
|
-
children:
|
|
425271
|
+
children: src_I18n.t("codedev_hook_invoked_failed")
|
|
425199
425272
|
});
|
|
425200
425273
|
};
|
|
425201
425274
|
const CollapsePanelWithHeaderImpl = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)=>{
|
|
@@ -425405,23 +425478,23 @@ const FunctionCallMessagesCollapse = (props)=>{
|
|
|
425405
425478
|
const { tool, total, llm, dataSet, jump, longTerm } = timeGroup;
|
|
425406
425479
|
const timeList = [
|
|
425407
425480
|
{
|
|
425408
|
-
label:
|
|
425481
|
+
label: src_I18n.t("debug_area_time_label_llm"),
|
|
425409
425482
|
value: llm
|
|
425410
425483
|
},
|
|
425411
425484
|
{
|
|
425412
|
-
label:
|
|
425485
|
+
label: src_I18n.t("debug_area_time_label_plugin"),
|
|
425413
425486
|
value: tool
|
|
425414
425487
|
},
|
|
425415
425488
|
{
|
|
425416
|
-
label:
|
|
425489
|
+
label: src_I18n.t("debug_area_time_label_dataset"),
|
|
425417
425490
|
value: dataSet
|
|
425418
425491
|
},
|
|
425419
425492
|
{
|
|
425420
|
-
label:
|
|
425493
|
+
label: src_I18n.t("agentflow_jump_running_process_jump_time"),
|
|
425421
425494
|
value: jump
|
|
425422
425495
|
},
|
|
425423
425496
|
{
|
|
425424
|
-
label:
|
|
425497
|
+
label: src_I18n.t("timecapsule_1228_001"),
|
|
425425
425498
|
value: longTerm
|
|
425426
425499
|
}
|
|
425427
425500
|
].filter((v)=>v.value);
|
|
@@ -425490,7 +425563,7 @@ const FunctionCallMessagesCollapse = (props)=>{
|
|
|
425490
425563
|
}
|
|
425491
425564
|
},
|
|
425492
425565
|
children: [
|
|
425493
|
-
|
|
425566
|
+
src_I18n.t("bot_preview_run_completed"),
|
|
425494
425567
|
" ",
|
|
425495
425568
|
getTotalTime()
|
|
425496
425569
|
]
|
|
@@ -425500,7 +425573,7 @@ const FunctionCallMessagesCollapse = (props)=>{
|
|
|
425500
425573
|
color: "primary",
|
|
425501
425574
|
"data-testid": "chat-area.fncall.bot_preview_run_terminated",
|
|
425502
425575
|
className: "my-4px mx-12px",
|
|
425503
|
-
children:
|
|
425576
|
+
children: src_I18n.t("bot_preview_run_terminated")
|
|
425504
425577
|
})
|
|
425505
425578
|
]
|
|
425506
425579
|
});
|
|
@@ -426117,7 +426190,7 @@ const LoadRetry = (param)=>{
|
|
|
426117
426190
|
}),
|
|
426118
426191
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
426119
426192
|
className: load_more_load_retry_module_.text,
|
|
426120
|
-
children:
|
|
426193
|
+
children: src_I18n.t("Coze_token_reload")
|
|
426121
426194
|
})
|
|
426122
426195
|
]
|
|
426123
426196
|
});
|
|
@@ -426582,6 +426655,507 @@ const DragUploadArea = ()=>{
|
|
|
426582
426655
|
});
|
|
426583
426656
|
};
|
|
426584
426657
|
|
|
426658
|
+
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/public/use-latest-section-id.ts
|
|
426659
|
+
/*
|
|
426660
|
+
* Copyright 2025 coze-dev Authors
|
|
426661
|
+
*
|
|
426662
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
426663
|
+
* you may not use this file except in compliance with the License.
|
|
426664
|
+
* You may obtain a copy of the License at
|
|
426665
|
+
*
|
|
426666
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
426667
|
+
*
|
|
426668
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
426669
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
426670
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
426671
|
+
* See the License for the specific language governing permissions and
|
|
426672
|
+
* limitations under the License.
|
|
426673
|
+
*/
|
|
426674
|
+
const use_latest_section_id_useLatestSectionId = ()=>{
|
|
426675
|
+
const { useSectionIdStore } = use_chat_area_context_useChatAreaStoreSet();
|
|
426676
|
+
const latestSectionId = useSectionIdStore((state)=>state.latestSectionId);
|
|
426677
|
+
return latestSectionId;
|
|
426678
|
+
};
|
|
426679
|
+
|
|
426680
|
+
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/context/use-conversation-id.ts
|
|
426681
|
+
/*
|
|
426682
|
+
* Copyright 2025 coze-dev Authors
|
|
426683
|
+
*
|
|
426684
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
426685
|
+
* you may not use this file except in compliance with the License.
|
|
426686
|
+
* You may obtain a copy of the License at
|
|
426687
|
+
*
|
|
426688
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
426689
|
+
*
|
|
426690
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
426691
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
426692
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
426693
|
+
* See the License for the specific language governing permissions and
|
|
426694
|
+
* limitations under the License.
|
|
426695
|
+
*/
|
|
426696
|
+
|
|
426697
|
+
|
|
426698
|
+
const useConversationId = ()=>{
|
|
426699
|
+
const chatAreaStoreSetContext = use_chat_area_context_useChatAreaStoreSet();
|
|
426700
|
+
if (!is_valid_context_isValidContext(chatAreaStoreSetContext)) throw new Error("chatAreaStoreSetContext is not valid");
|
|
426701
|
+
const { useGlobalInitStore } = chatAreaStoreSetContext;
|
|
426702
|
+
const conversationId = useGlobalInitStore((state)=>state.conversationId);
|
|
426703
|
+
return conversationId;
|
|
426704
|
+
};
|
|
426705
|
+
|
|
426706
|
+
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/file/use-upload-to-knowledge.ts
|
|
426707
|
+
/*
|
|
426708
|
+
* Copyright 2025 coze-dev Authors
|
|
426709
|
+
*
|
|
426710
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
426711
|
+
* you may not use this file except in compliance with the License.
|
|
426712
|
+
* You may obtain a copy of the License at
|
|
426713
|
+
*
|
|
426714
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
426715
|
+
*
|
|
426716
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
426717
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
426718
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
426719
|
+
* See the License for the specific language governing permissions and
|
|
426720
|
+
* limitations under the License.
|
|
426721
|
+
*/ /* eslint-disable max-lines -- This file contains complex upload logic that requires many lines */
|
|
426722
|
+
|
|
426723
|
+
|
|
426724
|
+
|
|
426725
|
+
// Try to import from open-chat if available
|
|
426726
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
426727
|
+
let use_upload_to_knowledge_useChatAppProps = null;
|
|
426728
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
426729
|
+
let use_upload_to_knowledge_useChatCozeSdk = null;
|
|
426730
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
426731
|
+
let use_upload_to_knowledge_useChatAppStore = null;
|
|
426732
|
+
// Try to import updateCurrentConversationInfo from open-chat if available
|
|
426733
|
+
// Note: This variable is currently unused but kept for future use
|
|
426734
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
426735
|
+
const use_upload_to_knowledge_updateCurrentConversationInfo = null;
|
|
426736
|
+
let use_upload_to_knowledge_createConversationForMessage = null;
|
|
426737
|
+
try {
|
|
426738
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
426739
|
+
const openChatModule = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module '@coze-studio/open-chat'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
|
|
426740
|
+
if (openChatModule.useChatAppProps) use_upload_to_knowledge_useChatAppProps = openChatModule.useChatAppProps;
|
|
426741
|
+
if (openChatModule.useChatCozeSdk) use_upload_to_knowledge_useChatCozeSdk = openChatModule.useChatCozeSdk;
|
|
426742
|
+
if (openChatModule.useChatAppStore) use_upload_to_knowledge_useChatAppStore = openChatModule.useChatAppStore;
|
|
426743
|
+
// Try to get updateCurrentConversationInfo from store
|
|
426744
|
+
try {
|
|
426745
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
426746
|
+
const storeHook = openChatModule.useChatAppStore;
|
|
426747
|
+
storeHook && typeof storeHook;
|
|
426748
|
+
} catch (error) {
|
|
426749
|
+
// Store not available
|
|
426750
|
+
error;
|
|
426751
|
+
}
|
|
426752
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
426753
|
+
const createConversationModule = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module '@coze-studio/open-chat/chat/builder-chat/services/create-conversation'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
|
|
426754
|
+
if (createConversationModule.createConversationForMessage) use_upload_to_knowledge_createConversationForMessage = createConversationModule.createConversationForMessage;
|
|
426755
|
+
} catch (error) {
|
|
426756
|
+
// Module not available, hooks will be null
|
|
426757
|
+
error;
|
|
426758
|
+
}
|
|
426759
|
+
/** 按 fileId 存储轮询的 AbortController,删除文件时用于停止轮询 */ const knowledgePollingControllers = new Map();
|
|
426760
|
+
/**
|
|
426761
|
+
* 取消指定 fileId 的知识库文件状态轮询(会话中删除正在上传的文件时调用)
|
|
426762
|
+
*/ function cancelKnowledgePolling(fileId) {
|
|
426763
|
+
const controller = knowledgePollingControllers.get(fileId);
|
|
426764
|
+
if (controller) {
|
|
426765
|
+
controller.abort();
|
|
426766
|
+
knowledgePollingControllers.delete(fileId);
|
|
426767
|
+
}
|
|
426768
|
+
}
|
|
426769
|
+
var use_upload_to_knowledge_FileProcessStatus;
|
|
426770
|
+
(function(FileProcessStatus) {
|
|
426771
|
+
FileProcessStatus[FileProcessStatus["Processing"] = 1] = "Processing";
|
|
426772
|
+
FileProcessStatus[FileProcessStatus["Completed"] = 2] = "Completed";
|
|
426773
|
+
FileProcessStatus[FileProcessStatus["Failed"] = 3] = "Failed";
|
|
426774
|
+
FileProcessStatus[FileProcessStatus["NotFound"] = -1] = "NotFound";
|
|
426775
|
+
})(use_upload_to_knowledge_FileProcessStatus || (use_upload_to_knowledge_FileProcessStatus = {}));
|
|
426776
|
+
/**
|
|
426777
|
+
* Query file processing status
|
|
426778
|
+
* @param params Query parameters
|
|
426779
|
+
* @returns File status items or null if query failed
|
|
426780
|
+
*/ async function queryFileStatus(params) {
|
|
426781
|
+
const { apiUrl, token, appId, conversationId, sectionId, knowledgeId, docIds } = params;
|
|
426782
|
+
try {
|
|
426783
|
+
const requestBody = {
|
|
426784
|
+
app_id: appId,
|
|
426785
|
+
conversation_id: conversationId,
|
|
426786
|
+
section_id: sectionId,
|
|
426787
|
+
knowledge_id: knowledgeId,
|
|
426788
|
+
doc_ids: docIds
|
|
426789
|
+
};
|
|
426790
|
+
const apiEndpoint = `${apiUrl}/v1/workflows/conversation/file/status`;
|
|
426791
|
+
const response = await fetch(apiEndpoint, {
|
|
426792
|
+
method: "POST",
|
|
426793
|
+
headers: {
|
|
426794
|
+
"Content-Type": "application/json",
|
|
426795
|
+
Authorization: `Bearer ${token}`
|
|
426796
|
+
},
|
|
426797
|
+
body: JSON.stringify(requestBody)
|
|
426798
|
+
});
|
|
426799
|
+
const result = await response.json();
|
|
426800
|
+
if (result.code === 0 && result.data) {
|
|
426801
|
+
// Log status for each file
|
|
426802
|
+
result.data.forEach((item)=>{
|
|
426803
|
+
const statusText = item.status === 1 ? "处理中" : item.status === 2 ? "已完成" : item.status === 3 ? "处理失败" : item.status === -1 ? "文件不存在或异常" : `未知状态(${item.status})`;
|
|
426804
|
+
console.log(`File ${item.file_id} status: ${statusText}`, {
|
|
426805
|
+
file_id: item.file_id,
|
|
426806
|
+
status: item.status,
|
|
426807
|
+
message: item.message
|
|
426808
|
+
});
|
|
426809
|
+
});
|
|
426810
|
+
return result.data;
|
|
426811
|
+
} else {
|
|
426812
|
+
console.error("Failed to query file status:", result.msg || "Unknown error");
|
|
426813
|
+
return null;
|
|
426814
|
+
}
|
|
426815
|
+
} catch (error) {
|
|
426816
|
+
console.error("Error querying file status:", error);
|
|
426817
|
+
return null;
|
|
426818
|
+
}
|
|
426819
|
+
}
|
|
426820
|
+
/**
|
|
426821
|
+
* Poll file status until completion or failure
|
|
426822
|
+
* @param params Query parameters
|
|
426823
|
+
* @param options Polling options (intervalMs, signal for cancellation)
|
|
426824
|
+
* @returns Final file status items or null if polling failed / was aborted
|
|
426825
|
+
*/ async function pollFileStatus(params) {
|
|
426826
|
+
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
426827
|
+
const { intervalMs = 2000, signal } = options;
|
|
426828
|
+
for(;;){
|
|
426829
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) return null;
|
|
426830
|
+
const statusResult = await queryFileStatus(params);
|
|
426831
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) return null;
|
|
426832
|
+
if (!statusResult || statusResult.length === 0) {
|
|
426833
|
+
await new Promise((resolve)=>setTimeout(resolve, intervalMs));
|
|
426834
|
+
continue;
|
|
426835
|
+
}
|
|
426836
|
+
// Check if all files are in final state (completed, failed, or not found)
|
|
426837
|
+
const allFinal = statusResult.every((item)=>item.status === 2 || item.status === 3 || item.status === -1);
|
|
426838
|
+
if (allFinal) return statusResult;
|
|
426839
|
+
// Some files are still processing, wait and retry
|
|
426840
|
+
await new Promise((resolve)=>setTimeout(resolve, intervalMs));
|
|
426841
|
+
}
|
|
426842
|
+
}
|
|
426843
|
+
/**
|
|
426844
|
+
* Hook to upload file to knowledge base
|
|
426845
|
+
*/ // eslint-disable-next-line @coze-arch/max-line-per-function
|
|
426846
|
+
const useUploadToKnowledge = (config)=>{
|
|
426847
|
+
const conversationId = useConversationId();
|
|
426848
|
+
const sectionId = use_latest_section_id_useLatestSectionId();
|
|
426849
|
+
const storeSet = use_chat_area_context_useChatAreaStoreSet();
|
|
426850
|
+
const { useGlobalInitStore, useSectionIdStore } = storeSet;
|
|
426851
|
+
// Get setLatestSectionId from the store
|
|
426852
|
+
// Always call the hook to satisfy React Hooks rules
|
|
426853
|
+
// useChatAreaStoreSet() throws if context is invalid, so useSectionIdStore is always defined
|
|
426854
|
+
const setLatestSectionId = useSectionIdStore((state)=>state.setLatestSectionId);
|
|
426855
|
+
// Try to get apiUrl from useChatAppStore as fallback
|
|
426856
|
+
let apiUrlFromStore;
|
|
426857
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
426858
|
+
const chatAppStoreHook = use_upload_to_knowledge_useChatAppStore;
|
|
426859
|
+
if (chatAppStoreHook && typeof chatAppStoreHook === "function") try {
|
|
426860
|
+
apiUrlFromStore = chatAppStoreHook((state)=>state.apiUrl);
|
|
426861
|
+
} catch (error) {
|
|
426862
|
+
// Store not available
|
|
426863
|
+
error;
|
|
426864
|
+
}
|
|
426865
|
+
const uploadFileToKnowledge = (0,react_.useCallback)(// eslint-disable-next-line @coze-arch/max-line-per-function, max-lines-per-function, complexity -- uploadFileToKnowledge requires many lines for complete file upload functionality
|
|
426866
|
+
async (file, options)=>{
|
|
426867
|
+
const fileId = options === null || options === void 0 ? void 0 : options.fileId;
|
|
426868
|
+
const controller = fileId ? new AbortController() : undefined;
|
|
426869
|
+
if (fileId && controller) knowledgePollingControllers.set(fileId, controller);
|
|
426870
|
+
try {
|
|
426871
|
+
var _chatConfig_appInfo, _chatConfig_auth;
|
|
426872
|
+
let chatConfig;
|
|
426873
|
+
let cozeApiSdk;
|
|
426874
|
+
// Use config from props first, then try to get from hooks, then fallback to store
|
|
426875
|
+
let apiUrl = (config === null || config === void 0 ? void 0 : config.apiUrl) || apiUrlFromStore;
|
|
426876
|
+
let appId = config === null || config === void 0 ? void 0 : config.appId;
|
|
426877
|
+
let token = config === null || config === void 0 ? void 0 : config.token;
|
|
426878
|
+
let workflowId = config === null || config === void 0 ? void 0 : config.workflowId;
|
|
426879
|
+
let draftMode = config === null || config === void 0 ? void 0 : config.draftMode;
|
|
426880
|
+
let conversationName = config === null || config === void 0 ? void 0 : config.conversationName;
|
|
426881
|
+
let connectorId = config === null || config === void 0 ? void 0 : config.connectorId;
|
|
426882
|
+
let chatType = config === null || config === void 0 ? void 0 : config.chatType;
|
|
426883
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- useChatAppProps may not be available in all contexts
|
|
426884
|
+
const chatAppPropsHook = use_upload_to_knowledge_useChatAppProps;
|
|
426885
|
+
if (chatAppPropsHook && typeof chatAppPropsHook === "function") try {
|
|
426886
|
+
const chatAppProps = chatAppPropsHook();
|
|
426887
|
+
chatConfig = chatAppProps === null || chatAppProps === void 0 ? void 0 : chatAppProps.chatConfig;
|
|
426888
|
+
// Use values from hook if not provided in config
|
|
426889
|
+
if (!apiUrl) {
|
|
426890
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- useChatAppStore may not be available in all contexts
|
|
426891
|
+
const storeHook = use_upload_to_knowledge_useChatAppStore;
|
|
426892
|
+
if (storeHook && typeof storeHook === "function") try {
|
|
426893
|
+
apiUrl = storeHook((state)=>state.apiUrl) || apiUrl;
|
|
426894
|
+
} catch (error) {
|
|
426895
|
+
// Store not available
|
|
426896
|
+
error;
|
|
426897
|
+
}
|
|
426898
|
+
}
|
|
426899
|
+
// Fill in missing values from chatConfig if not in config
|
|
426900
|
+
if (!appId) {
|
|
426901
|
+
var _chatConfig_appInfo1;
|
|
426902
|
+
appId = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo1 = chatConfig.appInfo) === null || _chatConfig_appInfo1 === void 0 ? void 0 : _chatConfig_appInfo1.appId) || (chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.bot_id);
|
|
426903
|
+
}
|
|
426904
|
+
if (!token) {
|
|
426905
|
+
var _chatConfig_auth1;
|
|
426906
|
+
token = chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_auth1 = chatConfig.auth) === null || _chatConfig_auth1 === void 0 ? void 0 : _chatConfig_auth1.token;
|
|
426907
|
+
}
|
|
426908
|
+
if (!workflowId) {
|
|
426909
|
+
var _chatConfig_appInfo2;
|
|
426910
|
+
workflowId = chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo2 = chatConfig.appInfo) === null || _chatConfig_appInfo2 === void 0 ? void 0 : _chatConfig_appInfo2.workflowId;
|
|
426911
|
+
}
|
|
426912
|
+
if (draftMode === undefined) {
|
|
426913
|
+
var _chatConfig_appInfo3;
|
|
426914
|
+
draftMode = chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo3 = chatConfig.appInfo) === null || _chatConfig_appInfo3 === void 0 ? void 0 : _chatConfig_appInfo3.draft_mode;
|
|
426915
|
+
}
|
|
426916
|
+
if (!conversationName) {
|
|
426917
|
+
var _chatConfig_appInfo4;
|
|
426918
|
+
conversationName = chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo4 = chatConfig.appInfo) === null || _chatConfig_appInfo4 === void 0 ? void 0 : _chatConfig_appInfo4.conversationName;
|
|
426919
|
+
}
|
|
426920
|
+
if (!connectorId) {
|
|
426921
|
+
var _chatConfig_auth2;
|
|
426922
|
+
connectorId = chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_auth2 = chatConfig.auth) === null || _chatConfig_auth2 === void 0 ? void 0 : _chatConfig_auth2.connectorId;
|
|
426923
|
+
}
|
|
426924
|
+
if (!chatType) chatType = chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.type;
|
|
426925
|
+
} catch (error) {
|
|
426926
|
+
// Hook not available in this context
|
|
426927
|
+
error;
|
|
426928
|
+
}
|
|
426929
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- useChatCozeSdk may not be available in all contexts
|
|
426930
|
+
const chatCozeSdkHook = use_upload_to_knowledge_useChatCozeSdk;
|
|
426931
|
+
if (chatCozeSdkHook && typeof chatCozeSdkHook === "function") try {
|
|
426932
|
+
const chatCozeSdk = chatCozeSdkHook();
|
|
426933
|
+
cozeApiSdk = chatCozeSdk === null || chatCozeSdk === void 0 ? void 0 : chatCozeSdk.cozeApiSdk;
|
|
426934
|
+
} catch (error1) {
|
|
426935
|
+
// Hook not available in this context
|
|
426936
|
+
error1;
|
|
426937
|
+
}
|
|
426938
|
+
// Check if we have minimum required info (apiUrl and appId)
|
|
426939
|
+
// We can work without chatConfig and cozeApiSdk if config is provided
|
|
426940
|
+
if (!apiUrl || !appId) {
|
|
426941
|
+
console.warn("Cannot upload to knowledge: apiUrl or appId is missing");
|
|
426942
|
+
return null;
|
|
426943
|
+
}
|
|
426944
|
+
// If we don't have chatConfig, create a minimal one from config
|
|
426945
|
+
if (!chatConfig) chatConfig = {
|
|
426946
|
+
type: chatType,
|
|
426947
|
+
appInfo: {
|
|
426948
|
+
appId,
|
|
426949
|
+
workflowId,
|
|
426950
|
+
draft_mode: draftMode,
|
|
426951
|
+
conversationName
|
|
426952
|
+
},
|
|
426953
|
+
bot_id: appId,
|
|
426954
|
+
auth: {
|
|
426955
|
+
token,
|
|
426956
|
+
connectorId
|
|
426957
|
+
}
|
|
426958
|
+
};
|
|
426959
|
+
// 1. Get or create conversation
|
|
426960
|
+
let currentConversationId = conversationId || "";
|
|
426961
|
+
let currentSectionId = sectionId || "";
|
|
426962
|
+
// If no conversation, create one
|
|
426963
|
+
if (!currentConversationId) {
|
|
426964
|
+
var _chatConfig_appInfo5, _chatConfig_appInfo6, _chatConfig_appInfo7, _chatConfig_appInfo8, _chatConfig_auth3, _chatConfig_auth4;
|
|
426965
|
+
const finalAppId = appId || ((_chatConfig_appInfo5 = chatConfig.appInfo) === null || _chatConfig_appInfo5 === void 0 ? void 0 : _chatConfig_appInfo5.appId) || chatConfig.bot_id || "";
|
|
426966
|
+
if (!finalAppId) {
|
|
426967
|
+
console.error("Cannot upload to knowledge: app_id is missing");
|
|
426968
|
+
return null;
|
|
426969
|
+
}
|
|
426970
|
+
const projectType = (chatType || chatConfig.type) === "app" ? "app" : "bot";
|
|
426971
|
+
const finalWorkflowId = workflowId || ((_chatConfig_appInfo6 = chatConfig.appInfo) === null || _chatConfig_appInfo6 === void 0 ? void 0 : _chatConfig_appInfo6.workflowId);
|
|
426972
|
+
const finalDraftMode = draftMode !== undefined ? draftMode : (_chatConfig_appInfo7 = chatConfig.appInfo) === null || _chatConfig_appInfo7 === void 0 ? void 0 : _chatConfig_appInfo7.draft_mode;
|
|
426973
|
+
const finalConversationName = conversationName || ((_chatConfig_appInfo8 = chatConfig.appInfo) === null || _chatConfig_appInfo8 === void 0 ? void 0 : _chatConfig_appInfo8.conversationName);
|
|
426974
|
+
const finalConnectorId = connectorId || ((_chatConfig_auth3 = chatConfig.auth) === null || _chatConfig_auth3 === void 0 ? void 0 : _chatConfig_auth3.connectorId);
|
|
426975
|
+
const finalToken = token || ((_chatConfig_auth4 = chatConfig.auth) === null || _chatConfig_auth4 === void 0 ? void 0 : _chatConfig_auth4.token) || "";
|
|
426976
|
+
// Try to use createConversationForMessage if available
|
|
426977
|
+
if (use_upload_to_knowledge_createConversationForMessage && cozeApiSdk) try {
|
|
426978
|
+
const conversationResult = await use_upload_to_knowledge_createConversationForMessage(cozeApiSdk, {
|
|
426979
|
+
projectType,
|
|
426980
|
+
projectId: finalAppId,
|
|
426981
|
+
workflowId: finalWorkflowId,
|
|
426982
|
+
mode: finalDraftMode ? "draft" : "release",
|
|
426983
|
+
conversationName: finalConversationName,
|
|
426984
|
+
connectorId: finalConnectorId
|
|
426985
|
+
});
|
|
426986
|
+
currentConversationId = conversationResult.conversationId;
|
|
426987
|
+
currentSectionId = conversationResult.sectionId;
|
|
426988
|
+
} catch (error) {
|
|
426989
|
+
console.warn("Failed to create conversation using createConversationForMessage:", error);
|
|
426990
|
+
// Fall through to direct API call
|
|
426991
|
+
}
|
|
426992
|
+
// If createConversationForMessage failed or is not available, use direct API call
|
|
426993
|
+
// Note: finalApiUrl is defined later in the code, so we use apiUrl here
|
|
426994
|
+
if (!currentConversationId && apiUrl && finalToken) try {
|
|
426995
|
+
let createUrl = "";
|
|
426996
|
+
let createPayload = {};
|
|
426997
|
+
if (projectType === "bot") {
|
|
426998
|
+
createUrl = `${apiUrl}/v1/conversations/create`;
|
|
426999
|
+
createPayload = {
|
|
427000
|
+
connector_id: finalConnectorId
|
|
427001
|
+
};
|
|
427002
|
+
} else {
|
|
427003
|
+
createUrl = `${apiUrl}/v1/workflow/conversation/create`;
|
|
427004
|
+
createPayload = {
|
|
427005
|
+
app_id: finalAppId,
|
|
427006
|
+
draft_mode: finalDraftMode || false,
|
|
427007
|
+
workflow_id: finalWorkflowId || "",
|
|
427008
|
+
connector_id: finalConnectorId
|
|
427009
|
+
};
|
|
427010
|
+
// Only add get_or_create if conversationName is provided
|
|
427011
|
+
if (finalConversationName && finalConversationName.trim() !== "") {
|
|
427012
|
+
createPayload.get_or_create = true;
|
|
427013
|
+
createPayload.conversation_name = finalConversationName;
|
|
427014
|
+
}
|
|
427015
|
+
}
|
|
427016
|
+
const createResponse = await fetch(createUrl, {
|
|
427017
|
+
method: "POST",
|
|
427018
|
+
headers: {
|
|
427019
|
+
"Content-Type": "application/json",
|
|
427020
|
+
Authorization: `Bearer ${finalToken}`,
|
|
427021
|
+
"Accept-Language": "en"
|
|
427022
|
+
},
|
|
427023
|
+
body: JSON.stringify(createPayload)
|
|
427024
|
+
});
|
|
427025
|
+
const createResult = await createResponse.json();
|
|
427026
|
+
if (createResult.code === 0 && createResult.data) {
|
|
427027
|
+
currentConversationId = createResult.data.id || "";
|
|
427028
|
+
currentSectionId = createResult.data.last_section_id || "";
|
|
427029
|
+
} else {
|
|
427030
|
+
console.error("Failed to create conversation:", createResult.msg || "Unknown error");
|
|
427031
|
+
return null;
|
|
427032
|
+
}
|
|
427033
|
+
} catch (error1) {
|
|
427034
|
+
console.error("Error creating conversation:", error1);
|
|
427035
|
+
return null;
|
|
427036
|
+
}
|
|
427037
|
+
// Update conversation ID in chat area
|
|
427038
|
+
if (currentConversationId) {
|
|
427039
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- useGlobalInitStore type may vary by context
|
|
427040
|
+
const globalStore = useGlobalInitStore;
|
|
427041
|
+
if (globalStore && typeof globalStore.getState === "function") {
|
|
427042
|
+
const { setConversationId } = globalStore.getState();
|
|
427043
|
+
setConversationId(currentConversationId);
|
|
427044
|
+
}
|
|
427045
|
+
if (currentSectionId && setLatestSectionId) setLatestSectionId(currentSectionId);
|
|
427046
|
+
// Also update currentConversationInfo in store so text messages can use it
|
|
427047
|
+
// First try to use the callback from config (preferred method)
|
|
427048
|
+
if (config === null || config === void 0 ? void 0 : config.updateCurrentConversationInfo) try {
|
|
427049
|
+
// Delay updating currentConversationInfo to ensure file message is displayed first
|
|
427050
|
+
// This prevents chatarea from refreshing before the file message is added to the store
|
|
427051
|
+
// Use requestAnimationFrame + setTimeout to ensure file message is fully rendered and saved
|
|
427052
|
+
const DELAY_MS = 200; // Increased delay to ensure file message is fully saved to store
|
|
427053
|
+
requestAnimationFrame(()=>{
|
|
427054
|
+
setTimeout(()=>{
|
|
427055
|
+
if (config.updateCurrentConversationInfo) config.updateCurrentConversationInfo({
|
|
427056
|
+
id: currentConversationId,
|
|
427057
|
+
last_section_id: currentSectionId
|
|
427058
|
+
});
|
|
427059
|
+
}, DELAY_MS);
|
|
427060
|
+
});
|
|
427061
|
+
} catch (error) {
|
|
427062
|
+
console.warn("Failed to schedule updateCurrentConversationInfo:", error);
|
|
427063
|
+
}
|
|
427064
|
+
else {
|
|
427065
|
+
// Fallback: try to use dynamically imported hook (may not work in callbacks)
|
|
427066
|
+
// Note: This is a fallback that may not work in callbacks
|
|
427067
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- fallback hook may not be available
|
|
427068
|
+
const storeHook = use_upload_to_knowledge_useChatAppStore;
|
|
427069
|
+
}
|
|
427070
|
+
}
|
|
427071
|
+
}
|
|
427072
|
+
if (!currentConversationId || !currentSectionId) {
|
|
427073
|
+
console.error("Cannot upload to knowledge: conversation_id or section_id is missing");
|
|
427074
|
+
return null;
|
|
427075
|
+
}
|
|
427076
|
+
// 2. Prepare FormData
|
|
427077
|
+
const formData = new FormData();
|
|
427078
|
+
formData.append("file", file);
|
|
427079
|
+
formData.append("app_id", appId || ((_chatConfig_appInfo = chatConfig.appInfo) === null || _chatConfig_appInfo === void 0 ? void 0 : _chatConfig_appInfo.appId) || chatConfig.bot_id || "");
|
|
427080
|
+
formData.append("conversation_id", currentConversationId);
|
|
427081
|
+
formData.append("section_id", currentSectionId);
|
|
427082
|
+
// 3. Call upload API
|
|
427083
|
+
// Use apiUrl from config, store, or from cozeApiSdk
|
|
427084
|
+
const finalApiUrl = apiUrl || (cozeApiSdk === null || cozeApiSdk === void 0 ? void 0 : cozeApiSdk.baseURL) || "";
|
|
427085
|
+
const finalToken = token || ((_chatConfig_auth = chatConfig.auth) === null || _chatConfig_auth === void 0 ? void 0 : _chatConfig_auth.token) || "";
|
|
427086
|
+
if (!finalApiUrl) {
|
|
427087
|
+
console.error("Cannot upload to knowledge: API URL is missing");
|
|
427088
|
+
return null;
|
|
427089
|
+
}
|
|
427090
|
+
// Use fetch to upload file
|
|
427091
|
+
const apiEndpoint = `${finalApiUrl}/v1/workflows/conversation/file/toKnowledge`;
|
|
427092
|
+
const response = await fetch(apiEndpoint, {
|
|
427093
|
+
method: "POST",
|
|
427094
|
+
headers: {
|
|
427095
|
+
Authorization: `Bearer ${finalToken}`
|
|
427096
|
+
},
|
|
427097
|
+
body: formData
|
|
427098
|
+
});
|
|
427099
|
+
const result = await response.json();
|
|
427100
|
+
if (result.code === 0 && result.data) {
|
|
427101
|
+
var _chatConfig_appInfo9;
|
|
427102
|
+
// Response data includes: url, uri, bytes, CreatedAt, file_name, id, doc_id, knowledge_id
|
|
427103
|
+
console.log("File uploaded to knowledge successfully:", {
|
|
427104
|
+
url: result.data.url,
|
|
427105
|
+
uri: result.data.uri,
|
|
427106
|
+
file_name: result.data.file_name,
|
|
427107
|
+
id: result.data.id,
|
|
427108
|
+
doc_id: result.data.doc_id,
|
|
427109
|
+
knowledge_id: result.data.knowledge_id,
|
|
427110
|
+
bytes: result.data.bytes,
|
|
427111
|
+
CreatedAt: result.data.CreatedAt
|
|
427112
|
+
});
|
|
427113
|
+
// 4. Query file status after upload (poll until completion or failure)
|
|
427114
|
+
const statusResult = await pollFileStatus({
|
|
427115
|
+
apiUrl: finalApiUrl,
|
|
427116
|
+
token: finalToken,
|
|
427117
|
+
appId: appId || ((_chatConfig_appInfo9 = chatConfig.appInfo) === null || _chatConfig_appInfo9 === void 0 ? void 0 : _chatConfig_appInfo9.appId) || chatConfig.bot_id || "",
|
|
427118
|
+
conversationId: currentConversationId,
|
|
427119
|
+
sectionId: currentSectionId,
|
|
427120
|
+
knowledgeId: result.data.knowledge_id,
|
|
427121
|
+
docIds: [
|
|
427122
|
+
result.data.doc_id
|
|
427123
|
+
]
|
|
427124
|
+
}, {
|
|
427125
|
+
intervalMs: 2000,
|
|
427126
|
+
signal: controller === null || controller === void 0 ? void 0 : controller.signal
|
|
427127
|
+
});
|
|
427128
|
+
// 轮询被用户取消(已删除文件)时不再更新 store,直接返回 null
|
|
427129
|
+
if (statusResult === null && (controller === null || controller === void 0 ? void 0 : controller.signal.aborted)) return null;
|
|
427130
|
+
if (statusResult) {
|
|
427131
|
+
// Check if file processing failed
|
|
427132
|
+
const failedFile = statusResult.find((item)=>item.status === 3);
|
|
427133
|
+
if (failedFile) console.error(`File processing failed: ${failedFile.message}`, failedFile);
|
|
427134
|
+
}
|
|
427135
|
+
return result.data;
|
|
427136
|
+
} else {
|
|
427137
|
+
console.error("Failed to upload file to knowledge:", result.msg || "Unknown error");
|
|
427138
|
+
return null;
|
|
427139
|
+
}
|
|
427140
|
+
} catch (error) {
|
|
427141
|
+
console.error("Error uploading file to knowledge:", error);
|
|
427142
|
+
return null;
|
|
427143
|
+
} finally{
|
|
427144
|
+
if (fileId) knowledgePollingControllers.delete(fileId);
|
|
427145
|
+
}
|
|
427146
|
+
}, [
|
|
427147
|
+
conversationId,
|
|
427148
|
+
sectionId,
|
|
427149
|
+
setLatestSectionId,
|
|
427150
|
+
useGlobalInitStore,
|
|
427151
|
+
apiUrlFromStore,
|
|
427152
|
+
config
|
|
427153
|
+
]);
|
|
427154
|
+
return {
|
|
427155
|
+
uploadFileToKnowledge
|
|
427156
|
+
};
|
|
427157
|
+
};
|
|
427158
|
+
|
|
426585
427159
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/file/use-delete-file.ts
|
|
426586
427160
|
/*
|
|
426587
427161
|
* Copyright 2025 coze-dev Authors
|
|
@@ -426599,10 +427173,12 @@ const DragUploadArea = ()=>{
|
|
|
426599
427173
|
* limitations under the License.
|
|
426600
427174
|
*/
|
|
426601
427175
|
|
|
427176
|
+
|
|
426602
427177
|
const use_delete_file_useDeleteFile = ()=>{
|
|
426603
427178
|
const { useBatchFileUploadStore } = use_chat_area_context_useChatAreaStoreSet();
|
|
426604
427179
|
const { cancelUploadById } = useUploadController();
|
|
426605
427180
|
return (fileId)=>{
|
|
427181
|
+
cancelKnowledgePolling(fileId);
|
|
426606
427182
|
const { immerDeleteFileDataById } = useBatchFileUploadStore.getState();
|
|
426607
427183
|
immerDeleteFileDataById(fileId);
|
|
426608
427184
|
cancelUploadById(fileId);
|
|
@@ -427107,7 +427683,7 @@ const CommonFile = (param)=>{
|
|
|
427107
427683
|
}),
|
|
427108
427684
|
isError ? /*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
427109
427685
|
className: batch_upload_file_list_common_file_index_module_["file-error-text"],
|
|
427110
|
-
children:
|
|
427686
|
+
children: src_I18n.t("multimodal_upload_file")
|
|
427111
427687
|
}) : null,
|
|
427112
427688
|
isSuccess ? /*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
427113
427689
|
className: batch_upload_file_list_common_file_index_module_["file-text"],
|
|
@@ -427286,6 +427862,31 @@ const BatchUploadFileList = ()=>{
|
|
|
427286
427862
|
});
|
|
427287
427863
|
};
|
|
427288
427864
|
|
|
427865
|
+
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/utils/batch-file-upload.ts
|
|
427866
|
+
/*
|
|
427867
|
+
* Copyright 2025 coze-dev Authors
|
|
427868
|
+
*
|
|
427869
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
427870
|
+
* you may not use this file except in compliance with the License.
|
|
427871
|
+
* You may obtain a copy of the License at
|
|
427872
|
+
*
|
|
427873
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
427874
|
+
*
|
|
427875
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
427876
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
427877
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
427878
|
+
* See the License for the specific language governing permissions and
|
|
427879
|
+
* limitations under the License.
|
|
427880
|
+
*/ const findFileDataIndexById = (fileIdList, id)=>{
|
|
427881
|
+
if (!id) return -1;
|
|
427882
|
+
return fileIdList.findIndex((fileId)=>fileId === id);
|
|
427883
|
+
};
|
|
427884
|
+
/**
|
|
427885
|
+
* @link https://developer.mozilla.org/zh-CN/docs/Web/API/Blob/type
|
|
427886
|
+
* @link https://www.iana.org/assignments/media-types/media-types.xhtml#image
|
|
427887
|
+
* The MIME for image types starts with image/
|
|
427888
|
+
*/ const batch_file_upload_isImage = (file)=>file.type.startsWith("image/");
|
|
427889
|
+
|
|
427289
427890
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/service/send-message/index.ts
|
|
427290
427891
|
/*
|
|
427291
427892
|
* Copyright 2025 coze-dev Authors
|
|
@@ -427315,6 +427916,7 @@ const BatchUploadFileList = ()=>{
|
|
|
427315
427916
|
|
|
427316
427917
|
|
|
427317
427918
|
|
|
427919
|
+
|
|
427318
427920
|
class send_message_SendMessageService {
|
|
427319
427921
|
sendTextMessage(params) {
|
|
427320
427922
|
const { methods } = this.context;
|
|
@@ -427347,20 +427949,37 @@ class send_message_SendMessageService {
|
|
|
427347
427949
|
sendMultimodalMessage(params) {
|
|
427348
427950
|
const { storeSets: { useBatchFileUploadStore }, methods: { sendMultimodalMessage } } = this.context;
|
|
427349
427951
|
const { inputPayload, from } = params;
|
|
427952
|
+
const fileDataList = useBatchFileUploadStore.getState().getFileDataList();
|
|
427953
|
+
// 从文件数据中收集 knowledge_id(仅非图片文件)
|
|
427954
|
+
const knowledgeIds = new Set();
|
|
427955
|
+
// 从文件数据中收集图片文件的 url(仅图片文件)
|
|
427956
|
+
const imageUrls = new Set();
|
|
427957
|
+
for (const fileData of fileDataList){
|
|
427958
|
+
if (fileData.knowledge_id) knowledgeIds.add(fileData.knowledge_id);
|
|
427959
|
+
// 如果是图片文件且有 url,收集 url
|
|
427960
|
+
if (batch_file_upload_isImage(fileData.file) && fileData.url) imageUrls.add(fileData.url);
|
|
427961
|
+
}
|
|
427350
427962
|
const mixList = [
|
|
427351
|
-
...formatFileDataListToMessagePayload(
|
|
427963
|
+
...formatFileDataListToMessagePayload(fileDataList),
|
|
427352
427964
|
{
|
|
427353
427965
|
type: types_ContentType.Text,
|
|
427354
427966
|
text: inputPayload.text
|
|
427355
427967
|
}
|
|
427356
427968
|
];
|
|
427969
|
+
// 构建 extendFiled,包含 knowledge_ids 和 image_urls
|
|
427970
|
+
const extendFiled = {};
|
|
427971
|
+
if (knowledgeIds.size > 0) extendFiled.knowledge_ids = Array.from(knowledgeIds);
|
|
427972
|
+
if (imageUrls.size > 0) extendFiled.image_urls = Array.from(imageUrls);
|
|
427973
|
+
const options = Object.keys(extendFiled).length > 0 ? {
|
|
427974
|
+
extendFiled
|
|
427975
|
+
} : undefined;
|
|
427357
427976
|
return sendMultimodalMessage({
|
|
427358
427977
|
payload: {
|
|
427359
427978
|
mixList,
|
|
427360
427979
|
mention_list: inputPayload.mentionList
|
|
427361
427980
|
},
|
|
427362
427981
|
audioFile: inputPayload.audioFile
|
|
427363
|
-
}, from);
|
|
427982
|
+
}, from, options);
|
|
427364
427983
|
}
|
|
427365
427984
|
constructor(params){
|
|
427366
427985
|
send_message_define_property(this, "context", void 0);
|
|
@@ -427779,6 +428398,11 @@ var components_chat_input_index_module_update = injectStylesIntoStyleTag_default
|
|
|
427779
428398
|
|
|
427780
428399
|
|
|
427781
428400
|
|
|
428401
|
+
|
|
428402
|
+
|
|
428403
|
+
|
|
428404
|
+
|
|
428405
|
+
|
|
427782
428406
|
|
|
427783
428407
|
|
|
427784
428408
|
|
|
@@ -427800,6 +428424,7 @@ const ChatInputArea = /*#__PURE__*/ (0,react_.forwardRef)((_, ref)=>{
|
|
|
427800
428424
|
});
|
|
427801
428425
|
});
|
|
427802
428426
|
const chat_input_ChatInput = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)=>{
|
|
428427
|
+
var _componentProps_copywritingConfig_uploadConfig, _componentProps_copywritingConfig;
|
|
427803
428428
|
const { component: InputComponent, componentProps, getChatInputController } = props;
|
|
427804
428429
|
const { eventCallback, lifeCycleService } = use_chat_area_context_useChatAreaContext();
|
|
427805
428430
|
const { useBatchFileUploadStore } = use_chat_area_context_useChatAreaStoreSet();
|
|
@@ -427807,7 +428432,10 @@ const chat_input_ChatInput = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)=>{
|
|
|
427807
428432
|
const multimodalUpload = useCreateFileAndUpload();
|
|
427808
428433
|
const { inputAddonTop: InputAddonTop, inputAboveOutside: InputAboveOutside, inputRightActions: InputRightActions } = useChatAreaCustomComponent();
|
|
427809
428434
|
const customInputAddonTopList = use_plugin_custom_components_usePluginCustomComponents("InputAddonTop");
|
|
427810
|
-
const { onBeforeSubmit, uploadButtonTooltipContent, wrapperClassName, inputNativeCallbacks, safeAreaClassName, inputMode: inputLayoutMode, ...restInputProps } = useChatInputProps();
|
|
428435
|
+
const { onBeforeSubmit, uploadButtonTooltipContent, wrapperClassName, inputNativeCallbacks, safeAreaClassName, inputMode: inputLayoutMode, componentProps: contextComponentProps, ...restInputProps } = useChatInputProps();
|
|
428436
|
+
// Get knowledge upload config from componentProps (from props or context)
|
|
428437
|
+
const knowledgeUploadConfig = (componentProps === null || componentProps === void 0 ? void 0 : componentProps.knowledgeUploadConfig) || (contextComponentProps === null || contextComponentProps === void 0 ? void 0 : contextComponentProps.knowledgeUploadConfig);
|
|
428438
|
+
const { uploadFileToKnowledge } = useUploadToKnowledge(knowledgeUploadConfig);
|
|
427811
428439
|
const showBackground = useShowBackGround();
|
|
427812
428440
|
const { messageWidth, readonly, uiKitChatInputButtonConfig, enableLegacyUpload, enableMultimodalUpload, showInputArea, layout, uikitChatInputButtonStatus, isInputReadonly, fileLimit } = usePreference();
|
|
427813
428441
|
const getScrollView = use_get_scroll_view_useGetScrollView();
|
|
@@ -427879,13 +428507,107 @@ const chat_input_ChatInput = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)=>{
|
|
|
427879
428507
|
const fileId = index_browser_nanoid();
|
|
427880
428508
|
multimodalUpload(fileId, payload.file);
|
|
427881
428509
|
};
|
|
427882
|
-
const handleUploadFile =
|
|
427883
|
-
|
|
428510
|
+
const handleUploadFile = async (uploadType, payload)=>{
|
|
428511
|
+
var _componentProps_copywritingConfig_uploadConfig, _componentProps_copywritingConfig;
|
|
428512
|
+
// 1. Check file size limit: single file should not exceed 50MB
|
|
428513
|
+
if (payload.file.size > MAX_FILE_SIZE_BYTES) {
|
|
428514
|
+
const fileSizeMB = (payload.file.size / BYTES_PER_MB).toFixed(2);
|
|
428515
|
+
esm_webpack_exports_Toast.error({
|
|
428516
|
+
content: `文件大小不能超过${MAX_FILE_SIZE_MB}MB,当前文件大小为 ${fileSizeMB}MB`,
|
|
428517
|
+
showClose: false
|
|
428518
|
+
});
|
|
428519
|
+
return;
|
|
428520
|
+
}
|
|
428521
|
+
// 2. Check file count limit: maximum 10 files
|
|
428522
|
+
const existingFileCount = useBatchFileUploadStore.getState().getExistingFileCount();
|
|
428523
|
+
if (existingFileCount >= MAX_FILE_COUNT) {
|
|
428524
|
+
esm_webpack_exports_Toast.error({
|
|
428525
|
+
content: `最多只能上传${MAX_FILE_COUNT}个文件,当前已有${existingFileCount}个文件`,
|
|
428526
|
+
showClose: false
|
|
428527
|
+
});
|
|
428528
|
+
return;
|
|
428529
|
+
}
|
|
428530
|
+
// Get uploadToKnowledge from componentProps first, then use true as default
|
|
428531
|
+
const uploadToKnowledgeFromProps = componentProps === null || componentProps === void 0 ? void 0 : (_componentProps_copywritingConfig = componentProps.copywritingConfig) === null || _componentProps_copywritingConfig === void 0 ? void 0 : (_componentProps_copywritingConfig_uploadConfig = _componentProps_copywritingConfig.uploadConfig) === null || _componentProps_copywritingConfig_uploadConfig === void 0 ? void 0 : _componentProps_copywritingConfig_uploadConfig.uploadToKnowledge;
|
|
428532
|
+
const uploadToKnowledge = uploadToKnowledgeFromProps !== undefined ? uploadToKnowledgeFromProps : true;
|
|
428533
|
+
// 判断文件是否为图片
|
|
428534
|
+
const fileIsImage = batch_file_upload_isImage(payload.file);
|
|
428535
|
+
// 如果是图片文件,使用普通上传接口
|
|
428536
|
+
if (fileIsImage) {
|
|
428537
|
+
if (enableMultimodalUpload) {
|
|
428538
|
+
handleMultimodalUpload(uploadType, payload);
|
|
428539
|
+
return;
|
|
428540
|
+
}
|
|
428541
|
+
if (enableLegacyUpload) {
|
|
428542
|
+
handleLegacyUpload(uploadType, payload);
|
|
428543
|
+
return;
|
|
428544
|
+
}
|
|
428545
|
+
return;
|
|
428546
|
+
}
|
|
428547
|
+
// 如果是非图片文件且 uploadToKnowledge 启用,上传到知识库
|
|
428548
|
+
if (uploadToKnowledge) {
|
|
428549
|
+
let fileId;
|
|
428550
|
+
try {
|
|
428551
|
+
// Add file to BatchUploadFileList (display above input) instead of sending as message
|
|
428552
|
+
const { immerCreateFileData } = useBatchFileUploadStore.getState();
|
|
428553
|
+
fileId = index_browser_nanoid();
|
|
428554
|
+
immerCreateFileData(fileId, payload.file);
|
|
428555
|
+
// Now upload to knowledge (this will create conversation and update currentConversationInfo)
|
|
428556
|
+
// The update is delayed to prevent chatarea refresh before file is displayed
|
|
428557
|
+
const uploadResult = await uploadFileToKnowledge(payload.file, {
|
|
428558
|
+
fileId
|
|
428559
|
+
});
|
|
428560
|
+
// Update file status based on upload result(若用户已删除该文件则不再更新,也不提示失败)
|
|
428561
|
+
const storeState = useBatchFileUploadStore.getState();
|
|
428562
|
+
const fileStillExists = storeState.fileIdList.includes(fileId);
|
|
428563
|
+
if (!fileStillExists) return;
|
|
428564
|
+
const { immerUpdateFileDataById } = storeState;
|
|
428565
|
+
if (uploadResult) // Upload successful, mark as success and save uri and fileId from response
|
|
428566
|
+
immerUpdateFileDataById(fileId, (data)=>{
|
|
428567
|
+
data.status = types_FileStatus.Success;
|
|
428568
|
+
data.percent = 100;
|
|
428569
|
+
// Save uri, fileId, and knowledge_id from API response for sending messages
|
|
428570
|
+
data.uri = uploadResult.uri;
|
|
428571
|
+
data.fileId = uploadResult.id;
|
|
428572
|
+
data.url = uploadResult.url;
|
|
428573
|
+
data.knowledge_id = uploadResult.knowledge_id;
|
|
428574
|
+
});
|
|
428575
|
+
else {
|
|
428576
|
+
// Upload failed, mark as error and show toast
|
|
428577
|
+
immerUpdateFileDataById(fileId, (data)=>{
|
|
428578
|
+
data.status = types_FileStatus.Error;
|
|
428579
|
+
data.percent = 0;
|
|
428580
|
+
});
|
|
428581
|
+
esm_webpack_exports_Toast.error({
|
|
428582
|
+
content: "上传文件到知识库失败,请重试",
|
|
428583
|
+
showClose: false
|
|
428584
|
+
});
|
|
428585
|
+
}
|
|
428586
|
+
return;
|
|
428587
|
+
} catch (error) {
|
|
428588
|
+
console.error("Failed to upload file to knowledge:", error);
|
|
428589
|
+
// 若用户已删除该文件(store 中不存在),不再重新创建并展示错误
|
|
428590
|
+
const storeState = useBatchFileUploadStore.getState();
|
|
428591
|
+
if (fileId === undefined || !storeState.fileIdList.includes(fileId)) return;
|
|
428592
|
+
// 上传异常时仅把当前文件标为错误,不重复创建新文件
|
|
428593
|
+
const { immerUpdateFileDataById } = storeState;
|
|
428594
|
+
immerUpdateFileDataById(fileId, (data)=>{
|
|
428595
|
+
data.status = types_FileStatus.Error;
|
|
428596
|
+
data.percent = 0;
|
|
428597
|
+
});
|
|
428598
|
+
esm_webpack_exports_Toast.error({
|
|
428599
|
+
content: "上传文件到知识库失败,请重试",
|
|
428600
|
+
showClose: false
|
|
428601
|
+
});
|
|
428602
|
+
return;
|
|
428603
|
+
}
|
|
428604
|
+
}
|
|
428605
|
+
// Then proceed with normal upload (only if uploadToKnowledge is false)
|
|
427884
428606
|
if (enableMultimodalUpload) {
|
|
427885
|
-
handleMultimodalUpload(
|
|
428607
|
+
handleMultimodalUpload(uploadType, payload);
|
|
427886
428608
|
return;
|
|
427887
428609
|
}
|
|
427888
|
-
if (enableLegacyUpload) handleLegacyUpload(
|
|
428610
|
+
if (enableLegacyUpload) handleLegacyUpload(uploadType, payload);
|
|
427889
428611
|
};
|
|
427890
428612
|
const handleInputClick = async ()=>{
|
|
427891
428613
|
var _eventCallback_onInputClick;
|
|
@@ -427901,6 +428623,8 @@ const chat_input_ChatInput = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)=>{
|
|
|
427901
428623
|
});
|
|
427902
428624
|
};
|
|
427903
428625
|
const { textareaPlaceholder, clearContextTooltipContent, textareaBottomTips } = useCopywriting();
|
|
428626
|
+
// Get uploadToKnowledge from copywriting config (can be overridden by componentProps)
|
|
428627
|
+
const uploadToKnowledgeFromConfig = componentProps === null || componentProps === void 0 ? void 0 : (_componentProps_copywritingConfig = componentProps.copywritingConfig) === null || _componentProps_copywritingConfig === void 0 ? void 0 : (_componentProps_copywritingConfig_uploadConfig = _componentProps_copywritingConfig.uploadConfig) === null || _componentProps_copywritingConfig_uploadConfig === void 0 ? void 0 : _componentProps_copywritingConfig_uploadConfig.uploadToKnowledge;
|
|
427904
428628
|
getChatInputController === null || getChatInputController === void 0 || getChatInputController({
|
|
427905
428629
|
sendMessage: handleSendMessage
|
|
427906
428630
|
});
|
|
@@ -427950,19 +428674,20 @@ const chat_input_ChatInput = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)=>{
|
|
|
427950
428674
|
copywritingConfig: {
|
|
427951
428675
|
inputPlaceholder: textareaPlaceholder,
|
|
427952
428676
|
tooltip: {
|
|
427953
|
-
sendButtonTooltipContent:
|
|
428677
|
+
sendButtonTooltipContent: src_I18n.t("mkpl_send_tooltips"),
|
|
427954
428678
|
moreButtonTooltipContent: uploadButtonTooltipContent,
|
|
427955
428679
|
clearContextButtonTooltipContent: clearContextTooltipContent,
|
|
427956
|
-
clearHistoryButtonTooltipContent:
|
|
427957
|
-
audioButtonTooltipContent:
|
|
427958
|
-
keyboardButtonTooltipContent:
|
|
428680
|
+
clearHistoryButtonTooltipContent: src_I18n.t("coze_home_delete_btn"),
|
|
428681
|
+
audioButtonTooltipContent: src_I18n.t("chat_input_hover_tip_voice_input_button"),
|
|
428682
|
+
keyboardButtonTooltipContent: src_I18n.t("chat_input_hover_tip_keyboard_input_button")
|
|
427959
428683
|
},
|
|
427960
428684
|
uploadConfig: {
|
|
427961
428685
|
fileSizeReachLimitToast: getFileSizeReachLimitI18n({
|
|
427962
428686
|
limitText: `${MAX_FILE_MBYTE}MB`
|
|
427963
428687
|
}),
|
|
427964
|
-
fileExceedsLimitToast:
|
|
427965
|
-
fileEmptyToast:
|
|
428688
|
+
fileExceedsLimitToast: src_I18n.t(FILE_EXCEEDS_LIMIT_I18N_KEY),
|
|
428689
|
+
fileEmptyToast: src_I18n.t("upload_empty_file"),
|
|
428690
|
+
uploadToKnowledge: uploadToKnowledgeFromConfig !== undefined ? uploadToKnowledgeFromConfig : true
|
|
427966
428691
|
},
|
|
427967
428692
|
bottomTips: textareaBottomTips
|
|
427968
428693
|
},
|
|
@@ -428292,7 +429017,7 @@ const AbsoluteRow = ()=>{
|
|
|
428292
429017
|
className: classnames_default()(components_absolute_row_index_module_["absolute-row"]),
|
|
428293
429018
|
children: [
|
|
428294
429019
|
showStopRespond && finalWaiting ? /*#__PURE__*/ (0,jsx_runtime_.jsx)(StopRespondButton, {
|
|
428295
|
-
content:
|
|
429020
|
+
content: src_I18n.t("coze_home_stop_btn"),
|
|
428296
429021
|
onClick: onStopRes,
|
|
428297
429022
|
className: classnames_default()(showBackground ? "!coz-bg-image-bots !coz-stroke-image-bots" : [
|
|
428298
429023
|
components_absolute_row_index_module_.bg,
|
|
@@ -428317,7 +429042,7 @@ const AbsoluteRow = ()=>{
|
|
|
428317
429042
|
}),
|
|
428318
429043
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
428319
429044
|
className: "leading-[20px] text-lg font-medium",
|
|
428320
|
-
children:
|
|
429045
|
+
children: src_I18n.t("chat_voice_input_speaking_cancel_send")
|
|
428321
429046
|
})
|
|
428322
429047
|
]
|
|
428323
429048
|
})
|
|
@@ -428339,16 +429064,16 @@ const AbsoluteRow = ()=>{
|
|
|
428339
429064
|
}),
|
|
428340
429065
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
428341
429066
|
className: "coz-fg-primary text-lg leading-[20px] font-normal",
|
|
428342
|
-
children:
|
|
429067
|
+
children: src_I18n.t("chat_voice_input_tip_speaking_record_and_send_after_x_seconds")
|
|
428343
429068
|
})
|
|
428344
429069
|
]
|
|
428345
429070
|
}) : null,
|
|
428346
429071
|
!isRecordingPointerOut && !audioLeftTime && (recordingInteractionType === "clickOrTouch" ? /*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
428347
429072
|
className: "coz-fg-primary leading-[20px] text-lg font-normal",
|
|
428348
|
-
children:
|
|
429073
|
+
children: src_I18n.t("chat_voice_input_tip_speaking_cancel_and_send")
|
|
428349
429074
|
}) : /*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
428350
429075
|
className: "coz-fg-primary leading-[20px] text-lg font-normal",
|
|
428351
|
-
children:
|
|
429076
|
+
children: src_I18n.t("chat_voice_input_tip_speaking_cancel_and_send_when_hold_down_space")
|
|
428352
429077
|
}))
|
|
428353
429078
|
]
|
|
428354
429079
|
})
|
|
@@ -428715,31 +429440,6 @@ const ChatArea = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)=>{
|
|
|
428715
429440
|
});
|
|
428716
429441
|
ChatArea.displayName = "ChatArea";
|
|
428717
429442
|
|
|
428718
|
-
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/utils/batch-file-upload.ts
|
|
428719
|
-
/*
|
|
428720
|
-
* Copyright 2025 coze-dev Authors
|
|
428721
|
-
*
|
|
428722
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
428723
|
-
* you may not use this file except in compliance with the License.
|
|
428724
|
-
* You may obtain a copy of the License at
|
|
428725
|
-
*
|
|
428726
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
428727
|
-
*
|
|
428728
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
428729
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
428730
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
428731
|
-
* See the License for the specific language governing permissions and
|
|
428732
|
-
* limitations under the License.
|
|
428733
|
-
*/ const findFileDataIndexById = (fileIdList, id)=>{
|
|
428734
|
-
if (!id) return -1;
|
|
428735
|
-
return fileIdList.findIndex((fileId)=>fileId === id);
|
|
428736
|
-
};
|
|
428737
|
-
/**
|
|
428738
|
-
* @link https://developer.mozilla.org/zh-CN/docs/Web/API/Blob/type
|
|
428739
|
-
* @link https://www.iana.org/assignments/media-types/media-types.xhtml#image
|
|
428740
|
-
* The MIME for image types starts with image/
|
|
428741
|
-
*/ const batch_file_upload_isImage = (file)=>file.type.startsWith("image/");
|
|
428742
|
-
|
|
428743
429443
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/service/upload-plugin.ts
|
|
428744
429444
|
/*
|
|
428745
429445
|
* Copyright 2025 coze-dev Authors
|
|
@@ -433295,6 +433995,7 @@ const createBatchFileUploadStore = (mark)=>esm_create()(devtools((set, get)=>({
|
|
|
433295
433995
|
fileId: null,
|
|
433296
433996
|
uri: null,
|
|
433297
433997
|
url: null,
|
|
433998
|
+
knowledge_id: null,
|
|
433298
433999
|
file,
|
|
433299
434000
|
id,
|
|
433300
434001
|
status: types_FileStatus.Uploading
|
|
@@ -434601,32 +435302,6 @@ const useInitStatus = ()=>{
|
|
|
434601
435302
|
return initStatus;
|
|
434602
435303
|
};
|
|
434603
435304
|
|
|
434604
|
-
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/context/use-conversation-id.ts
|
|
434605
|
-
/*
|
|
434606
|
-
* Copyright 2025 coze-dev Authors
|
|
434607
|
-
*
|
|
434608
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
434609
|
-
* you may not use this file except in compliance with the License.
|
|
434610
|
-
* You may obtain a copy of the License at
|
|
434611
|
-
*
|
|
434612
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
434613
|
-
*
|
|
434614
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
434615
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
434616
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
434617
|
-
* See the License for the specific language governing permissions and
|
|
434618
|
-
* limitations under the License.
|
|
434619
|
-
*/
|
|
434620
|
-
|
|
434621
|
-
|
|
434622
|
-
const useConversationId = ()=>{
|
|
434623
|
-
const chatAreaStoreSetContext = useChatAreaStoreSet();
|
|
434624
|
-
if (!isValidContext(chatAreaStoreSetContext)) throw new Error("chatAreaStoreSetContext is not valid");
|
|
434625
|
-
const { useGlobalInitStore } = chatAreaStoreSetContext;
|
|
434626
|
-
const conversationId = useGlobalInitStore((state)=>state.conversationId);
|
|
434627
|
-
return conversationId;
|
|
434628
|
-
};
|
|
434629
|
-
|
|
434630
435305
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/context/use-chat-area-waiting-state.ts
|
|
434631
435306
|
/*
|
|
434632
435307
|
* Copyright 2025 coze-dev Authors
|
|
@@ -435559,28 +436234,6 @@ const getLimitSelector = ()=>({
|
|
|
435559
436234
|
* Create a custom component helper function
|
|
435560
436235
|
*/ const create_custom_component_createCustomComponents = (customComponents)=>customComponents;
|
|
435561
436236
|
|
|
435562
|
-
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/public/use-latest-section-id.ts
|
|
435563
|
-
/*
|
|
435564
|
-
* Copyright 2025 coze-dev Authors
|
|
435565
|
-
*
|
|
435566
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
435567
|
-
* you may not use this file except in compliance with the License.
|
|
435568
|
-
* You may obtain a copy of the License at
|
|
435569
|
-
*
|
|
435570
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
435571
|
-
*
|
|
435572
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
435573
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
435574
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
435575
|
-
* See the License for the specific language governing permissions and
|
|
435576
|
-
* limitations under the License.
|
|
435577
|
-
*/
|
|
435578
|
-
const use_latest_section_id_useLatestSectionId = ()=>{
|
|
435579
|
-
const { useSectionIdStore } = useChatAreaStoreSet();
|
|
435580
|
-
const latestSectionId = useSectionIdStore((state)=>state.latestSectionId);
|
|
435581
|
-
return latestSectionId;
|
|
435582
|
-
};
|
|
435583
|
-
|
|
435584
436237
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/public/use-is-delete-message-lock.ts
|
|
435585
436238
|
/*
|
|
435586
436239
|
* Copyright 2025 coze-dev Authors
|
|
@@ -435819,7 +436472,7 @@ const conversation_display_name_isUUID = (str)=>{
|
|
|
435819
436472
|
// 如果name存在且不是UUID格式,使用name
|
|
435820
436473
|
if (item.name && !conversation_display_name_isUUID(item.name)) return item.name;
|
|
435821
436474
|
// 否则显示"新创建的会话"
|
|
435822
|
-
return
|
|
436475
|
+
return src_I18n.t("web_sdk_conversation_default_name", {}, "新创建的会话");
|
|
435823
436476
|
};
|
|
435824
436477
|
|
|
435825
436478
|
;// CONCATENATED MODULE: ../open-chat/src/types/conversations.ts
|
|
@@ -435848,15 +436501,15 @@ var conversations_ConversationSort;
|
|
|
435848
436501
|
const conversationSortMap = new Map([
|
|
435849
436502
|
[
|
|
435850
436503
|
0,
|
|
435851
|
-
|
|
436504
|
+
src_I18n.t("profile_history_today", {}, "今天")
|
|
435852
436505
|
],
|
|
435853
436506
|
[
|
|
435854
436507
|
1,
|
|
435855
|
-
|
|
436508
|
+
src_I18n.t("profile_history_yesterday", {}, "昨天")
|
|
435856
436509
|
],
|
|
435857
436510
|
[
|
|
435858
436511
|
2,
|
|
435859
|
-
|
|
436512
|
+
src_I18n.t("log_pay_wall_date_filter_30_days", {}, "过去30天")
|
|
435860
436513
|
],
|
|
435861
436514
|
[
|
|
435862
436515
|
999,
|
|
@@ -437394,7 +438047,7 @@ const MobileConversationOperate = (param)=>{
|
|
|
437394
438047
|
onRename();
|
|
437395
438048
|
},
|
|
437396
438049
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozEdit, {}),
|
|
437397
|
-
children:
|
|
438050
|
+
children: src_I18n.t("workflow_detail_node_rename", {}, "重命名")
|
|
437398
438051
|
}),
|
|
437399
438052
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Menu.Item, {
|
|
437400
438053
|
onClick: (_, e)=>{
|
|
@@ -437409,7 +438062,7 @@ const MobileConversationOperate = (param)=>{
|
|
|
437409
438062
|
style: {
|
|
437410
438063
|
color: "var(--coz-fg-hglt-red)"
|
|
437411
438064
|
},
|
|
437412
|
-
children:
|
|
438065
|
+
children: src_I18n.t("web_sdk_delete", {}, "删除")
|
|
437413
438066
|
})
|
|
437414
438067
|
})
|
|
437415
438068
|
]
|
|
@@ -437606,7 +438259,7 @@ const Operate = (param)=>{
|
|
|
437606
438259
|
onRename();
|
|
437607
438260
|
},
|
|
437608
438261
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozEdit, {}),
|
|
437609
|
-
children:
|
|
438262
|
+
children: src_I18n.t("workflow_detail_node_rename", {}, "重命名")
|
|
437610
438263
|
}),
|
|
437611
438264
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Menu.Item, {
|
|
437612
438265
|
onClick: (_, e)=>{
|
|
@@ -437621,7 +438274,7 @@ const Operate = (param)=>{
|
|
|
437621
438274
|
style: {
|
|
437622
438275
|
color: "var(--coz-fg-hglt-red)"
|
|
437623
438276
|
},
|
|
437624
|
-
children:
|
|
438277
|
+
children: src_I18n.t("web_sdk_delete", {}, "删除")
|
|
437625
438278
|
})
|
|
437626
438279
|
})
|
|
437627
438280
|
]
|
|
@@ -437789,7 +438442,7 @@ var conversation_list_index_module_update = injectStylesIntoStyleTag_default()(c
|
|
|
437789
438442
|
|
|
437790
438443
|
const ConversationList = /*#__PURE__*/ (0,react_.forwardRef)(// eslint-disable-next-line @coze-arch/max-line-per-function
|
|
437791
438444
|
(param, ref)=>{
|
|
437792
|
-
let { onRename, onDelete, loading, groupedConversations, conversations, hasMore, loadMore, removeConversation } = param;
|
|
438445
|
+
let { onRename, onDelete, onConversationKeyChange, loading, groupedConversations, conversations, hasMore, loadMore, removeConversation } = param;
|
|
437793
438446
|
const { currentConversationInfo, updateCurrentConversationInfo, cozeApi, updateConversations } = context_useChatAppStore(shallow_useShallow((state)=>({
|
|
437794
438447
|
currentConversationInfo: state.currentConversationInfo,
|
|
437795
438448
|
updateCurrentConversationInfo: state.updateCurrentConversationInfo,
|
|
@@ -437848,6 +438501,7 @@ const ConversationList = /*#__PURE__*/ (0,react_.forwardRef)(// eslint-disable-n
|
|
|
437848
438501
|
// 更新当前会话信息为空会话,这会触发 chat-area 重新初始化
|
|
437849
438502
|
updateCurrentConversationInfo(emptyConversationInfo);
|
|
437850
438503
|
conversationRef.current = emptyConversationInfo;
|
|
438504
|
+
onConversationKeyChange === null || onConversationKeyChange === void 0 || onConversationKeyChange("empty");
|
|
437851
438505
|
} catch (error) {
|
|
437852
438506
|
console.error(error);
|
|
437853
438507
|
} finally{
|
|
@@ -437875,6 +438529,7 @@ const ConversationList = /*#__PURE__*/ (0,react_.forwardRef)(// eslint-disable-n
|
|
|
437875
438529
|
};
|
|
437876
438530
|
conversationRef.current = c;
|
|
437877
438531
|
updateCurrentConversationInfo(c);
|
|
438532
|
+
onConversationKeyChange === null || onConversationKeyChange === void 0 || onConversationKeyChange(conversation.id);
|
|
437878
438533
|
return;
|
|
437879
438534
|
}
|
|
437880
438535
|
// 如果会话ID相同,检查是否真的需要更新(避免不必要的重载)
|
|
@@ -437899,6 +438554,7 @@ const ConversationList = /*#__PURE__*/ (0,react_.forwardRef)(// eslint-disable-n
|
|
|
437899
438554
|
console.log("handleConversationChange conversation2", c);
|
|
437900
438555
|
conversationRef.current = c;
|
|
437901
438556
|
updateCurrentConversationInfo(c);
|
|
438557
|
+
onConversationKeyChange === null || onConversationKeyChange === void 0 || onConversationKeyChange(conversation.id);
|
|
437902
438558
|
return;
|
|
437903
438559
|
}
|
|
437904
438560
|
// 会话ID不同,正常更新
|
|
@@ -437920,6 +438576,7 @@ const ConversationList = /*#__PURE__*/ (0,react_.forwardRef)(// eslint-disable-n
|
|
|
437920
438576
|
conversationRef.current = c;
|
|
437921
438577
|
// 然后更新 currentConversationInfo,这会触发 openRequestInit 重新调用
|
|
437922
438578
|
updateCurrentConversationInfo(c);
|
|
438579
|
+
onConversationKeyChange === null || onConversationKeyChange === void 0 || onConversationKeyChange(conversation.id);
|
|
437923
438580
|
};
|
|
437924
438581
|
const handleDeleteConversation = async (conversation)=>{
|
|
437925
438582
|
try {
|
|
@@ -438007,13 +438664,13 @@ const ConversationList = /*#__PURE__*/ (0,react_.forwardRef)(// eslint-disable-n
|
|
|
438007
438664
|
},
|
|
438008
438665
|
loading: addLoading,
|
|
438009
438666
|
disabled: addLoading,
|
|
438010
|
-
children:
|
|
438667
|
+
children: src_I18n.t("web_sdk_add_new_conversation")
|
|
438011
438668
|
}),
|
|
438012
438669
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
438013
438670
|
className: conversation_list_sider_conversation_list_index_module_["conversations-header"],
|
|
438014
438671
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
438015
438672
|
className: conversation_list_sider_conversation_list_index_module_["conversations-header-title"],
|
|
438016
|
-
children:
|
|
438673
|
+
children: src_I18n.t("web_sdk_conversation_history", {}, "会话历史")
|
|
438017
438674
|
})
|
|
438018
438675
|
}),
|
|
438019
438676
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
@@ -438137,6 +438794,12 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
|
|
|
438137
438794
|
const groupedConversations = useGroupedConversations(conversations);
|
|
438138
438795
|
const [isModalLoading, setIsModalLoading] = (0,react_.useState)(false);
|
|
438139
438796
|
const [modalInfo, setModalInfo] = (0,react_.useState)(null);
|
|
438797
|
+
// 使用稳定 key,避免空会话下上传文件创建新会话时因 key 从 '' 变为 newId 导致整树 remount、上传列表被清空
|
|
438798
|
+
const [fragmentKey, setFragmentKey] = (0,react_.useState)(()=>(currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.id) ?? "empty");
|
|
438799
|
+
// 点击「新会话」时使用唯一 key 强制 remount,否则 fragmentKey 本就为 'empty' 不会 remount,空会话界面不展示
|
|
438800
|
+
const handleConversationKeyChange = (0,react_.useCallback)((key)=>{
|
|
438801
|
+
setFragmentKey((k)=>key === "empty" ? `empty-${Date.now()}` : key);
|
|
438802
|
+
}, []);
|
|
438140
438803
|
const handleOpenRenameModal = (conversation)=>{
|
|
438141
438804
|
if (!(conversation === null || conversation === void 0 ? void 0 : conversation.id)) {
|
|
438142
438805
|
console.error("Cannot rename conversation: id is missing", conversation);
|
|
@@ -438262,6 +438925,7 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
|
|
|
438262
438925
|
ref: conversationListRef,
|
|
438263
438926
|
onRename: handleOpenRenameModal,
|
|
438264
438927
|
onDelete: handleOpenDeleteModal,
|
|
438928
|
+
onConversationKeyChange: handleConversationKeyChange,
|
|
438265
438929
|
loading: loading,
|
|
438266
438930
|
groupedConversations: groupedConversations,
|
|
438267
438931
|
conversations: conversations,
|
|
@@ -438271,7 +438935,7 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
|
|
|
438271
438935
|
}) : null,
|
|
438272
438936
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(react_.Fragment, {
|
|
438273
438937
|
children: children
|
|
438274
|
-
},
|
|
438938
|
+
}, fragmentKey),
|
|
438275
438939
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_SideSheet, {
|
|
438276
438940
|
visible: (currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.conversationListVisible) && !(currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.isLargeWidth),
|
|
438277
438941
|
closeIcon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozSideNav, {}),
|
|
@@ -438293,6 +438957,7 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
|
|
|
438293
438957
|
ref: conversationListRef,
|
|
438294
438958
|
onRename: handleOpenRenameModal,
|
|
438295
438959
|
onDelete: handleOpenDeleteModal,
|
|
438960
|
+
onConversationKeyChange: handleConversationKeyChange,
|
|
438296
438961
|
loading: loading,
|
|
438297
438962
|
groupedConversations: groupedConversations,
|
|
438298
438963
|
conversations: conversations,
|
|
@@ -438308,10 +438973,10 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
|
|
|
438308
438973
|
},
|
|
438309
438974
|
visible: modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.visible,
|
|
438310
438975
|
onCancel: ()=>setModalInfo(null),
|
|
438311
|
-
title: (modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.type) === "delete" ?
|
|
438976
|
+
title: (modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.type) === "delete" ? src_I18n.t("web_sdk_delete_conversation", {}, "删除会话") : src_I18n.t("web_sdk_rename_conversation", {}, "重命名会话"),
|
|
438312
438977
|
onOk: handleModalOk,
|
|
438313
|
-
okText: (modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.type) === "delete" ?
|
|
438314
|
-
cancelText:
|
|
438978
|
+
okText: (modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.type) === "delete" ? src_I18n.t("web_sdk_delete", {}, "删除") : src_I18n.t("web_sdk_confirm", {}, "确定"),
|
|
438979
|
+
cancelText: src_I18n.t("web_sdk_cancel", {}, "取消"),
|
|
438315
438980
|
okButtonColor: (modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.type) === "delete" ? "red" : "brand",
|
|
438316
438981
|
closable: false,
|
|
438317
438982
|
maskClosable: false,
|
|
@@ -438319,7 +438984,7 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
|
|
|
438319
438984
|
maxWidth: "80%"
|
|
438320
438985
|
},
|
|
438321
438986
|
children: (modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.type) === "rename" ? /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Input, {
|
|
438322
|
-
placeholder:
|
|
438987
|
+
placeholder: src_I18n.t("web_sdk_conversation_placeholder", {}, "请输入会话名称"),
|
|
438323
438988
|
value: modalInfo.conversation.name || "",
|
|
438324
438989
|
maxLength: 100,
|
|
438325
438990
|
onChange: (value)=>{
|
|
@@ -438341,7 +439006,7 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
|
|
|
438341
439006
|
}
|
|
438342
439007
|
}) : /*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
438343
439008
|
className: components_conversation_list_sider_index_module_["conversations-list-delete-modal-text"],
|
|
438344
|
-
children:
|
|
439009
|
+
children: src_I18n.t("web_sdk_conversation_delete_content", {}, "删除后,会话将无法恢复,确认要删除吗?")
|
|
438345
439010
|
})
|
|
438346
439011
|
})
|
|
438347
439012
|
]
|
|
@@ -438481,7 +439146,8 @@ const createChatStore = (chatConfig, userInfo)=>{
|
|
|
438481
439146
|
const chatConfigRef = {
|
|
438482
439147
|
current: chatConfig
|
|
438483
439148
|
};
|
|
438484
|
-
return esm_create()(devtools(
|
|
439149
|
+
return esm_create()(devtools(// eslint-disable-next-line
|
|
439150
|
+
subscribeWithSelector((set, get)=>({
|
|
438485
439151
|
userInfo: getDefaultUserInfo(userInfo),
|
|
438486
439152
|
token,
|
|
438487
439153
|
isNeedToken,
|
|
@@ -438504,6 +439170,8 @@ const createChatStore = (chatConfig, userInfo)=>{
|
|
|
438504
439170
|
hasRefusedCallByUser: false,
|
|
438505
439171
|
// 新增:初始化 apiUrl
|
|
438506
439172
|
apiUrl: undefined,
|
|
439173
|
+
// 新增:初始化会话知识库 ID 列表
|
|
439174
|
+
conversationKnowledgeIds: [],
|
|
438507
439175
|
setHasRefusedCallByUser: (hasRefusedCallByUser)=>{
|
|
438508
439176
|
set(immer_produce((s)=>{
|
|
438509
439177
|
s.hasRefusedCallByUser = hasRefusedCallByUser;
|
|
@@ -438692,6 +439360,12 @@ const createChatStore = (chatConfig, userInfo)=>{
|
|
|
438692
439360
|
set(immer_produce((s)=>{
|
|
438693
439361
|
s.apiUrl = apiUrl;
|
|
438694
439362
|
}));
|
|
439363
|
+
},
|
|
439364
|
+
// 新增:设置会话 section 关联的知识库 ID 列表
|
|
439365
|
+
setConversationKnowledgeIds: (knowledgeIds)=>{
|
|
439366
|
+
set(immer_produce((s)=>{
|
|
439367
|
+
s.conversationKnowledgeIds = knowledgeIds;
|
|
439368
|
+
}));
|
|
438695
439369
|
}
|
|
438696
439370
|
})), {
|
|
438697
439371
|
enabled: false,
|
|
@@ -441277,7 +441951,7 @@ const QuoteButton = (param)=>{
|
|
|
441277
441951
|
};
|
|
441278
441952
|
if (!enableGrab) return null;
|
|
441279
441953
|
return /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Tooltip, {
|
|
441280
|
-
content:
|
|
441954
|
+
content: src_I18n.t("quote_ask_in_chat"),
|
|
441281
441955
|
clickToHide: true,
|
|
441282
441956
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_IconButton, {
|
|
441283
441957
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(__webpack_exports__IconCozQuotation, {
|
|
@@ -445813,7 +446487,7 @@ const ChatCozeSdkProvider = (param)=>{
|
|
|
445813
446487
|
children: children
|
|
445814
446488
|
});
|
|
445815
446489
|
};
|
|
445816
|
-
const
|
|
446490
|
+
const context_useChatCozeSdk = ()=>{
|
|
445817
446491
|
const { cozeApiSdk, tokenManager, refMessageListLeft, refreshToken } = (0,react_.useContext)(ChatCozeSdkContext);
|
|
445818
446492
|
return {
|
|
445819
446493
|
cozeApiSdk,
|
|
@@ -445841,7 +446515,7 @@ const useChatCozeSdk = ()=>{
|
|
|
445841
446515
|
*/
|
|
445842
446516
|
|
|
445843
446517
|
const useUploadFileApi = ()=>{
|
|
445844
|
-
const { cozeApiSdk } =
|
|
446518
|
+
const { cozeApiSdk } = context_useChatCozeSdk();
|
|
445845
446519
|
return (0,react_.useCallback)(async (param)=>{
|
|
445846
446520
|
let { file } = param;
|
|
445847
446521
|
const result = await (cozeApiSdk === null || cozeApiSdk === void 0 ? void 0 : cozeApiSdk.files.upload({
|
|
@@ -446310,7 +446984,7 @@ const useMessageList = ()=>{
|
|
|
446310
446984
|
const getMessageListByPairs = useGetMessageListByPairs();
|
|
446311
446985
|
const { chatConfig } = context_useChatAppProps();
|
|
446312
446986
|
const { bot_id: botId } = chatConfig || {};
|
|
446313
|
-
const { refMessageListLeft } =
|
|
446987
|
+
const { refMessageListLeft } = context_useChatCozeSdk();
|
|
446314
446988
|
return (0,react_.useMemo)(()=>{
|
|
446315
446989
|
const onAfterResponse = [
|
|
446316
446990
|
(response)=>{
|
|
@@ -446362,7 +447036,7 @@ const useMessageList = ()=>{
|
|
|
446362
447036
|
};
|
|
446363
447037
|
// 接口返回的数据,并能保证 问题、回答 成对返回,因此需要将多返回的 回答 保存下来,等下次请求数据中的第一条数据是同一个 对话的时候,拼接上去。
|
|
446364
447038
|
const useGetMessageListByPairs = ()=>{
|
|
446365
|
-
const { refMessageListLeft } =
|
|
447039
|
+
const { refMessageListLeft } = context_useChatCozeSdk();
|
|
446366
447040
|
return (0,react_.useCallback)(function(conversationId) {
|
|
446367
447041
|
let messageList = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
446368
447042
|
var _refMessageListLeft_current;
|
|
@@ -446485,6 +447159,28 @@ const use_request_init_getConversationInfo = async (param)=>{
|
|
|
446485
447159
|
next_cursor: nextCursor
|
|
446486
447160
|
};
|
|
446487
447161
|
};
|
|
447162
|
+
// 新增:获取当前 section 对应的知识库列表(供清除对话后刷新知识库使用)
|
|
447163
|
+
const getConversationKnowledges = async (param)=>{
|
|
447164
|
+
let { cozeApiSdk, conversationId, sectionId, appId } = param;
|
|
447165
|
+
if (!conversationId || !sectionId || !appId) return [];
|
|
447166
|
+
try {
|
|
447167
|
+
var _res_data;
|
|
447168
|
+
const res = await cozeApiSdk.get("/v1/workflows/conversation/knowledges", {
|
|
447169
|
+
conversation_id: conversationId,
|
|
447170
|
+
section_id: sectionId,
|
|
447171
|
+
app_id: appId
|
|
447172
|
+
}, false, {
|
|
447173
|
+
headers: {
|
|
447174
|
+
"Accept-Language": intl_.language === "zh-CN" ? "zh" : "en"
|
|
447175
|
+
}
|
|
447176
|
+
});
|
|
447177
|
+
if ((res === null || res === void 0 ? void 0 : res.code) === 0 && (res === null || res === void 0 ? void 0 : (_res_data = res.data) === null || _res_data === void 0 ? void 0 : _res_data.knowledge_ids)) return res.data.knowledge_ids;
|
|
447178
|
+
return [];
|
|
447179
|
+
} catch (e) {
|
|
447180
|
+
console.warn("Failed to fetch conversation knowledges:", e);
|
|
447181
|
+
return [];
|
|
447182
|
+
}
|
|
447183
|
+
};
|
|
446488
447184
|
const getCustomInitInfo = async (param)=>{
|
|
446489
447185
|
let { cozeApiSdk, openRequestInit } = param;
|
|
446490
447186
|
let result;
|
|
@@ -446518,12 +447214,14 @@ const getCustomInitInfo = async (param)=>{
|
|
|
446518
447214
|
const useRequestInit = ()=>{
|
|
446519
447215
|
var _chatConfig_auth;
|
|
446520
447216
|
const { chatConfig, openRequestInit, defaultHistoryMessage = [], onDefaultHistoryClear } = context_useChatAppProps();
|
|
446521
|
-
const { cozeApiSdk } =
|
|
447217
|
+
const { cozeApiSdk } = context_useChatCozeSdk();
|
|
446522
447218
|
const setInitError = context_useChatAppStore((s)=>s.setInitError);
|
|
446523
447219
|
const setDefaultInputMode = context_useChatAppStore((s)=>s.setDefaultInputMode);
|
|
446524
447220
|
const updateShortcuts = context_useChatAppStore((s)=>s.updateShortcuts);
|
|
446525
447221
|
const setIsStartBotVoiceCall = context_useChatAppStore((s)=>s.setIsStartBotVoiceCall);
|
|
446526
447222
|
const updateBackgroundInfo = context_useChatAppStore((s)=>s.updateBackgroundInfo);
|
|
447223
|
+
// 新增:获取设置会话知识库 ID 列表的方法
|
|
447224
|
+
const setConversationKnowledgeIds = context_useChatAppStore((s)=>s.setConversationKnowledgeIds);
|
|
446527
447225
|
const { updateCurrentConversationInfo } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
446528
447226
|
updateCurrentConversationInfo: s.updateCurrentConversationInfo
|
|
446529
447227
|
})));
|
|
@@ -446578,6 +447276,23 @@ const useRequestInit = ()=>{
|
|
|
446578
447276
|
// 这样会话历史列表才能正确显示活跃状态
|
|
446579
447277
|
const actualConversationId = requestDataConversationInfo.conversationId;
|
|
446580
447278
|
const actualSectionId = requestDataConversationInfo.lastSectionId || "";
|
|
447279
|
+
// 新增:会话加载完成后,获取当前 section 对应的知识库列表(非阻塞)
|
|
447280
|
+
const appIdForKnowledge = (appInfo === null || appInfo === void 0 ? void 0 : appInfo.appId) || botId || "";
|
|
447281
|
+
if (actualConversationId && actualSectionId && cozeApiSdk && appIdForKnowledge) getConversationKnowledges({
|
|
447282
|
+
cozeApiSdk,
|
|
447283
|
+
conversationId: actualConversationId,
|
|
447284
|
+
sectionId: actualSectionId,
|
|
447285
|
+
appId: appIdForKnowledge
|
|
447286
|
+
}).then((knowledgeIds)=>{
|
|
447287
|
+
console.log("useRequestInit: conversation knowledges loaded", {
|
|
447288
|
+
conversationId: actualConversationId,
|
|
447289
|
+
sectionId: actualSectionId,
|
|
447290
|
+
knowledgeIds
|
|
447291
|
+
});
|
|
447292
|
+
setConversationKnowledgeIds(knowledgeIds);
|
|
447293
|
+
});
|
|
447294
|
+
else // 没有有效会话时清空知识库 ID
|
|
447295
|
+
setConversationKnowledgeIds([]);
|
|
446581
447296
|
// 如果从 openRequestInit 返回了 conversationName,使用它
|
|
446582
447297
|
const actualConversationName = conversationName || "";
|
|
446583
447298
|
// 从 ref 中获取最新的 currentConversationInfo 和 conversations
|
|
@@ -446687,6 +447402,7 @@ const useRequestInit = ()=>{
|
|
|
446687
447402
|
// 不再依赖 currentConversationInfo 和 conversations
|
|
446688
447403
|
// 在函数内部通过 getState() 获取最新值,避免 title/name 更新时触发重新初始化
|
|
446689
447404
|
updateCurrentConversationInfo,
|
|
447405
|
+
setConversationKnowledgeIds,
|
|
446690
447406
|
userInfo,
|
|
446691
447407
|
openRequestInit
|
|
446692
447408
|
]);
|
|
@@ -446799,7 +447515,7 @@ const getConnectorId = (props)=>{
|
|
|
446799
447515
|
|
|
446800
447516
|
|
|
446801
447517
|
// 用于发送消息时创建 conversation 的函数
|
|
446802
|
-
const
|
|
447518
|
+
const create_conversation_createConversationForMessage = async (apiSdk, props)=>{
|
|
446803
447519
|
let conversationId = "";
|
|
446804
447520
|
let sectionId = "";
|
|
446805
447521
|
let conversationName = undefined;
|
|
@@ -447022,6 +447738,18 @@ class MessageConverterToSdk {
|
|
|
447022
447738
|
parametersString = JSON.stringify(parameters);
|
|
447023
447739
|
else parametersString = String(parameters);
|
|
447024
447740
|
}
|
|
447741
|
+
// 从 messageBody 中提取 extendFiled 中的 knowledge_ids 和 image_urls,放入 ext 字段
|
|
447742
|
+
const ext = {};
|
|
447743
|
+
if (messageBody.knowledge_ids) {
|
|
447744
|
+
// extendFiled 被合并到顶层,所以 knowledge_ids 可能在顶层
|
|
447745
|
+
const knowledgeIds = Array.isArray(messageBody.knowledge_ids) ? messageBody.knowledge_ids : typeof messageBody.knowledge_ids === "string" ? JSON.parse(messageBody.knowledge_ids) : [];
|
|
447746
|
+
if (knowledgeIds.length > 0) ext.knowledge_ids = JSON.stringify(knowledgeIds);
|
|
447747
|
+
}
|
|
447748
|
+
if (messageBody.image_urls) {
|
|
447749
|
+
// extendFiled 被合并到顶层,所以 image_urls 可能在顶层
|
|
447750
|
+
const imageUrls = Array.isArray(messageBody.image_urls) ? messageBody.image_urls : typeof messageBody.image_urls === "string" ? JSON.parse(messageBody.image_urls) : [];
|
|
447751
|
+
if (imageUrls.length > 0) ext.image_urls = JSON.stringify(imageUrls);
|
|
447752
|
+
}
|
|
447025
447753
|
const requestBody = {
|
|
447026
447754
|
bot_id: messageBody.bot_id,
|
|
447027
447755
|
user_id: userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
|
|
@@ -447034,6 +447762,8 @@ class MessageConverterToSdk {
|
|
|
447034
447762
|
shortcut_command: this.convertShortcuts(shortcuts || [], shortcutCommand),
|
|
447035
447763
|
enable_card: true
|
|
447036
447764
|
};
|
|
447765
|
+
// 如果有 ext 字段,添加到 requestBody
|
|
447766
|
+
if (Object.keys(ext).length > 0) requestBody.ext = ext;
|
|
447037
447767
|
return JSON.stringify(requestBody);
|
|
447038
447768
|
}
|
|
447039
447769
|
// 替换 chat请求中的 message部分
|
|
@@ -448772,14 +449502,16 @@ class MessageParser {
|
|
|
448772
449502
|
{
|
|
448773
449503
|
var _messageError_last_error;
|
|
448774
449504
|
const messageError = src_safe_json_parse_safeJSONParse(data);
|
|
448775
|
-
const errorMsg = ((_messageError_last_error = messageError.last_error) === null || _messageError_last_error === void 0 ? void 0 : _messageError_last_error.msg) ||
|
|
449505
|
+
const errorMsg = ((_messageError_last_error = messageError.last_error) === null || _messageError_last_error === void 0 ? void 0 : _messageError_last_error.msg) || src_I18n.t("sendFailed");
|
|
448776
449506
|
esm_webpack_exports_Toast.error(errorMsg);
|
|
448777
449507
|
throw new Error("Chat stream error");
|
|
448778
449508
|
}
|
|
448779
449509
|
case "error":
|
|
448780
449510
|
{
|
|
448781
449511
|
const messageError = src_safe_json_parse_safeJSONParse(data);
|
|
448782
|
-
const
|
|
449512
|
+
const hasExplicitError = (messageError === null || messageError === void 0 ? void 0 : messageError.code) !== undefined && (messageError === null || messageError === void 0 ? void 0 : messageError.code) !== 0 || (messageError === null || messageError === void 0 ? void 0 : messageError.msg) !== undefined && String(messageError.msg).trim() !== "";
|
|
449513
|
+
if (!hasExplicitError) return;
|
|
449514
|
+
const errorMsg = (messageError === null || messageError === void 0 ? void 0 : messageError.msg) || src_I18n.t("sendFailed");
|
|
448783
449515
|
esm_webpack_exports_Toast.error(errorMsg);
|
|
448784
449516
|
throw new Error("Chat stream error");
|
|
448785
449517
|
}
|
|
@@ -449256,7 +449988,10 @@ class MessageParser {
|
|
|
449256
449988
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
449257
449989
|
* See the License for the specific language governing permissions and
|
|
449258
449990
|
* limitations under the License.
|
|
449259
|
-
*/
|
|
449991
|
+
*/ /* eslint-disable max-lines -- use-send-message requires many lines for complete message sending functionality */
|
|
449992
|
+
|
|
449993
|
+
|
|
449994
|
+
|
|
449260
449995
|
|
|
449261
449996
|
|
|
449262
449997
|
|
|
@@ -449271,17 +450006,19 @@ class MessageParser {
|
|
|
449271
450006
|
/* eslint-disable @coze-arch/max-line-per-function -- This adapter function handles complex message sending logic */ const useSendMessageAdapter = (userInfo, refChatFunc)=>{
|
|
449272
450007
|
var _chatConfig_auth;
|
|
449273
450008
|
const { debug, chatConfig } = context_useChatAppProps();
|
|
449274
|
-
const { shortcuts, apiUrl, updateConversations, updateCurrentConversationInfo, currentConversationInfo, conversations, cozeApi } = context_useChatAppStore(shallow_useShallow((state)=>({
|
|
450009
|
+
const { shortcuts, apiUrl, updateConversations, updateCurrentConversationInfo, currentConversationInfo, conversations, cozeApi, conversationKnowledgeIds, setConversationKnowledgeIds } = context_useChatAppStore(shallow_useShallow((state)=>({
|
|
449275
450010
|
shortcuts: state.shortcuts,
|
|
449276
450011
|
apiUrl: state.apiUrl,
|
|
449277
450012
|
updateConversations: state.updateConversations,
|
|
449278
450013
|
updateCurrentConversationInfo: state.updateCurrentConversationInfo,
|
|
449279
450014
|
currentConversationInfo: state.currentConversationInfo,
|
|
449280
450015
|
conversations: state.conversations,
|
|
449281
|
-
cozeApi: state.cozeApi
|
|
450016
|
+
cozeApi: state.cozeApi,
|
|
450017
|
+
conversationKnowledgeIds: state.conversationKnowledgeIds,
|
|
450018
|
+
setConversationKnowledgeIds: state.setConversationKnowledgeIds
|
|
449282
450019
|
})));
|
|
449283
450020
|
// 从 context 获取 cozeApiSdk 作为备用
|
|
449284
|
-
const { cozeApiSdk } =
|
|
450021
|
+
const { cozeApiSdk } = context_useChatCozeSdk();
|
|
449285
450022
|
const refChatConfig = (0,react_.useRef)(chatConfig);
|
|
449286
450023
|
const refConnectorId = (0,react_.useRef)("");
|
|
449287
450024
|
const shortcutsRef = (0,react_.useRef)(shortcuts);
|
|
@@ -449289,8 +450026,16 @@ class MessageParser {
|
|
|
449289
450026
|
const refUpdateCurrentConversationInfo = (0,react_.useRef)(updateCurrentConversationInfo);
|
|
449290
450027
|
const refCurrentConversationInfo = (0,react_.useRef)(currentConversationInfo);
|
|
449291
450028
|
const refConversations = (0,react_.useRef)(conversations);
|
|
450029
|
+
// Get store instance from context to access getState() in callbacks
|
|
450030
|
+
const { store: storeInstance } = (0,react_.useContext)(ChatPropsContext);
|
|
450031
|
+
const refStore = (0,react_.useRef)(storeInstance);
|
|
450032
|
+
refStore.current = storeInstance;
|
|
449292
450033
|
// 保存新创建的 conversation 信息,以便在消息发送成功后更新状态
|
|
449293
450034
|
const refPendingConversationInfo = (0,react_.useRef)(null);
|
|
450035
|
+
// 已因 DONE 返回过 synthetic ack 时置为 true,后续 ERROR 事件不再交给 parser(避免误报「发送失败」)
|
|
450036
|
+
const refStreamAlreadySucceeded = (0,react_.useRef)(false);
|
|
450037
|
+
// 新增:追踪最新的 conversationKnowledgeIds
|
|
450038
|
+
const refConversationKnowledgeIds = (0,react_.useRef)(conversationKnowledgeIds);
|
|
449294
450039
|
shortcutsRef.current = shortcuts;
|
|
449295
450040
|
refConnectorId.current = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_auth = chatConfig.auth) === null || _chatConfig_auth === void 0 ? void 0 : _chatConfig_auth.connectorId) || "";
|
|
449296
450041
|
refChatConfig.current = chatConfig;
|
|
@@ -449298,6 +450043,7 @@ class MessageParser {
|
|
|
449298
450043
|
refUpdateCurrentConversationInfo.current = updateCurrentConversationInfo;
|
|
449299
450044
|
refCurrentConversationInfo.current = currentConversationInfo;
|
|
449300
450045
|
refConversations.current = conversations;
|
|
450046
|
+
refConversationKnowledgeIds.current = conversationKnowledgeIds;
|
|
449301
450047
|
// 处理 conversation.update 事件的回调函数
|
|
449302
450048
|
// 使用 useRef 存储函数,但函数内部通过 ref 访问最新的值
|
|
449303
450049
|
const handleConversationUpdateRef = (0,react_.useRef)(null);
|
|
@@ -449405,102 +450151,141 @@ class MessageParser {
|
|
|
449405
450151
|
hasCozeApi: !!cozeApi,
|
|
449406
450152
|
hasChatConfig: !!refChatConfig.current
|
|
449407
450153
|
});
|
|
449408
|
-
// 如果没有 conversation_id
|
|
450154
|
+
// 如果没有 conversation_id,先检查 currentConversationInfo 是否有会话ID
|
|
449409
450155
|
if (!conversationId) {
|
|
449410
|
-
|
|
449411
|
-
//
|
|
449412
|
-
|
|
449413
|
-
|
|
449414
|
-
|
|
449415
|
-
|
|
449416
|
-
|
|
449417
|
-
|
|
449418
|
-
|
|
449419
|
-
|
|
449420
|
-
|
|
449421
|
-
console.
|
|
449422
|
-
throw new Error("chatConfig is required for creating conversation before sending message");
|
|
450156
|
+
var _refCurrentConversationInfo_current, _refCurrentConversationInfo_current1;
|
|
450157
|
+
// 检查 currentConversationInfo 是否已有会话ID(可能由文件上传创建)
|
|
450158
|
+
// 优先从 store 直接获取最新值,因为 ref 可能滞后
|
|
450159
|
+
let existingConversationId = (_refCurrentConversationInfo_current = refCurrentConversationInfo.current) === null || _refCurrentConversationInfo_current === void 0 ? void 0 : _refCurrentConversationInfo_current.id;
|
|
450160
|
+
// 从 store 直接获取最新值(文件上传后可能已经更新了 store)
|
|
450161
|
+
if (refStore.current && typeof refStore.current.getState === "function") try {
|
|
450162
|
+
var _latestState_currentConversationInfo;
|
|
450163
|
+
const latestState = refStore.current.getState();
|
|
450164
|
+
const latestConversationId = latestState === null || latestState === void 0 ? void 0 : (_latestState_currentConversationInfo = latestState.currentConversationInfo) === null || _latestState_currentConversationInfo === void 0 ? void 0 : _latestState_currentConversationInfo.id;
|
|
450165
|
+
if (latestConversationId && latestConversationId.trim() !== "") existingConversationId = latestConversationId;
|
|
450166
|
+
} catch (error) {
|
|
450167
|
+
console.warn("Failed to get latest state from store:", error);
|
|
449423
450168
|
}
|
|
449424
|
-
|
|
449425
|
-
|
|
449426
|
-
|
|
449427
|
-
|
|
449428
|
-
|
|
449429
|
-
|
|
449430
|
-
|
|
449431
|
-
|
|
449432
|
-
|
|
449433
|
-
|
|
449434
|
-
|
|
449435
|
-
|
|
449436
|
-
|
|
449437
|
-
|
|
449438
|
-
|
|
449439
|
-
|
|
449440
|
-
|
|
449441
|
-
|
|
449442
|
-
|
|
449443
|
-
|
|
449444
|
-
|
|
449445
|
-
|
|
449446
|
-
|
|
449447
|
-
|
|
449448
|
-
|
|
449449
|
-
|
|
449450
|
-
|
|
449451
|
-
|
|
449452
|
-
|
|
449453
|
-
|
|
449454
|
-
|
|
449455
|
-
const
|
|
449456
|
-
|
|
449457
|
-
|
|
449458
|
-
|
|
449459
|
-
|
|
449460
|
-
|
|
449461
|
-
|
|
449462
|
-
|
|
449463
|
-
...isAppType && {
|
|
449464
|
-
title: ""
|
|
449465
|
-
}
|
|
449466
|
-
};
|
|
449467
|
-
refUpdateConversations.current([
|
|
449468
|
-
newConversation
|
|
449469
|
-
], "add");
|
|
449470
|
-
console.log("onBeforeSendMessage: Conversation added to list immediately", {
|
|
450169
|
+
console.log("onBeforeSendMessage: Checking for existing conversation", {
|
|
450170
|
+
existingConversationId,
|
|
450171
|
+
refId: (_refCurrentConversationInfo_current1 = refCurrentConversationInfo.current) === null || _refCurrentConversationInfo_current1 === void 0 ? void 0 : _refCurrentConversationInfo_current1.id,
|
|
450172
|
+
hasStore: !!refStore.current,
|
|
450173
|
+
messageBodyConversationId: messageBody.conversation_id
|
|
450174
|
+
});
|
|
450175
|
+
if (existingConversationId && existingConversationId.trim() !== "") {
|
|
450176
|
+
console.log("onBeforeSendMessage: Using existing conversation from currentConversationInfo", existingConversationId);
|
|
450177
|
+
conversationId = existingConversationId;
|
|
450178
|
+
} else {
|
|
450179
|
+
// 确保 cozeApi 和 refChatConfig.current 都存在
|
|
450180
|
+
// 优先使用 store 中的 cozeApi,如果不存在则使用 context 中的 cozeApiSdk
|
|
450181
|
+
const finalCozeApi = cozeApi || cozeApiSdk;
|
|
450182
|
+
if (!finalCozeApi) {
|
|
450183
|
+
console.error("onBeforeSendMessage: cozeApi is not available, cannot create conversation", {
|
|
450184
|
+
cozeApiFromStore: !!cozeApi,
|
|
450185
|
+
cozeApiSdkFromContext: !!cozeApiSdk
|
|
450186
|
+
});
|
|
450187
|
+
throw new Error("cozeApi is required for creating conversation before sending message");
|
|
450188
|
+
}
|
|
450189
|
+
if (!refChatConfig.current) {
|
|
450190
|
+
console.error("onBeforeSendMessage: refChatConfig.current is not available, cannot create conversation");
|
|
450191
|
+
throw new Error("chatConfig is required for creating conversation before sending message");
|
|
450192
|
+
}
|
|
450193
|
+
try {
|
|
450194
|
+
const chatType = refChatConfig.current.type;
|
|
450195
|
+
const isAppType = chatType === client_ChatType.APP;
|
|
450196
|
+
const { appInfo } = refChatConfig.current;
|
|
450197
|
+
const botId = refChatConfig.current.bot_id;
|
|
450198
|
+
if (isAppType && !(appInfo === null || appInfo === void 0 ? void 0 : appInfo.appId) || !isAppType && !botId) throw new Error(`Missing required ID: ${isAppType ? "appId" : "botId"}`);
|
|
450199
|
+
console.log("onBeforeSendMessage: Creating conversation...");
|
|
450200
|
+
const conversationResult = await create_conversation_createConversationForMessage(finalCozeApi, {
|
|
450201
|
+
projectType: isAppType ? "app" : "bot",
|
|
450202
|
+
projectId: isAppType ? (appInfo === null || appInfo === void 0 ? void 0 : appInfo.appId) || "" : botId || "",
|
|
450203
|
+
workflowId: appInfo === null || appInfo === void 0 ? void 0 : appInfo.workflowId,
|
|
450204
|
+
mode: (appInfo === null || appInfo === void 0 ? void 0 : appInfo.draft_mode) ? "draft" : "release",
|
|
450205
|
+
connectorId: refConnectorId.current
|
|
450206
|
+
});
|
|
450207
|
+
console.log("onBeforeSendMessage: Conversation created", {
|
|
449471
450208
|
conversationId: conversationResult.conversationId,
|
|
450209
|
+
sectionId: conversationResult.sectionId,
|
|
449472
450210
|
conversationName: conversationResult.conversationName
|
|
449473
450211
|
});
|
|
450212
|
+
if (!conversationResult.conversationId) throw new Error("Failed to create conversation: empty conversationId");
|
|
450213
|
+
conversationId = conversationResult.conversationId;
|
|
450214
|
+
// 保存 conversationResult,以便在消息发送成功后更新状态
|
|
450215
|
+
refPendingConversationInfo.current = {
|
|
450216
|
+
conversationId: conversationResult.conversationId,
|
|
450217
|
+
sectionId: conversationResult.sectionId || "",
|
|
450218
|
+
conversationName: conversationResult.conversationName
|
|
450219
|
+
};
|
|
450220
|
+
refStreamAlreadySucceeded.current = false;
|
|
450221
|
+
// 立即添加会话到列表,使用创建时返回的名称
|
|
450222
|
+
const existingConversation = refConversations.current.find((c)=>c.id === conversationResult.conversationId);
|
|
450223
|
+
if (!existingConversation && refUpdateConversations.current) {
|
|
450224
|
+
// 重用外部作用域已声明的 chatType 和 isAppType
|
|
450225
|
+
const newConversation = {
|
|
450226
|
+
id: conversationResult.conversationId,
|
|
450227
|
+
last_section_id: conversationResult.sectionId || "",
|
|
450228
|
+
name: conversationResult.conversationName || "",
|
|
450229
|
+
created_at: Math.floor(Date.now() / 1000),
|
|
450230
|
+
updated_at: Math.floor(Date.now() / 1000),
|
|
450231
|
+
meta_data: {},
|
|
450232
|
+
// App 模式需要 title 字段,但从空会话创建的新会话 title 应该为空
|
|
450233
|
+
...isAppType && {
|
|
450234
|
+
title: ""
|
|
450235
|
+
}
|
|
450236
|
+
};
|
|
450237
|
+
refUpdateConversations.current([
|
|
450238
|
+
newConversation
|
|
450239
|
+
], "add");
|
|
450240
|
+
console.log("onBeforeSendMessage: Conversation added to list immediately", {
|
|
450241
|
+
conversationId: conversationResult.conversationId,
|
|
450242
|
+
conversationName: conversationResult.conversationName
|
|
450243
|
+
});
|
|
450244
|
+
// 立即更新 currentConversationInfo,使会话历史中新 item 显示选中样式(fragmentKey 已保证不会 remount)
|
|
450245
|
+
const existingInfo = refCurrentConversationInfo.current;
|
|
450246
|
+
refUpdateCurrentConversationInfo.current({
|
|
450247
|
+
...existingInfo,
|
|
450248
|
+
id: conversationResult.conversationId,
|
|
450249
|
+
last_section_id: conversationResult.sectionId || "",
|
|
450250
|
+
name: conversationResult.conversationName || "",
|
|
450251
|
+
...isAppType && {
|
|
450252
|
+
title: ""
|
|
450253
|
+
},
|
|
450254
|
+
created_at: newConversation.created_at,
|
|
450255
|
+
updated_at: newConversation.updated_at,
|
|
450256
|
+
meta_data: {},
|
|
450257
|
+
conversationListVisible: (existingInfo === null || existingInfo === void 0 ? void 0 : existingInfo.conversationListVisible) ?? false,
|
|
450258
|
+
isLargeWidth: (existingInfo === null || existingInfo === void 0 ? void 0 : existingInfo.isLargeWidth) ?? false
|
|
450259
|
+
});
|
|
450260
|
+
}
|
|
450261
|
+
// 选中新创建的会话:currentConversationInfo 已在上方更新,会话列表会显示选中样式
|
|
450262
|
+
// 确保 pendingInfo 被设置,以便在 DONE 事件时更新
|
|
450263
|
+
if (refPendingConversationInfo) {
|
|
450264
|
+
refPendingConversationInfo.current = {
|
|
450265
|
+
conversationId: conversationResult.conversationId,
|
|
450266
|
+
sectionId: conversationResult.sectionId || ""
|
|
450267
|
+
};
|
|
450268
|
+
refStreamAlreadySucceeded.current = false;
|
|
450269
|
+
}
|
|
450270
|
+
// 注意:不在这里调用 setConversationId,因为它会触发额外的 updateConversations 调用
|
|
450271
|
+
// 这会导致 useConversationList 的同步逻辑被触发,设置 isSyncing = true
|
|
450272
|
+
// 当真正的 store 更新发生时,isSyncing 仍然是 true,导致 useEffect 被跳过
|
|
450273
|
+
// setConversationId 会在消息流完成时被调用(在 onGetMessageStreamParser 的 DONE 事件中)
|
|
450274
|
+
// 更新 messageBody 中的 conversation_id
|
|
450275
|
+
messageBody.conversation_id = conversationId;
|
|
450276
|
+
console.log("onBeforeSendMessage: Conversation created and selected, ready to send message", {
|
|
450277
|
+
conversationId,
|
|
450278
|
+
pendingInfo: refPendingConversationInfo.current
|
|
450279
|
+
});
|
|
450280
|
+
} catch (error) {
|
|
450281
|
+
console.error("Failed to create conversation:", error);
|
|
450282
|
+
// 如果创建失败,抛出错误,阻止消息发送
|
|
450283
|
+
throw new Error(`Failed to create conversation before sending message: ${error instanceof Error ? error.message : String(error)}`);
|
|
449474
450284
|
}
|
|
449475
|
-
// 选中新创建的会话:先更新 currentConversationInfo,确保会话被选中
|
|
449476
|
-
// 不立即调用 updateCurrentConversationInfo,避免触发组件卸载
|
|
449477
|
-
// 将在消息流完成(DONE 事件)时更新 currentConversationInfo
|
|
449478
|
-
// 这样可以避免触发 useRequestInit 的依赖变化,防止重新初始化
|
|
449479
|
-
// 会话列表中的新会话已经通过 updateConversations 添加,可以正常显示
|
|
449480
|
-
console.log("onBeforeSendMessage: Conversation created, will update currentConversationInfo after stream completes", {
|
|
449481
|
-
conversationId: conversationResult.conversationId
|
|
449482
|
-
});
|
|
449483
|
-
// 确保 pendingInfo 被设置,以便在 DONE 事件时更新
|
|
449484
|
-
if (refPendingConversationInfo) refPendingConversationInfo.current = {
|
|
449485
|
-
conversationId: conversationResult.conversationId,
|
|
449486
|
-
sectionId: conversationResult.sectionId || ""
|
|
449487
|
-
};
|
|
449488
|
-
// 注意:不在这里调用 setConversationId,因为它会触发额外的 updateConversations 调用
|
|
449489
|
-
// 这会导致 useConversationList 的同步逻辑被触发,设置 isSyncing = true
|
|
449490
|
-
// 当真正的 store 更新发生时,isSyncing 仍然是 true,导致 useEffect 被跳过
|
|
449491
|
-
// setConversationId 会在消息流完成时被调用(在 onGetMessageStreamParser 的 DONE 事件中)
|
|
449492
|
-
// 更新 messageBody 中的 conversation_id
|
|
449493
|
-
messageBody.conversation_id = conversationId;
|
|
449494
|
-
console.log("onBeforeSendMessage: Conversation created and selected, ready to send message", {
|
|
449495
|
-
conversationId,
|
|
449496
|
-
pendingInfo: refPendingConversationInfo.current
|
|
449497
|
-
});
|
|
449498
|
-
} catch (error) {
|
|
449499
|
-
console.error("Failed to create conversation:", error);
|
|
449500
|
-
// 如果创建失败,抛出错误,阻止消息发送
|
|
449501
|
-
throw new Error(`Failed to create conversation before sending message: ${error instanceof Error ? error.message : String(error)}`);
|
|
449502
450285
|
}
|
|
449503
450286
|
}
|
|
450287
|
+
// 更新 messageBody 中的 conversation_id(无论是使用已有会话还是新创建的)
|
|
450288
|
+
messageBody.conversation_id = conversationId;
|
|
449504
450289
|
// 确保 conversationId 存在,否则抛出错误
|
|
449505
450290
|
if (!conversationId || conversationId.trim() === "") {
|
|
449506
450291
|
console.error("onBeforeSendMessage: conversationId is empty after creation");
|
|
@@ -449510,17 +450295,116 @@ class MessageParser {
|
|
|
449510
450295
|
const url = `${finalApiUrl}/v1/workflows/chat?conversation_id=${conversationId}`;
|
|
449511
450296
|
// 根据 chatType 选择正确的 parameters 来源
|
|
449512
450297
|
// App 模式使用 appInfo.parameters,Bot 模式使用 botInfo.parameters
|
|
449513
|
-
const
|
|
450298
|
+
const configParameters = ((_refChatConfig_current = refChatConfig.current) === null || _refChatConfig_current === void 0 ? void 0 : _refChatConfig_current.type) === client_ChatType.APP ? (_refChatConfig_current_appInfo = refChatConfig.current.appInfo) === null || _refChatConfig_current_appInfo === void 0 ? void 0 : _refChatConfig_current_appInfo.parameters : (_refChatConfig_current_botInfo = refChatConfig.current.botInfo) === null || _refChatConfig_current_botInfo === void 0 ? void 0 : _refChatConfig_current_botInfo.parameters;
|
|
450299
|
+
// 从 requestConfig.body 中提取已有的 parameters(可能包含 SETTING 等字段)
|
|
450300
|
+
const bodyParamsRaw = messageBody.parameters;
|
|
450301
|
+
let bodyParameters = {};
|
|
450302
|
+
if (bodyParamsRaw) {
|
|
450303
|
+
if (typeof bodyParamsRaw === "string") try {
|
|
450304
|
+
bodyParameters = JSON.parse(bodyParamsRaw);
|
|
450305
|
+
} catch {
|
|
450306
|
+
bodyParameters = {};
|
|
450307
|
+
}
|
|
450308
|
+
else if (typeof bodyParamsRaw === "object") bodyParameters = {
|
|
450309
|
+
...bodyParamsRaw
|
|
450310
|
+
};
|
|
450311
|
+
}
|
|
450312
|
+
// 合并 chatConfig parameters 和 requestConfig.body 中的 parameters
|
|
450313
|
+
const configParams = configParameters ? {
|
|
450314
|
+
...configParameters
|
|
450315
|
+
} : {};
|
|
450316
|
+
// body 中的 parameters 合并进来(body 中的优先级高于 config)
|
|
450317
|
+
const mergedParameters = {
|
|
450318
|
+
...configParams,
|
|
450319
|
+
...bodyParameters
|
|
450320
|
+
};
|
|
450321
|
+
// 深度合并 SETTING 字段(两者都可能有 SETTING,需要合并而非覆盖)
|
|
450322
|
+
const parseSetting = (raw)=>{
|
|
450323
|
+
if (!raw) return {};
|
|
450324
|
+
if (typeof raw === "string") try {
|
|
450325
|
+
return JSON.parse(raw);
|
|
450326
|
+
} catch {
|
|
450327
|
+
return {};
|
|
450328
|
+
}
|
|
450329
|
+
if (typeof raw === "object") return {
|
|
450330
|
+
...raw
|
|
450331
|
+
};
|
|
450332
|
+
return {};
|
|
450333
|
+
};
|
|
450334
|
+
const configSetting = parseSetting(configParams.SETTING);
|
|
450335
|
+
const bodySetting = parseSetting(bodyParameters.SETTING);
|
|
450336
|
+
const mergedSetting = {
|
|
450337
|
+
...configSetting,
|
|
450338
|
+
...bodySetting
|
|
450339
|
+
};
|
|
450340
|
+
// 提前解析 body 中的 knowledge_ids(文件上传等),与 store 一起参与 SETTING.KNOWLEDGE_IDS 合并
|
|
450341
|
+
const parsedBodyForKnowledge = catchParse(requestConfig.body) || {};
|
|
450342
|
+
let existingBodyKnowledgeIds = [];
|
|
450343
|
+
if (parsedBodyForKnowledge.knowledge_ids) existingBodyKnowledgeIds = Array.isArray(parsedBodyForKnowledge.knowledge_ids) ? parsedBodyForKnowledge.knowledge_ids.map(String) : typeof parsedBodyForKnowledge.knowledge_ids === "string" ? (()=>{
|
|
450344
|
+
try {
|
|
450345
|
+
return JSON.parse(parsedBodyForKnowledge.knowledge_ids);
|
|
450346
|
+
} catch {
|
|
450347
|
+
return [];
|
|
450348
|
+
}
|
|
450349
|
+
})() : [];
|
|
450350
|
+
// 合并会话 section 关联的知识库 ID 与本次 body 的 knowledge_ids 到 SETTING.KNOWLEDGE_IDS
|
|
450351
|
+
// 来源:mergedSetting 已有、store(ref)、body.knowledge_ids,保证第二次发送仍带上前一次的知识库
|
|
450352
|
+
let knowledgeIdsFromConversation = [];
|
|
450353
|
+
try {
|
|
450354
|
+
var _refStore_current;
|
|
450355
|
+
const latestStoreState = (_refStore_current = refStore.current) === null || _refStore_current === void 0 ? void 0 : _refStore_current.getState();
|
|
450356
|
+
knowledgeIdsFromConversation = (latestStoreState === null || latestStoreState === void 0 ? void 0 : latestStoreState.conversationKnowledgeIds) || [];
|
|
450357
|
+
} catch {
|
|
450358
|
+
knowledgeIdsFromConversation = refConversationKnowledgeIds.current || [];
|
|
450359
|
+
}
|
|
450360
|
+
let existingIds = [];
|
|
450361
|
+
if (mergedSetting.KNOWLEDGE_IDS) {
|
|
450362
|
+
if (Array.isArray(mergedSetting.KNOWLEDGE_IDS)) existingIds = mergedSetting.KNOWLEDGE_IDS.map(String);
|
|
450363
|
+
else if (typeof mergedSetting.KNOWLEDGE_IDS === "string") try {
|
|
450364
|
+
existingIds = JSON.parse(mergedSetting.KNOWLEDGE_IDS);
|
|
450365
|
+
} catch {
|
|
450366
|
+
existingIds = [];
|
|
450367
|
+
}
|
|
450368
|
+
}
|
|
450369
|
+
const allIds = [
|
|
450370
|
+
...existingIds,
|
|
450371
|
+
...knowledgeIdsFromConversation,
|
|
450372
|
+
...existingBodyKnowledgeIds
|
|
450373
|
+
];
|
|
450374
|
+
const uniqueIds = Array.from(new Set(allIds));
|
|
450375
|
+
if (uniqueIds.length > 0) {
|
|
450376
|
+
mergedSetting.KNOWLEDGE_IDS = uniqueIds;
|
|
450377
|
+
// 将本次请求使用的知识库 ID 同步到 store,保证下次发送(无 body knowledge_ids 时)仍能带上
|
|
450378
|
+
setConversationKnowledgeIds(uniqueIds);
|
|
450379
|
+
}
|
|
450380
|
+
if (uniqueIds.length > 0) console.log("onBeforeSendMessage: Merged conversation knowledge IDs into parameters", {
|
|
450381
|
+
knowledgeIdsFromConversation,
|
|
450382
|
+
existingBodyKnowledgeIds,
|
|
450383
|
+
existingIds,
|
|
450384
|
+
uniqueIds
|
|
450385
|
+
});
|
|
450386
|
+
// 将合并后的 SETTING 设回 parameters
|
|
450387
|
+
if (Object.keys(mergedSetting).length > 0) mergedParameters.SETTING = mergedSetting;
|
|
450388
|
+
console.log("onBeforeSendMessage: Final mergedParameters", mergedParameters);
|
|
449514
450389
|
// 更新 requestConfig.body 中的 conversation_id
|
|
449515
|
-
|
|
449516
|
-
|
|
450390
|
+
// 同时将会话知识库 ID 写入 body 的 knowledge_ids 字段
|
|
450391
|
+
const combinedKnowledgeIds = [
|
|
450392
|
+
...existingBodyKnowledgeIds,
|
|
450393
|
+
...knowledgeIdsFromConversation
|
|
450394
|
+
];
|
|
450395
|
+
const uniqueBodyKnowledgeIds = Array.from(new Set(combinedKnowledgeIds));
|
|
450396
|
+
const updatedBodyObj = {
|
|
450397
|
+
...parsedBodyForKnowledge,
|
|
449517
450398
|
conversation_id: conversationId
|
|
449518
|
-
}
|
|
450399
|
+
};
|
|
450400
|
+
// 只在有知识库 ID 时才添加 knowledge_ids 字段
|
|
450401
|
+
if (uniqueBodyKnowledgeIds.length > 0) updatedBodyObj.knowledge_ids = uniqueBodyKnowledgeIds;
|
|
450402
|
+
const updatedBody = JSON.stringify(updatedBodyObj);
|
|
449519
450403
|
const body = messageConverterToSdk.convertRequestBody({
|
|
449520
450404
|
body: updatedBody,
|
|
449521
450405
|
userInfo,
|
|
449522
450406
|
connectorId: refConnectorId.current,
|
|
449523
|
-
parameters,
|
|
450407
|
+
parameters: Object.keys(mergedParameters).length > 0 ? mergedParameters : configParameters,
|
|
449524
450408
|
shortcuts: shortcutsRef.current
|
|
449525
450409
|
});
|
|
449526
450410
|
console.log("onBeforeSendMessage: Final config", {
|
|
@@ -449529,6 +450413,7 @@ class MessageParser {
|
|
|
449529
450413
|
hasBody: !!body,
|
|
449530
450414
|
bodyLength: body === null || body === void 0 ? void 0 : body.length
|
|
449531
450415
|
});
|
|
450416
|
+
console.log("onBeforeSendMessage: body", JSON.stringify(body, null, 2));
|
|
449532
450417
|
// 确保 headers 是一个数组
|
|
449533
450418
|
const headers = Array.isArray(requestConfig.headers) ? [
|
|
449534
450419
|
...requestConfig.headers
|
|
@@ -449571,110 +450456,137 @@ class MessageParser {
|
|
|
449571
450456
|
sectionId: refChatFunc === null || refChatFunc === void 0 ? void 0 : (_refChatFunc_current = refChatFunc.current) === null || _refChatFunc_current === void 0 ? void 0 : _refChatFunc_current.getSectionId(),
|
|
449572
450457
|
onConversationUpdate: handleConversationUpdateRef.current || undefined
|
|
449573
450458
|
});
|
|
449574
|
-
//
|
|
449575
|
-
|
|
449576
|
-
|
|
449577
|
-
|
|
449578
|
-
|
|
450459
|
+
// 有 pending 时在 CHAT_CREATED/DONE 时更新会话状态;每次 DONE 时都刷新知识库列表
|
|
450460
|
+
if (!originalParser) return undefined;
|
|
450461
|
+
let hasUpdatedConversationList = false;
|
|
450462
|
+
let hasUpdatedChatCore = false;
|
|
450463
|
+
return (parseEvent, method)=>{
|
|
449579
450464
|
const pendingInfo = refPendingConversationInfo.current;
|
|
449580
|
-
|
|
449581
|
-
|
|
449582
|
-
|
|
449583
|
-
|
|
449584
|
-
|
|
449585
|
-
|
|
449586
|
-
|
|
449587
|
-
|
|
449588
|
-
|
|
449589
|
-
|
|
449590
|
-
|
|
449591
|
-
|
|
449592
|
-
|
|
449593
|
-
|
|
449594
|
-
|
|
449595
|
-
|
|
449596
|
-
const
|
|
449597
|
-
|
|
449598
|
-
|
|
449599
|
-
|
|
449600
|
-
|
|
449601
|
-
|
|
449602
|
-
|
|
449603
|
-
|
|
449604
|
-
|
|
449605
|
-
|
|
449606
|
-
|
|
449607
|
-
|
|
449608
|
-
|
|
449609
|
-
|
|
449610
|
-
|
|
449611
|
-
|
|
449612
|
-
title: pendingInfo.conversationName
|
|
449613
|
-
}
|
|
449614
|
-
};
|
|
449615
|
-
if (refUpdateConversations.current) refUpdateConversations.current([
|
|
449616
|
-
newConversation
|
|
449617
|
-
], "add");
|
|
449618
|
-
}
|
|
449619
|
-
// 在 CHAT_CREATED 时,只添加会话到列表,不更新 currentConversationInfo
|
|
449620
|
-
// 这样可以避免触发 useRequestInit 的依赖变化,防止重新初始化
|
|
449621
|
-
// 但是,我们需要确保 chatCore 的 conversationId 被更新,以便消息流能正常继续
|
|
449622
|
-
// 通过 refChatFunc.setConversationId 更新,但只更新 chatCore,不更新 currentConversationInfo
|
|
449623
|
-
// 注意:setConversationId 会检查会话是否存在,如果存在就不会添加,所以是安全的
|
|
449624
|
-
// 但是,setConversationId 也会更新 currentConversationInfo,这可能会触发重新初始化
|
|
449625
|
-
// 所以我们需要延迟更新,或者找到其他方式更新 chatCore 的 conversationId
|
|
449626
|
-
// 暂时不更新 currentConversationInfo,让 DONE 事件时再更新
|
|
449627
|
-
// 这样可以避免触发重新初始化,但会话列表中的新会话不会立即显示为选中状态
|
|
449628
|
-
// 这是可以接受的,因为用户正在查看消息流,不会立即点击会话列表
|
|
450465
|
+
const isErrorEvent = parseEvent.type === "event" && parseEvent.event === "error";
|
|
450466
|
+
if (isErrorEvent && refStreamAlreadySucceeded.current) return undefined;
|
|
450467
|
+
const result = originalParser(parseEvent, method);
|
|
450468
|
+
const { type, event } = parseEvent;
|
|
450469
|
+
const isChatCreatedEvent = type === "event" && event === "conversation.chat.created";
|
|
450470
|
+
const isDoneEvent = type === "event" && event === "done";
|
|
450471
|
+
// 空会话首条消息时 workflow 可能不推送 conversation.chat.created,流结束只有 DONE,chat-core 收不到 ack 会触发 MESSAGE_SEND_FAIL。在 DONE 且存在 pending 时补发合成 ack,使 sendMessage 正常 resolve
|
|
450472
|
+
const shouldReturnSyntheticAck = isDoneEvent && pendingInfo;
|
|
450473
|
+
// 有 pending 时:在 CHAT_CREATED 时更新会话列表
|
|
450474
|
+
if (pendingInfo && isChatCreatedEvent && !hasUpdatedConversationList && pendingInfo.conversationId) {
|
|
450475
|
+
hasUpdatedConversationList = true;
|
|
450476
|
+
console.log("onGetMessageStreamParser: Updating conversation list and currentConversationInfo after CHAT_CREATED", {
|
|
450477
|
+
conversationId: pendingInfo.conversationId
|
|
450478
|
+
});
|
|
450479
|
+
const existingConversation = refConversations.current.find((c)=>c.id === pendingInfo.conversationId);
|
|
450480
|
+
if (!existingConversation) {
|
|
450481
|
+
const chatType = refChatConfig.current.type;
|
|
450482
|
+
const isAppType = chatType === client_ChatType.APP;
|
|
450483
|
+
const newConversation = {
|
|
450484
|
+
id: pendingInfo.conversationId,
|
|
450485
|
+
last_section_id: pendingInfo.sectionId,
|
|
450486
|
+
name: pendingInfo.conversationName || "",
|
|
450487
|
+
created_at: Math.floor(Date.now() / 1000),
|
|
450488
|
+
updated_at: Math.floor(Date.now() / 1000),
|
|
450489
|
+
meta_data: {},
|
|
450490
|
+
...isAppType && pendingInfo.conversationName && {
|
|
450491
|
+
title: pendingInfo.conversationName
|
|
450492
|
+
}
|
|
450493
|
+
};
|
|
450494
|
+
if (refUpdateConversations.current) refUpdateConversations.current([
|
|
450495
|
+
newConversation
|
|
450496
|
+
], "add");
|
|
449629
450497
|
}
|
|
449630
|
-
|
|
449631
|
-
|
|
449632
|
-
|
|
449633
|
-
|
|
450498
|
+
}
|
|
450499
|
+
// DONE 时:若有 pending 则更新 currentConversationInfo 和 chatCore;并始终刷新知识库列表(含发送带文件消息后)
|
|
450500
|
+
if (isDoneEvent) {
|
|
450501
|
+
var _refChatFunc_current_getConversationId, _refChatFunc_current, _refChatFunc_current_getSectionId, _refChatFunc_current1, _refChatConfig_current_appInfo, _refChatConfig_current, _refChatConfig_current1;
|
|
450502
|
+
const conversationId = (pendingInfo === null || pendingInfo === void 0 ? void 0 : pendingInfo.conversationId) || (refChatFunc === null || refChatFunc === void 0 ? void 0 : (_refChatFunc_current = refChatFunc.current) === null || _refChatFunc_current === void 0 ? void 0 : (_refChatFunc_current_getConversationId = _refChatFunc_current.getConversationId) === null || _refChatFunc_current_getConversationId === void 0 ? void 0 : _refChatFunc_current_getConversationId.call(_refChatFunc_current));
|
|
450503
|
+
const sectionId = (pendingInfo === null || pendingInfo === void 0 ? void 0 : pendingInfo.sectionId) || (refChatFunc === null || refChatFunc === void 0 ? void 0 : (_refChatFunc_current1 = refChatFunc.current) === null || _refChatFunc_current1 === void 0 ? void 0 : (_refChatFunc_current_getSectionId = _refChatFunc_current1.getSectionId) === null || _refChatFunc_current_getSectionId === void 0 ? void 0 : _refChatFunc_current_getSectionId.call(_refChatFunc_current1));
|
|
450504
|
+
const appId = ((_refChatConfig_current = refChatConfig.current) === null || _refChatConfig_current === void 0 ? void 0 : (_refChatConfig_current_appInfo = _refChatConfig_current.appInfo) === null || _refChatConfig_current_appInfo === void 0 ? void 0 : _refChatConfig_current_appInfo.appId) || ((_refChatConfig_current1 = refChatConfig.current) === null || _refChatConfig_current1 === void 0 ? void 0 : _refChatConfig_current1.bot_id) || "";
|
|
450505
|
+
if (cozeApiSdk && conversationId && sectionId && appId && setConversationKnowledgeIds) getConversationKnowledges({
|
|
450506
|
+
cozeApiSdk,
|
|
450507
|
+
conversationId,
|
|
450508
|
+
sectionId,
|
|
450509
|
+
appId
|
|
450510
|
+
}).then((knowledgeIds)=>{
|
|
450511
|
+
// 仅当接口返回非空时更新 store,避免返回 [] 时清空已有知识库导致第二次发送缺少 KNOWLEDGE_IDS
|
|
450512
|
+
if (Array.isArray(knowledgeIds) && knowledgeIds.length > 0) setConversationKnowledgeIds(knowledgeIds);
|
|
450513
|
+
}).catch((e)=>{
|
|
450514
|
+
console.warn("Failed to refresh conversation knowledges after chat:", e);
|
|
450515
|
+
});
|
|
450516
|
+
if (pendingInfo && !hasUpdatedChatCore && pendingInfo.conversationId) {
|
|
449634
450517
|
var _refCurrentConversationInfo_current;
|
|
449635
450518
|
hasUpdatedChatCore = true;
|
|
449636
450519
|
console.log("onGetMessageStreamParser: Updating currentConversationInfo and chatCore after stream done", {
|
|
449637
450520
|
conversationId: pendingInfo.conversationId
|
|
449638
450521
|
});
|
|
449639
|
-
// 检查当前的 currentConversationInfo.id 是否已经是我们要设置的 conversationId
|
|
449640
450522
|
const currentId = (_refCurrentConversationInfo_current = refCurrentConversationInfo.current) === null || _refCurrentConversationInfo_current === void 0 ? void 0 : _refCurrentConversationInfo_current.id;
|
|
449641
450523
|
if (currentId === pendingInfo.conversationId) {
|
|
449642
450524
|
console.log("onGetMessageStreamParser: Conversation ID already matches, only updating chatCore", {
|
|
449643
450525
|
conversationId: pendingInfo.conversationId
|
|
449644
450526
|
});
|
|
449645
|
-
// 即使 ID 相同,也要更新 chatCore 的 conversationId
|
|
449646
450527
|
if (refChatFunc === null || refChatFunc === void 0 ? void 0 : refChatFunc.current) refChatFunc.current.setConversationId(pendingInfo.conversationId, pendingInfo.sectionId);
|
|
449647
450528
|
refPendingConversationInfo.current = null;
|
|
449648
450529
|
return result;
|
|
449649
450530
|
}
|
|
449650
|
-
// 使用 setTimeout 确保在消息发送流程完全完成后更新状态
|
|
449651
450531
|
setTimeout(()=>{
|
|
449652
450532
|
if (refUpdateCurrentConversationInfo.current) {
|
|
449653
|
-
// 保留当前的 conversationListVisible 和 isLargeWidth,避免会话列表被收起
|
|
449654
450533
|
const currentInfo = refCurrentConversationInfo.current;
|
|
449655
450534
|
refUpdateCurrentConversationInfo.current({
|
|
449656
450535
|
id: pendingInfo.conversationId,
|
|
449657
450536
|
last_section_id: pendingInfo.sectionId,
|
|
449658
|
-
// 不设置 name,让 useUpdateConversationNameByMessage hook 自动更新
|
|
449659
450537
|
name: "",
|
|
449660
450538
|
created_at: Math.floor(Date.now() / 1000),
|
|
449661
450539
|
updated_at: Math.floor(Date.now() / 1000),
|
|
449662
450540
|
meta_data: {},
|
|
449663
|
-
// 保留当前的 conversationListVisible,避免会话列表被收起
|
|
449664
450541
|
conversationListVisible: (currentInfo === null || currentInfo === void 0 ? void 0 : currentInfo.conversationListVisible) ?? false,
|
|
449665
|
-
// 保留当前的 isLargeWidth
|
|
449666
450542
|
isLargeWidth: (currentInfo === null || currentInfo === void 0 ? void 0 : currentInfo.isLargeWidth) ?? false
|
|
449667
450543
|
});
|
|
449668
450544
|
}
|
|
449669
450545
|
if (refChatFunc === null || refChatFunc === void 0 ? void 0 : refChatFunc.current) refChatFunc.current.setConversationId(pendingInfo.conversationId, pendingInfo.sectionId);
|
|
449670
|
-
// 清除 pending 信息
|
|
449671
450546
|
refPendingConversationInfo.current = null;
|
|
449672
450547
|
}, 0);
|
|
449673
450548
|
}
|
|
449674
|
-
|
|
449675
|
-
|
|
449676
|
-
|
|
449677
|
-
|
|
450549
|
+
}
|
|
450550
|
+
if (shouldReturnSyntheticAck && pendingInfo) {
|
|
450551
|
+
const localMessageId = (requestMessageRawBody === null || requestMessageRawBody === void 0 ? void 0 : requestMessageRawBody.local_message_id) || "";
|
|
450552
|
+
const replyId = pendingInfo.conversationId || `--ack--${localMessageId}`;
|
|
450553
|
+
refStreamAlreadySucceeded.current = true;
|
|
450554
|
+
const extraInfo = {
|
|
450555
|
+
local_message_id: localMessageId,
|
|
450556
|
+
input_tokens: "",
|
|
450557
|
+
output_tokens: "",
|
|
450558
|
+
token: "",
|
|
450559
|
+
plugin_status: "",
|
|
450560
|
+
time_cost: "",
|
|
450561
|
+
workflow_tokens: "",
|
|
450562
|
+
bot_state: "",
|
|
450563
|
+
plugin_request: "",
|
|
450564
|
+
tool_name: "",
|
|
450565
|
+
plugin: "",
|
|
450566
|
+
execute_display_name: ""
|
|
450567
|
+
};
|
|
450568
|
+
const syntheticAck = {
|
|
450569
|
+
event: "message",
|
|
450570
|
+
data: {
|
|
450571
|
+
index: 0,
|
|
450572
|
+
seq_id: 0,
|
|
450573
|
+
is_finish: true,
|
|
450574
|
+
message: {
|
|
450575
|
+
type: "ack",
|
|
450576
|
+
message_id: replyId,
|
|
450577
|
+
reply_id: replyId,
|
|
450578
|
+
section_id: pendingInfo.sectionId || "",
|
|
450579
|
+
content_type: types_ContentType.Text,
|
|
450580
|
+
content: "",
|
|
450581
|
+
extra_info: extraInfo,
|
|
450582
|
+
role: "user"
|
|
450583
|
+
}
|
|
450584
|
+
}
|
|
450585
|
+
};
|
|
450586
|
+
return syntheticAck;
|
|
450587
|
+
}
|
|
450588
|
+
return result;
|
|
450589
|
+
};
|
|
449678
450590
|
}
|
|
449679
450591
|
}
|
|
449680
450592
|
};
|
|
@@ -449698,19 +450610,20 @@ class MessageParser {
|
|
|
449698
450610
|
*/
|
|
449699
450611
|
|
|
449700
450612
|
const useClearHistoryAdapter = (param)=>{
|
|
449701
|
-
let { refChatFunc } = param;
|
|
450613
|
+
let { refChatFunc, onAfterCreateConversation } = param;
|
|
449702
450614
|
var _chatConfig_auth;
|
|
449703
450615
|
const { chatConfig } = context_useChatAppProps();
|
|
449704
450616
|
const refConnectorId = (0,react_.useRef)("");
|
|
449705
450617
|
refConnectorId.current = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_auth = chatConfig.auth) === null || _chatConfig_auth === void 0 ? void 0 : _chatConfig_auth.connectorId) || "";
|
|
449706
450618
|
return (0,react_.useMemo)(()=>{
|
|
449707
450619
|
const onAfterResponse = [
|
|
449708
|
-
(response)=>{
|
|
450620
|
+
async (response)=>{
|
|
449709
450621
|
var _refChatFunc_current;
|
|
449710
450622
|
const { data: resCreateConversation } = response;
|
|
449711
450623
|
const { code, data: conversationData } = resCreateConversation;
|
|
449712
450624
|
const { id: conversationId, last_section_id: sectionId } = conversationData || {};
|
|
449713
450625
|
refChatFunc === null || refChatFunc === void 0 || (_refChatFunc_current = refChatFunc.current) === null || _refChatFunc_current === void 0 || _refChatFunc_current.setConversationId(conversationId, sectionId);
|
|
450626
|
+
if (conversationId && sectionId && onAfterCreateConversation) await onAfterCreateConversation(conversationId, sectionId);
|
|
449714
450627
|
return {
|
|
449715
450628
|
...response,
|
|
449716
450629
|
data: {
|
|
@@ -449741,7 +450654,9 @@ const useClearHistoryAdapter = (param)=>{
|
|
|
449741
450654
|
}
|
|
449742
450655
|
};
|
|
449743
450656
|
return config;
|
|
449744
|
-
}, [
|
|
450657
|
+
}, [
|
|
450658
|
+
onAfterCreateConversation
|
|
450659
|
+
]);
|
|
449745
450660
|
};
|
|
449746
450661
|
|
|
449747
450662
|
;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/api-adapter/use-common-hooks.ts
|
|
@@ -449882,24 +450797,47 @@ const useBreakMessage = ()=>(0,react_.useMemo)(()=>{
|
|
|
449882
450797
|
|
|
449883
450798
|
|
|
449884
450799
|
|
|
450800
|
+
|
|
449885
450801
|
const useCoreManager = (param)=>{
|
|
449886
450802
|
let { refChatFunc } = param;
|
|
450803
|
+
var _chatConfig_appInfo;
|
|
449887
450804
|
const userInfo = useUserInfo();
|
|
449888
|
-
const { refreshToken } =
|
|
450805
|
+
const { refreshToken, cozeApiSdk } = context_useChatCozeSdk();
|
|
450806
|
+
const { chatConfig, requestManagerOptions } = context_useChatAppProps();
|
|
450807
|
+
const setConversationKnowledgeIds = context_useChatAppStore((s)=>s.setConversationKnowledgeIds);
|
|
449889
450808
|
// 获取 apiUrl
|
|
449890
450809
|
const { apiUrl } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
449891
450810
|
apiUrl: s.apiUrl
|
|
449892
450811
|
})));
|
|
450812
|
+
// 删除对话记录(创建新 conversation)成功后,重新拉取 workflows/conversation/knowledges 更新知识库列表
|
|
450813
|
+
const onAfterCreateConversation = (0,react_.useCallback)(async (conversationId, sectionId)=>{
|
|
450814
|
+
var _chatConfig_appInfo;
|
|
450815
|
+
if (!cozeApiSdk) return;
|
|
450816
|
+
const appId = (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) || "";
|
|
450817
|
+
if (!appId) return;
|
|
450818
|
+
const knowledgeIds = await getConversationKnowledges({
|
|
450819
|
+
cozeApiSdk,
|
|
450820
|
+
conversationId,
|
|
450821
|
+
sectionId,
|
|
450822
|
+
appId
|
|
450823
|
+
});
|
|
450824
|
+
setConversationKnowledgeIds(knowledgeIds);
|
|
450825
|
+
}, [
|
|
450826
|
+
cozeApiSdk,
|
|
450827
|
+
chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo = chatConfig.appInfo) === null || _chatConfig_appInfo === void 0 ? void 0 : _chatConfig_appInfo.appId,
|
|
450828
|
+
chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.bot_id,
|
|
450829
|
+
setConversationKnowledgeIds
|
|
450830
|
+
]);
|
|
449893
450831
|
const clearMessageContextAdapter = useClearMessageContextAdapter();
|
|
449894
450832
|
const sendMessageAdapter = useSendMessageAdapter(userInfo || undefined, refChatFunc);
|
|
449895
450833
|
const clearHistoryAdapter = useClearHistoryAdapter({
|
|
449896
|
-
refChatFunc
|
|
450834
|
+
refChatFunc,
|
|
450835
|
+
onAfterCreateConversation
|
|
449897
450836
|
});
|
|
449898
450837
|
const commonOnBeforeRequestHooks = useCommonOnBeforeRequestHooks();
|
|
449899
450838
|
const commonOnAfterResponseHooks = useCommonOnAfterResponseHooks(refreshToken);
|
|
449900
450839
|
const commonErrorResponseHooks = useCommonErrorResponseHooks(refreshToken);
|
|
449901
450840
|
const messageListAdapter = useMessageList();
|
|
449902
|
-
const { requestManagerOptions } = context_useChatAppProps();
|
|
449903
450841
|
const breakMessageAdapter = useBreakMessage();
|
|
449904
450842
|
// 计算最终的 baseURL
|
|
449905
450843
|
const finalBaseURL = apiUrl || openApiHostByRegionWithToken;
|
|
@@ -449952,7 +450890,7 @@ const useCoreManager = (param)=>{
|
|
|
449952
450890
|
const useCoreOverrideConfig = (param)=>{
|
|
449953
450891
|
let { refChatFunc } = param;
|
|
449954
450892
|
const { chatConfig } = context_useChatAppProps();
|
|
449955
|
-
const { tokenManager } =
|
|
450893
|
+
const { tokenManager } = context_useChatCozeSdk();
|
|
449956
450894
|
const requestManagerOptions = useCoreManager({
|
|
449957
450895
|
refChatFunc
|
|
449958
450896
|
});
|
|
@@ -451085,7 +452023,7 @@ const CopyTextMessage = (param)=>{
|
|
|
451085
452023
|
setIsCopySuccessful(true);
|
|
451086
452024
|
setTimeout(()=>setIsCopySuccessful(false), COUNT_DOWN_TIME * TIMES);
|
|
451087
452025
|
esm_webpack_exports_Toast.success({
|
|
451088
|
-
content:
|
|
452026
|
+
content: src_I18n.t("copy_success"),
|
|
451089
452027
|
showClose: false,
|
|
451090
452028
|
duration: COUNT_DOWN_TIME
|
|
451091
452029
|
});
|
|
@@ -451095,7 +452033,7 @@ const CopyTextMessage = (param)=>{
|
|
|
451095
452033
|
} else {
|
|
451096
452034
|
// Copy failed
|
|
451097
452035
|
esm_webpack_exports_Toast.warning({
|
|
451098
|
-
content:
|
|
452036
|
+
content: src_I18n.t("copy_failed"),
|
|
451099
452037
|
showClose: false,
|
|
451100
452038
|
duration: COUNT_DOWN_TIME
|
|
451101
452039
|
});
|
|
@@ -451110,7 +452048,7 @@ const CopyTextMessage = (param)=>{
|
|
|
451110
452048
|
if (!meta.isGroupLastAnswerMessage && isMustGroupLastAnswerMessage) return null;
|
|
451111
452049
|
const iconClassNames = classnames_default()(className, "w-[14px] h-[14px]");
|
|
451112
452050
|
return /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Tooltip, {
|
|
451113
|
-
content: isCopySuccessful ?
|
|
452051
|
+
content: isCopySuccessful ? src_I18n.t("copied") : src_I18n.t("copy"),
|
|
451114
452052
|
trigger: trigger,
|
|
451115
452053
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_IconButton, {
|
|
451116
452054
|
"data-testid": "chat-area.answer-action.copy-button",
|
|
@@ -451241,7 +452179,7 @@ const QuoteMessage = (props)=>{
|
|
|
451241
452179
|
if (!meta.isGroupLastAnswerMessage) return null;
|
|
451242
452180
|
if (!plugin) return null;
|
|
451243
452181
|
return /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Tooltip, {
|
|
451244
|
-
content:
|
|
452182
|
+
content: src_I18n.t("quote_ask_in_chat"),
|
|
451245
452183
|
trigger: trigger,
|
|
451246
452184
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_IconButton, {
|
|
451247
452185
|
"data-testid": "chat-area.answer-action.quote-message",
|
|
@@ -452310,7 +453248,7 @@ const useCurMessageInfo = ()=>{
|
|
|
452310
453248
|
const useDeleteMessage = ()=>{
|
|
452311
453249
|
const storeSet = use_chat_area_context_useChatAreaStoreSet();
|
|
452312
453250
|
const chatActionLockService = useChatActionLockService();
|
|
452313
|
-
const { cozeApiSdk } =
|
|
453251
|
+
const { cozeApiSdk } = context_useChatCozeSdk();
|
|
452314
453252
|
return async (conversationId, messageId)=>{
|
|
452315
453253
|
var _messageInfo_extra_info;
|
|
452316
453254
|
if (!messageId || !conversationId) return;
|
|
@@ -452332,7 +453270,7 @@ const useDeleteMessage = ()=>{
|
|
|
452332
453270
|
if (isLast) clearSuggestions();
|
|
452333
453271
|
} catch (e) {
|
|
452334
453272
|
console.error(e);
|
|
452335
|
-
esm_webpack_exports_Toast.error(
|
|
453273
|
+
esm_webpack_exports_Toast.error(src_I18n.t("Delete_failed"));
|
|
452336
453274
|
} finally{
|
|
452337
453275
|
chatActionLockService.answerAction.unlock(groupId, "deleteMessageGroup");
|
|
452338
453276
|
}
|
|
@@ -452380,7 +453318,7 @@ const components_delete_message_DeleteMessage = (param)=>{
|
|
|
452380
453318
|
return null;
|
|
452381
453319
|
return /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Tooltip, {
|
|
452382
453320
|
trigger: trigger,
|
|
452383
|
-
content:
|
|
453321
|
+
content: src_I18n.t("Delete"),
|
|
452384
453322
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_IconButton, {
|
|
452385
453323
|
"data-testid": "chat-area.answer-action.delete-message-button",
|
|
452386
453324
|
disabled: isDeleteMessageLock,
|
|
@@ -452499,10 +453437,6 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
|
|
|
452499
453437
|
actionBarSize
|
|
452500
453438
|
]);
|
|
452501
453439
|
if (!isShowHoverContainer) return null;
|
|
452502
|
-
console.log("actionBarSize:", {
|
|
452503
|
-
actionBarSize,
|
|
452504
|
-
actionBarLeft
|
|
452505
|
-
});
|
|
452506
453440
|
const wrapperClass = "flex justify-center items-center";
|
|
452507
453441
|
// 如果message不是最后一个message group 的消息,那么在hover时展示answer actions
|
|
452508
453442
|
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
|
|
@@ -453472,7 +454406,7 @@ const ChatProviderImpl = (param)=>{
|
|
|
453472
454406
|
let { children, plugins } = param;
|
|
453473
454407
|
var _chatConfig_ui, _chatConfig_appInfo, _chatConfig_ui_chatBot, _chatConfig_ui1;
|
|
453474
454408
|
const refLastIsError = (0,react_.useRef)(false);
|
|
453475
|
-
const { refreshToken } =
|
|
454409
|
+
const { refreshToken } = context_useChatCozeSdk();
|
|
453476
454410
|
const { initError, setInitError } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
453477
454411
|
initError: s.initError,
|
|
453478
454412
|
setInitError: s.setInitError
|
|
@@ -453578,7 +454512,7 @@ const ChatProviderImpl = (param)=>{
|
|
|
453578
454512
|
var _msg_content_obj_file_list_;
|
|
453579
454513
|
copy_to_clipboard_default()(((_msg_content_obj_file_list_ = msg.content_obj.file_list[fileIndex ?? 0]) === null || _msg_content_obj_file_list_ === void 0 ? void 0 : _msg_content_obj_file_list_.file_key) ?? "");
|
|
453580
454514
|
UIToast.success({
|
|
453581
|
-
content:
|
|
454515
|
+
content: src_I18n.t("copy_success") ?? "Copy Successfully"
|
|
453582
454516
|
});
|
|
453583
454517
|
}
|
|
453584
454518
|
}
|
|
@@ -453850,7 +454784,7 @@ const InputNodeRender = (param)=>{
|
|
|
453850
454784
|
}
|
|
453851
454785
|
});
|
|
453852
454786
|
},
|
|
453853
|
-
children:
|
|
454787
|
+
children: src_I18n.t("workflow_detail_title_testrun_submit")
|
|
453854
454788
|
})
|
|
453855
454789
|
]
|
|
453856
454790
|
})
|
|
@@ -454146,7 +455080,7 @@ const input_node_render_InputNodeRender = (param)=>{
|
|
|
454146
455080
|
}
|
|
454147
455081
|
});
|
|
454148
455082
|
},
|
|
454149
|
-
children:
|
|
455083
|
+
children: src_I18n.t("workflow_detail_title_testrun_submit")
|
|
454150
455084
|
})
|
|
454151
455085
|
]
|
|
454152
455086
|
})
|
|
@@ -454403,47 +455337,47 @@ const uuid_generate = (/* unused pure expression or super */ null && (shortid));
|
|
|
454403
455337
|
const ACCEPT_UPLOAD_TYPES = [
|
|
454404
455338
|
{
|
|
454405
455339
|
type: namespaces_shortcut_command_InputType.UploadImage,
|
|
454406
|
-
label:
|
|
455340
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_img"),
|
|
454407
455341
|
icon: image_success_
|
|
454408
455342
|
},
|
|
454409
455343
|
{
|
|
454410
455344
|
type: namespaces_shortcut_command_InputType.UploadTable,
|
|
454411
|
-
label:
|
|
455345
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_table"),
|
|
454412
455346
|
icon: xlsx_success_
|
|
454413
455347
|
},
|
|
454414
455348
|
{
|
|
454415
455349
|
type: namespaces_shortcut_command_InputType.UploadDoc,
|
|
454416
|
-
label:
|
|
455350
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_doc"),
|
|
454417
455351
|
icon: docx_success_
|
|
454418
455352
|
},
|
|
454419
455353
|
{
|
|
454420
455354
|
type: namespaces_shortcut_command_InputType.UploadAudio,
|
|
454421
|
-
label:
|
|
455355
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_audio"),
|
|
454422
455356
|
icon: audio_success_
|
|
454423
455357
|
},
|
|
454424
455358
|
{
|
|
454425
455359
|
type: namespaces_shortcut_command_InputType.CODE,
|
|
454426
|
-
label:
|
|
455360
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_code"),
|
|
454427
455361
|
icon: code_success_
|
|
454428
455362
|
},
|
|
454429
455363
|
{
|
|
454430
455364
|
type: namespaces_shortcut_command_InputType.ARCHIVE,
|
|
454431
|
-
label:
|
|
455365
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_zip"),
|
|
454432
455366
|
icon: zip_success_
|
|
454433
455367
|
},
|
|
454434
455368
|
{
|
|
454435
455369
|
type: namespaces_shortcut_command_InputType.PPT,
|
|
454436
|
-
label:
|
|
455370
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_ppt"),
|
|
454437
455371
|
icon: ppt_success_
|
|
454438
455372
|
},
|
|
454439
455373
|
{
|
|
454440
455374
|
type: namespaces_shortcut_command_InputType.VIDEO,
|
|
454441
|
-
label:
|
|
455375
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_video"),
|
|
454442
455376
|
icon: video_success_
|
|
454443
455377
|
},
|
|
454444
455378
|
{
|
|
454445
455379
|
type: namespaces_shortcut_command_InputType.TXT,
|
|
454446
|
-
label:
|
|
455380
|
+
label: src_I18n.t("shortcut_modal_upload_component_file_format_txt"),
|
|
454447
455381
|
icon: txt_success_
|
|
454448
455382
|
}
|
|
454449
455383
|
];
|
|
@@ -455326,7 +456260,7 @@ const UploadContent = (param)=>{
|
|
|
455326
456260
|
className: "coz-fg-hglt-red"
|
|
455327
456261
|
}),
|
|
455328
456262
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
455329
|
-
children:
|
|
456263
|
+
children: src_I18n.t("Retry")
|
|
455330
456264
|
})
|
|
455331
456265
|
]
|
|
455332
456266
|
}) : null,
|
|
@@ -455409,10 +456343,10 @@ const FileUpload = (param)=>{
|
|
|
455409
456343
|
...props,
|
|
455410
456344
|
disabled: disabled,
|
|
455411
456345
|
onAcceptInvalid: ()=>{
|
|
455412
|
-
es_toast_.error(
|
|
456346
|
+
es_toast_.error(src_I18n.t("shortcut_Illegal_file_format"));
|
|
455413
456347
|
},
|
|
455414
456348
|
onSizeError: ()=>{
|
|
455415
|
-
if (props.maxSize) es_toast_.error(
|
|
456349
|
+
if (props.maxSize) es_toast_.error(src_I18n.t("file_too_large", {
|
|
455416
456350
|
max_size: `${props.maxSize / 1024}MB`
|
|
455417
456351
|
}));
|
|
455418
456352
|
},
|
|
@@ -455450,7 +456384,7 @@ const FileUpload = (param)=>{
|
|
|
455450
456384
|
className: classnames_default()(widgets_upload_index_module_["upload-button"], "w-full"),
|
|
455451
456385
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
455452
456386
|
className: widgets_upload_index_module_["upload-button-text-short"],
|
|
455453
|
-
children:
|
|
456387
|
+
children: src_I18n.t("shortcut_component_upload_component_placeholder")
|
|
455454
456388
|
})
|
|
455455
456389
|
})
|
|
455456
456390
|
}),
|
|
@@ -455949,7 +456883,7 @@ const DSLPlaceholer = ()=>/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
|
455949
456883
|
style: {
|
|
455950
456884
|
height: 58
|
|
455951
456885
|
},
|
|
455952
|
-
children:
|
|
456886
|
+
children: src_I18n.t("shortcut_modal_components")
|
|
455953
456887
|
});
|
|
455954
456888
|
|
|
455955
456889
|
;// CONCATENATED MODULE: ../../../common/chat-area/plugin-chat-shortcuts/src/components/short-cut-panel/widgets/layout/index.tsx
|
|
@@ -457683,7 +458617,7 @@ const ShortcutsLoadMoreList = (param)=>{
|
|
|
457683
458617
|
children: [
|
|
457684
458618
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
457685
458619
|
className: "text-xs coz-fg-secondary mb-2 pl-2 pt-1",
|
|
457686
|
-
children:
|
|
458620
|
+
children: src_I18n.t("bot_ide_shortcut")
|
|
457687
458621
|
}),
|
|
457688
458622
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(LoadMoreList, {
|
|
457689
458623
|
className: classnames_default()("w-full max-h-[312px] overflow-y-auto cursor-pointer", src_shortcut_index_module_["load-more-list"]),
|
|
@@ -458176,7 +459110,7 @@ const load_more_LoadMore = (props)=>{
|
|
|
458176
459110
|
children: [
|
|
458177
459111
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
458178
459112
|
className: "mr-1",
|
|
458179
|
-
children:
|
|
459113
|
+
children: src_I18n.t("More")
|
|
458180
459114
|
}),
|
|
458181
459115
|
isLoadMoreActive ? /*#__PURE__*/ (0,jsx_runtime_.jsx)("img", {
|
|
458182
459116
|
className: "arraw-icon",
|
|
@@ -461302,8 +462236,8 @@ const getVar = (text)=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("span", {
|
|
|
461302
462236
|
"}}"
|
|
461303
462237
|
]
|
|
461304
462238
|
});
|
|
461305
|
-
const var1 = getVar(
|
|
461306
|
-
const var2 = getVar(
|
|
462239
|
+
const var1 = getVar(src_I18n.t("shortcut_modal_query_message_hover_tip_component_mode_var1"));
|
|
462240
|
+
const var2 = getVar(src_I18n.t("shortcut_modal_query_message_hover_tip_component_mode_var2"));
|
|
461307
462241
|
const queryTip = ()=>/*#__PURE__*/ _jsxs("div", {
|
|
461308
462242
|
className: "p[16px] leading-[16px] text-[12px] font-normal coz-fg-secondary",
|
|
461309
462243
|
children: [
|
|
@@ -461336,7 +462270,7 @@ const queryTip = ()=>/*#__PURE__*/ _jsxs("div", {
|
|
|
461336
462270
|
})
|
|
461337
462271
|
]
|
|
461338
462272
|
});
|
|
461339
|
-
const compTip = ()=>
|
|
462273
|
+
const compTip = ()=>src_I18n.t("shortcut_modal_components_hover_tip", {
|
|
461340
462274
|
var1,
|
|
461341
462275
|
var2
|
|
461342
462276
|
});
|
|
@@ -462651,7 +463585,7 @@ const upload_contnet_UploadContent = (props)=>{
|
|
|
462651
463585
|
children: [
|
|
462652
463586
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
462653
463587
|
className: "coz-fg-plus text-[16px] font-medium",
|
|
462654
|
-
children:
|
|
463588
|
+
children: src_I18n.t("shortcut_modal_upload_component_supported_file_formats")
|
|
462655
463589
|
}),
|
|
462656
463590
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(upload_contnet_CheckboxGroup, {
|
|
462657
463591
|
field: "values.uploadTypes",
|
|
@@ -462665,7 +463599,7 @@ const upload_contnet_UploadContent = (props)=>{
|
|
|
462665
463599
|
rules: [
|
|
462666
463600
|
{
|
|
462667
463601
|
validator: (rules, newValue)=>!!(newValue === null || newValue === void 0 ? void 0 : newValue.length),
|
|
462668
|
-
message:
|
|
463602
|
+
message: src_I18n.t("shortcut_modal_please_select_file_formats_for_upload_component_tip")
|
|
462669
463603
|
}
|
|
462670
463604
|
],
|
|
462671
463605
|
children: ACCEPT_UPLOAD_TYPES.map((param)=>{
|
|
@@ -462832,7 +463766,7 @@ const OptionsList = (param)=>{
|
|
|
462832
463766
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
462833
463767
|
className: "ml-2",
|
|
462834
463768
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(tooltip_Tooltip, {
|
|
462835
|
-
content:
|
|
463769
|
+
content: src_I18n.t("Remove"),
|
|
462836
463770
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(es_iconButton_, {
|
|
462837
463771
|
size: "small",
|
|
462838
463772
|
icon: /*#__PURE__*/ (0,jsx_runtime_.jsx)(IconShortcutTrash, {}),
|
|
@@ -462884,7 +463818,7 @@ const SelectContent = (param)=>{
|
|
|
462884
463818
|
children: [
|
|
462885
463819
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
462886
463820
|
className: "coz-fg-plus mb-[14px] font-medium",
|
|
462887
|
-
children:
|
|
463821
|
+
children: src_I18n.t("shortcut_modal_selector_component_options")
|
|
462888
463822
|
}),
|
|
462889
463823
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
462890
463824
|
className: "flex justify-between",
|
|
@@ -462904,7 +463838,7 @@ const SelectContent = (param)=>{
|
|
|
462904
463838
|
}
|
|
462905
463839
|
]);
|
|
462906
463840
|
},
|
|
462907
|
-
children:
|
|
463841
|
+
children: src_I18n.t("shortcut_modal_selector_component_options")
|
|
462908
463842
|
})
|
|
462909
463843
|
}),
|
|
462910
463844
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
@@ -462932,7 +463866,7 @@ const SelectContentField = (props)=>{
|
|
|
462932
463866
|
rules: [
|
|
462933
463867
|
{
|
|
462934
463868
|
validator: (rules, value)=>!!(value === null || value === void 0 ? void 0 : value.length),
|
|
462935
|
-
message:
|
|
463869
|
+
message: src_I18n.t("shortcut_modal_selector_component_no_options_error")
|
|
462936
463870
|
}
|
|
462937
463871
|
]
|
|
462938
463872
|
})
|
|
@@ -462997,9 +463931,9 @@ const SelectContentField = (props)=>{
|
|
|
462997
463931
|
|
|
462998
463932
|
const { RadioGroup: component_type_select_RadioGroup, Radio: component_type_select_Radio } = baseForm_;
|
|
462999
463933
|
const SelectTypeAndLableMap = {
|
|
463000
|
-
text:
|
|
463001
|
-
select:
|
|
463002
|
-
upload:
|
|
463934
|
+
text: src_I18n.t("shortcut_component_type_text"),
|
|
463935
|
+
select: src_I18n.t("shortcut_component_type_selector"),
|
|
463936
|
+
upload: src_I18n.t("shortcut_modal_components_modal_upload_component")
|
|
463003
463937
|
};
|
|
463004
463938
|
const ComponentTypeSelectRecordItem = (props)=>{
|
|
463005
463939
|
const { value: defaultValue, onSubmit, disabled = false } = props;
|
|
@@ -463046,11 +463980,11 @@ const ComponentTypeSelectRecordItem = (props)=>{
|
|
|
463046
463980
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Button, {
|
|
463047
463981
|
color: "highlight",
|
|
463048
463982
|
onClick: ()=>setSelectPopoverVisible(false),
|
|
463049
|
-
children:
|
|
463983
|
+
children: src_I18n.t("cancel")
|
|
463050
463984
|
}),
|
|
463051
463985
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Button, {
|
|
463052
463986
|
onClick: onComponentTypeSelectFormSubmit,
|
|
463053
|
-
children:
|
|
463987
|
+
children: src_I18n.t("Confirm")
|
|
463054
463988
|
})
|
|
463055
463989
|
]
|
|
463056
463990
|
})
|
|
@@ -463061,7 +463995,7 @@ const ComponentTypeSelectRecordItem = (props)=>{
|
|
|
463061
463995
|
suffix: /*#__PURE__*/ (0,jsx_runtime_.jsx)(icons_IconChevronDown_, {
|
|
463062
463996
|
onClick: ()=>setSelectPopoverVisible(!selectPopoverVisible)
|
|
463063
463997
|
}),
|
|
463064
|
-
placeholder:
|
|
463998
|
+
placeholder: src_I18n.t("shortcut_modal_selector_component_default_text"),
|
|
463065
463999
|
value: SelectTypeAndLableMap[submitValue === null || submitValue === void 0 ? void 0 : submitValue.type],
|
|
463066
464000
|
onClick: ()=>setSelectPopoverVisible(!selectPopoverVisible),
|
|
463067
464001
|
disabled: disabled,
|
|
@@ -463125,7 +464059,7 @@ const ComponentTypeSelectForm = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)
|
|
|
463125
464059
|
children: [
|
|
463126
464060
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
463127
464061
|
className: "coz-fg-plus text-[16px] font-medium",
|
|
463128
|
-
children:
|
|
464062
|
+
children: src_I18n.t("shortcut_modal_components_modal_component_type")
|
|
463129
464063
|
}),
|
|
463130
464064
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(component_type_select_RadioGroup, {
|
|
463131
464065
|
fieldStyle: {
|
|
@@ -463160,17 +464094,17 @@ const ComponentTypeSelectForm = /*#__PURE__*/ (0,react_.forwardRef)((props, ref)
|
|
|
463160
464094
|
});
|
|
463161
464095
|
const getComponentTypeOptionMap = (initValue)=>({
|
|
463162
464096
|
text: {
|
|
463163
|
-
label:
|
|
464097
|
+
label: src_I18n.t("shortcut_component_type_text")
|
|
463164
464098
|
},
|
|
463165
464099
|
select: {
|
|
463166
|
-
label:
|
|
464100
|
+
label: src_I18n.t("shortcut_component_type_selector"),
|
|
463167
464101
|
render: ()=>/*#__PURE__*/ (0,jsx_runtime_.jsx)(SelectContentField, {
|
|
463168
464102
|
field: "values.options",
|
|
463169
464103
|
value: initValue === null || initValue === void 0 ? void 0 : initValue.options
|
|
463170
464104
|
})
|
|
463171
464105
|
},
|
|
463172
464106
|
upload: {
|
|
463173
|
-
label:
|
|
464107
|
+
label: src_I18n.t("shortcut_modal_components_modal_upload_component"),
|
|
463174
464108
|
render: ()=>/*#__PURE__*/ (0,jsx_runtime_.jsx)(upload_contnet_UploadContent, {
|
|
463175
464109
|
value: initValue === null || initValue === void 0 ? void 0 : initValue.uploadTypes
|
|
463176
464110
|
})
|
|
@@ -463239,7 +464173,7 @@ const ComponentParameter = (param)=>{
|
|
|
463239
464173
|
}),
|
|
463240
464174
|
Boolean(required) && /*#__PURE__*/ (0,jsx_runtime_.jsx)("span", {
|
|
463241
464175
|
className: "rounded coz-mg-primary px-[6px] py-[1px]",
|
|
463242
|
-
children:
|
|
464176
|
+
children: src_I18n.t("workflow_add_parameter_required")
|
|
463243
464177
|
})
|
|
463244
464178
|
]
|
|
463245
464179
|
}),
|
|
@@ -463395,7 +464329,7 @@ const ComponentDefaultValue = (props)=>{
|
|
|
463395
464329
|
},
|
|
463396
464330
|
field: field,
|
|
463397
464331
|
noErrorMessage: true,
|
|
463398
|
-
placeholder:
|
|
464332
|
+
placeholder: src_I18n.t("shortcut_modal_use_tool_parameter_default_value_placeholder"),
|
|
463399
464333
|
disabled: disabled
|
|
463400
464334
|
});
|
|
463401
464335
|
if (type === "select") return /*#__PURE__*/ (0,jsx_runtime_.jsx)(SelectWithInputTypeField, {
|
|
@@ -463485,7 +464419,7 @@ const getOperationColumns = (param)=>{
|
|
|
463485
464419
|
showDelete ? /*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
463486
464420
|
className: "px-2",
|
|
463487
464421
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(TooltipWithDisabled, {
|
|
463488
|
-
content:
|
|
464422
|
+
content: src_I18n.t("Remove"),
|
|
463489
464423
|
disabled: !deleteable,
|
|
463490
464424
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(es_iconButton_, {
|
|
463491
464425
|
size: "small",
|
|
@@ -463511,7 +464445,7 @@ const getColumnsMap = (params)=>{
|
|
|
463511
464445
|
key: "name",
|
|
463512
464446
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(baseForm_.Label, {
|
|
463513
464447
|
className: "leading-5 p-0 m-0",
|
|
463514
|
-
text:
|
|
464448
|
+
text: src_I18n.t("shortcut_modal_component_name"),
|
|
463515
464449
|
required: true
|
|
463516
464450
|
}),
|
|
463517
464451
|
width: 1,
|
|
@@ -463528,7 +464462,7 @@ const getColumnsMap = (params)=>{
|
|
|
463528
464462
|
maxLength: 20,
|
|
463529
464463
|
field: `values.[${index}].name`,
|
|
463530
464464
|
noErrorMessage: true,
|
|
463531
|
-
placeholder:
|
|
464465
|
+
placeholder: src_I18n.t("shortcut_modal_component_name"),
|
|
463532
464466
|
rules: [
|
|
463533
464467
|
{
|
|
463534
464468
|
required: true
|
|
@@ -463543,7 +464477,7 @@ const getColumnsMap = (params)=>{
|
|
|
463543
464477
|
key: "description",
|
|
463544
464478
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(baseForm_.Label, {
|
|
463545
464479
|
className: "leading-5 p-0 m-0",
|
|
463546
|
-
text:
|
|
464480
|
+
text: src_I18n.t("Description")
|
|
463547
464481
|
}),
|
|
463548
464482
|
width: "190px",
|
|
463549
464483
|
render: (_, record, index)=>/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
@@ -463553,7 +464487,7 @@ const getColumnsMap = (params)=>{
|
|
|
463553
464487
|
maxLength: 100,
|
|
463554
464488
|
field: `values.[${index}].description`,
|
|
463555
464489
|
noErrorMessage: true,
|
|
463556
|
-
placeholder:
|
|
464490
|
+
placeholder: src_I18n.t("Description"),
|
|
463557
464491
|
disabled: disabled || record.hide
|
|
463558
464492
|
})
|
|
463559
464493
|
})
|
|
@@ -463562,7 +464496,7 @@ const getColumnsMap = (params)=>{
|
|
|
463562
464496
|
key: "input_type",
|
|
463563
464497
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(baseForm_.Label, {
|
|
463564
464498
|
className: "leading-5 p-0 m-0",
|
|
463565
|
-
text:
|
|
464499
|
+
text: src_I18n.t("shortcut_modal_component_type"),
|
|
463566
464500
|
required: true
|
|
463567
464501
|
}),
|
|
463568
464502
|
render: (_, record, index)=>/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
@@ -463594,7 +464528,7 @@ const getColumnsMap = (params)=>{
|
|
|
463594
464528
|
key: "default_value",
|
|
463595
464529
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(baseForm_.Label, {
|
|
463596
464530
|
className: "leading-5 p-0 m-0",
|
|
463597
|
-
text:
|
|
464531
|
+
text: src_I18n.t("shortcut_modal_use_tool_parameter_default_value")
|
|
463598
464532
|
}),
|
|
463599
464533
|
render: (_, record, index)=>/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
463600
464534
|
className: "pl-[2px] max-w-[136px]",
|
|
@@ -463613,7 +464547,7 @@ const getColumnsMap = (params)=>{
|
|
|
463613
464547
|
key: "parameter",
|
|
463614
464548
|
title: /*#__PURE__*/ (0,jsx_runtime_.jsx)(baseForm_.Label, {
|
|
463615
464549
|
className: "leading-5 p-0 m-0",
|
|
463616
|
-
text:
|
|
464550
|
+
text: src_I18n.t("shortcut_modal_component_plugin_wf_parameter")
|
|
463617
464551
|
}),
|
|
463618
464552
|
dataIndex: "parameter",
|
|
463619
464553
|
render: (text)=>/*#__PURE__*/ (0,jsx_runtime_.jsx)(ComponentParameter, {
|
|
@@ -463718,7 +464652,7 @@ var components_table_index_module_update = injectStylesIntoStyleTag_default()(co
|
|
|
463718
464652
|
|
|
463719
464653
|
const tableEmpty = (useTool, selected)=>/*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
463720
464654
|
className: shortcut_edit_components_table_index_module_.empty,
|
|
463721
|
-
children: useTool ? selected ?
|
|
464655
|
+
children: useTool ? selected ? src_I18n.t("shortcut_modal_skill_has_no_param_tip") : src_I18n.t("shortcut_modal_skill_select_button") : src_I18n.t("shortcut_modal_form_to_be_filled_up_tip")
|
|
463722
464656
|
});
|
|
463723
464657
|
|
|
463724
464658
|
;// CONCATENATED MODULE: ../../../common/chat-area/plugin-chat-shortcuts/src/shortcut-tool/shortcut-edit/components-table/index.tsx
|
|
@@ -463779,7 +464713,7 @@ const ComponentsTable = /*#__PURE__*/ (/* unused pure expression or super */ nul
|
|
|
463779
464713
|
var _component_options;
|
|
463780
464714
|
return component.input_type === namespaces_shortcut_command_InputType.Select && !((_component_options = component.options) === null || _component_options === void 0 ? void 0 : _component_options.length);
|
|
463781
464715
|
})) {
|
|
463782
|
-
es_toast_.error(
|
|
464716
|
+
es_toast_.error(src_I18n.t("shortcut_modal_selector_component_no_options_error"));
|
|
463783
464717
|
throw Error("shortcut_modal_selector_component_no_options_error");
|
|
463784
464718
|
}
|
|
463785
464719
|
if (formRef.current && checkDuplicateName(values, formRef.current)) throw Error("duplicated names");
|
|
@@ -463843,10 +464777,10 @@ const ComponentsTable = /*#__PURE__*/ (/* unused pure expression or super */ nul
|
|
|
463843
464777
|
}
|
|
463844
464778
|
]);
|
|
463845
464779
|
},
|
|
463846
|
-
children:
|
|
464780
|
+
children: src_I18n.t("add")
|
|
463847
464781
|
});
|
|
463848
464782
|
const tipBtn = oversize ? /*#__PURE__*/ (0,jsx_runtime_.jsx)(tooltip_Tooltip, {
|
|
463849
|
-
content:
|
|
464783
|
+
content: src_I18n.t("shortcut_modal_max_component_tip", {
|
|
463850
464784
|
maxCount: components_table_MAX_COMPONENTS
|
|
463851
464785
|
}),
|
|
463852
464786
|
children: addBtn
|
|
@@ -463859,7 +464793,7 @@ const ComponentsTable = /*#__PURE__*/ (/* unused pure expression or super */ nul
|
|
|
463859
464793
|
children: [
|
|
463860
464794
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(field_label_, {
|
|
463861
464795
|
tip: compTip(),
|
|
463862
|
-
children:
|
|
464796
|
+
children: src_I18n.t("shortcut_modal_components")
|
|
463863
464797
|
}),
|
|
463864
464798
|
showAdd ? tipBtn : null
|
|
463865
464799
|
]
|
|
@@ -464333,7 +465267,7 @@ const useChatChatButtonInfo = (opList)=>{
|
|
|
464333
465267
|
width: "18px",
|
|
464334
465268
|
height: "18px"
|
|
464335
465269
|
}),
|
|
464336
|
-
text:
|
|
465270
|
+
text: src_I18n.t("web_sdk_add_new_conversation"),
|
|
464337
465271
|
disabled: isClearHistoryButtonDisabled || readonly,
|
|
464338
465272
|
onClick: ()=>{
|
|
464339
465273
|
clearHistory === null || clearHistory === void 0 || clearHistory();
|
|
@@ -464344,7 +465278,7 @@ const useChatChatButtonInfo = (opList)=>{
|
|
|
464344
465278
|
width: "18px",
|
|
464345
465279
|
height: "18px"
|
|
464346
465280
|
}),
|
|
464347
|
-
text:
|
|
465281
|
+
text: src_I18n.t("store_start_new_chat"),
|
|
464348
465282
|
disabled: isClearContextButtonDisabled || readonly,
|
|
464349
465283
|
onClick: ()=>{
|
|
464350
465284
|
clearContext();
|
|
@@ -464355,7 +465289,7 @@ const useChatChatButtonInfo = (opList)=>{
|
|
|
464355
465289
|
width: "18px",
|
|
464356
465290
|
height: "18px"
|
|
464357
465291
|
}),
|
|
464358
|
-
text:
|
|
465292
|
+
text: src_I18n.t("coze_home_delete_btn"),
|
|
464359
465293
|
disabled: isClearHistoryButtonDisabled || readonly,
|
|
464360
465294
|
onClick: ()=>{
|
|
464361
465295
|
clearHistory === null || clearHistory === void 0 || clearHistory();
|
|
@@ -464550,15 +465484,24 @@ var area_index_module_update = injectStylesIntoStyleTag_default()(area_index_mod
|
|
|
464550
465484
|
|
|
464551
465485
|
|
|
464552
465486
|
|
|
465487
|
+
// Tab index constant for chat area container
|
|
465488
|
+
const CHAT_AREA_TAB_INDEX = 1000;
|
|
464553
465489
|
// eslint-disable-next-line complexity
|
|
464554
465490
|
const StudioChatArea = (param)=>{
|
|
464555
|
-
let { coreAreaClassName, className, showInputArea = true, inputPlaceholder, inputNativeCallbacks, messageGroupListClassName, renderChatInputTopSlot, renderChatInputRightActions, isShowClearContextDivider, headerNode, messageMaxWidth, isMiniScreen, enableMultimodalUpload = false, uiKitCustomComponents, contentBox, getMessageRenderIndex, inputMode, onboardingPrologue, showOnboardingBotInfo, showOnboardingSuggestions } = param;
|
|
464556
|
-
var _chatConfig_ui_chatBot, _chatConfig_ui, _chatConfig_ui_chatBot1, _chatConfig_ui1, _chatConfig_ui_footer, _chatConfig_ui2
|
|
465491
|
+
let { coreAreaClassName, className, showInputArea = true, inputPlaceholder, inputNativeCallbacks, messageGroupListClassName, renderChatInputTopSlot, renderChatInputRightActions, isShowClearContextDivider, headerNode, messageMaxWidth, isMiniScreen, enableMultimodalUpload = false, uiKitCustomComponents, contentBox, getMessageRenderIndex, inputMode, input, onboardingPrologue, showOnboardingBotInfo, showOnboardingSuggestions } = param;
|
|
465492
|
+
var _chatConfig_ui_chatBot, _chatConfig_ui, _chatConfig_ui_chatBot1, _chatConfig_ui1, _chatConfig_ui_footer, _chatConfig_ui2, _input_uploadConfig, _chatConfig_ui_input_uploadConfig, _chatConfig_ui_input, // eslint-disable-next-line @typescript-eslint/no-explicit-any -- chatConfig.ui type may not include input field in all contexts
|
|
465493
|
+
_chatConfig_ui3, _chatConfig_appInfo, _chatConfig_auth, _chatConfig_appInfo1, _chatConfig_appInfo2, _chatConfig_appInfo3, _chatConfig_auth1;
|
|
464557
465494
|
const initStatus = useInitStatus();
|
|
464558
465495
|
const { layout, onInitStateChange, chatConfig } = context_useChatAppProps();
|
|
464559
465496
|
const refContainer = (0,react_.useRef)(null);
|
|
464560
465497
|
const { readonly } = context_useChatAppProps();
|
|
464561
465498
|
const currentConversationInfo = context_useChatAppStore((state)=>state.currentConversationInfo);
|
|
465499
|
+
const updateConversations = context_useChatAppStore((state)=>state.updateConversations);
|
|
465500
|
+
const conversations = context_useChatAppStore((state)=>state.conversations);
|
|
465501
|
+
// Get apiUrl from store for knowledge upload
|
|
465502
|
+
const apiUrl = context_useChatAppStore((state)=>state.apiUrl);
|
|
465503
|
+
// Get updateCurrentConversationInfo from store for knowledge upload
|
|
465504
|
+
const updateCurrentConversationInfo = context_useChatAppStore((state)=>state.updateCurrentConversationInfo);
|
|
464562
465505
|
// 空会话的判断:id 为空字符串
|
|
464563
465506
|
const isEmptyConversation = !currentConversationInfo || currentConversationInfo.id === "";
|
|
464564
465507
|
const InputRightActionsComponent = (0,react_.useMemo)(()=>renderChatInputRightActions ? (()=>{
|
|
@@ -464605,7 +465548,7 @@ const StudioChatArea = (param)=>{
|
|
|
464605
465548
|
className: classnames_default()(studio_open_chat_area_index_module_.area, className, {
|
|
464606
465549
|
[studio_open_chat_area_index_module_.disabled]: readonly
|
|
464607
465550
|
}),
|
|
464608
|
-
tabIndex:
|
|
465551
|
+
tabIndex: CHAT_AREA_TAB_INDEX,
|
|
464609
465552
|
ref: refContainer,
|
|
464610
465553
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(ChatArea, {
|
|
464611
465554
|
classname: coreAreaClassName,
|
|
@@ -464618,7 +465561,7 @@ const StudioChatArea = (param)=>{
|
|
|
464618
465561
|
showStopRespond: true,
|
|
464619
465562
|
enableLegacyUpload: enableLegacyUploadFlag,
|
|
464620
465563
|
enableMultimodalUpload: enableMultimodalUploadFlag,
|
|
464621
|
-
fileLimit: enableMultimodalUploadFlag ?
|
|
465564
|
+
fileLimit: enableMultimodalUploadFlag ? 10 : undefined,
|
|
464622
465565
|
textareaPlaceholder: inputPlaceholder || intl_i18n.t("chatInputPlaceholder"),
|
|
464623
465566
|
enableMessageBoxActionBar: true,
|
|
464624
465567
|
chatInputProps: {
|
|
@@ -464626,7 +465569,50 @@ const StudioChatArea = (param)=>{
|
|
|
464626
465569
|
inputNativeCallbacks,
|
|
464627
465570
|
safeAreaClassName: (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_ui2 = chatConfig.ui) === null || _chatConfig_ui2 === void 0 ? void 0 : (_chatConfig_ui_footer = _chatConfig_ui2.footer) === null || _chatConfig_ui_footer === void 0 ? void 0 : _chatConfig_ui_footer.isShow) !== false ? studio_open_chat_area_index_module_["safe-area"] : "",
|
|
464628
465571
|
leftActions: /*#__PURE__*/ (0,jsx_runtime_.jsx)(ChatInputLeftSlot, {}),
|
|
464629
|
-
inputMode
|
|
465572
|
+
inputMode,
|
|
465573
|
+
componentProps: {
|
|
465574
|
+
copywritingConfig: {
|
|
465575
|
+
uploadConfig: {
|
|
465576
|
+
uploadToKnowledge: (input === null || input === void 0 ? void 0 : (_input_uploadConfig = input.uploadConfig) === null || _input_uploadConfig === void 0 ? void 0 : _input_uploadConfig.uploadToKnowledge) ?? (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_ui3 = chatConfig.ui) === null || _chatConfig_ui3 === void 0 ? void 0 : (_chatConfig_ui_input = _chatConfig_ui3.input) === null || _chatConfig_ui_input === void 0 ? void 0 : (_chatConfig_ui_input_uploadConfig = _chatConfig_ui_input.uploadConfig) === null || _chatConfig_ui_input_uploadConfig === void 0 ? void 0 : _chatConfig_ui_input_uploadConfig.uploadToKnowledge) ?? true
|
|
465577
|
+
}
|
|
465578
|
+
},
|
|
465579
|
+
// Pass knowledge upload config
|
|
465580
|
+
knowledgeUploadConfig: {
|
|
465581
|
+
apiUrl,
|
|
465582
|
+
appId: (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),
|
|
465583
|
+
token: chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_auth = chatConfig.auth) === null || _chatConfig_auth === void 0 ? void 0 : _chatConfig_auth.token,
|
|
465584
|
+
workflowId: chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo1 = chatConfig.appInfo) === null || _chatConfig_appInfo1 === void 0 ? void 0 : _chatConfig_appInfo1.workflowId,
|
|
465585
|
+
draftMode: chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo2 = chatConfig.appInfo) === null || _chatConfig_appInfo2 === void 0 ? void 0 : _chatConfig_appInfo2.draft_mode,
|
|
465586
|
+
conversationName: chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo3 = chatConfig.appInfo) === null || _chatConfig_appInfo3 === void 0 ? void 0 : _chatConfig_appInfo3.conversationName,
|
|
465587
|
+
connectorId: chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_auth1 = chatConfig.auth) === null || _chatConfig_auth1 === void 0 ? void 0 : _chatConfig_auth1.connectorId,
|
|
465588
|
+
chatType: chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.type,
|
|
465589
|
+
// Pass updateCurrentConversationInfo callback so file upload can update the store
|
|
465590
|
+
updateCurrentConversationInfo: (info)=>{
|
|
465591
|
+
// Update currentConversationInfo with the new conversation info
|
|
465592
|
+
updateCurrentConversationInfo({
|
|
465593
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- currentConversationInfo may have additional fields not in type definition
|
|
465594
|
+
...currentConversationInfo,
|
|
465595
|
+
id: info.id,
|
|
465596
|
+
last_section_id: info.last_section_id,
|
|
465597
|
+
name: info.name
|
|
465598
|
+
});
|
|
465599
|
+
// 上传文件创建新会话时,将会话加入会话历史列表,否则列表中看不到新会话
|
|
465600
|
+
if (info.id && !conversations.some((c)=>c.id === info.id)) {
|
|
465601
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
465602
|
+
updateConversations([
|
|
465603
|
+
{
|
|
465604
|
+
id: info.id,
|
|
465605
|
+
last_section_id: info.last_section_id ?? "",
|
|
465606
|
+
name: info.name ?? "",
|
|
465607
|
+
created_at: timestamp,
|
|
465608
|
+
updated_at: timestamp,
|
|
465609
|
+
meta_data: {}
|
|
465610
|
+
}
|
|
465611
|
+
], "add");
|
|
465612
|
+
}
|
|
465613
|
+
}
|
|
465614
|
+
}
|
|
465615
|
+
}
|
|
464630
465616
|
},
|
|
464631
465617
|
componentTypes: chatAreaComponentTypes,
|
|
464632
465618
|
readonly: readonly,
|
|
@@ -464911,10 +465897,10 @@ const ChatHeader = (param)=>{
|
|
|
464911
465897
|
},
|
|
464912
465898
|
visible: isRenameModalVisible,
|
|
464913
465899
|
onCancel: ()=>setIsRenameModalVisible(false),
|
|
464914
|
-
title:
|
|
465900
|
+
title: src_I18n.t("web_sdk_rename_conversation", {}, "重命名会话"),
|
|
464915
465901
|
onOk: handleRenameConfirm,
|
|
464916
|
-
okText:
|
|
464917
|
-
cancelText:
|
|
465902
|
+
okText: src_I18n.t("web_sdk_confirm", {}, "确定"),
|
|
465903
|
+
cancelText: src_I18n.t("web_sdk_cancel", {}, "取消"),
|
|
464918
465904
|
okButtonColor: "brand",
|
|
464919
465905
|
closable: false,
|
|
464920
465906
|
maskClosable: false,
|
|
@@ -464922,7 +465908,7 @@ const ChatHeader = (param)=>{
|
|
|
464922
465908
|
maxWidth: "80%"
|
|
464923
465909
|
},
|
|
464924
465910
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Input, {
|
|
464925
|
-
placeholder:
|
|
465911
|
+
placeholder: src_I18n.t("web_sdk_conversation_placeholder", {}, "请输入会话名称"),
|
|
464926
465912
|
value: renameInputValue,
|
|
464927
465913
|
maxLength: 100,
|
|
464928
465914
|
onChange: (value)=>setRenameInputValue(value),
|
|
@@ -465131,10 +466117,10 @@ const ChatHeaderMobile = (param)=>{
|
|
|
465131
466117
|
},
|
|
465132
466118
|
visible: isRenameModalVisible,
|
|
465133
466119
|
onCancel: ()=>setIsRenameModalVisible(false),
|
|
465134
|
-
title:
|
|
466120
|
+
title: src_I18n.t("web_sdk_rename_conversation", {}, "重命名会话"),
|
|
465135
466121
|
onOk: handleRenameConfirm,
|
|
465136
|
-
okText:
|
|
465137
|
-
cancelText:
|
|
466122
|
+
okText: src_I18n.t("web_sdk_confirm", {}, "确定"),
|
|
466123
|
+
cancelText: src_I18n.t("web_sdk_cancel", {}, "取消"),
|
|
465138
466124
|
okButtonColor: "brand",
|
|
465139
466125
|
closable: false,
|
|
465140
466126
|
maskClosable: false,
|
|
@@ -465142,7 +466128,7 @@ const ChatHeaderMobile = (param)=>{
|
|
|
465142
466128
|
maxWidth: "80%"
|
|
465143
466129
|
},
|
|
465144
466130
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Input, {
|
|
465145
|
-
placeholder:
|
|
466131
|
+
placeholder: src_I18n.t("web_sdk_conversation_placeholder", {}, "请输入会话名称"),
|
|
465146
466132
|
value: renameInputValue,
|
|
465147
466133
|
maxLength: 100,
|
|
465148
466134
|
onChange: (value)=>setRenameInputValue(value),
|
|
@@ -465206,7 +466192,7 @@ const FloatBtn = ()=>{
|
|
|
465206
466192
|
currentConversationInfo: s.currentConversationInfo
|
|
465207
466193
|
})));
|
|
465208
466194
|
return (currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.conversationListVisible) ? null : /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Tooltip, {
|
|
465209
|
-
content:
|
|
466195
|
+
content: src_I18n.t("web_sdk_open_conversations"),
|
|
465210
466196
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_IconButton, {
|
|
465211
466197
|
className: components_header_index_module_["float-open-conversations-btn"],
|
|
465212
466198
|
size: "small",
|
|
@@ -465279,12 +466265,12 @@ var footer_index_module_update = injectStylesIntoStyleTag_default()(footer_index
|
|
|
465279
466265
|
|
|
465280
466266
|
|
|
465281
466267
|
|
|
465282
|
-
const getDefaultText = ()=>
|
|
466268
|
+
const getDefaultText = ()=>src_I18n.t("web_sdk_official_banner", {
|
|
465283
466269
|
docs_link: /*#__PURE__*/ (0,jsx_runtime_.jsx)("a", {
|
|
465284
466270
|
className: components_footer_index_module_.link,
|
|
465285
466271
|
href: cozeOfficialHost,
|
|
465286
466272
|
target: "_blank",
|
|
465287
|
-
children:
|
|
466273
|
+
children: src_I18n.t("web_sdk_official_banner_link")
|
|
465288
466274
|
}, "web_sdk_official_banner")
|
|
465289
466275
|
});
|
|
465290
466276
|
const getTextByExpress = (expressionText, linkvars)=>{
|
|
@@ -465373,13 +466359,13 @@ var error_fallback_index_module_update = injectStylesIntoStyleTag_default()(erro
|
|
|
465373
466359
|
|
|
465374
466360
|
const error_fallback_ErrorFallback = (param)=>{
|
|
465375
466361
|
let { error, onBeforeRetry, refresh } = param;
|
|
465376
|
-
let msg =
|
|
466362
|
+
let msg = src_I18n.t("overview_bi_assistant_system_error");
|
|
465377
466363
|
if (error) {
|
|
465378
466364
|
msg = error.msg;
|
|
465379
466365
|
const wrapError = getServerError(error);
|
|
465380
466366
|
if (wrapError) msg = wrapError.msg;
|
|
465381
466367
|
}
|
|
465382
|
-
const defaultError =
|
|
466368
|
+
const defaultError = src_I18n.t("web_sdk_retry_notification");
|
|
465383
466369
|
const hideExtra = !!(error === null || error === void 0 ? void 0 : error.code) && specCodeList.includes(error.code);
|
|
465384
466370
|
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
465385
466371
|
className: components_error_fallback_index_module_.wrapper,
|
|
@@ -465394,7 +466380,7 @@ const error_fallback_ErrorFallback = (param)=>{
|
|
|
465394
466380
|
}),
|
|
465395
466381
|
!hideExtra && /*#__PURE__*/ (0,jsx_runtime_.jsx)("div", {
|
|
465396
466382
|
className: components_error_fallback_index_module_.extra,
|
|
465397
|
-
children:
|
|
466383
|
+
children: src_I18n.t(`web_sdk_api_error_${error === null || error === void 0 ? void 0 : error.code}`, {}, defaultError)
|
|
465398
466384
|
}),
|
|
465399
466385
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(esm_webpack_exports_Button, {
|
|
465400
466386
|
className: components_error_fallback_index_module_.btn,
|
|
@@ -465403,7 +466389,7 @@ const error_fallback_ErrorFallback = (param)=>{
|
|
|
465403
466389
|
if (refresh) refresh === null || refresh === void 0 || refresh();
|
|
465404
466390
|
else location.reload();
|
|
465405
466391
|
},
|
|
465406
|
-
children:
|
|
466392
|
+
children: src_I18n.t("retry")
|
|
465407
466393
|
})
|
|
465408
466394
|
]
|
|
465409
466395
|
});
|
|
@@ -465443,10 +466429,10 @@ const { Title: error_boundary_Title, Text: error_boundary_Text } = es_typography
|
|
|
465443
466429
|
const error_boundary_FallbackComponent = ()=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
465444
466430
|
children: [
|
|
465445
466431
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(error_boundary_Title, {
|
|
465446
|
-
children:
|
|
466432
|
+
children: src_I18n.t("404_title")
|
|
465447
466433
|
}),
|
|
465448
466434
|
/*#__PURE__*/ (0,jsx_runtime_.jsx)(error_boundary_Text, {
|
|
465449
|
-
children:
|
|
466435
|
+
children: src_I18n.t("404_content")
|
|
465450
466436
|
})
|
|
465451
466437
|
]
|
|
465452
466438
|
});
|
|
@@ -466315,6 +467301,7 @@ const useInitChat = (props)=>{
|
|
|
466315
467301
|
|
|
466316
467302
|
|
|
466317
467303
|
|
|
467304
|
+
// eslint-disable-next-line
|
|
466318
467305
|
const use_core_manager_useCoreManager = (props)=>{
|
|
466319
467306
|
const refProps = (0,react_.useRef)(props);
|
|
466320
467307
|
const appData = useGetAppDataCombineWithProps();
|
|
@@ -466330,7 +467317,8 @@ const use_core_manager_useCoreManager = (props)=>{
|
|
|
466330
467317
|
}, [
|
|
466331
467318
|
props.apiUrl
|
|
466332
467319
|
]);
|
|
466333
|
-
return (0,react_.useMemo)(
|
|
467320
|
+
return (0,react_.useMemo)(// eslint-disable-next-line
|
|
467321
|
+
()=>({
|
|
466334
467322
|
// 添加统一的 baseURL
|
|
466335
467323
|
baseURL: finalApiUrl,
|
|
466336
467324
|
scenes: {
|
|
@@ -466352,7 +467340,109 @@ const use_core_manager_useCoreManager = (props)=>{
|
|
|
466352
467340
|
const processedParameters = {
|
|
466353
467341
|
...workflowParameters
|
|
466354
467342
|
};
|
|
466355
|
-
|
|
467343
|
+
// 从 ext 字段或顶层字段中收集文件的 knowledge_id(如果存在)
|
|
467344
|
+
const knowledgeIds = new Set();
|
|
467345
|
+
// 从 ext 字段或顶层字段中收集图片文件的 url(如果存在)
|
|
467346
|
+
const imageUrls = new Set();
|
|
467347
|
+
// 检查顶层是否有 knowledge_ids(extendFiled 被合并到顶层)
|
|
467348
|
+
if (bodyDataOld.knowledge_ids) {
|
|
467349
|
+
const topLevelKnowledgeIds = Array.isArray(bodyDataOld.knowledge_ids) ? bodyDataOld.knowledge_ids : typeof bodyDataOld.knowledge_ids === "string" ? JSON.parse(bodyDataOld.knowledge_ids) : [];
|
|
467350
|
+
for (const id of topLevelKnowledgeIds)if (id) knowledgeIds.add(String(id));
|
|
467351
|
+
}
|
|
467352
|
+
// 检查顶层是否有 image_urls(extendFiled 被合并到顶层)
|
|
467353
|
+
if (bodyDataOld.image_urls) {
|
|
467354
|
+
const topLevelImageUrls = Array.isArray(bodyDataOld.image_urls) ? bodyDataOld.image_urls : typeof bodyDataOld.image_urls === "string" ? JSON.parse(bodyDataOld.image_urls) : [];
|
|
467355
|
+
for (const url of topLevelImageUrls)if (url) imageUrls.add(String(url));
|
|
467356
|
+
}
|
|
467357
|
+
// 检查 ext 字段中是否有 knowledge_ids
|
|
467358
|
+
if (bodyDataOld.ext && typeof bodyDataOld.ext === "object") {
|
|
467359
|
+
const ext = bodyDataOld.ext;
|
|
467360
|
+
// 检查 ext 中是否有 knowledge_ids 字段
|
|
467361
|
+
if (ext.knowledge_ids) {
|
|
467362
|
+
const extKnowledgeIds = Array.isArray(ext.knowledge_ids) ? ext.knowledge_ids : typeof ext.knowledge_ids === "string" ? JSON.parse(ext.knowledge_ids) : [];
|
|
467363
|
+
for (const id of extKnowledgeIds)if (id) knowledgeIds.add(String(id));
|
|
467364
|
+
}
|
|
467365
|
+
// 检查 ext 中是否有 image_urls 字段
|
|
467366
|
+
if (ext.image_urls) {
|
|
467367
|
+
const extImageUrls = Array.isArray(ext.image_urls) ? ext.image_urls : typeof ext.image_urls === "string" ? JSON.parse(ext.image_urls) : [];
|
|
467368
|
+
for (const url of extImageUrls)if (url) imageUrls.add(String(url));
|
|
467369
|
+
}
|
|
467370
|
+
}
|
|
467371
|
+
// 从前一个 hook 的 body 中提取 parameters.SETTING
|
|
467372
|
+
// 这里可能包含对话流入参配置中传递的 SETTING 字段
|
|
467373
|
+
let prevHookSetting = {};
|
|
467374
|
+
if (bodyDataOld.parameters) try {
|
|
467375
|
+
const prevParams = typeof bodyDataOld.parameters === "string" ? JSON.parse(bodyDataOld.parameters) : bodyDataOld.parameters;
|
|
467376
|
+
if (prevParams === null || prevParams === void 0 ? void 0 : prevParams.SETTING) {
|
|
467377
|
+
if (typeof prevParams.SETTING === "string") try {
|
|
467378
|
+
prevHookSetting = JSON.parse(prevParams.SETTING);
|
|
467379
|
+
} catch {
|
|
467380
|
+
prevHookSetting = {};
|
|
467381
|
+
}
|
|
467382
|
+
else if (typeof prevParams.SETTING === "object") prevHookSetting = {
|
|
467383
|
+
...prevParams.SETTING
|
|
467384
|
+
};
|
|
467385
|
+
}
|
|
467386
|
+
} catch {
|
|
467387
|
+
// 解析失败则忽略
|
|
467388
|
+
console.error("parse prevParams.SETTING failed");
|
|
467389
|
+
}
|
|
467390
|
+
// 处理 SETTING 字段
|
|
467391
|
+
// 先将 processedParameters.SETTING 统一解析为对象(可能是字符串或对象)
|
|
467392
|
+
let workflowSetting = {};
|
|
467393
|
+
if (processedParameters.SETTING) {
|
|
467394
|
+
if (typeof processedParameters.SETTING === "string") try {
|
|
467395
|
+
workflowSetting = JSON.parse(processedParameters.SETTING);
|
|
467396
|
+
} catch {
|
|
467397
|
+
workflowSetting = {};
|
|
467398
|
+
}
|
|
467399
|
+
else if (typeof processedParameters.SETTING === "object") workflowSetting = {
|
|
467400
|
+
...processedParameters.SETTING
|
|
467401
|
+
};
|
|
467402
|
+
}
|
|
467403
|
+
// 判断是否有需要处理的 SETTING 内容
|
|
467404
|
+
const hasWorkflowSetting = Object.keys(workflowSetting).length > 0;
|
|
467405
|
+
const hasPrevHookSetting = Object.keys(prevHookSetting).length > 0;
|
|
467406
|
+
if (hasWorkflowSetting || hasPrevHookSetting || knowledgeIds.size > 0 || imageUrls.size > 0) {
|
|
467407
|
+
// 合并 SETTING:prevHookSetting 作为基础,workflowSetting 的字段优先级更高
|
|
467408
|
+
const setting = {
|
|
467409
|
+
...prevHookSetting,
|
|
467410
|
+
...workflowSetting
|
|
467411
|
+
};
|
|
467412
|
+
// 获取现有的 KNOWLEDGE_IDS
|
|
467413
|
+
let existingKnowledgeIds = [];
|
|
467414
|
+
if (typeof setting.KNOWLEDGE_IDS === "string") try {
|
|
467415
|
+
existingKnowledgeIds = JSON.parse(setting.KNOWLEDGE_IDS);
|
|
467416
|
+
} catch {
|
|
467417
|
+
if (Array.isArray(setting.KNOWLEDGE_IDS)) existingKnowledgeIds = setting.KNOWLEDGE_IDS.map(String);
|
|
467418
|
+
}
|
|
467419
|
+
else if (Array.isArray(setting.KNOWLEDGE_IDS)) existingKnowledgeIds = setting.KNOWLEDGE_IDS.map(String);
|
|
467420
|
+
// 合并 knowledge_id,去重
|
|
467421
|
+
const allKnowledgeIds = [
|
|
467422
|
+
...existingKnowledgeIds,
|
|
467423
|
+
...Array.from(knowledgeIds)
|
|
467424
|
+
];
|
|
467425
|
+
const uniqueKnowledgeIds = Array.from(new Set(allKnowledgeIds));
|
|
467426
|
+
// 更新 KNOWLEDGE_IDS
|
|
467427
|
+
if (uniqueKnowledgeIds.length > 0) setting.KNOWLEDGE_IDS = uniqueKnowledgeIds;
|
|
467428
|
+
// 获取现有的 IMAGE_URLS
|
|
467429
|
+
let existingImageUrls = [];
|
|
467430
|
+
if (typeof setting.IMAGE_URLS === "string") try {
|
|
467431
|
+
existingImageUrls = JSON.parse(setting.IMAGE_URLS);
|
|
467432
|
+
} catch {
|
|
467433
|
+
if (Array.isArray(setting.IMAGE_URLS)) existingImageUrls = setting.IMAGE_URLS.map(String);
|
|
467434
|
+
}
|
|
467435
|
+
else if (Array.isArray(setting.IMAGE_URLS)) existingImageUrls = setting.IMAGE_URLS.map(String);
|
|
467436
|
+
// 合并 image_urls,去重
|
|
467437
|
+
const allImageUrls = [
|
|
467438
|
+
...existingImageUrls,
|
|
467439
|
+
...Array.from(imageUrls)
|
|
467440
|
+
];
|
|
467441
|
+
const uniqueImageUrls = Array.from(new Set(allImageUrls));
|
|
467442
|
+
// 更新 IMAGE_URLS
|
|
467443
|
+
if (uniqueImageUrls.length > 0) setting.IMAGE_URLS = uniqueImageUrls;
|
|
467444
|
+
processedParameters.SETTING = JSON.stringify(setting);
|
|
467445
|
+
}
|
|
466356
467446
|
bodyData.parameters = processedParameters;
|
|
466357
467447
|
} else bodyData.parameters = workflowParameters;
|
|
466358
467448
|
bodyData.version = (refProps === null || refProps === void 0 ? void 0 : (_refProps_current2 = refProps.current) === null || _refProps_current2 === void 0 ? void 0 : (_refProps_current_project = _refProps_current2.project) === null || _refProps_current_project === void 0 ? void 0 : _refProps_current_project.version) || undefined;
|
|
@@ -466363,7 +467453,9 @@ const use_core_manager_useCoreManager = (props)=>{
|
|
|
466363
467453
|
bodyData.connector_id = getConnectorId(refProps === null || refProps === void 0 ? void 0 : refProps.current);
|
|
466364
467454
|
bodyData.ext = {
|
|
466365
467455
|
_caller: refProps === null || refProps === void 0 ? void 0 : (_refProps_current8 = refProps.current) === null || _refProps_current8 === void 0 ? void 0 : (_refProps_current_project6 = _refProps_current8.project) === null || _refProps_current_project6 === void 0 ? void 0 : _refProps_current_project6.caller,
|
|
466366
|
-
user_id: bodyDataOld.user_id
|
|
467456
|
+
user_id: bodyDataOld.user_id,
|
|
467457
|
+
// 保留原有的 ext 字段(可能包含 knowledge_ids)
|
|
467458
|
+
...bodyDataOld.ext && typeof bodyDataOld.ext === "object" ? bodyDataOld.ext : {}
|
|
466367
467459
|
};
|
|
466368
467460
|
bodyData.suggest_reply_info = ((_refAppData_current = refAppData.current) === null || _refAppData_current === void 0 ? void 0 : _refAppData_current.suggestPromoteInfo) ? {
|
|
466369
467461
|
suggest_reply_mode: (_refAppData_current1 = refAppData.current) === null || _refAppData_current1 === void 0 ? void 0 : (_refAppData_current_suggestPromoteInfo = _refAppData_current1.suggestPromoteInfo) === null || _refAppData_current_suggestPromoteInfo === void 0 ? void 0 : _refAppData_current_suggestPromoteInfo.suggestReplyMode,
|
|
@@ -466773,7 +467865,7 @@ const BuilderChatContent = /*#__PURE__*/ (0,react_.forwardRef)((param, ref)=>{
|
|
|
466773
467865
|
...chatProps,
|
|
466774
467866
|
...areaUi || {},
|
|
466775
467867
|
coreAreaClassName: chat_builder_chat_index_module_["core-area"],
|
|
466776
|
-
inputPlaceholder: (areaUi === null || areaUi === void 0 ? void 0 : (_areaUi_input3 = areaUi.input) === null || _areaUi_input3 === void 0 ? void 0 : _areaUi_input3.placeholder) ||
|
|
467868
|
+
inputPlaceholder: (areaUi === null || areaUi === void 0 ? void 0 : (_areaUi_input3 = areaUi.input) === null || _areaUi_input3 === void 0 ? void 0 : _areaUi_input3.placeholder) || src_I18n.t("chatInputPlaceholder"),
|
|
466777
467869
|
messageMaxWidth: (uiBuilderProps === null || uiBuilderProps === void 0 ? void 0 : (_uiBuilderProps_project1 = uiBuilderProps.project) === null || _uiBuilderProps_project1 === void 0 ? void 0 : _uiBuilderProps_project1.mode) !== "websdk" ? "600px" : undefined,
|
|
466778
467870
|
enableMultimodalUpload: true,
|
|
466779
467871
|
showInputArea: areaUi === null || areaUi === void 0 ? void 0 : (_areaUi_input4 = areaUi.input) === null || _areaUi_input4 === void 0 ? void 0 : _areaUi_input4.isShow,
|
|
@@ -466838,7 +467930,7 @@ const BuilderChatWrap = (param)=>{
|
|
|
466838
467930
|
}
|
|
466839
467931
|
};
|
|
466840
467932
|
if (((_props_project1 = props.project) === null || _props_project1 === void 0 ? void 0 : _props_project1.mode) !== "websdk") {
|
|
466841
|
-
if (!footerConfig.expressionText) footerConfig.expressionText =
|
|
467933
|
+
if (!footerConfig.expressionText) footerConfig.expressionText = src_I18n.t("chat_GenAI_tips");
|
|
466842
467934
|
}
|
|
466843
467935
|
if (initStatus !== "initSuccess") {
|
|
466844
467936
|
var _props_areaUi_renderLoading, _props_areaUi2;
|
|
@@ -467172,7 +468264,7 @@ var non_iframe_app_index_module_update = injectStylesIntoStyleTag_default()(non_
|
|
|
467172
468264
|
|
|
467173
468265
|
const NonIframeApp = (param)=>{
|
|
467174
468266
|
let { client, onImageClick, uiKitCustomComponents, contentBox } = param;
|
|
467175
|
-
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,
|
|
468267
|
+
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_ui_input6, _options_ui19, _options_ui20, _options_ui21, _options_ui22, _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_ui23, _options_config_appInfo5, _options_userInfo, _options_userInfo1, _options_userInfo2, _options_auth, _options_auth1;
|
|
467176
468268
|
const options = client === null || client === void 0 ? void 0 : client.options;
|
|
467177
468269
|
const setThemeType = useGlobalStore((s)=>s.setThemeType);
|
|
467178
468270
|
const isNeedExtra = (options === null || options === void 0 ? void 0 : (_options_ui = options.ui) === null || _options_ui === void 0 ? void 0 : (_options_ui_header = _options_ui.header) === null || _options_ui_header === void 0 ? void 0 : _options_ui_header.isNeedClose) ?? true;
|
|
@@ -467205,11 +468297,12 @@ const NonIframeApp = (param)=>{
|
|
|
467205
468297
|
placeholder: options === null || options === void 0 ? void 0 : (_options_ui15 = options.ui) === null || _options_ui15 === void 0 ? void 0 : (_options_ui_input2 = _options_ui15.input) === null || _options_ui_input2 === void 0 ? void 0 : _options_ui_input2.placeholder,
|
|
467206
468298
|
isShow: options === null || options === void 0 ? void 0 : (_options_ui16 = options.ui) === null || _options_ui16 === void 0 ? void 0 : (_options_ui_input3 = _options_ui16.input) === null || _options_ui_input3 === void 0 ? void 0 : _options_ui_input3.isShow,
|
|
467207
468299
|
defaultText: options === null || options === void 0 ? void 0 : (_options_ui17 = options.ui) === null || _options_ui17 === void 0 ? void 0 : (_options_ui_input4 = _options_ui17.input) === null || _options_ui_input4 === void 0 ? void 0 : _options_ui_input4.defaultText,
|
|
467208
|
-
inputMode: options === null || options === void 0 ? void 0 : (_options_ui18 = options.ui) === null || _options_ui18 === void 0 ? void 0 : (_options_ui_input5 = _options_ui18.input) === null || _options_ui_input5 === void 0 ? void 0 : _options_ui_input5.inputMode
|
|
468300
|
+
inputMode: options === null || options === void 0 ? void 0 : (_options_ui18 = options.ui) === null || _options_ui18 === void 0 ? void 0 : (_options_ui_input5 = _options_ui18.input) === null || _options_ui_input5 === void 0 ? void 0 : _options_ui_input5.inputMode,
|
|
468301
|
+
uploadConfig: options === null || options === void 0 ? void 0 : (_options_ui19 = options.ui) === null || _options_ui19 === void 0 ? void 0 : (_options_ui_input6 = _options_ui19.input) === null || _options_ui_input6 === void 0 ? void 0 : _options_ui_input6.uploadConfig
|
|
467209
468302
|
},
|
|
467210
|
-
footer: options === null || options === void 0 ? void 0 : (
|
|
467211
|
-
onboarding: options === null || options === void 0 ? void 0 : (
|
|
467212
|
-
getMessageRenderIndex: options === null || options === void 0 ? void 0 : (
|
|
468303
|
+
footer: options === null || options === void 0 ? void 0 : (_options_ui20 = options.ui) === null || _options_ui20 === void 0 ? void 0 : _options_ui20.footer,
|
|
468304
|
+
onboarding: options === null || options === void 0 ? void 0 : (_options_ui21 = options.ui) === null || _options_ui21 === void 0 ? void 0 : _options_ui21.onboarding,
|
|
468305
|
+
getMessageRenderIndex: options === null || options === void 0 ? void 0 : (_options_ui22 = options.ui) === null || _options_ui22 === void 0 ? void 0 : _options_ui22.getMessageRenderIndex
|
|
467213
468306
|
};
|
|
467214
468307
|
return /*#__PURE__*/ (0,jsx_runtime_.jsx)(CommentProviderWrapper, {
|
|
467215
468308
|
client: client,
|
|
@@ -467228,7 +468321,7 @@ const NonIframeApp = (param)=>{
|
|
|
467228
468321
|
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" : "websdk",
|
|
467229
468322
|
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) || "",
|
|
467230
468323
|
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,
|
|
467231
|
-
layout: options === null || options === void 0 ? void 0 : (
|
|
468324
|
+
layout: options === null || options === void 0 ? void 0 : (_options_ui23 = options.ui) === null || _options_ui23 === void 0 ? void 0 : (_options_ui_base1 = _options_ui23.base) === null || _options_ui_base1 === void 0 ? void 0 : _options_ui_base1.layout,
|
|
467232
468325
|
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
|
|
467233
468326
|
},
|
|
467234
468327
|
userInfo: {
|
|
@@ -504857,4 +505950,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
|
|
|
504857
505950
|
}
|
|
504858
505951
|
|
|
504859
505952
|
}();
|
|
504860
|
-
var __webpack_exports__ = __webpack_require__("
|
|
505953
|
+
var __webpack_exports__ = __webpack_require__("68913");
|