@xuda.io/ai_module 1.1.5612 → 1.1.5613
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/index.mjs +18 -16
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4266,14 +4266,17 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
4266
4266
|
// write conversation to host after thumbnail update
|
|
4267
4267
|
// get sender conversation
|
|
4268
4268
|
|
|
4269
|
-
|
|
4269
|
+
// Re-fetch the freshest copy of the conversation doc after process_conversation
|
|
4270
|
+
// had a chance to write thumbnail / title updates. Renamed (was `conversation_doc`)
|
|
4271
|
+
// to avoid TDZ shadowing the outer-scope `conversation_doc` we read for the lookup id.
|
|
4272
|
+
const fresh_conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_doc._id);
|
|
4270
4273
|
|
|
4271
4274
|
const recipient_account_profile_info = await get_active_account_profile_info(recipient_uid);
|
|
4272
|
-
let recipient_conversation_doc = await db_module.get_app_couch_doc_native(recipient_account_profile_info.app_id,
|
|
4273
|
-
recipient_conversation_doc.title =
|
|
4275
|
+
let recipient_conversation_doc = await db_module.get_app_couch_doc_native(recipient_account_profile_info.app_id, fresh_conversation_doc._id);
|
|
4276
|
+
recipient_conversation_doc.title = fresh_conversation_doc.title;
|
|
4274
4277
|
|
|
4275
|
-
recipient_conversation_doc.thumbnail_request_ts =
|
|
4276
|
-
recipient_conversation_doc.chat_image =
|
|
4278
|
+
recipient_conversation_doc.thumbnail_request_ts = fresh_conversation_doc.thumbnail_request_ts;
|
|
4279
|
+
recipient_conversation_doc.chat_image = fresh_conversation_doc.chat_image;
|
|
4277
4280
|
recipient_conversation_doc.direction = 'in';
|
|
4278
4281
|
await db_module.save_app_couch_doc_native(recipient_account_profile_info.app_id, recipient_conversation_doc);
|
|
4279
4282
|
|
|
@@ -5927,13 +5930,7 @@ Return a concise answer. Include only non-sensitive findings and mention when th
|
|
|
5927
5930
|
|
|
5928
5931
|
await fs.promises.mkdir(dump_dir, { recursive: true });
|
|
5929
5932
|
const sitemap_xml = await fetch_text(`${website_base}/sitemap.xml`, 8000);
|
|
5930
|
-
const priority_urls = [
|
|
5931
|
-
`${website_base}/`,
|
|
5932
|
-
`${website_base}/about`,
|
|
5933
|
-
`${website_base}/legal/privacy-policy`,
|
|
5934
|
-
`${website_base}/legal/terms`,
|
|
5935
|
-
`${website_base}/contact`,
|
|
5936
|
-
];
|
|
5933
|
+
const priority_urls = [`${website_base}/`, `${website_base}/about`, `${website_base}/legal/privacy-policy`, `${website_base}/legal/terms`, `${website_base}/contact`];
|
|
5937
5934
|
const sitemap_urls = [...sitemap_xml.matchAll(/<loc>([\s\S]*?)<\/loc>/gi)]
|
|
5938
5935
|
.map((match) => decode_html(match[1]).trim())
|
|
5939
5936
|
.filter((url) => {
|
|
@@ -6029,10 +6026,7 @@ Return a concise answer. Include only non-sensitive findings and mention when th
|
|
|
6029
6026
|
};
|
|
6030
6027
|
|
|
6031
6028
|
try {
|
|
6032
|
-
const data = await Promise.race([
|
|
6033
|
-
run_lookup(),
|
|
6034
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error('xuda.ai website lookup timed out')), 20000)),
|
|
6035
|
-
]);
|
|
6029
|
+
const data = await Promise.race([run_lookup(), new Promise((_, reject) => setTimeout(() => reject(new Error('xuda.ai website lookup timed out')), 20000))]);
|
|
6036
6030
|
return JSON.stringify(data, null, 2);
|
|
6037
6031
|
} catch (err) {
|
|
6038
6032
|
return `xuda.ai website lookup failed: ${err.message || String(err)}`;
|
|
@@ -8197,6 +8191,14 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
8197
8191
|
const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
|
|
8198
8192
|
const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`);
|
|
8199
8193
|
|
|
8194
|
+
// Normalize: visitor accounts created through the chat widget can arrive with
|
|
8195
|
+
// account_type missing, null, or some other value. Treat anything that isn't
|
|
8196
|
+
// explicitly 'business' as 'personal' so the chat flow doesn't crash before
|
|
8197
|
+
// ever reaching the agent reply.
|
|
8198
|
+
if (account_type !== 'personal' && account_type !== 'business') {
|
|
8199
|
+
account_type = 'personal';
|
|
8200
|
+
}
|
|
8201
|
+
|
|
8200
8202
|
const { email, create_avatar } = metadata;
|
|
8201
8203
|
|
|
8202
8204
|
let prompt,
|