isdata-customer-sdk 0.1.74 → 0.1.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -29562,7 +29562,6 @@ __webpack_require__.r(__webpack_exports__);
29562
29562
  // EXPORTS
29563
29563
  __webpack_require__.d(__webpack_exports__, {
29564
29564
  ChatClientMgr: function() { return /* reexport */ ChatClientMgr; },
29565
- addAndCleanDocument: function() { return /* reexport */ addAndCleanDocument; },
29566
29565
  addEventAction: function() { return /* reexport */ addEventAction; },
29567
29566
  addIMMapping: function() { return /* reexport */ addIMMapping; },
29568
29567
  addObjectUsedTimes: function() { return /* reexport */ addObjectUsedTimes; },
@@ -29621,6 +29620,7 @@ __webpack_require__.d(__webpack_exports__, {
29621
29620
  removeEventAction: function() { return /* reexport */ removeEventAction; },
29622
29621
  removeEventListener: function() { return /* reexport */ removeEventListener; },
29623
29622
  removeWindowTrustedOrigin: function() { return /* reexport */ removeWindowTrustedOrigin; },
29623
+ sendPostToAIAgent: function() { return /* reexport */ sendPostToAIAgent; },
29624
29624
  sendWindowMessage: function() { return /* reexport */ sendWindowMessage; },
29625
29625
  setPortalPageConfig: function() { return /* reexport */ setPortalPageConfig; },
29626
29626
  switchPortalLogin: function() { return /* reexport */ switchPortalLogin; },
@@ -31029,7 +31029,6 @@ class ChatClientMgr {
31029
31029
  this.customParams = params.customParams || {};
31030
31030
  this.chartOrigin = params.chartOrigin;
31031
31031
  console.log("ChatClientMgr init:", this.actionKey);
31032
- // this.charAIs = {};
31033
31032
  }
31034
31033
  makeKey(key) {
31035
31034
  return `${key}-${this.actionKey}`;
@@ -31092,6 +31091,9 @@ class ChatClientMgr {
31092
31091
  this.handler.addChatListener(this.makeKey(`sdata_close_frame_window`), async (data, event) => {
31093
31092
  return this.handler.closeWindow();
31094
31093
  });
31094
+ this.handler.addChatListener(this.makeKey(`sdata_chat_aiAgent_event`), async (data, event) => {
31095
+ return this.handler.onAIAgentEvent(data, event);
31096
+ });
31095
31097
  this.handler.addChatListener(this.makeKey(`sdata_alllife_event_regist`), async (data, event) => {
31096
31098
  this.appSKID = data.appid;
31097
31099
  this.imType = data.im_type;
@@ -31101,7 +31103,7 @@ class ChatClientMgr {
31101
31103
  singleChatID: this.singleChatID,
31102
31104
  customParams: this.customParams
31103
31105
  };
31104
- console.log("charParams", charParams);
31106
+ // console.log("charParams", charParams);
31105
31107
  this.handler.fireEventToChatWindow(event, this.chartOrigin, this.makeKey("sdata_alllife_initChat"), charParams, result => {
31106
31108
  if (result) {
31107
31109
  this.handler.onChatInitFinished();
@@ -31388,6 +31390,9 @@ const getIMHanlder = customerHanlder => {
31388
31390
  },
31389
31391
  onChatInitFinished: async () => {
31390
31392
  // this.chatInitFinish = true;
31393
+ },
31394
+ onAIAgentEvent: async (data, event) => {
31395
+ // this.onAIAgentEvent(data,event);
31391
31396
  }
31392
31397
  };
31393
31398
  handler = {
@@ -31400,35 +31405,22 @@ const getIMHanlder = customerHanlder => {
31400
31405
  ;// ./src/api/dify.js
31401
31406
 
31402
31407
 
31403
- const addAndCleanDocument = async (fileUrl, options = {}) => {
31404
- let home_page = window.smardaten_api_context_path;
31405
- let finalUrl = `${home_page}/storage_area/public${fileUrl}`;
31406
- let fileType = finalUrl.split(".").pop().toLowerCase();
31407
- let fileName = options.fileName || dify_extractFilenameFromUrl(finalUrl);
31408
- fileType = getDifyFileType(fileType);
31409
- let loginUserData = window.anonymousIsLogin || window.currentUser;
31410
- let user_id = options.userID || loginUserData?.id;
31411
- let appid = options.appID || getPoratlAppID(false, []);
31408
+ const sendPostToAIAgent = async (queryData, successCallback, errorCallback) => {
31409
+ let appid = getPoratlAppID(false, []);
31412
31410
  let appCustomData = await getAppCustomData(appid);
31413
- let aiAgentServerIP = options.aiAgentServerIP || appCustomData?.aiAgentServerIP || "";
31411
+ let aiAgentServerIP = appCustomData?.aiAgentServerIP || "";
31412
+ if (!aiAgentServerIP) {
31413
+ console.error("没有配置AI Agent服务地址,请联系管理员");
31414
+ if (errorCallback) errorCallback("没有配置AI Agent服务地址,请联系管理员");
31415
+ return;
31416
+ }
31414
31417
  let serverUrl = `${aiAgentServerIP}/addAndCleanDocument`;
31415
- let queryData = {
31416
- params: {
31417
- inputs: {
31418
- fileName: fileName
31419
- },
31420
- files: [{
31421
- type: fileType,
31422
- transfer_method: options.transfer_method || "remote_url",
31423
- url: finalUrl
31424
- }],
31425
- user: user_id
31426
- }
31427
- };
31428
31418
  request.post(serverUrl, JSON.stringify(queryData)).then(res => {
31429
31419
  console.log("发送消息成功:", res);
31420
+ if (successCallback) successCallback(res);
31430
31421
  }).catch(error => {
31431
31422
  console.error("发送消息失败:", error);
31423
+ if (errorCallback) errorCallback(error);
31432
31424
  });
31433
31425
  };
31434
31426
  const getDifyFileType = fileType => {
@@ -31469,10 +31461,10 @@ const getDifyFileType = fileType => {
31469
31461
  return typeOptions[key] || "custom";
31470
31462
  };
31471
31463
 
31472
- /**
31473
- * 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
31474
- * @param {string} url - 文件 URL
31475
- * @returns {string} - 提取的文件名
31464
+ /**
31465
+ * 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
31466
+ * @param {string} url - 文件 URL
31467
+ * @returns {string} - 提取的文件名
31476
31468
  */
31477
31469
  const dify_extractFilenameFromUrl = url => {
31478
31470
  try {