@yrpri/api 9.0.102 → 9.0.104

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 (223) hide show
  1. package/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +56 -0
  2. package/active-citizen/llms/imageGeneration/collectionImageGenerator.js +6 -0
  3. package/agents/controllers/agentProductController.js +2 -1
  4. package/agents/controllers/agentSubscriptionController.js +20 -11
  5. package/agents/controllers/assistantsController.js +28 -18
  6. package/agents/controllers/policySynthAgents.js +33 -12
  7. package/agents/managers/newAiModelSetup.js +96 -0
  8. package/agents/managers/subscriptionManager.js +2 -2
  9. package/app.js +12 -12
  10. package/authorization.cjs +4 -0
  11. package/controllers/allOurIdeas.js +2 -1
  12. package/controllers/communities.cjs +47 -1
  13. package/controllers/groups.cjs +67 -4
  14. package/controllers/index.cjs +7 -7
  15. package/controllers/nonSpa.cjs +1 -1
  16. package/package.json +46 -44
  17. package/server.d.ts +104 -2
  18. package/utils/copy_utils.cjs +7 -1
  19. package/active-citizen/engine/allOurIdeas/aiHelper.d.ts +0 -21
  20. package/active-citizen/engine/allOurIdeas/aiHelper.d.ts.map +0 -1
  21. package/active-citizen/engine/allOurIdeas/explainAnswersAssistant.d.ts.map +0 -1
  22. package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts +0 -12
  23. package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts.map +0 -1
  24. package/active-citizen/engine/analytics/export_anon_community_activities.d.ts.map +0 -1
  25. package/active-citizen/engine/analytics/importer.d.ts.map +0 -1
  26. package/active-citizen/engine/old/exporters/categories_dataset.d.ts.map +0 -1
  27. package/active-citizen/engine/old/exporters/dataset_tools.d.ts.map +0 -1
  28. package/active-citizen/engine/old/exporters/sentiment_dataset.d.ts.map +0 -1
  29. package/active-citizen/engine/reports/xls_all_our_ideas_export.js +0 -141
  30. package/active-citizen/llms/baseChatBot.d.ts +0 -51
  31. package/active-citizen/llms/baseChatBot.d.ts.map +0 -1
  32. package/active-citizen/llms/collectionImageGenerator.js +0 -357
  33. package/active-citizen/llms/llmTranslation.d.ts +0 -24
  34. package/active-citizen/llms/llmTranslation.d.ts.map +0 -1
  35. package/active-citizen/scripts/fix_old_delayed_notifications.d.ts.map +0 -1
  36. package/active-citizen/scripts/kue_status.d.ts.map +0 -1
  37. package/active-citizen/scripts/kue_watch_stuck_jobs.d.ts.map +0 -1
  38. package/active-citizen/scripts/translation_clear_language.d.ts.map +0 -1
  39. package/active-citizen/scripts/translation_delete.d.ts.map +0 -1
  40. package/active-citizen/scripts/translation_replace_text_from_url.d.ts.map +0 -1
  41. package/active-citizen/scripts/translation_update.d.ts.map +0 -1
  42. package/active-citizen/scripts/translations_list.d.ts.map +0 -1
  43. package/active-citizen/utils/airbrake.d.ts.map +0 -1
  44. package/active-citizen/utils/airbrake.js +0 -17
  45. package/active-citizen/utils/updateAllLocalesFromEn.d.ts +0 -21
  46. package/active-citizen/utils/updateAllLocalesFromEn.d.ts.map +0 -1
  47. package/active-citizen/utils/updateLocaleFolders.d.ts +0 -2
  48. package/active-citizen/utils/updateLocaleFolders.d.ts.map +0 -1
  49. package/active-citizen/workers/cloudflare/voiceSession/worker.js +0 -213
  50. package/active-citizen/workers/generativeAi.d.ts.map +0 -1
  51. package/agents/agentProductManager.js +0 -91
  52. package/agents/assistants/agentAssistantOld.js +0 -863
  53. package/agents/assistants/modes/agentConfigurationMode.js +0 -63
  54. package/agents/assistants/modes/agentOperationsMode.js +0 -195
  55. package/agents/assistants/modes/commonTools.js +0 -58
  56. package/agents/assistants/modes/directConversationMode.js +0 -14
  57. package/agents/assistants/modes/toolHandlers/accountHandlers.js +0 -46
  58. package/agents/assistants/modes/toolHandlers/commonHandlers.js +0 -57
  59. package/agents/assistants/modes/toolHandlers/commonTools.js +0 -58
  60. package/agents/assistants/modes/toolHandlers/loginHandlers.js +0 -46
  61. package/agents/assistants/modes/toolHandlers/subscriptionHandlers.js +0 -469
  62. package/agents/assistants/modes/tools/agentConnectionTools.js +0 -326
  63. package/agents/assistants/modes/tools/commonHandlers.js +0 -57
  64. package/agents/assistants/modes/tools/loginHandlers.js +0 -46
  65. package/agents/assistants/modes/tools/subscriptionHandlers.js +0 -469
  66. package/agents/assistants/modes/tools/workflowConversationTools.js +0 -326
  67. package/agents/assistants/modes/tools/workflowTools.js +0 -112
  68. package/agents/controllers/assistantController.js +0 -243
  69. package/agents/managers/workflowManager.js +0 -76
  70. package/agents/models/testData/setupConfig.js +0 -140
  71. package/agents/models/workflow.js +0 -53
  72. package/agents/models/workflowConverstation.js +0 -53
  73. package/agents/subscriptionManager.js +0 -218
  74. package/agents/tools/updateCommunityWorkflow.js +0 -1
  75. package/agents/tools/updateTemplateWorkflow.js +0 -45
  76. package/app.d.ts +0 -40
  77. package/app.d.ts.map +0 -1
  78. package/bot_control.d.ts.map +0 -1
  79. package/migrations/200824_create_embeddings_and_org_update.cjs +0 -15
  80. package/migrations/270724_createUsersAndAdminsForClasses.cjs +0 -100
  81. package/publish.d.ts.map +0 -1
  82. package/repack.d.ts.map +0 -1
  83. package/scripts/addRatingUsersToGroup.d.ts.map +0 -1
  84. package/scripts/addUserToOrganization.d.ts.map +0 -1
  85. package/scripts/analyseRatingsForCommunity.d.ts.map +0 -1
  86. package/scripts/analyzeAndFixBrokenPointUsers.d.ts.map +0 -1
  87. package/scripts/analyzeEndorsementsByCountry.d.ts.map +0 -1
  88. package/scripts/analyzePostsForCommunity.d.ts.map +0 -1
  89. package/scripts/bulkStatusUpdates/listUpdates.d.ts.map +0 -1
  90. package/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.d.ts.map +0 -1
  91. package/scripts/bulkStatusUpdates/performUpdate.d.ts.map +0 -1
  92. package/scripts/bulkStatusUpdates/performUpdateForGroup.d.ts.map +0 -1
  93. package/scripts/bulkStatusUpdates/performUpdateForGroup.js +0 -125
  94. package/scripts/bulkStatusUpdates/performUpdateForStatus.d.ts.map +0 -1
  95. package/scripts/change/changeVideoAspectTo.d.ts.map +0 -1
  96. package/scripts/change/setDomainAdmin.cjs +0 -45
  97. package/scripts/changeCommunityGroupcount.d.ts.map +0 -1
  98. package/scripts/changeCommunityPostCount.d.ts.map +0 -1
  99. package/scripts/changeGroupPostCount.d.ts.map +0 -1
  100. package/scripts/changeLanguage.d.ts.map +0 -1
  101. package/scripts/changeOfficalStatus.d.ts.map +0 -1
  102. package/scripts/cleanups/deleteAnonNotifications.d.ts.map +0 -1
  103. package/scripts/cleanups/deleteAnonNotifications.js +0 -91
  104. package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.d.ts.map +0 -1
  105. package/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.d.ts.map +0 -1
  106. package/scripts/clearAllEndorsementInGroup.d.ts.map +0 -1
  107. package/scripts/cloning/clearUsersForCommunitiesFromUrl.d.ts.map +0 -1
  108. package/scripts/cloning/cloneFromUrlScript.d.ts.map +0 -1
  109. package/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
  110. package/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.d.ts.map +0 -1
  111. package/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.d.ts.map +0 -1
  112. package/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.d.ts.map +0 -1
  113. package/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.d.ts.map +0 -1
  114. package/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.d.ts.map +0 -1
  115. package/scripts/cloning/copyCommunityToDomainWithEverything.d.ts.map +0 -1
  116. package/scripts/cloning/copyCommunityToDomainWithOnlyGroups.d.ts.map +0 -1
  117. package/scripts/cloning/copyGroupConfigAndTranslationsFromURL.d.ts.map +0 -1
  118. package/scripts/cloning/copyPostToGroupOld.d.ts.map +0 -1
  119. package/scripts/cloning/copyPostVideosFromURL.d.ts.map +0 -1
  120. package/scripts/cloning/copyPostWithOutAnyVotingOrActivities.d.ts.map +0 -1
  121. package/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
  122. package/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
  123. package/scripts/cloning/setAdminsFromURL.d.ts.map +0 -1
  124. package/scripts/cloning/setExternalIdsFromURL.d.ts.map +0 -1
  125. package/scripts/countCommunity.d.ts.map +0 -1
  126. package/scripts/countCommunityUsers.d.ts.map +0 -1
  127. package/scripts/countDelayedNotifications.d.ts.map +0 -1
  128. package/scripts/countGroup.d.ts.map +0 -1
  129. package/scripts/countStuff.d.ts.map +0 -1
  130. package/scripts/countUniqueVotersInAGroup.d.ts.map +0 -1
  131. package/scripts/createInvitesAndShow.d.ts.map +0 -1
  132. package/scripts/database/seedTestAiModels.js +0 -64
  133. package/scripts/database/sync_database.d.ts.map +0 -1
  134. package/scripts/database/sync_dev_database.d.ts.map +0 -1
  135. package/scripts/debugNotifications.d.ts.map +0 -1
  136. package/scripts/deleteAllNewsFeeds.d.ts.map +0 -1
  137. package/scripts/deleteCategory.d.ts.map +0 -1
  138. package/scripts/deleteOldAppActivities.d.ts.map +0 -1
  139. package/scripts/deletePostContactDataForCommunity.d.ts.map +0 -1
  140. package/scripts/destroy/destroy_all_but_one_domain.d.ts.map +0 -1
  141. package/scripts/displayAuthorForPost.d.ts.map +0 -1
  142. package/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.d.ts.map +0 -1
  143. package/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.d.ts.map +0 -1
  144. package/scripts/exportAllStatusChanges.d.ts.map +0 -1
  145. package/scripts/exportClientAcitivity.d.ts.map +0 -1
  146. package/scripts/exportEndorsementsForCommunity.d.ts.map +0 -1
  147. package/scripts/exportPointQualitiesForCommunity.d.ts.map +0 -1
  148. package/scripts/exportPostsAndPointsForCommunity.d.ts.map +0 -1
  149. package/scripts/exportPostsDataSetForDomain.d.ts.map +0 -1
  150. package/scripts/exportPostsForGroup.d.ts.map +0 -1
  151. package/scripts/exportRatingsForPost.d.ts.map +0 -1
  152. package/scripts/exportUserEndorsementsWithUserAnalysis.d.ts.map +0 -1
  153. package/scripts/exportUsersForCommunity.d.ts.map +0 -1
  154. package/scripts/exportUsersForDomain.d.ts.map +0 -1
  155. package/scripts/exportUsersForGroup.d.ts.map +0 -1
  156. package/scripts/exports/ratingDistribution.d.ts.map +0 -1
  157. package/scripts/exports/whoEndorsedWhatByCommunity.d.ts.map +0 -1
  158. package/scripts/findUnusedClientImports.d.ts.map +0 -1
  159. package/scripts/fixAllPostPointCounts.d.ts.map +0 -1
  160. package/scripts/fixAnonNotificationsSettings.d.ts.map +0 -1
  161. package/scripts/fixCountKopavogur.d.ts.map +0 -1
  162. package/scripts/fixEndorsementsAfterCopyPostToGroup.d.ts.map +0 -1
  163. package/scripts/fixExternalUserId.d.ts.map +0 -1
  164. package/scripts/fixGroupAccess.d.ts.map +0 -1
  165. package/scripts/fixGroupIdeasAndPointsCount.d.ts.map +0 -1
  166. package/scripts/fixNotificationSettings.d.ts.map +0 -1
  167. package/scripts/fixSurveyRadioBakedInSubCodes.d.ts.map +0 -1
  168. package/scripts/fixWrongUserIdForStatusUpdates.d.ts.map +0 -1
  169. package/scripts/gallery/exportGalleryData.d.ts.map +0 -1
  170. package/scripts/gallery/importGalleryForCommunity.d.ts.map +0 -1
  171. package/scripts/gallery/readJsonAndDownloadImagesVersion2.d.ts.map +0 -1
  172. package/scripts/gallery/refreshAcApiPostIdsForCommunity.d.ts.map +0 -1
  173. package/scripts/genderAnalysis.d.ts.map +0 -1
  174. package/scripts/genderAnalysisByStatus.d.ts.map +0 -1
  175. package/scripts/importAllLocalesFromLocalFolders.d.ts.map +0 -1
  176. package/scripts/importDomain.d.ts.map +0 -1
  177. package/scripts/landUseGame/export3Ddata.d.ts.map +0 -1
  178. package/scripts/listLanguagesForGroup.d.ts.map +0 -1
  179. package/scripts/loadTestCreateDummyContentForGroup.d.ts.map +0 -1
  180. package/scripts/makeRecursiveMapData.d.ts.map +0 -1
  181. package/scripts/mapping/community_map_csv.d.ts.map +0 -1
  182. package/scripts/moveCommunityToDomain.d.ts.map +0 -1
  183. package/scripts/moveGroupToCommunity.d.ts.map +0 -1
  184. package/scripts/movePostToGroup.d.ts.map +0 -1
  185. package/scripts/movePostsToGroupsRecountGroupFromUrl.d.ts.map +0 -1
  186. package/scripts/oldMovePostToGroup.d.ts.map +0 -1
  187. package/scripts/processCsvForPdfUrls.d.ts.map +0 -1
  188. package/scripts/processCsvForTranslationAndToxicity.d.ts.map +0 -1
  189. package/scripts/recount/recount_recursive_communities.d.ts.map +0 -1
  190. package/scripts/recountALLCommunityGroupCounts.d.ts.map +0 -1
  191. package/scripts/recountAll.d.ts.map +0 -1
  192. package/scripts/recountCommunitesFromUrl.d.ts.map +0 -1
  193. package/scripts/recountCommunity.d.ts.map +0 -1
  194. package/scripts/recountGroup.d.ts.map +0 -1
  195. package/scripts/recountGroupNoUserChange.d.ts.map +0 -1
  196. package/scripts/resetAllEndorsementsForGroup.d.ts.map +0 -1
  197. package/scripts/resetEnTranslationForGroup.d.ts.map +0 -1
  198. package/scripts/setDomainLocales.d.ts.map +0 -1
  199. package/scripts/setLanguageOnGroupCommunitesFromUrl.d.ts.map +0 -1
  200. package/scripts/setMemberOfAll.d.ts.map +0 -1
  201. package/scripts/setNewUserForContentOfCommunity.d.ts.map +0 -1
  202. package/scripts/setOfficialStatusOnAllPostsForCommunity.d.ts.map +0 -1
  203. package/scripts/setUserOnAll.d.ts.map +0 -1
  204. package/scripts/showCategoryForGroup.d.ts.map +0 -1
  205. package/scripts/showOldActivityTypes.d.ts.map +0 -1
  206. package/scripts/showPostsMissingCategoryForGroup.d.ts.map +0 -1
  207. package/scripts/showStatuses.d.ts.map +0 -1
  208. package/scripts/showUniqueVotersInCommunity.d.ts.map +0 -1
  209. package/scripts/showUserAgentsAndIpsForEmails.d.ts.map +0 -1
  210. package/scripts/simpleExportForGroupsForCommunity.d.ts.map +0 -1
  211. package/scripts/simpleExportForPointsForCommunity.d.ts.map +0 -1
  212. package/scripts/simpleExportForPostsForCommunity.d.ts.map +0 -1
  213. package/scripts/testForEndorsments.d.ts.map +0 -1
  214. package/scripts/undeleteGroupAndAllContent.d.ts.map +0 -1
  215. package/scripts/undeletePost.d.ts.map +0 -1
  216. package/scripts/unlinkSsn.d.ts.map +0 -1
  217. package/scripts/updateFromAlthingi.d.ts.map +0 -1
  218. package/server.d.ts.map +0 -1
  219. package/utils/copyGroup.js +0 -246
  220. package/utils/loggerTs.d.ts +0 -4
  221. package/utils/loggerTs.d.ts.map +0 -1
  222. package/utils/ypLanguages.d.ts +0 -18
  223. package/utils/ypLanguages.d.ts.map +0 -1
@@ -1,76 +0,0 @@
1
- import { YpWorkflowConversation } from "../models/workflowConverstation.js";
2
- export class WorkflowManager {
3
- constructor() { }
4
- async createWorkflow(data) {
5
- try {
6
- const workflow = await YpWorkflowConversation.create({
7
- agentProductId: data.agentProductId,
8
- userId: data.userId || null,
9
- configuration: data.configuration || {},
10
- });
11
- return workflow;
12
- }
13
- catch (error) {
14
- throw new Error(`Error creating workflow: ${error.message}`);
15
- }
16
- }
17
- async getWorkflow(workflowId) {
18
- try {
19
- const workflow = await YpWorkflowConversation.findByPk(workflowId);
20
- return workflow;
21
- }
22
- catch (error) {
23
- throw new Error(`Error retrieving workflow: ${error.message}`);
24
- }
25
- }
26
- async updateWorkflow(workflowId, updates) {
27
- try {
28
- const workflow = await YpWorkflowConversation.findByPk(workflowId);
29
- if (!workflow) {
30
- throw new Error("Workflow not found");
31
- }
32
- Object.assign(workflow, updates);
33
- await workflow.save();
34
- return workflow;
35
- }
36
- catch (error) {
37
- throw new Error(`Error updating workflow: ${error.message}`);
38
- }
39
- }
40
- async connectToWorkflow(workflowId, connectionData) {
41
- try {
42
- const workflow = await YpWorkflowConversation.findByPk(workflowId);
43
- if (!workflow) {
44
- throw new Error("Workflow not found");
45
- }
46
- workflow.configuration = { ...workflow.configuration, ...connectionData };
47
- await workflow.save();
48
- return workflow;
49
- }
50
- catch (error) {
51
- throw new Error(`Error connecting to workflow: ${error.message}`);
52
- }
53
- }
54
- async getWorkflowsForUser(userId) {
55
- try {
56
- const workflows = await YpWorkflowConversation.findAll({ where: { userId } });
57
- return workflows;
58
- }
59
- catch (error) {
60
- throw new Error(`Error retrieving workflows for user ${userId}: ${error.message}`);
61
- }
62
- }
63
- async getRunningWorkflowsForUser(userId) {
64
- try {
65
- const allWorkflows = await this.getWorkflowsForUser(userId);
66
- const runningWorkflows = allWorkflows.filter((workflow) => {
67
- return (workflow.configuration &&
68
- workflow.configuration.running === true);
69
- });
70
- return runningWorkflows;
71
- }
72
- catch (error) {
73
- throw new Error(`Error retrieving running workflows for user ${userId}: ${error.message}`);
74
- }
75
- }
76
- }
@@ -1,140 +0,0 @@
1
- // createAgentProductsAndPlans.ts
2
- import { YpAgentProduct } from "../agentProduct.js";
3
- async function setupAgentProductsConfiguration() {
4
- const competitionAgent = await YpAgentProduct.findByPk(1);
5
- if (competitionAgent) {
6
- if (!competitionAgent.configuration?.avatar) {
7
- competitionAgent.configuration.avatar = {
8
- systemPrompt: `You are the Competition Agent. You are an expert in analyzing competitor strategies and market positions. You are given a business description and you need to analyze the competition and market positions. You need to provide a report on the state of the market based on the competition analysis.
9
-
10
- There are five stages:
11
- 1. Wide Search: You need to search for competitor strategies and market positions.
12
- 2. Human Prioritization: You need to prioritize the wide search results.
13
- 3. Detailed Search: You need to search for competitor strategies and market positions in more detail.
14
- 4. Detailed Search Human Prioritization: You need to prioritize the detailed search results.
15
- 5. State of the Market Report: You need to provide a report on the state of the market based on the competition analysis.
16
-
17
- The output of the agent is a state of the market report in PDF and DOCX formats.
18
- The full version of the agent includes 2 runs per month and up to 10 key competitors to analyze for detailed search.
19
-
20
- The free version of the agent includes 1 run per month and up to 3 key competitors to analyze for detailed search.
21
-
22
- Please help the user understand all this but also all about competition analysis in general that is your speciality.
23
- `,
24
- imageUrl: "https://assets.evoly.ai/dl/754a1e727d768b1107826c1deb67b6ac--retina-1.png",
25
- voiceName: "shimmer",
26
- };
27
- }
28
- await competitionAgent.save();
29
- }
30
- const leadGenerationAgent = await YpAgentProduct.findByPk(2);
31
- if (leadGenerationAgent) {
32
- await leadGenerationAgent.update({
33
- configuration: {
34
- avatar: {
35
- systemPrompt: `You are the Lead Generation Agent. You are an expert in generating leads and potential client contacts. You are given a business description and you need to generate leads and potential client contacts. You need to provide a report on the leads and potential client contacts.
36
-
37
- There are five stages:
38
- 1. Wide Search: You need to search for leads and potential client contacts.
39
- 2. Human Prioritization: You need to prioritize the wide search results.
40
- 3. Detailed Search: You need to search for leads and potential client contacts in more detail.
41
- 4. Detailed Search Human Prioritization: You need to prioritize the detailed search results.
42
- 5. Leads and Potential Client Contacts Report: You need to provide a report on the leads and potential client contacts.
43
-
44
- The output of the agent is a list of leads and potential client contacts in XLS format.
45
-
46
- The full version of the agent includes 4 runs per month and up to 100 leads to generate each time.
47
-
48
- `,
49
- imageUrl: "https://assets.evoly.ai/dl/f86bf2c221801b4c56d71b098c36ef54--retina-1.png",
50
- voiceName: "ash",
51
- },
52
- },
53
- });
54
- }
55
- const productionInnovationAgent = await YpAgentProduct.findByPk(3);
56
- if (productionInnovationAgent) {
57
- await productionInnovationAgent.update({
58
- configuration: {
59
- avatar: {
60
- systemPrompt: `You are the Production Innovation Agent. You are an expert in generating innovative ideas for production processes. You are given a business description and you need to generate innovative ideas for production processes. You need to provide a report on the innovative ideas for production processes.
61
-
62
- There are six stages:
63
- 1. Wide Search: You need to search for innovative ideas for production processes.
64
- 2. Human Prioritization: You need to prioritize the wide search results.
65
- 3. Detailed Search: You need to search for innovative ideas for production processes in more detail.
66
- 4. Detailed Search Human Prioritization: You need to prioritize the detailed search results.
67
- 5. Genetic Algorithm: The agent uses a genetic algorithm to generate innovative ideas for production processes.
68
- 6. Innovative Ideas for Production Processes Report: You need to provide a report on the innovative ideas for production processes.
69
-
70
- The output of the agent is a list of innovative ideas for production processes in XLS format.
71
- `,
72
- imageUrl: "https://assets.evoly.ai/dl/1d91f5bfb69446f57c678a4a3e873d35--retina-1.png",
73
- voiceName: "coral",
74
- },
75
- },
76
- });
77
- }
78
- const marketingOpsAgent = await YpAgentProduct.findByPk(4);
79
- if (marketingOpsAgent) {
80
- await marketingOpsAgent.update({
81
- configuration: {
82
- avatar: {
83
- systemPrompt: `You are the Marketing Ops Agent. You are an expert in optimizing marketing operations and campaign strategies. You are given a business description and you need to optimize marketing operations and campaign strategies. You need to provide a report on the optimized marketing operations and campaign strategies.
84
-
85
- Our comprehensive content creation and distribution workflow includes:
86
- 1. Automated Blog Creation with Human Refinement
87
- - AI-generated initial blog drafts
88
- - Human expert review and enhancement
89
- - SEO optimization and content polishing
90
-
91
- 2. Multi-Format Content Transformation
92
- - Converting blogs into AI-voiced podcasts using premium voice synthesis
93
- - Creating engaging social media snippets and posts from blog content
94
- - Generating AI video podcasts featuring dynamic AI avatars
95
- - Synchronizing AI-generated visuals with voice content
96
-
97
- 3. Cross-Platform Distribution
98
- - Coordinated publishing across all major social media platforms
99
- - Content scheduling and timing optimization
100
- - Performance tracking and analytics
101
-
102
- The output of the agent includes:
103
- - Professionally written blog posts
104
- - High-quality AI-voiced podcast episodes
105
- - Engaging video content with AI avatars
106
- - Ready-to-publish social media content packages
107
- - Comprehensive performance metrics and optimization recommendations
108
-
109
- Each piece of content maintains brand consistency while being optimized for its specific platform and audience engagement.
110
- `,
111
- imageUrl: "https://assets.evoly.ai/dl/6f8757bfb637206ddae009597aa4ab6d--retina-1.png",
112
- voiceName: "alloy",
113
- },
114
- },
115
- });
116
- }
117
- const fundingAgent = await YpAgentProduct.findByPk(5);
118
- if (fundingAgent) {
119
- await fundingAgent.update({
120
- configuration: {
121
- avatar: {
122
- systemPrompt: `You are the Funding Agent. You are an expert in identifying and analyzing funding opportunities and investment strategies. You are given a business description and you need to identify and analyze funding opportunities and investment strategies. You need to provide a report on the funding opportunities and investment strategies.
123
-
124
- There are five stages:
125
- 1. Wide Search: You need to search for funding opportunities and investment strategies.
126
- 2. Human Prioritization: You need to prioritize the wide search results.
127
- 3. Detailed Search: You need to search for funding opportunities and investment strategies in more detail.
128
- 4. Detailed Search Human Prioritization: You need to prioritize the detailed search results.
129
- 5. Funding Opportunities and Investment Strategies Report: You need to provide a report on the funding opportunities and investment strategies.
130
-
131
- The output of the agent is a list of funding opportunities and investment strategies in XLS format.
132
- `,
133
- imageUrl: "https://assets.evoly.ai/dl/f80b64c1ab385e6f3ec0d3f552f38801--retina-1.png",
134
- voiceName: "ballad",
135
- },
136
- },
137
- });
138
- }
139
- }
140
- setupAgentProductsConfiguration();
@@ -1,53 +0,0 @@
1
- import { Model, DataTypes } from "sequelize";
2
- import { sequelize } from "@policysynth/agents/dbModels/sequelize.js";
3
- export class YpWorkflowConversation extends Model {
4
- static initModel(sequelizeInstance = sequelize) {
5
- YpWorkflowConversation.init({
6
- id: {
7
- type: DataTypes.INTEGER,
8
- primaryKey: true,
9
- autoIncrement: true,
10
- },
11
- agentProductId: {
12
- type: DataTypes.INTEGER,
13
- allowNull: true,
14
- field: "agent_product_id",
15
- },
16
- userId: {
17
- type: DataTypes.INTEGER,
18
- allowNull: false,
19
- field: "user_id",
20
- },
21
- configuration: {
22
- type: DataTypes.JSONB,
23
- allowNull: false,
24
- defaultValue: {},
25
- },
26
- created_at: {
27
- type: DataTypes.DATE,
28
- allowNull: false,
29
- defaultValue: DataTypes.NOW,
30
- },
31
- updated_at: {
32
- type: DataTypes.DATE,
33
- allowNull: false,
34
- defaultValue: DataTypes.NOW,
35
- },
36
- }, {
37
- sequelize: sequelizeInstance,
38
- tableName: "workflows",
39
- timestamps: false,
40
- });
41
- return YpWorkflowConversation;
42
- }
43
- static associate(models) {
44
- YpWorkflowConversation.belongsTo(models.YpAgentProduct, {
45
- foreignKey: "agentProductId",
46
- as: "agentProduct",
47
- });
48
- YpWorkflowConversation.hasMany(models.YpAgentProductRun, {
49
- foreignKey: "workflowId",
50
- as: "agentProductRuns",
51
- });
52
- }
53
- }
@@ -1,53 +0,0 @@
1
- import { Model, DataTypes } from "sequelize";
2
- import { sequelize } from "@policysynth/agents/dbModels/sequelize.js";
3
- export class YpWorkflowConversation extends Model {
4
- static initModel(sequelizeInstance = sequelize) {
5
- YpWorkflowConversation.init({
6
- id: {
7
- type: DataTypes.INTEGER,
8
- primaryKey: true,
9
- autoIncrement: true,
10
- },
11
- agentProductId: {
12
- type: DataTypes.INTEGER,
13
- allowNull: true,
14
- field: "agent_product_id",
15
- },
16
- userId: {
17
- type: DataTypes.INTEGER,
18
- allowNull: false,
19
- field: "user_id",
20
- },
21
- configuration: {
22
- type: DataTypes.JSONB,
23
- allowNull: false,
24
- defaultValue: {},
25
- },
26
- created_at: {
27
- type: DataTypes.DATE,
28
- allowNull: false,
29
- defaultValue: DataTypes.NOW,
30
- },
31
- updated_at: {
32
- type: DataTypes.DATE,
33
- allowNull: false,
34
- defaultValue: DataTypes.NOW,
35
- },
36
- }, {
37
- sequelize: sequelizeInstance,
38
- tableName: "workflow_conversations",
39
- timestamps: false,
40
- });
41
- return YpWorkflowConversation;
42
- }
43
- static associate(models) {
44
- YpWorkflowConversation.belongsTo(models.YpAgentProduct, {
45
- foreignKey: "agentProductId",
46
- as: "agentProduct",
47
- });
48
- YpWorkflowConversation.hasMany(models.YpAgentProductRun, {
49
- foreignKey: "workflowId",
50
- as: "agentProductRuns",
51
- });
52
- }
53
- }
@@ -1,218 +0,0 @@
1
- // SubscriptionManager.ts
2
- import { YpSubscriptionPlan } from './models/subscriptionPlan.js';
3
- import { YpSubscription } from './models/subscription.js';
4
- import { YpAgentProduct } from './models/agentProduct.js';
5
- import { YpAgentProductRun } from './models/agentProductRun.js';
6
- import Stripe from 'stripe';
7
- import { YpAgentProductBundle } from './models/agentProductBundle.js';
8
- const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
9
- apiVersion: '2024-09-30.acacia',
10
- });
11
- export class SubscriptionManager {
12
- constructor() {
13
- // Initialize if necessary
14
- }
15
- // Get available subscription plans
16
- async getPlans() {
17
- try {
18
- const plans = await YpSubscriptionPlan.findAll({
19
- attributes: {
20
- exclude: ['created_at', 'updated_at']
21
- },
22
- include: [
23
- {
24
- model: YpAgentProduct,
25
- as: 'AgentProduct',
26
- attributes: {
27
- exclude: ['created_at', 'updated_at']
28
- },
29
- include: [{
30
- model: YpAgentProductBundle,
31
- as: 'Bundles',
32
- attributes: {
33
- exclude: ['created_at', 'updated_at']
34
- }
35
- }]
36
- }
37
- ],
38
- });
39
- return plans;
40
- }
41
- catch (error) {
42
- throw new Error(`Error fetching subscription plans: ${error.message}`);
43
- }
44
- }
45
- // Create subscriptions for a user
46
- async createSubscriptions(userId, agentProductIds, planIds, paymentMethodId) {
47
- try {
48
- if (agentProductIds.length !== planIds.length) {
49
- throw new Error('agentProductIds and planIds arrays must be of the same length');
50
- }
51
- let totalAmount = 0;
52
- const currency = 'usd';
53
- // Calculate total amount to charge
54
- for (let i = 0; i < planIds.length; i++) {
55
- const plan = await YpSubscriptionPlan.findByPk(planIds[i]);
56
- if (!plan) {
57
- throw new Error(`Subscription plan with ID ${planIds[i]} not found`);
58
- }
59
- totalAmount += Number(plan.amount) * 100;
60
- }
61
- // Create a PaymentIntent with Stripe
62
- const paymentIntent = await stripe.paymentIntents.create({
63
- amount: totalAmount,
64
- currency: currency,
65
- payment_method: paymentMethodId,
66
- confirmation_method: 'manual',
67
- confirm: false,
68
- payment_method_types: ['card'],
69
- description: 'Subscription Purchase',
70
- metadata: {
71
- userId: userId.toString(),
72
- agentProductIds: agentProductIds.join(','),
73
- planIds: planIds.join(','),
74
- },
75
- });
76
- // Return the client secret for frontend confirmation
77
- return {
78
- clientSecret: paymentIntent.client_secret,
79
- subscriptionId: paymentIntent.id
80
- };
81
- }
82
- catch (error) {
83
- if (error instanceof Stripe.errors.StripeCardError) {
84
- throw new Error(`Payment failed: ${error.message}`);
85
- }
86
- else if (error instanceof Stripe.errors.StripeInvalidRequestError) {
87
- throw new Error(`Invalid payment request: ${error.message}`);
88
- }
89
- else {
90
- throw new Error(`Error creating subscriptions: ${error.message}`);
91
- }
92
- }
93
- }
94
- // Add a new method to handle successful payments
95
- async handleSuccessfulPayment(paymentIntentId) {
96
- try {
97
- const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId);
98
- if (paymentIntent.status !== 'succeeded') {
99
- throw new Error('Payment not successful');
100
- }
101
- const userId = Number(paymentIntent.metadata.userId);
102
- const agentProductIds = paymentIntent.metadata.agentProductIds.split(',').map(Number);
103
- const planIds = paymentIntent.metadata.planIds.split(',').map(Number);
104
- const subscriptions = [];
105
- // Create subscriptions after successful payment
106
- for (let i = 0; i < agentProductIds.length; i++) {
107
- const nextBillingDate = await this.calculateNextBillingDate(planIds[i]);
108
- const subscription = await YpSubscription.create({
109
- user_id: userId,
110
- agent_product_id: agentProductIds[i],
111
- plan_id: planIds[i],
112
- start_date: new Date(),
113
- next_billing_date: nextBillingDate,
114
- status: 'active',
115
- payment_method: 'stripe',
116
- transaction_id: paymentIntentId,
117
- });
118
- subscriptions.push(subscription);
119
- }
120
- return subscriptions;
121
- }
122
- catch (error) {
123
- throw new Error(`Error processing successful payment: ${error.message}`);
124
- }
125
- }
126
- // Start an agent run
127
- async startAgentRun(agentProductId, subscriptionId) {
128
- try {
129
- // Check if the subscription is active
130
- const subscription = await YpSubscription.findByPk(subscriptionId);
131
- if (!subscription || subscription.status !== 'active') {
132
- throw new Error('Subscription is not active');
133
- }
134
- // Check if the agent product matches the subscription
135
- if (subscription.agent_product_id !== agentProductId) {
136
- throw new Error('Agent product does not match the subscription');
137
- }
138
- // Check runs limit
139
- await this.checkRunsLimit(subscription);
140
- // Create a new agent product run
141
- const agentProductRun = await YpAgentProductRun.create({
142
- agent_product_id: agentProductId,
143
- start_time: new Date(),
144
- status: 'running',
145
- });
146
- // Update runs used
147
- await this.incrementRunsUsed(subscription);
148
- return agentProductRun;
149
- }
150
- catch (error) {
151
- throw new Error(`Error starting agent run: ${error.message}`);
152
- }
153
- }
154
- // Stop an agent run
155
- async stopAgentRun(agentProductRunId) {
156
- try {
157
- const agentProductRun = await YpAgentProductRun.findByPk(agentProductRunId);
158
- if (!agentProductRun || agentProductRun.status !== 'running') {
159
- throw new Error('Agent run is not running');
160
- }
161
- agentProductRun.end_time = new Date();
162
- agentProductRun.status = 'completed';
163
- agentProductRun.duration = Math.floor((agentProductRun.end_time.getTime() - agentProductRun.start_time.getTime()) / 1000); // Duration in seconds
164
- await agentProductRun.save();
165
- }
166
- catch (error) {
167
- throw new Error(`Error stopping agent run: ${error.message}`);
168
- }
169
- }
170
- // Additional helper methods
171
- async calculateNextBillingDate(planId) {
172
- const plan = await YpSubscriptionPlan.findByPk(planId);
173
- if (!plan) {
174
- throw new Error('Subscription plan not found');
175
- }
176
- const nextBillingDate = new Date();
177
- switch (plan.billing_cycle) {
178
- case 'monthly':
179
- nextBillingDate.setMonth(nextBillingDate.getMonth() + 1);
180
- break;
181
- case 'yearly':
182
- nextBillingDate.setFullYear(nextBillingDate.getFullYear() + 1);
183
- break;
184
- case 'weekly':
185
- nextBillingDate.setDate(nextBillingDate.getDate() + 7);
186
- break;
187
- default:
188
- throw new Error('Invalid billing cycle');
189
- }
190
- return nextBillingDate;
191
- }
192
- async incrementRunsUsed(subscription) {
193
- // Increment runs used in the subscription
194
- // Also check if runs limit is reached
195
- const plan = await YpSubscriptionPlan.findByPk(subscription.plan_id);
196
- if (!plan) {
197
- throw new Error('Subscription plan not found');
198
- }
199
- // For simplicity, we can assume runs_used is stored in subscription metadata
200
- let runsUsed = subscription.metadata?.runs_used || 0;
201
- runsUsed += 1;
202
- if (runsUsed > plan.max_runs_per_cycle) {
203
- throw new Error('Maximum runs per cycle exceeded');
204
- }
205
- subscription.metadata = { ...subscription.metadata, runs_used: runsUsed };
206
- await subscription.save();
207
- }
208
- async checkRunsLimit(subscription) {
209
- const plan = await YpSubscriptionPlan.findByPk(subscription.plan_id);
210
- if (!plan) {
211
- throw new Error('Subscription plan not found');
212
- }
213
- const runsUsed = subscription.metadata?.runs_used || 0;
214
- if (runsUsed >= plan.max_runs_per_cycle) {
215
- throw new Error('Maximum runs per cycle reached');
216
- }
217
- }
218
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
1
- import { sequelize } from "@policysynth/agents/dbModels/index.js";
2
- import { YpAgentProduct } from "../models/agentProduct.js";
3
- /**
4
- * Updates the templateWorkflowCommunityId in the configuration of a specific agent product.
5
- *
6
- * Usage:
7
- * ts-node setTemplateWorkflowCommunityId.ts <agentProductId> <templateWorkflowCommunityId>
8
- */
9
- async function setTemplateWorkflowCommunityId(agentProductId, templateWorkflowCommunityId) {
10
- try {
11
- // Find the Agent Product by ID
12
- const agentProduct = await YpAgentProduct.findByPk(agentProductId);
13
- if (!agentProduct) {
14
- console.error(`Agent Product with ID ${agentProductId} not found.`);
15
- return;
16
- }
17
- // If the product is found, update its configuration
18
- const currentConfig = agentProduct.configuration ?? {};
19
- currentConfig.templateWorkflowCommunityId = templateWorkflowCommunityId;
20
- // Update the record
21
- agentProduct.configuration = currentConfig;
22
- await agentProduct.save();
23
- console.log(`Successfully updated Agent Product ${agentProductId} with templateWorkflowCommunityId = ${templateWorkflowCommunityId}`);
24
- }
25
- catch (error) {
26
- console.error(`Error updating templateWorkflowCommunityId for Agent Product ${agentProductId}:`, error);
27
- }
28
- finally {
29
- // Close the database connection
30
- await sequelize.close();
31
- }
32
- }
33
- // --- Parse command line arguments ---
34
- const args = process.argv.slice(2);
35
- if (args.length !== 2) {
36
- console.error("Usage: ts-node setTemplateWorkflowCommunityId.ts <agentProductId> <templateWorkflowCommunityId>");
37
- process.exit(1);
38
- }
39
- const [agentProductId, templateWorkflowCommunityId] = args.map((arg) => Number(arg));
40
- if (isNaN(agentProductId) || isNaN(templateWorkflowCommunityId)) {
41
- console.error("Both arguments must be valid numbers.");
42
- process.exit(1);
43
- }
44
- // --- Run the function ---
45
- setTemplateWorkflowCommunityId(agentProductId, templateWorkflowCommunityId);
package/app.d.ts DELETED
@@ -1,40 +0,0 @@
1
- import express from "express";
2
- import WebSocket, { WebSocketServer } from "ws";
3
- interface YpRequest extends express.Request {
4
- ypDomain?: any;
5
- ypCommunity?: any;
6
- sso?: any;
7
- redisClient?: any;
8
- user?: any;
9
- dirName?: string;
10
- }
11
- export declare class YourPrioritiesApi {
12
- app: express.Application;
13
- port: number;
14
- httpServer: any;
15
- ws: WebSocketServer;
16
- redisClient: any;
17
- wsClients: Map<string, WebSocket>;
18
- constructor(port?: number | undefined);
19
- addRedisToRequest(): void;
20
- addDirnameToRequest(): void;
21
- forceHttps(): void;
22
- handleShortenedRedirects(): void;
23
- handleServiceWorkerRequests(): void;
24
- setupDomainAndCommunity(): void;
25
- initializeRateLimiting(): Promise<void>;
26
- setupSitemapRoute(): void;
27
- bearerCallback: () => void;
28
- checkAuthForSsoInit(): void;
29
- setupStaticFileServing(): void;
30
- initializeMiddlewares(): void;
31
- initializeEsControllers(): Promise<void>;
32
- initializeRoutes(): void;
33
- initializePassportStrategies(): void;
34
- completeRegisterUserLogin: (user: any, loginType: string, req: YpRequest, done: () => void) => void;
35
- registerUserLogin: (user: any | null, userId: number, loginProvider: string, req: YpRequest, done: () => void) => void;
36
- setupErrorHandler(): void;
37
- listen(): Promise<void>;
38
- }
39
- export {};
40
- //# sourceMappingURL=app.d.ts.map
package/app.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAyB,MAAM,SAAS,CAAC;AAwGhD,OAAO,SAAS,EAAE,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAGhD,UAAU,SAAU,SAAQ,OAAO,CAAC,OAAO;IACzC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAgCD,qBAAa,iBAAiB;IACrB,GAAG,EAAE,OAAO,CAAC,WAAW,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,GAAG,CAAC;IAChB,EAAE,EAAG,eAAe,CAAC;IACrB,WAAW,EAAE,GAAG,CAAC;IACjB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBAE7B,IAAI,GAAE,MAAM,GAAG,SAAqB;IAoBhD,iBAAiB,IAAI,IAAI;IAgBzB,UAAU,IAAI,IAAI;IAiBlB,wBAAwB,IAAI,IAAI;IA+BhC,2BAA2B,IAAI,IAAI;IAgBnC,uBAAuB,IAAI,IAAI;IAoBzB,sBAAsB;IAyC5B,iBAAiB,IAAI,IAAI;IAwBzB,cAAc,aAIZ;IAEF,mBAAmB,IAAI,IAAI;IAmB3B,sBAAsB,IAAI,IAAI;IA+D9B,qBAAqB;IA8Bf,uBAAuB;IAiB7B,gBAAgB;IA0GhB,4BAA4B;IAkJ5B,yBAAyB,SACjB,GAAG,aACE,MAAM,OACZ,SAAS,QACR,MAAM,IAAI,KACf,IAAI,CAkCL;IAEF,iBAAiB,SACT,GAAG,GAAG,IAAI,UACR,MAAM,iBACC,MAAM,OAChB,SAAS,QACR,MAAM,IAAI,KACf,IAAI,CAqBL;IAEF,iBAAiB,IAAI,IAAI;IAqFnB,MAAM;CAoIb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"bot_control.d.ts","sourceRoot":"","sources":["../bot_control.js"],"names":[],"mappings":"AAsoBA,4CA8vCC;AAED,qDAEC;AAED,8CAIC;AAlxCD,2CAA8D"}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- module.exports = {
3
- up: async (queryInterface, Sequelize) => {
4
- return [];
5
- },
6
- down: function (queryInterface, Sequelize) {
7
- /*
8
- Add reverting commands here.
9
- Return a promise to correctly handle asynchronicity.
10
-
11
- Example:
12
- return queryInterface.dropTable('users');
13
- */
14
- },
15
- };