@xuda.io/ai_module 1.1.4166 → 1.1.4168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +47 -45
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2711,9 +2711,10 @@ export const unarchive_mini_app = async function (req) {
2711
2711
  export const delete_mini_app = async function (req) {
2712
2712
  let { prog_id, uid } = req;
2713
2713
 
2714
+ const account_profile_info = await account_module.get_active_account_profile_info(uid);
2714
2715
  const app_id = await account_module.get_account_default_project_id(uid);
2715
2716
  try {
2716
- let prog_doc = await db_module.get_app_couch_doc_native(app_id, prog_id);
2717
+ let prog_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, prog_id);
2717
2718
 
2718
2719
  if (prog_doc.stat !== 5) {
2719
2720
  throw new Error('A document can only be deleted after it has been archived');
@@ -2727,7 +2728,7 @@ export const delete_mini_app = async function (req) {
2727
2728
  } else {
2728
2729
  prog_doc.stat = 4;
2729
2730
  prog_doc.ts = Date.now();
2730
- save_ret = await db_module.save_app_couch_doc(app_id, prog_doc);
2731
+ save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, prog_doc);
2731
2732
  delete_depended_chats(uid, prog_id);
2732
2733
  }
2733
2734
  return save_ret;
@@ -2780,29 +2781,29 @@ export const update_ai_agent = async function (req, job_id, headers) {
2780
2781
  }
2781
2782
  };
2782
2783
 
2783
- export const install_ai_agent = async function (req) {
2784
- let { agent_id, agent_uid, uid } = req;
2784
+ // export const install_ai_agent = async function (req) {
2785
+ // let { agent_id, agent_uid, uid } = req;
2785
2786
 
2786
- const source_project_db = await get_account_project_db(agent_uid);
2787
- const target_project_db = await get_account_project_db(uid);
2787
+ // const source_project_db = await get_account_project_db(agent_uid);
2788
+ // const target_project_db = await get_account_project_db(uid);
2788
2789
 
2789
- try {
2790
- let agent_doc = await source_project_db.get(agent_id);
2791
- if (agent_doc.agentConfig.agent_visibility === 'private') {
2792
- throw new Error('agent is private');
2793
- }
2794
- const t = Date.now();
2795
- agent_doc.ts = t;
2796
- agent_doc.studio_meta.installed_ts = t;
2797
- agent_doc.studio_meta.installed_from_app_id = await account_module.get_account_default_project_id(agent_uid);
2790
+ // try {
2791
+ // let agent_doc = await source_project_db.get(agent_id);
2792
+ // if (agent_doc.agentConfig.agent_visibility === 'private') {
2793
+ // throw new Error('agent is private');
2794
+ // }
2795
+ // const t = Date.now();
2796
+ // agent_doc.ts = t;
2797
+ // agent_doc.studio_meta.installed_ts = t;
2798
+ // agent_doc.studio_meta.installed_from_app_id = await account_module.get_account_default_project_id(agent_uid);
2798
2799
 
2799
- const data = await target_project_db.insert(agent_doc);
2800
+ // const data = await target_project_db.insert(agent_doc);
2800
2801
 
2801
- return { code: 10, data };
2802
- } catch (err) {
2803
- return { code: -10, data: err.message };
2804
- }
2805
- };
2802
+ // return { code: 10, data };
2803
+ // } catch (err) {
2804
+ // return { code: -10, data: err.message };
2805
+ // }
2806
+ // };
2806
2807
 
2807
2808
  export const get_apps = async function (req, job_id, headers) {
2808
2809
  let { uid, _id, search, filter_type = 'all', limit, skip, mini_app_id } = req;
@@ -2869,12 +2870,12 @@ export const get_apps = async function (req, job_id, headers) {
2869
2870
  opt.selector._id = mini_app_id;
2870
2871
  }
2871
2872
  //////////////
2872
-
2873
+ const account_profile_info = await account_module.get_active_account_profile_info(uid);
2873
2874
  const app_id = await account_module.get_account_default_project_id(uid);
2874
2875
 
2875
2876
  let user_apps = { docs: [], total_docs: 0 };
2876
2877
  if (filter_type !== 'pending') {
2877
- user_apps = await db_module.find_app_couch_query(app_id, opt);
2878
+ user_apps = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
2878
2879
  if (!limit || mini_app_id) {
2879
2880
  user_apps.total_docs = user_apps.docs.length;
2880
2881
  } else {
@@ -2883,7 +2884,7 @@ export const get_apps = async function (req, job_id, headers) {
2883
2884
  opt.limit = 9999;
2884
2885
  opt.fields = ['_id'];
2885
2886
 
2886
- const counter = await db_module.find_app_couch_query(app_id, opt);
2887
+ const counter = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
2887
2888
  user_apps.total_docs = counter.docs.length;
2888
2889
  }
2889
2890
  }
@@ -3016,7 +3017,7 @@ const upload_agent_files = async function (uid, agent_doc) {
3016
3017
 
3017
3018
  case 'document':
3018
3019
  case 'text': {
3019
- file = await get_drive_file_stream('user', app_id, uid, tool.file.name);
3020
+ file = await get_drive_file_stream('user', agent_doc.account_profile_info.app_id, uid, tool.file.name);
3020
3021
  // tool.file.file_id = await upload_file_to_openai_storage(tool.file.name);
3021
3022
  break;
3022
3023
  }
@@ -3081,34 +3082,35 @@ const upload_agent_files = async function (uid, agent_doc) {
3081
3082
  }
3082
3083
  };
3083
3084
 
3084
- const validate_ai_agent = async function (req) {
3085
- // "tool_type": {
3086
- // "name": "Tool Type",
3087
- // "description": "",
3088
- // "type": "array",
3089
- // "enum": [
3090
- // "web_search",
3091
- // "file_search",
3092
- // "program",
3093
- // "mcp",
3094
- // "plugin",
3095
- // "ai_agent",
3096
- // "table",
3097
- // "image_generate"
3098
- // ],
3099
- // "mandatory": true
3100
- // }
3101
- };
3085
+ // const validate_ai_agent = async function (req) {
3086
+ // // "tool_type": {
3087
+ // // "name": "Tool Type",
3088
+ // // "description": "",
3089
+ // // "type": "array",
3090
+ // // "enum": [
3091
+ // // "web_search",
3092
+ // // "file_search",
3093
+ // // "program",
3094
+ // // "mcp",
3095
+ // // "plugin",
3096
+ // // "ai_agent",
3097
+ // // "table",
3098
+ // // "image_generate"
3099
+ // // ],
3100
+ // // "mandatory": true
3101
+ // // }
3102
+ // };
3102
3103
 
3103
3104
  const save_agent_status = async function (uid, agent_id, stat, agentConfig) {
3104
3105
  const project_db = await get_account_project_db(uid);
3106
+ const account_profile_info = await account_module.get_active_account_profile_info(uid);
3105
3107
 
3106
3108
  try {
3107
- let agent_doc = await project_db.get(agent_id);
3109
+ let agent_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
3108
3110
  agent_doc.ts = Date.now();
3109
3111
  agent_doc.stat = stat;
3110
3112
  agent_doc.agentConfig = agentConfig;
3111
- const data = await project_db.insert(agent_doc);
3113
+ const data = await db_module.save_app_couch_doc_native(account_profile_info.app_id, agent_doc);
3112
3114
 
3113
3115
  return { code: 12, data };
3114
3116
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4166",
3
+ "version": "1.1.4168",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",