@xuda.io/ai_module 1.1.4907 → 1.1.4908

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 (3) hide show
  1. package/index.mjs +1 -0
  2. package/index_ms.mjs +266 -0
  3. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1121,6 +1121,7 @@ export const get_chat_conversation = async function (req) {
1121
1121
  };
1122
1122
 
1123
1123
  export const get_ai_chats = async function (req, job_id, headers) {
1124
+ debugger;
1124
1125
  let { uid, reference_id, _id, search, filter_type = 'all', conversation_type, limit, skip, conversation_id, profile_id } = req;
1125
1126
 
1126
1127
  const account_profile_info = await account_module.get_active_account_profile_info(uid, profile_id);
package/index_ms.mjs ADDED
@@ -0,0 +1,266 @@
1
+ // =====================================================
2
+ // Queue wrapper – generated from index.mjs
3
+ // Queue target : ai_module
4
+ // =====================================================
5
+
6
+ import amqplib from 'amqplib';
7
+ import { randomUUID } from 'crypto';
8
+
9
+ let queue={}
10
+
11
+ // --- AMQP Connection & Channel ---
12
+ const conn = await amqplib.connect('amqp://localhost');
13
+ const channel = await conn.createChannel();
14
+ await channel.assertQueue(`_ai_module-${global.module_in}_ch`, { durable: false });
15
+
16
+ channel.consume(`_ai_module-${global.module_in}_ch`, async (msg) => {
17
+ try{
18
+
19
+ debugger;
20
+ if (msg === null) {
21
+ console.log('Consumer cancelled by server');
22
+ return;
23
+ }
24
+
25
+ const content = JSON.parse(msg.content.toString());
26
+
27
+ queue[content.queue_id].resolve(content.ret)
28
+
29
+ channel.ack(msg);
30
+ } catch (err) {
31
+ channel.ack(msg); // Acknowledge to prevent requeue loops on error
32
+ console.error(module_in, content.method, err.message, err);
33
+ // debugger;
34
+ }
35
+ });
36
+
37
+
38
+ const send_to_queue =async function(ms_method, ...args) {
39
+
40
+ const queue_id = randomUUID();
41
+ return new Promise((resolve,reject)=>{
42
+
43
+ queue[queue_id] = { resolve, reject };
44
+
45
+ // Set timeout to prevent hanging
46
+ const timeout = setTimeout(() => {
47
+ delete queue[queue_id];
48
+ reject(new Error(`Queue timeout for ${ms_method}`));
49
+ }, 30000); // 30 second timeout
50
+
51
+ // Wrap resolve to clean up
52
+ queue[queue_id].resolve = (value) => {
53
+ clearTimeout(timeout);
54
+ delete queue[queue_id];
55
+ resolve(value);
56
+ };
57
+
58
+ // Wrap reject to clean up
59
+ queue[queue_id].reject = (error) => {
60
+ clearTimeout(timeout);
61
+ delete queue[queue_id];
62
+ reject(error);
63
+ };
64
+
65
+ global[`_${global.module_in}_ch`].sendToQueue(
66
+ 'ai_module',
67
+ Buffer.from(
68
+ JSON.stringify({
69
+ ms_method,
70
+ data: args,
71
+ cb:`_ai_module-${global.module_in}_ch`,
72
+ queue_id
73
+ })
74
+ )
75
+ );
76
+
77
+ })
78
+
79
+ };
80
+
81
+ // You must define this somewhere before using these wrappers:
82
+ const module_name = 'ai_module';
83
+
84
+ export const get_chat_conversation = async function (...args) {
85
+ return await send_to_queue("get_chat_conversation", ...args);
86
+ };
87
+
88
+ export const get_ai_chats = async function (...args) {
89
+ return await send_to_queue("get_ai_chats", ...args);
90
+ };
91
+
92
+ export const delete_ai_chat = async function (...args) {
93
+ return await send_to_queue("delete_ai_chat", ...args);
94
+ };
95
+
96
+ export const archive_ai_chat = async function (...args) {
97
+ return await send_to_queue("archive_ai_chat", ...args);
98
+ };
99
+
100
+ export const unarchive_ai_chat = async function (...args) {
101
+ return await send_to_queue("unarchive_ai_chat", ...args);
102
+ };
103
+
104
+ export const get_ai_agent_info = async function (...args) {
105
+ return await send_to_queue("get_ai_agent_info", ...args);
106
+ };
107
+
108
+ export const get_ai_agents = async function (...args) {
109
+ return await send_to_queue("get_ai_agents", ...args);
110
+ };
111
+
112
+ export const delete_ai_agent = async function (...args) {
113
+ return await send_to_queue("delete_ai_agent", ...args);
114
+ };
115
+
116
+ export const uninstall_ai_agent = async function (...args) {
117
+ return await send_to_queue("uninstall_ai_agent", ...args);
118
+ };
119
+
120
+ export const unarchive_ai_agent = async function (...args) {
121
+ return await send_to_queue("unarchive_ai_agent", ...args);
122
+ };
123
+
124
+ export const archive_ai_agent = async function (...args) {
125
+ return await send_to_queue("archive_ai_agent", ...args);
126
+ };
127
+
128
+ export const archive_mini_app = async function (...args) {
129
+ return await send_to_queue("archive_mini_app", ...args);
130
+ };
131
+
132
+ export const unarchive_mini_app = async function (...args) {
133
+ return await send_to_queue("unarchive_mini_app", ...args);
134
+ };
135
+
136
+ export const delete_mini_app = async function (...args) {
137
+ return await send_to_queue("delete_mini_app", ...args);
138
+ };
139
+
140
+ export const update_ai_agent = async function (...args) {
141
+ return await send_to_queue("update_ai_agent", ...args);
142
+ };
143
+
144
+ export const get_apps = async function (...args) {
145
+ return await send_to_queue("get_apps", ...args);
146
+ };
147
+
148
+ export const create_ai_agent = async function (...args) {
149
+ return await send_to_queue("create_ai_agent", ...args);
150
+ };
151
+
152
+ export const update_ai_agent_properties = async function (...args) {
153
+ return await send_to_queue("update_ai_agent_properties", ...args);
154
+ };
155
+
156
+ export const update_thumbnail = async function (...args) {
157
+ return await send_to_queue("update_thumbnail", ...args);
158
+ };
159
+
160
+ export const upload_prompt_attachment = async function (...args) {
161
+ return await send_to_queue("upload_prompt_attachment", ...args);
162
+ };
163
+
164
+ export const delete_prompt_attachment = async function (...args) {
165
+ return await send_to_queue("delete_prompt_attachment", ...args);
166
+ };
167
+
168
+ export const submit_chat_gpt_prompt = async function (...args) {
169
+ return await send_to_queue("submit_chat_gpt_prompt", ...args);
170
+ };
171
+
172
+ export const create_conversation = async function (...args) {
173
+ return await send_to_queue("create_conversation", ...args);
174
+ };
175
+
176
+ export const submit_chat_conversation = async function (...args) {
177
+ return await send_to_queue("submit_chat_conversation", ...args);
178
+ };
179
+
180
+ export const create_avatar = async function (...args) {
181
+ return await send_to_queue("create_avatar", ...args);
182
+ };
183
+
184
+ export const get_profile_avatar = async function (...args) {
185
+ return await send_to_queue("get_profile_avatar", ...args);
186
+ };
187
+
188
+ export const get_profile_picture = async function (...args) {
189
+ return await send_to_queue("get_profile_picture", ...args);
190
+ };
191
+
192
+ export const conversation_actions = async function (...args) {
193
+ return await send_to_queue("conversation_actions", ...args);
194
+ };
195
+
196
+ export const modify_profile_avatar = async function (...args) {
197
+ return await send_to_queue("modify_profile_avatar", ...args);
198
+ };
199
+
200
+ export const get_ai_workspace_pending_counts = async function (...args) {
201
+ return await send_to_queue("get_ai_workspace_pending_counts", ...args);
202
+ };
203
+
204
+ export const create_mini_app = async function (...args) {
205
+ return await send_to_queue("create_mini_app", ...args);
206
+ };
207
+
208
+ export const pin_ai_agent = async function (...args) {
209
+ return await send_to_queue("pin_ai_agent", ...args);
210
+ };
211
+
212
+ export const unpin_ai_agent = async function (...args) {
213
+ return await send_to_queue("unpin_ai_agent", ...args);
214
+ };
215
+
216
+ export const get_transcript = async function (...args) {
217
+ return await send_to_queue("get_transcript", ...args);
218
+ };
219
+
220
+ export const add_transcript_conversation_item = async function (...args) {
221
+ return await send_to_queue("add_transcript_conversation_item", ...args);
222
+ };
223
+
224
+ export const is_spam_email = async function (...args) {
225
+ return await send_to_queue("is_spam_email", ...args);
226
+ };
227
+
228
+ export const is_business_contact = async function (...args) {
229
+ return await send_to_queue("is_business_contact", ...args);
230
+ };
231
+
232
+ export const is_business_contact_has_person = async function (...args) {
233
+ return await send_to_queue("is_business_contact_has_person", ...args);
234
+ };
235
+
236
+ export const get_name_from_email_addr = async function (...args) {
237
+ return await send_to_queue("get_name_from_email_addr", ...args);
238
+ };
239
+
240
+ export const categorize_email_subject = async function (...args) {
241
+ return await send_to_queue("categorize_email_subject", ...args);
242
+ };
243
+
244
+ export const categorize_ai_prompt = async function (...args) {
245
+ return await send_to_queue("categorize_ai_prompt", ...args);
246
+ };
247
+
248
+ export const categorize_text_message = async function (...args) {
249
+ return await send_to_queue("categorize_text_message", ...args);
250
+ };
251
+
252
+ export const categorize_contact_note = async function (...args) {
253
+ return await send_to_queue("categorize_contact_note", ...args);
254
+ };
255
+
256
+ export const get_business_info = async function (...args) {
257
+ return await send_to_queue("get_business_info", ...args);
258
+ };
259
+
260
+ export const get_person_info = async function (...args) {
261
+ return await send_to_queue("get_person_info", ...args);
262
+ };
263
+
264
+ export const open_ai_alive_check = async function (...args) {
265
+ return await send_to_queue("open_ai_alive_check", ...args);
266
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4907",
3
+ "version": "1.1.4908",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",