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.
@@ -29552,7 +29552,6 @@ __webpack_require__.r(__webpack_exports__);
29552
29552
  // EXPORTS
29553
29553
  __webpack_require__.d(__webpack_exports__, {
29554
29554
  ChatClientMgr: function() { return /* reexport */ ChatClientMgr; },
29555
- addAndCleanDocument: function() { return /* reexport */ addAndCleanDocument; },
29556
29555
  addEventAction: function() { return /* reexport */ addEventAction; },
29557
29556
  addIMMapping: function() { return /* reexport */ addIMMapping; },
29558
29557
  addObjectUsedTimes: function() { return /* reexport */ addObjectUsedTimes; },
@@ -29611,6 +29610,7 @@ __webpack_require__.d(__webpack_exports__, {
29611
29610
  removeEventAction: function() { return /* reexport */ removeEventAction; },
29612
29611
  removeEventListener: function() { return /* reexport */ removeEventListener; },
29613
29612
  removeWindowTrustedOrigin: function() { return /* reexport */ removeWindowTrustedOrigin; },
29613
+ sendPostToAIAgent: function() { return /* reexport */ sendPostToAIAgent; },
29614
29614
  sendWindowMessage: function() { return /* reexport */ sendWindowMessage; },
29615
29615
  setPortalPageConfig: function() { return /* reexport */ setPortalPageConfig; },
29616
29616
  switchPortalLogin: function() { return /* reexport */ switchPortalLogin; },
@@ -31019,7 +31019,6 @@ class ChatClientMgr {
31019
31019
  this.customParams = params.customParams || {};
31020
31020
  this.chartOrigin = params.chartOrigin;
31021
31021
  console.log("ChatClientMgr init:", this.actionKey);
31022
- // this.charAIs = {};
31023
31022
  }
31024
31023
  makeKey(key) {
31025
31024
  return `${key}-${this.actionKey}`;
@@ -31082,6 +31081,9 @@ class ChatClientMgr {
31082
31081
  this.handler.addChatListener(this.makeKey(`sdata_close_frame_window`), async (data, event) => {
31083
31082
  return this.handler.closeWindow();
31084
31083
  });
31084
+ this.handler.addChatListener(this.makeKey(`sdata_chat_aiAgent_event`), async (data, event) => {
31085
+ return this.handler.onAIAgentEvent(data, event);
31086
+ });
31085
31087
  this.handler.addChatListener(this.makeKey(`sdata_alllife_event_regist`), async (data, event) => {
31086
31088
  this.appSKID = data.appid;
31087
31089
  this.imType = data.im_type;
@@ -31091,7 +31093,7 @@ class ChatClientMgr {
31091
31093
  singleChatID: this.singleChatID,
31092
31094
  customParams: this.customParams
31093
31095
  };
31094
- console.log("charParams", charParams);
31096
+ // console.log("charParams", charParams);
31095
31097
  this.handler.fireEventToChatWindow(event, this.chartOrigin, this.makeKey("sdata_alllife_initChat"), charParams, result => {
31096
31098
  if (result) {
31097
31099
  this.handler.onChatInitFinished();
@@ -31378,6 +31380,9 @@ const getIMHanlder = customerHanlder => {
31378
31380
  },
31379
31381
  onChatInitFinished: async () => {
31380
31382
  // this.chatInitFinish = true;
31383
+ },
31384
+ onAIAgentEvent: async (data, event) => {
31385
+ // this.onAIAgentEvent(data,event);
31381
31386
  }
31382
31387
  };
31383
31388
  handler = {
@@ -31390,35 +31395,22 @@ const getIMHanlder = customerHanlder => {
31390
31395
  ;// ./src/api/dify.js
31391
31396
 
31392
31397
 
31393
- const addAndCleanDocument = async (fileUrl, options = {}) => {
31394
- let home_page = window.smardaten_api_context_path;
31395
- let finalUrl = `${home_page}/storage_area/public${fileUrl}`;
31396
- let fileType = finalUrl.split(".").pop().toLowerCase();
31397
- let fileName = options.fileName || dify_extractFilenameFromUrl(finalUrl);
31398
- fileType = getDifyFileType(fileType);
31399
- let loginUserData = window.anonymousIsLogin || window.currentUser;
31400
- let user_id = options.userID || loginUserData?.id;
31401
- let appid = options.appID || getPoratlAppID(false, []);
31398
+ const sendPostToAIAgent = async (queryData, successCallback, errorCallback) => {
31399
+ let appid = getPoratlAppID(false, []);
31402
31400
  let appCustomData = await getAppCustomData(appid);
31403
- let aiAgentServerIP = options.aiAgentServerIP || appCustomData?.aiAgentServerIP || "";
31401
+ let aiAgentServerIP = appCustomData?.aiAgentServerIP || "";
31402
+ if (!aiAgentServerIP) {
31403
+ console.error("没有配置AI Agent服务地址,请联系管理员");
31404
+ if (errorCallback) errorCallback("没有配置AI Agent服务地址,请联系管理员");
31405
+ return;
31406
+ }
31404
31407
  let serverUrl = `${aiAgentServerIP}/addAndCleanDocument`;
31405
- let queryData = {
31406
- params: {
31407
- inputs: {
31408
- fileName: fileName
31409
- },
31410
- files: [{
31411
- type: fileType,
31412
- transfer_method: options.transfer_method || "remote_url",
31413
- url: finalUrl
31414
- }],
31415
- user: user_id
31416
- }
31417
- };
31418
31408
  request.post(serverUrl, JSON.stringify(queryData)).then(res => {
31419
31409
  console.log("发送消息成功:", res);
31410
+ if (successCallback) successCallback(res);
31420
31411
  }).catch(error => {
31421
31412
  console.error("发送消息失败:", error);
31413
+ if (errorCallback) errorCallback(error);
31422
31414
  });
31423
31415
  };
31424
31416
  const getDifyFileType = fileType => {
@@ -31459,10 +31451,10 @@ const getDifyFileType = fileType => {
31459
31451
  return typeOptions[key] || "custom";
31460
31452
  };
31461
31453
 
31462
- /**
31463
- * 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
31464
- * @param {string} url - 文件 URL
31465
- * @returns {string} - 提取的文件名
31454
+ /**
31455
+ * 从 URL 中提取文件名(如 https://example.com/path/image.png → image.png)
31456
+ * @param {string} url - 文件 URL
31457
+ * @returns {string} - 提取的文件名
31466
31458
  */
31467
31459
  const dify_extractFilenameFromUrl = url => {
31468
31460
  try {