@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
@@ -3,6 +3,7 @@ import { YpBaseAssistantWithVoice } from "./baseAssistantWithVoice.js";
3
3
  import { AgentSelectionMode } from "./modes/agentSelectionMode.js";
4
4
  import { DirectConversationMode } from "./modes/agentDirectConnection.js";
5
5
  import { SubscriptionManager } from "../managers/subscriptionManager.js";
6
+ import log from "../../utils/loggerTs.js";
6
7
  export class YpAgentAssistant extends YpBaseAssistantWithVoice {
7
8
  constructor(wsClientId, wsClients, redis, voiceEnabled, redisKey, domainId) {
8
9
  super(wsClientId, wsClients, redis, voiceEnabled, redisKey, domainId);
@@ -30,7 +31,7 @@ export class YpAgentAssistant extends YpBaseAssistantWithVoice {
30
31
  }
31
32
  handleMemoryChanged(memory) {
32
33
  if (this.DEBUG) {
33
- console.log(`Sending memory changed to client: ${JSON.stringify(this.simplifiedMemory, null, 2)}`);
34
+ log.info(`Sending memory changed to client: ${JSON.stringify(this.simplifiedMemory, null, 2)}`);
34
35
  }
35
36
  this.sendToClient("system", JSON.stringify(this.simplifiedMemory), "memory-changed");
36
37
  }
@@ -39,12 +40,12 @@ export class YpAgentAssistant extends YpBaseAssistantWithVoice {
39
40
  }
40
41
  get isSubscribedToCurrentAgentProduct() {
41
42
  if (this.DEBUG) {
42
- console.log(`-------------------------------------------> isSubscribedToCurrentAgent: ${JSON.stringify(this.memory.currentAgentStatus, null, 2)}`);
43
+ log.info(`-------------------------------------------> isSubscribedToCurrentAgent: ${JSON.stringify(this.memory.currentAgentStatus, null, 2)}`);
43
44
  }
44
45
  return this.memory.currentAgentStatus?.subscriptionId != undefined;
45
46
  }
46
47
  get hasConfiguredcurrentAgentProduct() {
47
- console.log(`configuration: ${this.redisKey}: ${JSON.stringify(this.memory.currentAgentStatus, null, 2)}`);
48
+ log.info(`configuration: ${this.redisKey}: ${JSON.stringify(this.memory.currentAgentStatus, null, 2)}`);
48
49
  return this.memory.currentAgentStatus?.configurationState === "configured";
49
50
  }
50
51
  async isCurrentAgentRunning() {
@@ -5,6 +5,7 @@ import { YpAgentProduct } from "../models/agentProduct.js";
5
5
  import { YpSubscription } from "../models/subscription.js";
6
6
  import { YpSubscriptionPlan } from "../models/subscriptionPlan.js";
7
7
  import { YpAgentProductRun } from "../models/agentProductRun.js";
8
+ import log from "../../utils/loggerTs.js";
8
9
  /**
9
10
  * Common modes that implementations might use
10
11
  */
@@ -76,22 +77,22 @@ Never engage in off topic conversations, always politely steer the conversation
76
77
  const message = JSON.parse(data.toString());
77
78
  switch (message.type) {
78
79
  case "client_system_message":
79
- console.log("WebSockets: Processing client_system_message:", message);
80
+ log.info("WebSockets: Processing client_system_message:", message);
80
81
  this.processClientSystemMessage(message);
81
82
  break;
82
83
  default:
83
- //console.log('Unhandled message type:', message.type);
84
+ //log.info('Unhandled message type:', message.type);
84
85
  }
85
86
  }
86
87
  catch (error) {
87
- console.error("Error processing message:", error);
88
+ log.error("Error processing message:", error);
88
89
  }
89
90
  }
90
91
  setupClientSystemMessageListener() {
91
- console.log("WebSockets: setupClientSystemMessageListener called for wsClientId:", this.wsClientId, this.clientSystemMessageListener);
92
+ log.info("WebSockets: setupClientSystemMessageListener called for wsClientId:", this.wsClientId, this.clientSystemMessageListener);
92
93
  this.wsClientSocket.on("message", this.clientSystemMessageListener);
93
94
  const listenerCountAfter = this.wsClientSocket.listenerCount("message");
94
- console.log('Number of "message" listeners after adding:', listenerCountAfter);
95
+ log.info('Number of "message" listeners after adding:', listenerCountAfter);
95
96
  }
96
97
  async getCurrentAgentProduct() {
97
98
  if (this.memory.currentAgentStatus?.subscriptionPlanId) {
@@ -109,7 +110,7 @@ Never engage in off topic conversations, always politely steer the conversation
109
110
  return subscriptionPlan?.AgentProduct;
110
111
  }
111
112
  else {
112
- console.error("--------------------> No subscription plan found");
113
+ log.error("--------------------> No subscription plan found");
113
114
  }
114
115
  return undefined;
115
116
  }
@@ -142,30 +143,30 @@ Never engage in off topic conversations, always politely steer the conversation
142
143
  }));
143
144
  }
144
145
  else {
145
- console.error("No active agent run found");
146
+ log.error("No active agent run found");
146
147
  }
147
148
  return undefined;
148
149
  }
149
150
  async updateAiModelSession(message) {
150
- console.log(`updateAiModelSession: ${message}`);
151
+ log.info(`updateAiModelSession: ${message}`);
151
152
  }
152
153
  async maybeSendTextResponse(message) {
153
154
  if (!this.voiceEnabled) {
154
155
  this.sendToClient("assistant", message, "message");
155
156
  await this.addAssistantMessage(message);
156
- console.debug(`Sent text message to client: ${message}`);
157
+ log.debug(`Sent text message to client: ${message}`);
157
158
  }
158
159
  }
159
160
  async processClientSystemMessage(clientEvent) {
160
- console.log(`processClientSystemMessage: ${JSON.stringify(clientEvent, null, 2)}`);
161
+ log.info(`processClientSystemMessage: ${JSON.stringify(clientEvent, null, 2)}`);
161
162
  await this.loadMemoryAsync();
162
163
  if (clientEvent.message === "user_logged_in") {
163
- console.log(`user_logged_in emitting`);
164
+ log.info(`user_logged_in emitting`);
164
165
  this.emit("update-ai-model-session", "User is logged in, lets move to the next step");
165
166
  await this.maybeSendTextResponse("Logged in, ready to move on to the next step.");
166
167
  }
167
168
  else if (clientEvent.message === "agent_configuration_submitted") {
168
- console.log(`agent_configuration_submitted emitting`);
169
+ log.info(`agent_configuration_submitted emitting`);
169
170
  try {
170
171
  if (!this.memory.currentAgentStatus.subscriptionId) {
171
172
  throw new Error("No subscription found");
@@ -190,13 +191,13 @@ Never engage in off topic conversations, always politely steer the conversation
190
191
  await this.maybeSendTextResponse("The agent configuration was submitted successfully and the agent is ready to create its first agent run.");
191
192
  }
192
193
  catch (error) {
193
- console.error(`Error finding subscription: ${error}`);
194
+ log.error(`Error finding subscription: ${error}`);
194
195
  this.emit("update-ai-model-session", `Failed to submit agent configuration: ${error}`);
195
196
  }
196
197
  }
197
198
  else if (clientEvent.message === "agent_run_changed") {
198
199
  try {
199
- console.log(`agent_run_changed`);
200
+ log.info(`agent_run_changed`);
200
201
  if (!this.memory.currentAgentStatus?.activeAgentRunId) {
201
202
  throw new Error("No active agent run found");
202
203
  }
@@ -208,12 +209,12 @@ Never engage in off topic conversations, always politely steer the conversation
208
209
  if (!agentRun) {
209
210
  throw new Error("No agent run found");
210
211
  }
211
- console.log(`agent_run_changed emitting`);
212
+ log.info(`agent_run_changed emitting`);
212
213
  const currentWorkflowStep = agentRun.workflow?.steps[agentRun.workflow?.currentStepIndex];
213
214
  this.emit("update-ai-model-session", `The agent run status has been updated to ${agentRun.status} ${JSON.stringify({ workflow: agentRun.workflow, currentWorkflowStep }, null, 2)} offer the user assistance with this next step in the workflow`);
214
215
  }
215
216
  catch (error) {
216
- console.error(`Error finding agent run: ${error}`);
217
+ log.error(`Error finding agent run: ${error}`);
217
218
  this.emit("update-ai-model-session", `Failed to update agent run status: ${error}`);
218
219
  }
219
220
  }
@@ -254,7 +255,7 @@ Never engage in off topic conversations, always politely steer the conversation
254
255
  ? "configured"
255
256
  : "not_configured",
256
257
  };
257
- console.log(`updateCurrentAgentProductPlan: ${JSON.stringify(this.memory.currentAgentStatus, null, 2)}`);
258
+ log.info(`updateCurrentAgentProductPlan: ${JSON.stringify(this.memory.currentAgentStatus, null, 2)}`);
258
259
  await this.saveMemory();
259
260
  }
260
261
  /**
@@ -262,7 +263,7 @@ Never engage in off topic conversations, always politely steer the conversation
262
263
  */
263
264
  convertToolResultToMessage(toolCall, result) {
264
265
  if (this.DEBUG) {
265
- console.log(`convertToolResultToMessage: ${JSON.stringify(toolCall, null, 2)}`);
266
+ log.info(`convertToolResultToMessage: ${JSON.stringify(toolCall, null, 2)}`);
266
267
  }
267
268
  return {
268
269
  role: "tool",
@@ -276,7 +277,7 @@ Never engage in off topic conversations, always politely steer the conversation
276
277
  */
277
278
  async handleToolCalls(toolCalls) {
278
279
  if (this.DEBUG) {
279
- console.log(`====================================> handleToolCalls: ${JSON.stringify(Array.from(toolCalls.values()), null, 2)}`);
280
+ log.info(`====================================> handleToolCalls: ${JSON.stringify(Array.from(toolCalls.values()), null, 2)}`);
280
281
  }
281
282
  const toolResponses = [];
282
283
  for (const toolCall of toolCalls.values()) {
@@ -295,7 +296,7 @@ Never engage in off topic conversations, always politely steer the conversation
295
296
  // Execute the function and get result
296
297
  const result = await func.handler(parsedArgs);
297
298
  if (this.DEBUG) {
298
- console.log(`----------------------------------> Tool execution result:`, JSON.stringify(result, null, 2));
299
+ log.info(`----------------------------------> Tool execution result:`, JSON.stringify(result, null, 2));
299
300
  }
300
301
  // Store the result in memory for context
301
302
  if (result.success && result.data) {
@@ -319,7 +320,7 @@ Never engage in off topic conversations, always politely steer the conversation
319
320
  await this.saveMemoryIfNeeded();
320
321
  }
321
322
  else {
322
- console.error(`No data returned from tool execution: ${toolCall.name}`);
323
+ log.error(`No data returned from tool execution: ${toolCall.name}`);
323
324
  }
324
325
  if (result.html) {
325
326
  this.sendToClient("assistant", result.html, "html", result.uniqueToken, true);
@@ -327,7 +328,7 @@ Never engage in off topic conversations, always politely steer the conversation
327
328
  }
328
329
  if (result.clientEvents) {
329
330
  if (this.DEBUG) {
330
- console.log(`clientEvents: ${JSON.stringify(result.clientEvents, null, 2)}`);
331
+ log.info(`clientEvents: ${JSON.stringify(result.clientEvents, null, 2)}`);
331
332
  }
332
333
  for (const clientEvent of result.clientEvents) {
333
334
  this.sendToClient("assistant", clientEvent.details, clientEvent.name);
@@ -335,12 +336,12 @@ Never engage in off topic conversations, always politely steer the conversation
335
336
  }
336
337
  // If error, throw it after recording the result
337
338
  if (!result.success) {
338
- console.error(`Unknown error in tool execution: ${result.error}`);
339
+ log.error(`Unknown error in tool execution: ${result.error}`);
339
340
  }
340
341
  }
341
342
  catch (error) {
342
343
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
343
- console.error(`Error executing tool ${toolCall.name}: ${errorMessage}`);
344
+ log.error(`Error executing tool ${toolCall.name}: ${errorMessage}`);
344
345
  throw error;
345
346
  }
346
347
  }
@@ -354,7 +355,7 @@ Never engage in off topic conversations, always politely steer the conversation
354
355
  */
355
356
  async handleToolResponses(toolResponses) {
356
357
  if (this.DEBUG) {
357
- console.log(`handleToolResponses: ${JSON.stringify(toolResponses, null, 2)}`);
358
+ log.info(`handleToolResponses: ${JSON.stringify(toolResponses, null, 2)}`);
358
359
  }
359
360
  // Get existing chat messages
360
361
  const messages = [
@@ -378,7 +379,7 @@ Never engage in off topic conversations, always politely steer the conversation
378
379
  },
379
380
  ...toolResponses,
380
381
  ];
381
- console.log(`handleToolResponses: ${JSON.stringify(messages, null, 2)}`);
382
+ log.info(`handleToolResponses: ${JSON.stringify(messages, null, 2)}`);
382
383
  try {
383
384
  const stream = await this.openaiClient.chat.completions.create({
384
385
  model: this.modelName,
@@ -397,17 +398,17 @@ Never engage in off topic conversations, always politely steer the conversation
397
398
  await this.streamWebSocketResponses(stream);
398
399
  }
399
400
  catch (error) {
400
- console.error("Error handling tool responses:", error);
401
+ log.error("Error handling tool responses:", error);
401
402
  throw error;
402
403
  }
403
404
  }
404
405
  async setupMemoryAsync() {
405
406
  if (!this.memory) {
406
- console.log("loadMemoryWithOwnership: loading memory");
407
+ log.info("loadMemoryWithOwnership: loading memory");
407
408
  this.memory = (await this.loadMemory());
408
409
  }
409
410
  if (!this.memory) {
410
- console.error("loadMemoryWithOwnership: No memory found!!!");
411
+ log.error("loadMemoryWithOwnership: No memory found!!!");
411
412
  }
412
413
  }
413
414
  async loadMemoryAsync() {
@@ -418,10 +419,10 @@ Never engage in off topic conversations, always politely steer the conversation
418
419
  }
419
420
  async setCurrentMode(mode) {
420
421
  if (mode) {
421
- console.log(`Setting currentMode to ${mode} it was ${this.memory.currentMode}`);
422
+ log.info(`Setting currentMode to ${mode} it was ${this.memory.currentMode}`);
422
423
  }
423
424
  else {
424
- console.log(`No currentMode provided, keeping ${this.memory.currentMode}`);
425
+ log.info(`No currentMode provided, keeping ${this.memory.currentMode}`);
425
426
  }
426
427
  await this.loadMemoryAsync();
427
428
  this.memory.currentMode = mode;
@@ -431,13 +432,13 @@ Never engage in off topic conversations, always politely steer the conversation
431
432
  * Initialize modes from subclass definitions
432
433
  */
433
434
  async initializeModes() {
434
- console.log("---------------------> initializeModes");
435
+ log.info("---------------------> initializeModes");
435
436
  await this.setupMemoryAsync();
436
437
  this.availableTools.clear();
437
438
  const modes = await this.defineAvailableModes();
438
439
  for (const mode of modes) {
439
440
  this.modes.set(mode.name, mode);
440
- console.log(`initializeModes: ${mode.name}`);
441
+ log.info(`initializeModes: ${mode.name}`);
441
442
  // Register mode's functions
442
443
  for (const func of mode.tools) {
443
444
  this.availableTools.set(func.name, func);
@@ -455,7 +456,7 @@ Never engage in off topic conversations, always politely steer the conversation
455
456
  getCurrentModeFunctions() {
456
457
  const currentMode = this.modes.get(this.memory.currentMode);
457
458
  if (!currentMode) {
458
- console.error(`No current mode found: ${this.memory.currentMode}`);
459
+ log.error(`No current mode found: ${this.memory.currentMode}`);
459
460
  return [];
460
461
  }
461
462
  // Combine mode-specific functions with core functions
@@ -480,7 +481,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
480
481
  getCurrentSystemPrompt() {
481
482
  const currentMode = this.modes.get(this.memory.currentMode);
482
483
  if (!currentMode) {
483
- console.error(`No current mode found: ${this.memory.currentMode}`);
484
+ log.error(`No current mode found: ${this.memory.currentMode}`);
484
485
  return `${this.defaultSystemPrompt}\n\n${this.renderLoginStatus()}`;
485
486
  }
486
487
  return `${this.defaultSystemPrompt}\n\n${this.renderLoginStatus()}\n\n<furtherAgentInstructions>\n${currentMode.systemPrompt}\n</furtherAgentInstructions>`;
@@ -587,11 +588,11 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
587
588
  parameters: f.parameters,
588
589
  },
589
590
  }));
590
- console.log("======================> conversation currentMode", this.memory?.currentMode);
591
+ log.info("======================> conversation currentMode", this.memory?.currentMode);
591
592
  if (this.DEBUG) {
592
- console.log("======================> conversation", JSON.stringify(messages, null, 2));
593
+ log.info("======================> conversation", JSON.stringify(messages, null, 2));
593
594
  }
594
- console.log("======================> conversation", JSON.stringify(tools, null, 2));
595
+ log.info("======================> conversation", JSON.stringify(tools, null, 2));
595
596
  const stream = await this.openaiClient.chat.completions.create({
596
597
  model: this.modelName,
597
598
  messages,
@@ -602,7 +603,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
602
603
  await this.streamWebSocketResponses(stream);
603
604
  }
604
605
  catch (error) {
605
- console.error("Error in conversation:", error);
606
+ log.error("Error in conversation:", error);
606
607
  this.sendToClient("assistant", "Error processing request", "error");
607
608
  }
608
609
  }
@@ -612,7 +613,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
612
613
  return agentProduct;
613
614
  }
614
615
  catch (error) {
615
- console.error(`Error getting agent product for ${agentProductId}: ${error}`);
616
+ log.error(`Error getting agent product for ${agentProductId}: ${error}`);
616
617
  return null;
617
618
  }
618
619
  }
@@ -627,7 +628,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
627
628
  return { role: message.sender, content: message.message };
628
629
  }
629
630
  else {
630
- console.debug("Message content is null, message: " + JSON.stringify(message));
631
+ log.debug("Message content is null, message: " + JSON.stringify(message));
631
632
  return null;
632
633
  }
633
634
  })
@@ -638,17 +639,17 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
638
639
  */
639
640
  async handleModeSwitch(newMode, reason, params) {
640
641
  await this.loadMemoryAsync();
641
- console.log(`handleModeSwitch: ${newMode}${reason ? ": " + reason : ""}`);
642
+ log.info(`handleModeSwitch: ${newMode}${reason ? ": " + reason : ""}`);
642
643
  const oldMode = this.memory.currentMode;
643
644
  if (!this.modes.has(newMode)) {
644
645
  throw new Error(`Invalid mode: ${newMode}`);
645
646
  }
646
647
  if (oldMode === newMode) {
647
- console.error(`Trying to switch to the same mode: ${oldMode} to ${newMode}`);
648
+ log.error(`Trying to switch to the same mode: ${oldMode} to ${newMode}`);
648
649
  return;
649
650
  }
650
651
  if (oldMode && !this.validateModeTransition(oldMode, newMode)) {
651
- console.warn(`Invalid mode transition from ${oldMode} to ${newMode}`);
652
+ log.warn(`Invalid mode transition from ${oldMode} to ${newMode}`);
652
653
  }
653
654
  // Perform cleanup of old mode
654
655
  if (oldMode) {
@@ -671,7 +672,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
671
672
  mode: this.memory.currentMode,
672
673
  }));
673
674
  await this.saveMemory();
674
- console.log("handleModeSwitch: CurrentMode after save", this.memory.currentMode);
675
+ log.info("handleModeSwitch: CurrentMode after save", this.memory.currentMode);
675
676
  this.sendToClient("system", newMode, "modeChange", undefined, true);
676
677
  }
677
678
  async addUserMessage(message) {
@@ -710,7 +711,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
710
711
  async streamWebSocketResponses(stream) {
711
712
  return new Promise(async (resolve, reject) => {
712
713
  if (this.DEBUG)
713
- console.log("Starting streamWebSocketResponses");
714
+ log.info("Starting streamWebSocketResponses");
714
715
  this.sendToClient("assistant", "", "start");
715
716
  try {
716
717
  let botMessage = "";
@@ -719,32 +720,32 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
719
720
  let currentToolCallId = null;
720
721
  for await (const part of stream) {
721
722
  if (this.DEBUG) {
722
- console.log("Received stream part:", JSON.stringify(part, null, 2));
723
+ log.info("Received stream part:", JSON.stringify(part, null, 2));
723
724
  }
724
725
  if (!part.choices?.[0]?.delta) {
725
726
  if (this.DEBUG)
726
- console.log("Skipping invalid stream part - no choices or delta");
727
+ log.info("Skipping invalid stream part - no choices or delta");
727
728
  continue;
728
729
  }
729
730
  const delta = part.choices[0].delta;
730
731
  if (this.DEBUG) {
731
- console.log("Processing delta:", JSON.stringify(delta, null, 2));
732
+ log.info("Processing delta:", JSON.stringify(delta, null, 2));
732
733
  }
733
734
  if ("tool_calls" in delta && delta.tool_calls) {
734
735
  if (this.DEBUG)
735
- console.log("Processing tool calls in delta");
736
+ log.info("Processing tool calls in delta");
736
737
  for (const toolCall of delta.tool_calls) {
737
738
  // If we have a new tool call ID, update the current ID
738
739
  if (toolCall.id) {
739
740
  if (this.DEBUG)
740
- console.log(`Setting current tool call ID to: ${toolCall.id}`);
741
+ log.info(`Setting current tool call ID to: ${toolCall.id}`);
741
742
  currentToolCallId = toolCall.id;
742
743
  }
743
744
  // Always use the currentToolCallId for processing
744
745
  if (currentToolCallId) {
745
746
  const now = Date.now();
746
747
  if (this.DEBUG) {
747
- console.log(`Processing tool call ${currentToolCallId}:`, {
748
+ log.info(`Processing tool call ${currentToolCallId}:`, {
748
749
  name: toolCall.function?.name,
749
750
  newArguments: toolCall.function?.arguments,
750
751
  exists: toolCalls.has(currentToolCallId),
@@ -753,7 +754,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
753
754
  // Initialize tool call if it's new
754
755
  if (!toolCalls.has(currentToolCallId)) {
755
756
  if (this.DEBUG)
756
- console.log(`Initializing new tool call ${currentToolCallId}`);
757
+ log.info(`Initializing new tool call ${currentToolCallId}`);
757
758
  toolCalls.set(currentToolCallId, {
758
759
  id: currentToolCallId,
759
760
  name: toolCall.function?.name ?? "",
@@ -766,13 +767,13 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
766
767
  // Check timeout
767
768
  if (now - existingCall.startTime > this.toolCallTimeout) {
768
769
  if (this.DEBUG)
769
- console.log(`Tool call timeout for ${existingCall.name}`);
770
+ log.info(`Tool call timeout for ${existingCall.name}`);
770
771
  throw new Error(`Tool call timeout for ${existingCall.name}`);
771
772
  }
772
773
  // Update name if provided
773
774
  if (toolCall.function?.name) {
774
775
  if (this.DEBUG)
775
- console.log(`Updating tool call name to ${toolCall.function.name}`);
776
+ log.info(`Updating tool call name to ${toolCall.function.name}`);
776
777
  existingCall.name = toolCall.function.name;
777
778
  }
778
779
  // Concatenate arguments if provided
@@ -780,7 +781,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
780
781
  const currentArgs = toolCallArguments.get(currentToolCallId) || "";
781
782
  const newArgs = currentArgs + toolCall.function.arguments;
782
783
  if (this.DEBUG) {
783
- console.log(`Updating arguments for ${currentToolCallId}:`, {
784
+ log.info(`Updating arguments for ${currentToolCallId}:`, {
784
785
  previous: currentArgs,
785
786
  new: toolCall.function.arguments,
786
787
  combined: newArgs,
@@ -791,7 +792,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
791
792
  }
792
793
  toolCalls.set(currentToolCallId, existingCall);
793
794
  if (this.DEBUG) {
794
- console.log(`Current state of tool call ${currentToolCallId}:`, {
795
+ log.info(`Current state of tool call ${currentToolCallId}:`, {
795
796
  name: existingCall.name,
796
797
  arguments: existingCall.arguments,
797
798
  });
@@ -799,22 +800,22 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
799
800
  }
800
801
  else {
801
802
  if (this.DEBUG)
802
- console.log("No current tool call ID available");
803
+ log.info("No current tool call ID available");
803
804
  }
804
805
  }
805
806
  }
806
807
  else if ("content" in delta && delta.content) {
807
808
  if (this.DEBUG)
808
- console.log("Processing content:", delta.content);
809
+ log.info("Processing content:", delta.content);
809
810
  const content = delta.content;
810
811
  this.sendToClient("assistant", content);
811
812
  botMessage += content;
812
813
  }
813
814
  const finishReason = part.choices[0].finish_reason;
814
815
  if (this.DEBUG) {
815
- console.log("Finish reason:", finishReason);
816
+ log.info("Finish reason:", finishReason);
816
817
  if (finishReason === "tool_calls") {
817
- console.log("Final state of all tool calls:", Object.fromEntries(toolCalls.entries()));
818
+ log.info("Final state of all tool calls:", Object.fromEntries(toolCalls.entries()));
818
819
  }
819
820
  }
820
821
  if (finishReason === "tool_calls") {
@@ -824,7 +825,7 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
824
825
  for (const [id, call] of toolCalls) {
825
826
  try {
826
827
  if (this.DEBUG) {
827
- console.log(`Validating JSON for tool call ${id}:`, call.arguments);
828
+ log.info(`Validating JSON for tool call ${id}:`, call.arguments);
828
829
  }
829
830
  // Handle empty arguments case
830
831
  if (!call.arguments.trim()) {
@@ -834,24 +835,24 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
834
835
  }
835
836
  catch (e) {
836
837
  if (this.DEBUG) {
837
- console.error(`JSON validation failed for ${id}:`, e);
838
- console.log("Invalid arguments:", call.arguments);
838
+ log.error(`JSON validation failed for ${id}:`, e);
839
+ log.info("Invalid arguments:", call.arguments);
839
840
  }
840
841
  throw new Error(`Invalid JSON in function arguments for ${call.name}: ${call.arguments}`);
841
842
  }
842
843
  }
843
844
  if (this.DEBUG)
844
- console.log("Executing tool calls");
845
+ log.info("Executing tool calls");
845
846
  await this.handleToolCalls(toolCalls);
846
847
  if (this.DEBUG)
847
- console.log("Clearing tool calls and arguments");
848
+ log.info("Clearing tool calls and arguments");
848
849
  toolCalls.clear();
849
850
  toolCallArguments.clear();
850
851
  }
851
852
  else if (finishReason === "stop") {
852
853
  if (botMessage) {
853
854
  if (this.DEBUG)
854
- console.log("Saving bot message to chat log");
855
+ log.info("Saving bot message to chat log");
855
856
  this.memory.chatLog.push({
856
857
  sender: "assistant",
857
858
  message: botMessage,
@@ -864,22 +865,22 @@ ${this.isLoggedIn ? "The user is logged in." : "The user is not logged in."}
864
865
  }
865
866
  }
866
867
  catch (error) {
867
- console.error("Stream processing error:", error);
868
+ log.error("Stream processing error:", error);
868
869
  // Attempt to switch to error recovery mode
869
870
  try {
870
871
  if (this.DEBUG)
871
- console.log("Attempting to switch to error recovery mode");
872
+ log.info("Attempting to switch to error recovery mode");
872
873
  await this.handleModeSwitch("error_recovery", error instanceof Error ? error.message : "Unknown error", {});
873
874
  }
874
875
  catch (e) {
875
- console.error("Failed to switch to error recovery mode:", e);
876
+ log.error("Failed to switch to error recovery mode:", e);
876
877
  }
877
878
  this.sendToClient("assistant", "There has been an error, please retry", "error");
878
879
  reject(error);
879
880
  }
880
881
  finally {
881
882
  if (this.DEBUG)
882
- console.log("Finalizing stream response");
883
+ log.info("Finalizing stream response");
883
884
  this.sendToClient("assistant", "", "end");
884
885
  resolve();
885
886
  }
@@ -1,5 +1,6 @@
1
1
  import { YpBaseAssistant } from "./baseAssistant.js";
2
2
  import { YpBaseChatBotWithVoice } from "./voiceAssistant.js";
3
+ import log from "../../utils/loggerTs.js";
3
4
  export class YpBaseAssistantWithVoice extends YpBaseAssistant {
4
5
  constructor(wsClientId, wsClients, redis, voiceEnabled, redisKey, domainId) {
5
6
  super(wsClientId, wsClients, redis, redisKey, domainId);
@@ -59,13 +60,13 @@ export class YpBaseAssistantWithVoice extends YpBaseAssistant {
59
60
  }
60
61
  }
61
62
  catch (error) {
62
- console.error("Error processing message:", error);
63
+ log.error("Error processing message:", error);
63
64
  }
64
65
  };
65
66
  ws.on("message", this.mainBotWsHandler);
66
67
  }
67
68
  else {
68
- console.error("No WebSocket found for client: ", this.wsClientId);
69
+ log.error("No WebSocket found for client: ", this.wsClientId);
69
70
  }
70
71
  }
71
72
  destroyVoiceBot() {
@@ -102,7 +103,7 @@ export class YpBaseAssistantWithVoice extends YpBaseAssistant {
102
103
  this.sendToClient(event.sender || "bot", event.message || "", event.type);
103
104
  }
104
105
  catch (error) {
105
- console.error("Error forwarding voice event:", error);
106
+ log.error("Error forwarding voice event:", error);
106
107
  }
107
108
  };
108
109
  this.voiceBot?.wsClientSocket?.on("message", this.forwardEventHandler);
@@ -125,7 +126,7 @@ export class YpBaseAssistantWithVoice extends YpBaseAssistant {
125
126
  tools: this.getCurrentModeFunctions(),
126
127
  modalities: ["text", "audio"]
127
128
  });
128
- console.log("handleModeSwitch", newMode, params);
129
+ log.info("handleModeSwitch", newMode, params);
129
130
  if (newMode === "agent_direct_connection_mode") {
130
131
  this.voiceBot?.initializeDirectAgentVoiceConnection();
131
132
  }
@@ -137,7 +138,7 @@ export class YpBaseAssistantWithVoice extends YpBaseAssistant {
137
138
  }
138
139
  async conversation(chatLog) {
139
140
  if (this.voiceEnabled) {
140
- console.log("voiceEnabled: Updating voice config");
141
+ log.info("voiceEnabled: Updating voice config");
141
142
  await this.voiceBot?.updateVoiceConfig({
142
143
  instructions: this.getCurrentSystemPrompt(),
143
144
  tools: this.getCurrentModeFunctions(),