@yrpri/api 9.0.139 → 9.0.141

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 (322) hide show
  1. package/agents/assistants/agentAssistant.js +4 -3
  2. package/agents/assistants/baseAssistant.js +72 -71
  3. package/agents/assistants/baseAssistantWithVoice.js +6 -5
  4. package/agents/assistants/modes/agentDirectConnection.js +8 -7
  5. package/agents/assistants/modes/agentSelectionMode.js +2 -1
  6. package/agents/assistants/modes/baseAssistantMode.js +3 -2
  7. package/agents/assistants/modes/tools/agentTools.js +11 -10
  8. package/agents/assistants/modes/tools/loginTools.js +7 -6
  9. package/agents/assistants/modes/tools/models/agents.js +6 -5
  10. package/agents/assistants/modes/tools/models/subscriptions.js +7 -6
  11. package/agents/assistants/modes/tools/navigationTools.js +7 -6
  12. package/agents/assistants/modes/tools/subscriptionTools.js +12 -11
  13. package/agents/assistants/modes/tools/workflowConverstationTools.js +7 -6
  14. package/agents/assistants/voiceAssistant.js +45 -44
  15. package/agents/controllers/agentProductController.js +8 -7
  16. package/agents/controllers/agentSubscriptionController.js +13 -12
  17. package/agents/controllers/assistantsController.js +45 -44
  18. package/agents/controllers/policySynthAgents.js +33 -32
  19. package/agents/managers/emailInvitesManager.js +4 -3
  20. package/agents/managers/newAiModelSetup.js +46 -45
  21. package/agents/managers/notificationAgentQueueManager.js +55 -54
  22. package/agents/managers/subscriptionManager.js +24 -23
  23. package/agents/models/agentProduct.js +2 -1
  24. package/agents/models/agentProductBoosterPurchase.js +2 -1
  25. package/agents/models/testData/createEvolyAgentProduct.js +7 -6
  26. package/agents/models/testData/old/updateAgentWorkflowConfiguration.js +5 -4
  27. package/agents/models/testData/updateAgentWorkflowConfiguration.js +5 -4
  28. package/agents/tools/setTemplateWorkflowCommunityId.js +6 -5
  29. package/app.d.ts +2 -1
  30. package/app.js +60 -34
  31. package/authorization.cjs +4 -4
  32. package/controllers/allOurIdeas.js +45 -44
  33. package/controllers/groups.cjs +4 -9
  34. package/controllers/images.cjs +8 -8
  35. package/controllers/index.cjs +1 -1
  36. package/controllers/points.cjs +1 -1
  37. package/controllers/posts.cjs +3 -3
  38. package/deleteUnwantedDeclerations.cjs +6 -5
  39. package/models/community.cjs +1 -1
  40. package/models/domain.cjs +7 -7
  41. package/models/image.cjs +2 -2
  42. package/models/index.cjs +8 -4
  43. package/models/post.cjs +10 -10
  44. package/models/user.cjs +1 -1
  45. package/models/video.cjs +4 -4
  46. package/package.json +5 -5
  47. package/scripts/addRatingUsersToGroup.js +1 -1
  48. package/scripts/addUserToOrganization.js +8 -8
  49. package/scripts/agents/changeModelForWorkflowGroupTemplate.js +13 -12
  50. package/scripts/agents/generateAgentWorkflowTemplateFromAgentClass.js +5 -4
  51. package/scripts/analyseRatingsForCommunity.js +2 -2
  52. package/scripts/analyzeAndFixBrokenPointUsers.js +3 -3
  53. package/scripts/analyzeEndorsementsByCountry.js +7 -7
  54. package/scripts/analyzePostsForCommunity.js +1 -1
  55. package/scripts/bulkStatusUpdates/listUpdates.js +2 -2
  56. package/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +5 -5
  57. package/scripts/bulkStatusUpdates/performUpdate.js +9 -9
  58. package/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +12 -11
  59. package/scripts/bulkStatusUpdates/performUpdateForStatus.js +15 -15
  60. package/scripts/change/changeVideoAspectTo.js +3 -3
  61. package/scripts/change/setUseNewVersion.cjs +5 -4
  62. package/scripts/changeCommunityGroupcount.js +3 -3
  63. package/scripts/changeCommunityPostCount.js +3 -3
  64. package/scripts/changeGroupPostCount.js +3 -3
  65. package/scripts/changeLanguage.js +4 -4
  66. package/scripts/changeOfficalStatus.js +3 -3
  67. package/scripts/cleanups/deleteAnonNotifications.cjs +8 -7
  68. package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +8 -8
  69. package/scripts/cleanups/deleteYearOldNotifications.cjs +6 -5
  70. package/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +5 -5
  71. package/scripts/clearAllEndorsementInGroup.js +5 -5
  72. package/scripts/cloning/clearUsersForCommunitiesFromUrl.js +3 -3
  73. package/scripts/cloning/cloneFromUrlScript.js +4 -4
  74. package/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +6 -6
  75. package/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +6 -6
  76. package/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +6 -6
  77. package/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +3 -3
  78. package/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +2 -2
  79. package/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +2 -2
  80. package/scripts/cloning/copyCommunityToDomainWithEverything.js +2 -2
  81. package/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +3 -3
  82. package/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +3 -3
  83. package/scripts/cloning/copyPostToGroupOld.js +12 -12
  84. package/scripts/cloning/copyPostVideosFromURL.js +3 -3
  85. package/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +2 -2
  86. package/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +7 -7
  87. package/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +6 -6
  88. package/scripts/cloning/setAdminsFromURL.js +5 -5
  89. package/scripts/cloning/setExternalIdsFromURL.js +3 -3
  90. package/scripts/countCommunity.js +11 -11
  91. package/scripts/countCommunityUsers.js +4 -4
  92. package/scripts/countDelayedNotifications.js +3 -3
  93. package/scripts/countGroup.js +11 -11
  94. package/scripts/countStuff.js +3 -3
  95. package/scripts/countUniqueVotersInAGroup.js +3 -3
  96. package/scripts/createInvitesAndShow.js +2 -2
  97. package/scripts/database/sync_database.js +2 -2
  98. package/scripts/database/sync_dev_database.js +3 -3
  99. package/scripts/debugNotifications.js +5 -5
  100. package/scripts/deleteAllNewsFeeds.js +2 -2
  101. package/scripts/deleteCategory.js +1 -1
  102. package/scripts/deleteOldAppActivities.js +5 -4
  103. package/scripts/deletePostContactDataForCommunity.js +5 -4
  104. package/scripts/destroy/destroy_all_but_one_domain.js +59 -59
  105. package/scripts/displayAuthorForPost.js +1 -1
  106. package/scripts/domains/createDomain.js +5 -4
  107. package/scripts/domains/importDomainsFromXls.js +7 -6
  108. package/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +2 -2
  109. package/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +9 -9
  110. package/scripts/exportAllStatusChanges.js +5 -5
  111. package/scripts/exportEndorsementsForCommunity.js +5 -5
  112. package/scripts/exportPointQualitiesForCommunity.js +5 -5
  113. package/scripts/exportPostsAndPointsForCommunity.js +9 -9
  114. package/scripts/exportPostsDataSetForDomain.js +12 -12
  115. package/scripts/exportPostsForGroup.js +7 -7
  116. package/scripts/exportRatingsForPost.js +2 -2
  117. package/scripts/exportUserEndorsementsWithUserAnalysis.js +6 -6
  118. package/scripts/exportUsersForCommunity.js +3 -3
  119. package/scripts/exportUsersForDomain.js +3 -3
  120. package/scripts/exportUsersForGroup.js +3 -3
  121. package/scripts/exports/ratingDistribution.js +6 -6
  122. package/scripts/exports/whoEndorsedWhatByCommunity.js +2 -2
  123. package/scripts/findUnusedClientImports.js +2 -2
  124. package/scripts/fixAllPostPointCounts.js +1 -1
  125. package/scripts/fixAnonNotificationsSettings.js +5 -5
  126. package/scripts/fixCountKopavogur.js +1 -1
  127. package/scripts/fixEndorsementsAfterCopyPostToGroup.js +10 -10
  128. package/scripts/fixExternalUserId.js +2 -2
  129. package/scripts/fixGroupAccess.js +3 -3
  130. package/scripts/fixGroupIdeasAndPointsCount.js +2 -2
  131. package/scripts/fixNotificationSettings.js +4 -4
  132. package/scripts/fixSurveyRadioBakedInSubCodes.js +6 -6
  133. package/scripts/fixWrongUserIdForStatusUpdates.js +6 -5
  134. package/scripts/gallery/exportGalleryData.js +2 -2
  135. package/scripts/gallery/importGalleryForCommunity.js +14 -14
  136. package/scripts/gallery/readJsonAndDownloadImagesVersion2.js +6 -6
  137. package/scripts/gallery/refreshAcApiPostIdsForCommunity.js +5 -5
  138. package/scripts/genderAnalysis.js +10 -10
  139. package/scripts/genderAnalysisByStatus.js +4 -4
  140. package/scripts/importAllLocalesFromLocalFolders.js +7 -7
  141. package/scripts/importDomain.js +131 -131
  142. package/scripts/keys/addOidcToDomain.cjs +10 -9
  143. package/scripts/landUseGame/export3Ddata.js +15 -15
  144. package/scripts/listLanguagesForGroup.js +6 -6
  145. package/scripts/loadTestCreateDummyContentForGroup.js +2 -2
  146. package/scripts/makeRecursiveMapData.js +4 -4
  147. package/scripts/mapping/community_map_csv.js +5 -5
  148. package/scripts/moveCommunityToDomain.js +3 -3
  149. package/scripts/moveGroupToCommunity.js +3 -3
  150. package/scripts/movePostToGroup.js +5 -5
  151. package/scripts/movePostsToGroupsRecountGroupFromUrl.js +6 -6
  152. package/scripts/oldMovePostToGroup.js +9 -9
  153. package/scripts/processCsvForPdfUrls.js +2 -2
  154. package/scripts/processCsvForTranslationAndToxicity.js +10 -10
  155. package/scripts/recount/recount_recursive_communities.js +6 -6
  156. package/scripts/recountALLCommunityGroupCounts.js +4 -4
  157. package/scripts/recountAll.js +3 -3
  158. package/scripts/recountCommunitesFromUrl.js +3 -3
  159. package/scripts/recountCommunity.js +2 -2
  160. package/scripts/recountGroup.js +5 -5
  161. package/scripts/recountGroupNoUserChange.js +5 -5
  162. package/scripts/resetAllEndorsementsForGroup.js +3 -3
  163. package/scripts/resetEnTranslationForGroup.js +5 -5
  164. package/scripts/setAdminOnAll.cjs +15 -14
  165. package/scripts/setDomainAdmin.cjs +7 -6
  166. package/scripts/setDomainLocales.js +2 -2
  167. package/scripts/setEarlQuestionIdOnGroup.cjs +5 -4
  168. package/scripts/setLanguageOnGroupCommunitesFromUrl.js +3 -3
  169. package/scripts/setMemberOfAll.js +14 -14
  170. package/scripts/setNewUserForContentOfCommunity.js +9 -9
  171. package/scripts/setOfficialStatusOnAllPostsForCommunity.js +1 -1
  172. package/scripts/setUserOnAll.js +14 -14
  173. package/scripts/showCategoryForGroup.js +1 -1
  174. package/scripts/showOldActivityTypes.js +3 -3
  175. package/scripts/showPostsMissingCategoryForGroup.js +2 -2
  176. package/scripts/showStatuses.js +4 -4
  177. package/scripts/showUniqueVotersInCommunity.js +4 -4
  178. package/scripts/showUserAgentsAndIpsForEmails.js +4 -4
  179. package/scripts/simpleExportForGroupsForCommunity.js +5 -5
  180. package/scripts/simpleExportForPointsForCommunity.js +5 -5
  181. package/scripts/simpleExportForPostsForCommunity.js +5 -5
  182. package/scripts/testForEndorsments.js +4 -4
  183. package/scripts/undeleteGroupAndAllContent.js +8 -8
  184. package/scripts/undeletePost.js +7 -7
  185. package/scripts/unlinkSsn.js +4 -4
  186. package/scripts/updateFromAlthingi.js +8 -8
  187. package/scripts/users/createUserAddDomain.js +6 -5
  188. package/scripts/users/importUsersForDomainsFromXls.js +4 -3
  189. package/scripts/users/listDomainUsersWithSsn.js +6 -5
  190. package/scripts/users/removeUserFromDomain.js +6 -5
  191. package/scripts/users/updatePasswordFromSsn.js +5 -4
  192. package/scripts/users/updateUserSsnFromEmail.js +5 -4
  193. package/services/controllers/activities.cjs +1 -1
  194. package/services/controllers/news_feeds.cjs +1 -1
  195. package/services/controllers/notifications.cjs +1 -1
  196. package/services/controllers/recommendations.cjs +1 -1
  197. package/services/engine/allOurIdeas/aiHelper.js +10 -9
  198. package/services/engine/analytics/export_anon_community_activities.js +3 -3
  199. package/services/engine/analytics/importer.js +10 -10
  200. package/services/engine/analytics/plausible/manager.cjs +4 -4
  201. package/services/engine/analytics/statsCalc.cjs +1 -1
  202. package/services/engine/analytics/utils.cjs +11 -10
  203. package/services/engine/marketing/campaign.cjs +1 -0
  204. package/services/engine/moderation/fraud/CreateFraudAuditReport.cjs +2 -1
  205. package/services/engine/moderation/fraud/FraudBase.cjs +3 -2
  206. package/services/engine/moderation/fraud/FraudDeleteBase.cjs +5 -4
  207. package/services/engine/moderation/fraud/FraudGetBase.cjs +2 -1
  208. package/services/engine/moderation/fraud/FraudGetEndorsements.cjs +2 -1
  209. package/services/engine/moderation/fraud/FraudGetPointQualities.cjs +2 -1
  210. package/services/engine/moderation/fraud/FraudGetPoints.cjs +2 -1
  211. package/services/engine/moderation/fraud/FraudGetPosts.cjs +2 -1
  212. package/services/engine/moderation/fraud/FraudGetRatings.cjs +2 -1
  213. package/services/engine/moderation/fraud/FraudScannerNotifier.cjs +10 -9
  214. package/services/engine/moderation/get_moderation_items.cjs +1 -1
  215. package/services/engine/moderation/image_labeling/ImageLabelingBase.cjs +1 -1
  216. package/services/engine/moderation/process_moderation_items.cjs +1 -1
  217. package/services/engine/moderation/toxicity_analysis.cjs +1 -1
  218. package/services/engine/news_feeds/generate_dynamically.cjs +1 -1
  219. package/services/engine/news_feeds/generate_from_notifications.cjs +1 -1
  220. package/services/engine/notifications/emails_utils.cjs +2 -2
  221. package/services/engine/notifications/generate_point_notifications.cjs +1 -1
  222. package/services/engine/notifications/generate_post_notifications.cjs +1 -1
  223. package/services/engine/notifications/process_delayed_notifications.cjs +38 -38
  224. package/services/engine/notifications/process_general_notifications.cjs +1 -0
  225. package/services/engine/old/exporters/categories_dataset.js +11 -11
  226. package/services/engine/old/exporters/sentiment_dataset.js +12 -12
  227. package/services/engine/recommendations/events_importer.cjs +5 -5
  228. package/services/engine/recommendations/events_manager.cjs +1 -1
  229. package/services/engine/reports/add_points_to_sheet.cjs +3 -2
  230. package/services/engine/reports/commonUtils.js +3 -2
  231. package/services/engine/reports/common_utils.cjs +8 -8
  232. package/services/engine/reports/docx_group_report.cjs +1 -1
  233. package/services/engine/reports/xlsAllOurIdeasExport.js +16 -15
  234. package/services/engine/reports/xls_community_users_report.cjs +2 -2
  235. package/services/engine/reports/xls_group_report.cjs +1 -1
  236. package/services/llms/baseChatBot.js +12 -11
  237. package/services/llms/imageGeneration/chatGptImageGenerator.js +3 -2
  238. package/services/llms/imageGeneration/collectionImageGenerator.js +7 -6
  239. package/services/llms/imageGeneration/dalleImageGenerator.js +6 -5
  240. package/services/llms/imageGeneration/fluxImageGenerator.js +5 -4
  241. package/services/llms/imageGeneration/imageProcessorService.js +2 -1
  242. package/services/llms/imageGeneration/imagenImageGenerator.js +8 -7
  243. package/services/llms/imageGeneration/s3Service.js +12 -11
  244. package/services/llms/llmTranslation.js +30 -29
  245. package/services/models/ac_activity.cjs +1 -1
  246. package/services/models/ac_notification.cjs +1 -1
  247. package/services/models/ac_translation_cache.cjs +11 -11
  248. package/services/scripts/analytics/setup_all_plausible_goals.cjs +3 -2
  249. package/services/scripts/fix_old_delayed_notifications.js +3 -3
  250. package/services/scripts/kue_status.js +11 -11
  251. package/services/scripts/kue_watch_stuck_jobs.js +6 -6
  252. package/services/scripts/translation_clear_language.js +21 -21
  253. package/services/scripts/translation_delete.js +4 -4
  254. package/services/scripts/translation_replace_text_from_url.js +4 -4
  255. package/services/scripts/translation_update.js +4 -4
  256. package/services/scripts/translations_list.js +5 -5
  257. package/services/utils/airbrake.cjs +2 -1
  258. package/services/utils/redisConnection.cjs +6 -5
  259. package/services/utils/translation_helpers.cjs +3 -2
  260. package/services/utils/updateAllLocalesFromEn.js +20 -19
  261. package/services/utils/updateLocaleFolders.js +7 -6
  262. package/services/workers/activity.cjs +1 -1
  263. package/services/workers/anonymizations.cjs +1 -1
  264. package/services/workers/bulk_status_update.cjs +2 -2
  265. package/services/workers/delayed_jobs.cjs +1 -1
  266. package/services/workers/deletions.cjs +1 -1
  267. package/services/workers/email.cjs +1 -1
  268. package/services/workers/fraud_management.cjs +3 -3
  269. package/services/workers/generativeAi.js +6 -5
  270. package/services/workers/main.cjs +1 -1
  271. package/services/workers/marketing.cjs +1 -1
  272. package/services/workers/moderation.cjs +1 -1
  273. package/services/workers/notification_delivery.cjs +1 -1
  274. package/services/workers/notification_news_feed.cjs +1 -1
  275. package/services/workers/queue.cjs +2 -2
  276. package/services/workers/recount.cjs +1 -1
  277. package/services/workers/reports.cjs +1 -1
  278. package/services/workers/similarities.cjs +4 -2
  279. package/services/workers/speech_to_text.cjs +1 -1
  280. package/utils/airbrake.cjs +2 -1
  281. package/utils/cjsCodeReview.js +7 -6
  282. package/utils/community_mapping_tools.cjs +3 -2
  283. package/utils/copy_utils.cjs +32 -31
  284. package/utils/export_utils.cjs +7 -7
  285. package/utils/generateDocumentation.js +10 -9
  286. package/utils/logger.cjs +2 -23
  287. package/utils/logger.d.cts +1 -1
  288. package/utils/loggerAirbrakeTransport.cjs +52 -0
  289. package/utils/loggerAirbrakeTransport.d.cts +15 -0
  290. package/utils/loggerAirbrakeTransportTs.d.ts +15 -0
  291. package/utils/loggerAirbrakeTransportTs.js +45 -0
  292. package/utils/loggerCore.cjs +29 -0
  293. package/utils/loggerCore.d.cts +2 -0
  294. package/utils/loggerCoreTs.d.ts +2 -0
  295. package/utils/loggerCoreTs.js +23 -0
  296. package/utils/loggerTs.d.ts +1 -2
  297. package/utils/loggerTs.js +2 -25
  298. package/utils/manifest_generator.cjs +1 -0
  299. package/utils/recount_utils.cjs +6 -5
  300. package/utils/seedModels.js +50 -49
  301. package/utils/sitemap_generator.cjs +4 -4
  302. package/utils/ypLanguages.js +2 -2
  303. package/webSockets.js +8 -7
  304. package/services/utils/logger.cjs +0 -25
  305. package/services/utils/logger.d.cts +0 -2
  306. package/src/agents/assistants/assistant.d.ts +0 -156
  307. package/src/controllers/audios.d.ts +0 -5
  308. package/src/controllers/categories.d.ts +0 -5
  309. package/src/controllers/communities.d.ts +0 -5
  310. package/src/controllers/domains.d.ts +0 -5
  311. package/src/controllers/groups.d.ts +0 -5
  312. package/src/controllers/images.d.ts +0 -5
  313. package/src/controllers/points.d.ts +0 -5
  314. package/src/controllers/posts.d.ts +0 -5
  315. package/src/controllers/ratings.d.ts +0 -5
  316. package/src/controllers/users.d.ts +0 -5
  317. package/src/controllers/videos.d.ts +0 -5
  318. package/src/models/index.d.ts +0 -84
  319. package/src/services/controllers/activities.d.ts +0 -5
  320. package/src/services/controllers/notifications.d.ts +0 -5
  321. package/src/utils/copy_utils.d.ts +0 -4
  322. package/src/utils/manifest_generator.d.ts +0 -18
@@ -10,6 +10,7 @@ import { YpSubscription } from "../models/subscription.js";
10
10
  import { YpAgentProductBundle } from "../models/agentProductBundle.js";
11
11
  import queue from "../../services/workers/queue.cjs";
12
12
  import { EmailTemplateRenderer } from "./emailTemplateRenderer.js";
13
+ import log from "../../utils/loggerTs.js";
13
14
  const dbModels = models;
14
15
  const Group = dbModels.Group;
15
16
  const User = dbModels.User;
@@ -18,13 +19,13 @@ const Domain = dbModels.Domain;
18
19
  export class NotificationAgentQueueManager extends AgentQueueManager {
19
20
  constructor(wsClients) {
20
21
  super();
21
- console.log("NotificationAgentQueueManager: Initializing");
22
+ log.info("NotificationAgentQueueManager: Initializing");
22
23
  this.initializeRedis();
23
24
  this.queues = new Map();
24
25
  this.wsClients = wsClients;
25
26
  }
26
27
  async sendNotification(agent, agentRun, action, wsClientId, status, result, agentRunId, updatedWorkflow) {
27
- console.log("NotificationAgentQueueManager: Sending notification", agentRunId, updatedWorkflow);
28
+ log.info("NotificationAgentQueueManager: Sending notification", agentRunId, updatedWorkflow);
28
29
  const wsClient = this.wsClients.get(wsClientId);
29
30
  if (wsClient) {
30
31
  const currentWorkflowStep = updatedWorkflow?.steps[updatedWorkflow?.currentStepIndex];
@@ -42,13 +43,13 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
42
43
  }));
43
44
  }
44
45
  else {
45
- console.error(`NotificationAgentQueueManager: WebSocket client with ID ${wsClientId} not found`);
46
+ log.error(`NotificationAgentQueueManager: WebSocket client with ID ${wsClientId} not found`);
46
47
  }
47
48
  if (updatedWorkflow) {
48
49
  await this.sendNotificationEmail(agent, agentRun, updatedWorkflow);
49
50
  }
50
51
  else {
51
- console.error("NotificationAgentQueueManager: No updated workflow found");
52
+ log.error("NotificationAgentQueueManager: No updated workflow found");
52
53
  }
53
54
  }
54
55
  async sendNotificationEmail(agent, agentRun, updatedWorkflow) {
@@ -95,7 +96,7 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
95
96
  }
96
97
  }
97
98
  else {
98
- console.error("No group admins with email found");
99
+ log.error("No group admins with email found");
99
100
  return;
100
101
  }
101
102
  }
@@ -105,13 +106,13 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
105
106
  attributes: ["id", "workflow", "status"],
106
107
  });
107
108
  if (!agentRun || !agentRun.workflow) {
108
- console.error(`NotificationAgentQueueManager: Agent run ${agentRunId} or its workflow not found`);
109
+ log.error(`NotificationAgentQueueManager: Agent run ${agentRunId} or its workflow not found`);
109
110
  return;
110
111
  }
111
112
  const workflowConfig = agentRun.workflow;
112
113
  if (currentWorkflowStepIndex !== undefined &&
113
114
  currentWorkflowStepIndex !== workflowConfig.currentStepIndex) {
114
- console.error("NotificationAgentQueueManager: Current workflow step index is undefined or matches the current step index, not advancing to the next step");
115
+ log.error("NotificationAgentQueueManager: Current workflow step index is undefined or matches the current step index, not advancing to the next step");
115
116
  return;
116
117
  }
117
118
  if (currentWorkflowStepIndex === 0) {
@@ -136,7 +137,7 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
136
137
  }
137
138
  async advanceWorkflowStepOrCompleteAgentRun(agentRunId, status, wsClientId, currentWorkflowStepIndex = undefined) {
138
139
  try {
139
- console.log("NotificationAgentQueueManager: Advancing workflow step or completing agent run", agentRunId, status);
140
+ log.info("NotificationAgentQueueManager: Advancing workflow step or completing agent run", agentRunId, status);
140
141
  // Get the agent run record
141
142
  const agentRun = await YpAgentProductRun.findByPk(agentRunId, {
142
143
  attributes: ["id", "workflow", "status"],
@@ -149,7 +150,7 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
149
150
  ],
150
151
  });
151
152
  if (!agentRun || !agentRun.workflow) {
152
- console.error(`NotificationAgentQueueManager: Agent run ${agentRunId} or its workflow not found`);
153
+ log.error(`NotificationAgentQueueManager: Agent run ${agentRunId} or its workflow not found`);
153
154
  return;
154
155
  }
155
156
  const workflowConfig = agentRun.workflow;
@@ -160,7 +161,7 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
160
161
  }
161
162
  if (currentWorkflowStepIndex !== undefined &&
162
163
  currentWorkflowStepIndex !== workflowConfig.currentStepIndex) {
163
- console.error("NotificationAgentQueueManager: Current workflow step index is undefined or matches the current step index, not advancing to the next step");
164
+ log.error("NotificationAgentQueueManager: Current workflow step index is undefined or matches the current step index, not advancing to the next step");
164
165
  return;
165
166
  }
166
167
  // Check if there are more steps
@@ -180,7 +181,7 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
180
181
  agentRun.changed("workflow", true);
181
182
  await agentRun.save();
182
183
  //TODO: UPDATE AGENT MEMORY, Maybe
183
- console.log("NotificationAgentQueueManager: Updated workflow for agent run", agentRunId, status, workflowConfig);
184
+ log.info("NotificationAgentQueueManager: Updated workflow for agent run", agentRunId, status, workflowConfig);
184
185
  }
185
186
  else {
186
187
  // This was the last step, mark the workflow as completed
@@ -188,12 +189,12 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
188
189
  agentRun.changed("status", true);
189
190
  await agentRun.save();
190
191
  await agentRun.update({ status: "completed", completedAt: new Date() });
191
- console.log("NotificationAgentQueueManager: Updated workflow for agent run", agentRunId, "to completed");
192
+ log.info("NotificationAgentQueueManager: Updated workflow for agent run", agentRunId, "to completed");
192
193
  }
193
194
  return workflowConfig;
194
195
  }
195
196
  catch (error) {
196
- console.error(`NotificationAgentQueueManager: Error in advanceWorkflowStepOrCompleteAgentRun:`, error);
197
+ log.error(`NotificationAgentQueueManager: Error in advanceWorkflowStepOrCompleteAgentRun:`, error);
197
198
  }
198
199
  }
199
200
  static async getAgentRun(agentRunId) {
@@ -231,17 +232,17 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
231
232
  });
232
233
  }
233
234
  getQueue(queueName) {
234
- console.log(`NotificationAgentQueueManager: Getting queue for ${queueName}`);
235
+ log.info(`NotificationAgentQueueManager: Getting queue for ${queueName}`);
235
236
  if (!this.queues.has(queueName)) {
236
- console.log(`NotificationAgentQueueManager: Creating new queue for ${queueName}`);
237
+ log.info(`NotificationAgentQueueManager: Creating new queue for ${queueName}`);
237
238
  const newQueue = new Queue(queueName, {
238
239
  connection: this.redisClient,
239
240
  });
240
241
  newQueue.on("error", (error) => {
241
- console.log(`NotificationAgentQueueManager: Error in queue ${queueName}:`, error);
242
+ log.info(`NotificationAgentQueueManager: Error in queue ${queueName}:`, error);
242
243
  });
243
244
  newQueue.on("waiting", (jobId) => {
244
- console.log(`Job ${jobId} is waiting in queue ${queueName}`);
245
+ log.info(`Job ${jobId} is waiting in queue ${queueName}`);
245
246
  });
246
247
  // Create QueueEvents instance for global events
247
248
  const queueEvents = new QueueEvents(queueName, {
@@ -249,31 +250,31 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
249
250
  });
250
251
  // Add event listeners for debugging
251
252
  queueEvents.on("waiting", ({ jobId }) => {
252
- console.log(`Job ${jobId} is waiting in queue ${queueName}`);
253
+ log.info(`Job ${jobId} is waiting in queue ${queueName}`);
253
254
  });
254
255
  queueEvents.on("active", ({ jobId, prev }) => {
255
- console.log(`Job ${jobId} is active in queue ${queueName} (prev state: ${prev})`);
256
+ log.info(`Job ${jobId} is active in queue ${queueName} (prev state: ${prev})`);
256
257
  });
257
258
  queueEvents.on("completed", async ({ jobId, returnvalue }) => {
258
- console.log(`Job ${jobId} completed in queue ${queueName}. Result:`, returnvalue);
259
+ log.info(`Job ${jobId} completed in queue ${queueName}. Result:`, returnvalue);
259
260
  try {
260
- console.log("NotificationAgentQueueManager: Job completed in queue", queueName, jobId);
261
+ log.info("NotificationAgentQueueManager: Job completed in queue", queueName, jobId);
261
262
  // Retrieve the job instance
262
263
  const job = await newQueue.getJob(jobId);
263
264
  if (job) {
264
265
  const { agentId, type, wsClientId, agentRunId, currentWorkflowStepIndex, } = job.data;
265
- console.log("NotificationAgentQueueManager: Job data", job.data);
266
- console.log("NotificationAgentQueueManager: currentWorkflowStepIndex", currentWorkflowStepIndex);
266
+ log.info("NotificationAgentQueueManager: Job data", job.data);
267
+ log.info("NotificationAgentQueueManager: currentWorkflowStepIndex", currentWorkflowStepIndex);
267
268
  // Load the agent database record
268
269
  const agent = await PsAgent.findByPk(agentId, {
269
270
  include: [{ model: PsAgentClass, as: "Class" }],
270
271
  });
271
272
  const agentRun = await NotificationAgentQueueManager.getAgentRun(agentRunId);
272
273
  if (!agentRun) {
273
- console.error(`NotificationAgentQueueManager: Agent run with ID ${agentRunId} not found.`);
274
+ log.error(`NotificationAgentQueueManager: Agent run with ID ${agentRunId} not found.`);
274
275
  return;
275
276
  }
276
- console.log("NotificationAgentQueueManager: Agent", agent);
277
+ log.info("NotificationAgentQueueManager: Agent", agent);
277
278
  let updatedWorkflow;
278
279
  if (agentRun.status === "running" ||
279
280
  agentRun.status === "waiting_on_user") {
@@ -282,14 +283,14 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
282
283
  await this.advanceWorkflowStepOrCompleteAgentRun(agentRunId, agentRun.status, wsClientId, currentWorkflowStepIndex);
283
284
  }
284
285
  else {
285
- console.error(`NotificationAgentQueueManager: Agent run ID ${agentRunId} not found.`);
286
+ log.error(`NotificationAgentQueueManager: Agent run ID ${agentRunId} not found.`);
286
287
  }
287
288
  if (agent) {
288
289
  // Send notification
289
290
  await this.sendNotification(agent, agentRun, type, wsClientId, agentRun.status, returnvalue, agentRunId, updatedWorkflow);
290
291
  }
291
292
  else {
292
- console.error(`NotificationAgentQueueManager: Agent with ID ${agentId} not found.`);
293
+ log.error(`NotificationAgentQueueManager: Agent with ID ${agentId} not found.`);
293
294
  }
294
295
  }
295
296
  else if (agentRun.status === "stopped") {
@@ -297,29 +298,29 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
297
298
  updatedWorkflow = await this.goBackOneWorkflowStepIfNeeded(agentRunId, agentRun.status, wsClientId, currentWorkflowStepIndex);
298
299
  }
299
300
  else {
300
- console.error(`NotificationAgentQueueManager: Agent run ID ${agentRunId} not found.`);
301
+ log.error(`NotificationAgentQueueManager: Agent run ID ${agentRunId} not found.`);
301
302
  }
302
303
  }
303
304
  else {
304
- console.error(`NotificationAgentQueueManager: Agent run ${agentRunId} is not completed, status ${agentRun.status} but the job completed`);
305
+ log.error(`NotificationAgentQueueManager: Agent run ${agentRunId} is not completed, status ${agentRun.status} but the job completed`);
305
306
  }
306
307
  }
307
308
  else {
308
- console.error(`NotificationAgentQueueManager: Job with ID ${jobId} not found.`);
309
+ log.error(`NotificationAgentQueueManager: Job with ID ${jobId} not found.`);
309
310
  }
310
311
  }
311
312
  catch (error) {
312
- console.error(`NotificationAgentQueueManager: Error handling job completion for job ${jobId}:`, error);
313
+ log.error(`NotificationAgentQueueManager: Error handling job completion for job ${jobId}:`, error);
313
314
  }
314
315
  });
315
316
  queueEvents.on("failed", async ({ jobId, failedReason }) => {
316
- console.log(`Job ${jobId} failed in queue ${queueName}. Reason:`, failedReason);
317
+ log.info(`Job ${jobId} failed in queue ${queueName}. Reason:`, failedReason);
317
318
  try {
318
319
  // Retrieve the job instance
319
320
  const job = await newQueue.getJob(jobId);
320
321
  if (job) {
321
322
  const { agentId, type, wsClientId, agentRunId } = job.data;
322
- console.log("NotificationAgentQueueManager: FAILED Job data", job.data);
323
+ log.info("NotificationAgentQueueManager: FAILED Job data", job.data);
323
324
  // Load the agent database record
324
325
  const agent = await PsAgent.findByPk(agentId, {
325
326
  include: [{ model: PsAgentClass, as: "Class" }],
@@ -340,10 +341,10 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
340
341
  );*/
341
342
  }
342
343
  else {
343
- console.error(`NotificationAgentQueueManager: Agent with ID ${agentId} not found.`);
344
+ log.error(`NotificationAgentQueueManager: Agent with ID ${agentId} not found.`);
344
345
  }
345
346
  if (!agentRun) {
346
- console.error(`NotificationAgentQueueManager: Agent run with ID ${agentRunId} not found.`);
347
+ log.error(`NotificationAgentQueueManager: Agent run with ID ${agentRunId} not found.`);
347
348
  return;
348
349
  }
349
350
  agentRun.workflow.steps[agentRun.workflow.currentStepIndex].endTime = new Date();
@@ -354,68 +355,68 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
354
355
  await agentRun.save();
355
356
  }
356
357
  else {
357
- console.error(`Job with ID ${jobId} not found.`);
358
+ log.error(`Job with ID ${jobId} not found.`);
358
359
  }
359
360
  }
360
361
  catch (error) {
361
- console.error(`Error handling job failure for job ${jobId}:`, error);
362
+ log.error(`Error handling job failure for job ${jobId}:`, error);
362
363
  }
363
364
  });
364
365
  queueEvents.on("progress", ({ jobId, data }) => {
365
- console.log(`Job ${jobId} reported progress in queue ${queueName}:`, data);
366
+ log.info(`Job ${jobId} reported progress in queue ${queueName}:`, data);
366
367
  });
367
368
  queueEvents.on("removed", ({ jobId }) => {
368
- console.log(`Job ${jobId} was removed from queue ${queueName}`);
369
+ log.info(`Job ${jobId} was removed from queue ${queueName}`);
369
370
  });
370
371
  queueEvents.on("drained", () => {
371
- console.log(`Queue ${queueName} was drained`);
372
+ log.info(`Queue ${queueName} was drained`);
372
373
  });
373
374
  queueEvents.on("error", (error) => {
374
- console.log(`Error in queue ${queueName}:`, error);
375
+ log.info(`Error in queue ${queueName}:`, error);
375
376
  });
376
377
  this.queues.set(queueName, newQueue);
377
378
  }
378
379
  return this.queues.get(queueName);
379
380
  }
380
381
  async controlAgent(agentId, action) {
381
- console.log(`AgentQueueManager: Controlling agent ${agentId} with action ${action}`);
382
+ log.info(`AgentQueueManager: Controlling agent ${agentId} with action ${action}`);
382
383
  const agent = await PsAgent.findByPk(agentId, {
383
384
  include: [{ model: PsAgentClass, as: "Class" }],
384
385
  });
385
386
  if (!agent || !agent.Class) {
386
- console.error(`AgentQueueManager: Agent or Agent Class not found for agent ${agentId}`);
387
+ log.error(`AgentQueueManager: Agent or Agent Class not found for agent ${agentId}`);
387
388
  throw new Error("Agent or Agent Class not found");
388
389
  }
389
390
  const queueName = agent.Class.configuration.queueName;
390
391
  if (!queueName) {
391
- console.error(`AgentQueueManager: Queue name not defined for agent class ${agent.Class.id}`);
392
+ log.error(`AgentQueueManager: Queue name not defined for agent class ${agent.Class.id}`);
392
393
  throw new Error("Queue name not defined for this agent class");
393
394
  }
394
395
  const queue = this.getQueue(queueName);
395
- console.log(`AgentQueueManager: Adding ${action} job to queue ${queueName} for agent ${agentId}`);
396
+ log.info(`AgentQueueManager: Adding ${action} job to queue ${queueName} for agent ${agentId}`);
396
397
  await queue.add(`${action}Agent`, { agentId, action });
397
398
  const message = `${action.charAt(0).toUpperCase() + action.slice(1)} request for agent ${agentId} queued in ${queueName}`;
398
- console.log(`AgentQueueManager: ${message}`);
399
+ log.info(`AgentQueueManager: ${message}`);
399
400
  return message;
400
401
  }
401
402
  async startAgentProcessingWithWsClient(agentId, agentRunId, wsClientId, structuredAnswersOverrides) {
402
- console.log(`NotificationAgentQueueManager: Starting agent processing for agent ${agentId}`);
403
+ log.info(`NotificationAgentQueueManager: Starting agent processing for agent ${agentId}`);
403
404
  const agent = await PsAgent.findByPk(agentId, {
404
405
  include: [{ model: PsAgentClass, as: "Class" }],
405
406
  });
406
407
  if (!agent || !agent.Class) {
407
- console.error(`NotificationAgentQueueManager: Agent or Agent Class not found for agent ${agentId}`);
408
+ log.error(`NotificationAgentQueueManager: Agent or Agent Class not found for agent ${agentId}`);
408
409
  return undefined;
409
410
  }
410
411
  const agentRun = await NotificationAgentQueueManager.getAgentRun(agentRunId);
411
412
  if (!agentRun) {
412
- console.error(`NotificationAgentQueueManager: Agent run with ID ${agentRunId} not found.`);
413
+ log.error(`NotificationAgentQueueManager: Agent run with ID ${agentRunId} not found.`);
413
414
  return undefined;
414
415
  }
415
416
  const currentWorkflow = agentRun.workflow;
416
417
  const queueName = agent.Class.configuration.queueName;
417
418
  const queue = this.getQueue(queueName);
418
- console.log(`NotificationAgentQueueManager: Adding start-processing job to queue ${queueName} for agent ${agentId}`);
419
+ log.info(`NotificationAgentQueueManager: Adding start-processing job to queue ${queueName} for agent ${agentId}`);
419
420
  const action = "start";
420
421
  const job = await queue.add("control-message", {
421
422
  type: `${action}Agent${agent.id}`,
@@ -426,12 +427,12 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
426
427
  structuredAnswersOverrides: structuredAnswersOverrides,
427
428
  currentWorkflowStepIndex: currentWorkflow.currentStepIndex,
428
429
  });
429
- console.log(`NotificationAgentQueueManager: Updating agent ${agentId} status to running`);
430
+ log.info(`NotificationAgentQueueManager: Updating agent ${agentId} status to running`);
430
431
  await this.updateAgentStatus(agent.id, "running");
431
432
  return job.id;
432
433
  }
433
434
  async stopAgentProcessing(agentId, wsClientId, agentRunId) {
434
- console.log(`NotificationAgentQueueManager: Stopping agent processing for agent ${agentId}`);
435
+ log.info(`NotificationAgentQueueManager: Stopping agent processing for agent ${agentId}`);
435
436
  const agent = await PsAgent.findByPk(agentId, {
436
437
  include: [{ model: PsAgentClass, as: "Class" }],
437
438
  });
@@ -440,14 +441,14 @@ export class NotificationAgentQueueManager extends AgentQueueManager {
440
441
  }
441
442
  const agentRun = await NotificationAgentQueueManager.getAgentRun(agentRunId);
442
443
  if (!agentRun) {
443
- console.error(`NotificationAgentQueueManager: Agent run with ID ${agentRunId} not found.`);
444
+ log.error(`NotificationAgentQueueManager: Agent run with ID ${agentRunId} not found.`);
444
445
  return false;
445
446
  }
446
447
  const currentWorkflow = agentRun.workflow;
447
448
  const queueName = agent.Class.configuration.queueName;
448
449
  const queue = this.getQueue(queueName);
449
450
  const action = "stop";
450
- console.log(`NotificationAgentQueueManager: Adding stop-processing job to queue ${queueName} for agent ${agentId} ${action}`);
451
+ log.info(`NotificationAgentQueueManager: Adding stop-processing job to queue ${queueName} for agent ${agentId} ${action}`);
451
452
  await queue.add("control-message", {
452
453
  type: `${action}Agent${agent.id}`,
453
454
  agentId: agent.id,
@@ -12,6 +12,7 @@ import { PsAgent } from "@policysynth/agents/dbModels/agent.js";
12
12
  import { PsAgentClass, PsAiModel } from "@policysynth/agents/dbModels/index.js";
13
13
  import { NotificationAgentQueueManager } from "./notificationAgentQueueManager.js";
14
14
  import models from "../../models/index.cjs";
15
+ import log from "../../utils/loggerTs.js";
15
16
  const dbModels = models;
16
17
  const YpGroup = dbModels.Group;
17
18
  export class SubscriptionManager {
@@ -51,7 +52,7 @@ export class SubscriptionManager {
51
52
  }
52
53
  }
53
54
  async cloneCommunityTemplate(communityTemplateId, toDomainId) {
54
- console.log("cloneCommunityTemplate", communityTemplateId, toDomainId);
55
+ log.info("cloneCommunityTemplate", communityTemplateId, toDomainId);
55
56
  return new Promise((resolve, reject) => {
56
57
  copyCommunity(communityTemplateId, toDomainId, {
57
58
  copyGroups: true,
@@ -73,15 +74,15 @@ export class SubscriptionManager {
73
74
  });
74
75
  }
75
76
  async cloneCommunityWorkflowTemplate(agentProduct, domainId, currentUser) {
76
- console.log("cloneCommunityWorkflowTemplate", agentProduct, domainId);
77
+ log.info("cloneCommunityWorkflowTemplate", agentProduct, domainId);
77
78
  let newCommunity = await this.cloneCommunityTemplate(agentProduct.configuration.templateWorkflowCommunityId, domainId);
78
- console.log("newCommunity", newCommunity);
79
+ log.info("newCommunity", newCommunity);
79
80
  const groups = await YpGroup.findAll({
80
81
  where: {
81
82
  community_id: newCommunity.id
82
83
  }
83
84
  });
84
- console.log("groups", groups);
85
+ log.info("groups", groups);
85
86
  // Find the workflow group
86
87
  const workflowGroup = groups.find((group) => group.configuration.groupType == 3);
87
88
  if (!workflowGroup) {
@@ -101,32 +102,32 @@ export class SubscriptionManager {
101
102
  const hasCommunityUser = await newCommunity.hasCommunityUsers(userInstance);
102
103
  if (!hasCommunityUser) {
103
104
  await newCommunity.addCommunityUsers(userInstance);
104
- console.log("Added current user as community user", userInstance.id);
105
+ log.info("Added current user as community user", userInstance.id);
105
106
  }
106
107
  else {
107
- console.log("Community already has the user as user", userInstance.id);
108
+ log.info("Community already has the user as user", userInstance.id);
108
109
  }
109
110
  for (const group of groups) {
110
111
  const hasGroupAdmin = await group.hasGroupAdmins(userInstance);
111
112
  if (!hasGroupAdmin) {
112
113
  await group.addGroupAdmins(userInstance);
113
- console.log("Added current user as group admin", userInstance.id);
114
+ log.info("Added current user as group admin", userInstance.id);
114
115
  }
115
116
  else {
116
- console.log("Group already has the user as admin", userInstance.id);
117
+ log.info("Group already has the user as admin", userInstance.id);
117
118
  }
118
119
  const hasGroupUser = await group.hasGroupUsers(userInstance);
119
120
  if (!hasGroupUser) {
120
121
  await group.addGroupUsers(userInstance);
121
- console.log("Added current user as group user", userInstance.id);
122
+ log.info("Added current user as group user", userInstance.id);
122
123
  }
123
124
  else {
124
- console.log("Group already has the user as user", userInstance.id);
125
+ log.info("Group already has the user as user", userInstance.id);
125
126
  }
126
127
  }
127
128
  // Create a map of old group IDs to new group IDs
128
129
  const groupIdMap = newCommunity.groupMapping;
129
- console.log("groupIdMap", groupIdMap);
130
+ log.info("groupIdMap", groupIdMap);
130
131
  // Get the original top level agent and all its sub-agents
131
132
  const originalTopLevelAgent = await PsAgent.findByPk(topLevelAgentId, {
132
133
  include: [
@@ -178,9 +179,9 @@ export class SubscriptionManager {
178
179
  group_id: workflowGroup.id,
179
180
  parent_agent_id: undefined
180
181
  });
181
- console.log("clonedTopLevelAgent", clonedTopLevelAgent);
182
+ log.info("clonedTopLevelAgent", clonedTopLevelAgent);
182
183
  if (originalTopLevelAgent.Class?.class_base_id) {
183
- console.log("Setting agentUuidMap", originalTopLevelAgent.Class.class_base_id, clonedTopLevelAgent.id);
184
+ log.info("Setting agentUuidMap", originalTopLevelAgent.Class.class_base_id, clonedTopLevelAgent.id);
184
185
  agentUuidMap.set(originalTopLevelAgent.Class.class_base_id, clonedTopLevelAgent.id);
185
186
  }
186
187
  const agentInputConnectorGroupsIds = new Map();
@@ -199,7 +200,7 @@ export class SubscriptionManager {
199
200
  if (subAgent.Class?.class_base_id) {
200
201
  agentUuidMap.set(subAgent.Class.class_base_id, clonedSubAgent.id);
201
202
  }
202
- console.log("agentUuidMap", agentUuidMap);
203
+ log.info("agentUuidMap", agentUuidMap);
203
204
  const subAgentAiModels = await subAgent.getAiModels();
204
205
  if (subAgentAiModels && subAgentAiModels.length > 0) {
205
206
  await clonedSubAgent.setAiModels(subAgentAiModels);
@@ -208,7 +209,7 @@ export class SubscriptionManager {
208
209
  for (const connector of (subAgent.InputConnectors ??
209
210
  [])) {
210
211
  const connectorConfig = { ...connector.configuration };
211
- console.log("connectorConfig", connectorConfig);
212
+ log.info("connectorConfig", connectorConfig);
212
213
  // Update the group ID if it exists in the map
213
214
  if (connectorConfig.groupId &&
214
215
  groupIdMap.has(connectorConfig.groupId)) {
@@ -231,7 +232,7 @@ export class SubscriptionManager {
231
232
  for (const connector of (subAgent.OutputConnectors ??
232
233
  [])) {
233
234
  const connectorConfig = { ...connector.configuration };
234
- console.log("connectorConfig", connectorConfig);
235
+ log.info("connectorConfig", connectorConfig);
235
236
  // Update the group ID if it exists in the map
236
237
  if (connectorConfig.groupId &&
237
238
  groupIdMap.has(connectorConfig.groupId)) {
@@ -253,7 +254,7 @@ export class SubscriptionManager {
253
254
  }
254
255
  // Update the workflow group configuration
255
256
  workflowGroup.configuration.agents.topLevelAgentId = clonedTopLevelAgent.id;
256
- console.log(`Set top level agent id to ${clonedTopLevelAgent.id} for workflow group ${workflowGroup.id}`);
257
+ log.info(`Set top level agent id to ${clonedTopLevelAgent.id} for workflow group ${workflowGroup.id}`);
257
258
  workflowGroup.changed('configuration', true);
258
259
  await workflowGroup.save();
259
260
  if (agentProduct.configuration.structuredAnswersOverride) {
@@ -264,11 +265,11 @@ export class SubscriptionManager {
264
265
  ...(originalTopLevelAgent.SubAgents ?? []),
265
266
  originalTopLevelAgent,
266
267
  ]) {
267
- console.log("update answers for agent", agent);
268
+ log.info("update answers for agent", agent);
268
269
  if (agent.configuration?.answers) {
269
270
  const answerIndex = agent.configuration.answers.findIndex((a) => a.uniqueId === override.uniqueId);
270
271
  if (answerIndex !== -1) {
271
- console.log("update answers for agent", agent.configuration.answers[answerIndex], override);
272
+ log.info("update answers for agent", agent.configuration.answers[answerIndex], override);
272
273
  agent.configuration.answers[answerIndex] = {
273
274
  ...agent.configuration.answers[answerIndex],
274
275
  ...override,
@@ -286,7 +287,7 @@ export class SubscriptionManager {
286
287
  newStep.agentId = agentUuidMap.get(step.agentClassUuid);
287
288
  }
288
289
  else if (step.agentClassUuid) {
289
- console.error("agentClassUuid not found in agentUuidMap", step.agentClassUuid);
290
+ log.error("agentClassUuid not found in agentUuidMap", step.agentClassUuid);
290
291
  }
291
292
  if (newStep.type === "engagmentFromInputConnector" && newStep.agentId) {
292
293
  newStep.groupId = agentInputConnectorGroupsIds.get(newStep.agentId);
@@ -297,7 +298,7 @@ export class SubscriptionManager {
297
298
  return newStep;
298
299
  });
299
300
  updatedWorkflow.workflowGroupId = workflowGroup.id;
300
- console.log("updatedWorkflow", updatedWorkflow);
301
+ log.info("updatedWorkflow", updatedWorkflow);
301
302
  return {
302
303
  workflow: updatedWorkflow,
303
304
  requiredQuestions: agentProduct.configuration.requiredStructuredQuestions,
@@ -460,7 +461,7 @@ export class SubscriptionManager {
460
461
  }
461
462
  }
462
463
  catch (error) {
463
- console.error("Error starting agent processing:", error);
464
+ log.error("Error starting agent processing:", error);
464
465
  return false;
465
466
  }
466
467
  }
@@ -515,7 +516,7 @@ export class SubscriptionManager {
515
516
  let runsUsed = subscription.metadata?.runs_used || 0;
516
517
  runsUsed += 1;
517
518
  if (runsUsed > plan.configuration.max_runs_per_cycle) {
518
- console.error("Maximum runs per cycle exceeded");
519
+ log.error("Maximum runs per cycle exceeded");
519
520
  //TODO: Look into activating this again !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
520
521
  //throw new Error("Maximum runs per cycle exceeded");
521
522
  }
@@ -1,5 +1,6 @@
1
1
  import { DataTypes, Model } from "sequelize";
2
2
  import { sequelize } from "@policysynth/agents/dbModels/sequelize.js";
3
+ import log from "../../utils/loggerTs.js";
3
4
  export class YpAgentProduct extends Model {
4
5
  }
5
6
  YpAgentProduct.init({
@@ -70,7 +71,7 @@ YpAgentProduct.init({
70
71
  underscored: true,
71
72
  });
72
73
  YpAgentProduct.associate = (models) => {
73
- console.log(`YpAgentProduct.associate`);
74
+ log.info(`YpAgentProduct.associate`);
74
75
  YpAgentProduct.belongsTo(models.YpSubscriptionUser, {
75
76
  foreignKey: "user_id",
76
77
  as: "User",
@@ -1,5 +1,6 @@
1
1
  import { DataTypes, Model } from 'sequelize';
2
2
  import { sequelize } from "@policysynth/agents/dbModels/sequelize.js";
3
+ import log from "../../utils/loggerTs.js";
3
4
  export class YpAgentProductBoosterPurchase extends Model {
4
5
  }
5
6
  YpAgentProductBoosterPurchase.init({
@@ -38,7 +39,7 @@ YpAgentProductBoosterPurchase.init({
38
39
  });
39
40
  // Associations
40
41
  YpAgentProductBoosterPurchase.associate = (models) => {
41
- console.log('YpAgentProductBoosterPurchase.associate');
42
+ log.info('YpAgentProductBoosterPurchase.associate');
42
43
  YpAgentProductBoosterPurchase.belongsTo(models.YpSubscriptionUser, {
43
44
  foreignKey: 'user_id',
44
45
  as: 'User'
@@ -5,12 +5,13 @@ import { YpSubscriptionPlan } from "../subscriptionPlan.js";
5
5
  import { YpSubscriptionUser } from "../subscriptionUser.js";
6
6
  import { YpSubscription } from "../subscription.js";
7
7
  import { YpAgentProductBundle } from "../agentProductBundle.js";
8
+ import log from "../../../utils/loggerTs.js";
8
9
  async function createAgentProductsAndPlans() {
9
10
  let transaction;
10
11
  try {
11
12
  // Connect to the database
12
13
  await sequelize.authenticate();
13
- console.log("Connection has been established successfully.");
14
+ log.info("Connection has been established successfully.");
14
15
  // Start transaction
15
16
  transaction = await sequelize.transaction();
16
17
  // Define the user and domain (assuming they exist or create them)
@@ -428,7 +429,7 @@ async function createAgentProductsAndPlans() {
428
429
  runs_used: 0,
429
430
  extra_runs_purchased: 0,
430
431
  }, { transaction });
431
- console.log(`Created Agent Product: ${agentData.name} (ID: ${agentProduct.id})`);
432
+ log.info(`Created Agent Product: ${agentData.name} (ID: ${agentProduct.id})`);
432
433
  // Create the Subscription Plan associated with this Agent Product
433
434
  const planData = agentData.subscriptionPlan;
434
435
  const subscriptionPlan = await YpSubscriptionPlan.create({
@@ -454,19 +455,19 @@ async function createAgentProductsAndPlans() {
454
455
  runs_remaining: planData.configuration.max_runs_per_cycle,
455
456
  },
456
457
  }, { transaction });
457
- console.log(`Created Free Trial Subscription (ID: ${subscription.id})`);
458
+ log.info(`Created Free Trial Subscription (ID: ${subscription.id})`);
458
459
  }
459
- console.log(`Created Subscription Plan: ${planData.name} (ID: ${subscriptionPlan.id})`);
460
+ log.info(`Created Subscription Plan: ${planData.name} (ID: ${subscriptionPlan.id})`);
460
461
  }
461
462
  // Commit the transaction
462
463
  await transaction.commit();
463
- console.log("All Agent Products and Subscription Plans have been created.");
464
+ log.info("All Agent Products and Subscription Plans have been created.");
464
465
  }
465
466
  catch (error) {
466
467
  // Rollback the transaction if there's an error
467
468
  if (transaction)
468
469
  await transaction.rollback();
469
- console.error("Error creating Agent Products and Subscription Plans:", error);
470
+ log.error("Error creating Agent Products and Subscription Plans:", error);
470
471
  throw error; // Re-throw the error to handle it at a higher level if needed
471
472
  }
472
473
  finally {